コード例 #1
0
ファイル: java_linkers.py プロジェクト: bartdag/recodoc2
    def link_references(self, progress_monitor=NullProgressMonitor(),
            local_object_id=None):

        # Annotation Field
        ann_refs = self._get_query(self.ann_field_kind, local_object_id)
        acount = ann_refs.count()
        progress_monitor.info('Annotation Field count: {0}'.format(acount))
        try:
            self._link_ann_fields(queryset_iterator(ann_refs), acount,
                    progress_monitor)
        except Exception:
            logger.exception('Error while processing annotation fields')
        call_gc()

        # Enumeration Values
        enum_refs = self._get_query(self.enum_value_kind, local_object_id)
        ecount = enum_refs.count()
        progress_monitor.info('Enumeration Value count: {0}'.format(ecount))
        try:
            self._link_enum_values(queryset_iterator(enum_refs), ecount,
                    progress_monitor)
        except Exception:
            logger.exception('Error while processing enumeration values')
        call_gc()

        # Fields
        field_refs = self._get_query(self.field_kind, local_object_id)
        fcount = field_refs.count()
        progress_monitor.info('Field count: {0}'.format(fcount))
        try:
            self._link_fields(queryset_iterator(field_refs), fcount,
                    progress_monitor)
        except Exception:
            logger.exception('Error while processing fields')
        call_gc()
コード例 #2
0
ファイル: java_linkers.py プロジェクト: bartdag/recodoc2
    def link_references(self, progress_monitor=NullProgressMonitor(),
            local_object_id=None):

        # Annotations
        ann_refs = self._get_query(self.ann_kind, local_object_id)
        acount = ann_refs.count()
        progress_monitor.info('Annotation count: {0}'.format(acount))
        try:
            self._link_annotations(queryset_iterator(ann_refs), acount,
                    progress_monitor)
        except Exception:
            logger.exception('Error while processing annotations.')
        call_gc()

        # Enumerations
        enum_refs = self._get_query(self.enum_kind, local_object_id)
        ecount = enum_refs.count()
        progress_monitor.info('Enumeration count: {0}'.format(ecount))
        try:
            self._link_enumerations(queryset_iterator(enum_refs), ecount,
                    progress_monitor)
        except Exception:
            logger.exception('Error while processing enumerations.')
        call_gc()

        # All types (including classes!)
        class_refs = self._get_query(self.class_kind, local_object_id)
        ccount = class_refs.count()
        progress_monitor.info('Class count: {0}'.format(ccount))
        try:
            self._link_classes(queryset_iterator(class_refs), ccount,
                    progress_monitor)
        except Exception:
            logger.exception('Error while processing classes.')
        call_gc()
コード例 #3
0
ファイル: java_linkers.py プロジェクト: bartdag/recodoc2
 def link_references(self, progress_monitor=NullProgressMonitor(),
         local_object_id=None):
     unknown_refs = self._get_query(self.unknown_kind, local_object_id)
     ucount = unknown_refs.count()
     progress_monitor.info('Unknown reference count: {0}'.format(ucount))
     try:
         self._link_all_references(queryset_iterator(unknown_refs), ucount,
                 progress_monitor)
     except Exception:
         logger.exception('Error while processing unknown references.')
     call_gc()
コード例 #4
0
ファイル: java_linkers.py プロジェクト: nengnengwu/recodoc2
 def link_references(self,
                     progress_monitor=NullProgressMonitor(),
                     local_object_id=None):
     unknown_refs = self._get_query(self.unknown_kind, local_object_id)
     ucount = unknown_refs.count()
     progress_monitor.info('Unknown reference count: {0}'.format(ucount))
     try:
         self._link_all_references(queryset_iterator(unknown_refs), ucount,
                                   progress_monitor)
     except Exception:
         logger.exception('Error while processing unknown references.')
     call_gc()
コード例 #5
0
ファイル: java_linkers.py プロジェクト: bartdag/recodoc2
    def link_references(self, progress_monitor=NullProgressMonitor(),
            local_object_id=None):

        method_refs = self._get_query(self.method_kind, local_object_id)
        mcount = method_refs.count()
        progress_monitor.info('Method count: {0}'.format(mcount))
        try:
            self._link_methods(queryset_iterator(method_refs), mcount,
                    progress_monitor)
        except Exception:
            logger.exception('Error while processing methods')

        call_gc()
コード例 #6
0
ファイル: java_linkers.py プロジェクト: nengnengwu/recodoc2
    def link_references(self,
                        progress_monitor=NullProgressMonitor(),
                        local_object_id=None):

        method_refs = self._get_query(self.method_kind, local_object_id)
        mcount = method_refs.count()
        progress_monitor.info('Method count: {0}'.format(mcount))
        try:
            self._link_methods(queryset_iterator(method_refs), mcount,
                               progress_monitor)
        except Exception:
            logger.exception('Error while processing methods')

        call_gc()
コード例 #7
0
ファイル: java_linkers.py プロジェクト: nengnengwu/recodoc2
    def link_references(self,
                        progress_monitor=NullProgressMonitor(),
                        local_object_id=None):

        # Annotation Field
        ann_refs = self._get_query(self.ann_field_kind, local_object_id)
        acount = ann_refs.count()
        progress_monitor.info('Annotation Field count: {0}'.format(acount))
        try:
            self._link_ann_fields(queryset_iterator(ann_refs), acount,
                                  progress_monitor)
        except Exception:
            logger.exception('Error while processing annotation fields')
        call_gc()

        # Enumeration Values
        enum_refs = self._get_query(self.enum_value_kind, local_object_id)
        ecount = enum_refs.count()
        progress_monitor.info('Enumeration Value count: {0}'.format(ecount))
        try:
            self._link_enum_values(queryset_iterator(enum_refs), ecount,
                                   progress_monitor)
        except Exception:
            logger.exception('Error while processing enumeration values')
        call_gc()

        # Fields
        field_refs = self._get_query(self.field_kind, local_object_id)
        fcount = field_refs.count()
        progress_monitor.info('Field count: {0}'.format(fcount))
        try:
            self._link_fields(queryset_iterator(field_refs), fcount,
                              progress_monitor)
        except Exception:
            logger.exception('Error while processing fields')
        call_gc()
コード例 #8
0
ファイル: java_linkers.py プロジェクト: nengnengwu/recodoc2
    def link_references(self,
                        progress_monitor=NullProgressMonitor(),
                        local_object_id=None):

        # Annotations
        ann_refs = self._get_query(self.ann_kind, local_object_id)
        acount = ann_refs.count()
        progress_monitor.info('Annotation count: {0}'.format(acount))
        try:
            self._link_annotations(queryset_iterator(ann_refs), acount,
                                   progress_monitor)
        except Exception:
            logger.exception('Error while processing annotations.')
        call_gc()

        # Enumerations
        enum_refs = self._get_query(self.enum_kind, local_object_id)
        ecount = enum_refs.count()
        progress_monitor.info('Enumeration count: {0}'.format(ecount))
        try:
            self._link_enumerations(queryset_iterator(enum_refs), ecount,
                                    progress_monitor)
        except Exception:
            logger.exception('Error while processing enumerations.')
        call_gc()

        # All types (including classes!)
        class_refs = self._get_query(self.class_kind, local_object_id)
        ccount = class_refs.count()
        progress_monitor.info('Class count: {0}'.format(ccount))
        try:
            self._link_classes(queryset_iterator(class_refs), ccount,
                               progress_monitor)
        except Exception:
            logger.exception('Error while processing classes.')
        call_gc()
コード例 #9
0
ファイル: java_linkers.py プロジェクト: nengnengwu/recodoc2
    def link_references(self,
                        progress_monitor=NullProgressMonitor(),
                        local_object_id=None):

        # Get link to filter.
        linksets = ReleaseLinkSet.objects\
                .filter(project_release=self.prelease)\
                .filter(first_link__code_element__kind__is_type=True)

        count = linksets.count()
        progress_monitor.start('Post-Processing Classes', count)
        log = gl.LinkerLog(self, 'type')

        for linkset in queryset_iterator(linksets):
            log.reset_variables()
            scode_reference = linkset.code_reference
            lcount = linkset.links.count()
            if lcount <= 1:
                log.log_type('', '', scode_reference,
                             linkset.first_link.code_element,
                             [linkset.first_link], lcount, 'onlyone')
                progress_monitor.work('Skipped a linkset.', 1)
                continue

            local_ctx_id = scode_reference.local_object_id
            source = scode_reference.source
            prefix = '{0}{1}{2}'.format(PREFIX_CLASS_POST_LINKER,
                                        cu.get_codebase_key(self.codebase),
                                        source)
            package_freq = cu.get_value(prefix, local_ctx_id, get_package_freq,
                                        [local_ctx_id, source, self.prelease])

            # Find package with highest frequency
            code_element = self._find_package_by_freq(linkset, package_freq)
            rationale = 'highest_frequency'

            # Heuristic
            if code_element is None:
                code_element = self._find_package_by_depth(linkset)
                rationale = 'heuristic_depth'

            # Update links
            if code_element is not None:
                linkset.first_link.code_element = code_element
                linkset.first_link.linker_name = self.name
                linkset.first_link.rationale = rationale
                linkset.first_link.save()
                for link in linkset.links.all()[1:]:
                    link.delete()
                log.log_type('', '', scode_reference,
                             linkset.first_link.code_element,
                             [linkset.first_link], lcount, rationale)
                progress_monitor.info(
                    'FOUND Best Package {0} because {1}'.format(
                        code_element.fqn, rationale))
            else:
                potentials =\
                    [link.code_element for link in linkset.links.all()]
                log.log_type('', '', scode_reference,
                             linkset.first_link.code_element, potentials,
                             lcount, 'nomatch')

            progress_monitor.work('Processed a linkset.', 1)

        progress_monitor.done()
コード例 #10
0
ファイル: java_linkers.py プロジェクト: bartdag/recodoc2
    def link_references(self, progress_monitor=NullProgressMonitor(),
            local_object_id=None):

        # Get link to filter.
        linksets = ReleaseLinkSet.objects\
                .filter(project_release=self.prelease)\
                .filter(first_link__code_element__kind__is_type=True)

        count = linksets.count()
        progress_monitor.start('Post-Processing Classes', count)
        log = gl.LinkerLog(self, 'type')

        for linkset in queryset_iterator(linksets):
            log.reset_variables()
            scode_reference = linkset.code_reference
            lcount = linkset.links.count()
            if lcount <= 1:
                log.log_type('', '', scode_reference,
                        linkset.first_link.code_element,
                        [linkset.first_link], lcount, 'onlyone')
                progress_monitor.work('Skipped a linkset.', 1)
                continue

            local_ctx_id = scode_reference.local_object_id
            source = scode_reference.source
            prefix = '{0}{1}{2}'.format(PREFIX_CLASS_POST_LINKER,
                cu.get_codebase_key(self.codebase), source)
            package_freq = cu.get_value(
                    prefix,
                    local_ctx_id,
                    get_package_freq,
                    [local_ctx_id, source, self.prelease])

            # Find package with highest frequency
            code_element = self._find_package_by_freq(linkset, package_freq)
            rationale = 'highest_frequency'

            # Heuristic
            if code_element is None:
                code_element = self._find_package_by_depth(linkset)
                rationale = 'heuristic_depth'

            # Update links
            if code_element is not None:
                linkset.first_link.code_element = code_element
                linkset.first_link.linker_name = self.name
                linkset.first_link.rationale = rationale
                linkset.first_link.save()
                for link in linkset.links.all()[1:]:
                    link.delete()
                log.log_type('', '', scode_reference,
                        linkset.first_link.code_element,
                        [linkset.first_link], lcount, rationale)
                progress_monitor.info('FOUND Best Package {0} because {1}'
                        .format(code_element.fqn, rationale))
            else:
                potentials =\
                    [link.code_element for link in linkset.links.all()]
                log.log_type('', '', scode_reference,
                        linkset.first_link.code_element,
                        potentials, lcount, 'nomatch')

            progress_monitor.work('Processed a linkset.', 1)

        progress_monitor.done()