Esempio n. 1
0
    def _link_fields(self, field_refs, acount, progress_monitor):
        count = 0
        progress_monitor.start('Parsing fields', acount)
        log = gl.LinkerLog(self, self.field_kind.kind)

        for scode_reference in field_refs:
            (field_name, fqn_container) = self._get_field_name(scode_reference)
            code_elements = []
            code_elements.extend(
                self._get_field_elements(field_name, PREFIX_FIELD_LINKER,
                                         self.field_kind))
            code_elements.extend(
                self._get_field_elements(field_name, PREFIX_ENUM_VAL_LINKER,
                                         self.enum_value_kind))
            code_elements.extend(
                self._get_field_elements(field_name, PREFIX_ANN_FIELD_LINKER,
                                         self.ann_field_kind))

            (code_element,
             potentials) = self.get_code_element(scode_reference,
                                                 code_elements, field_name,
                                                 fqn_container, log)
            count += gl.save_link(scode_reference, code_element, potentials,
                                  self)

            if not log.custom_filtered:
                reclassify_java(code_element, scode_reference)

            progress_monitor.work('Processed field', 1)

        log.close()
        progress_monitor.done()
        print('Associated {0} fields'.format(count))
Esempio n. 2
0
    def _link_fields(self, field_refs, acount, progress_monitor):
        count = 0
        progress_monitor.start('Parsing fields', acount)
        log = gl.LinkerLog(self, self.field_kind.kind)

        for scode_reference in field_refs:
            (field_name, fqn_container) = self._get_field_name(scode_reference)
            code_elements = []
            code_elements.extend(self._get_field_elements(field_name,
                    PREFIX_FIELD_LINKER, self.field_kind))
            code_elements.extend(self._get_field_elements(field_name,
                    PREFIX_ENUM_VAL_LINKER, self.enum_value_kind))
            code_elements.extend(self._get_field_elements(field_name,
                    PREFIX_ANN_FIELD_LINKER, self.ann_field_kind))

            (code_element, potentials) = self.get_code_element(
                    scode_reference, code_elements, field_name, fqn_container,
                    log)
            count += gl.save_link(scode_reference, code_element, potentials,
                    self)

            if not log.custom_filtered:
                reclassify_java(code_element, scode_reference)

            progress_monitor.work('Processed field', 1)

        log.close()
        progress_monitor.done()
        print('Associated {0} fields'.format(count))
Esempio n. 3
0
    def _link_enum_values(self, enum_refs, ecount, progress_monitor):
        count = 0
        progress_monitor.start('Parsing enumeration values', ecount)
        log = gl.LinkerLog(self, self.enum_value_kind.kind)

        for scode_reference in enum_refs:
            (field_name, fqn_container) = self._get_field_name(scode_reference)
            code_elements = self._get_field_elements(field_name,
                                                     PREFIX_ENUM_VAL_LINKER,
                                                     self.enum_value_kind)

            (code_element,
             potentials) = self.get_code_element(scode_reference,
                                                 code_elements, field_name,
                                                 fqn_container, log)
            count += gl.save_link(scode_reference, code_element, potentials,
                                  self)

            if not log.custom_filtered:
                reclassify_java(code_element, scode_reference)

            progress_monitor.work('Processed enum value', 1)

        log.close()
        progress_monitor.done()
        print('Associated {0} enum values'.format(count))
Esempio n. 4
0
    def _link_enumerations(self, enum_refs, ecount, progress_monitor):
        count = 0
        progress_monitor.start('Parsing enumerations', ecount)
        log = gl.LinkerLog(self, self.enum_kind.kind)

        for scode_reference in enum_refs:
            if scode_reference.declaration:
                progress_monitor.work('Skipped declaration', 1)
                continue

            (simple, fqn) = je.get_annotation_name(scode_reference.content,
                    scode_reference.snippet is not None)

            if simple is not None:
                prefix = '{0}{1}{2}'.format(PREFIX_ENUMERATION_LINKER, EXACT,
                    cu.get_codebase_key(self.codebase))
                code_elements = cu.get_value(
                        prefix,
                        simple,
                        gl.get_type_code_elements,
                        [simple, self.codebase, self.enum_kind])

                (code_element, potentials) = self.get_code_element(
                        scode_reference, code_elements, simple, fqn, log)
                count += gl.save_link(scode_reference, code_element,
                        potentials, self)

                if not log.custom_filtered:
                    reclassify_java(code_element, scode_reference)

            progress_monitor.work('Processed enumeration', 1)

        log.close()
        progress_monitor.done()
        print('Associated {0} enumerations'.format(count))
Esempio n. 5
0
    def _link_methods(self, method_refs, mcount, progress_monitor):
        count = 0
        progress_monitor.start('Parsing methods', mcount)
        log = gl.LinkerLog(self, self.method_kind.kind)

        for scode_reference in method_refs:
            method_info = self._get_method_info(scode_reference)
            code_elements = self._get_method_elements(method_info)

            (code_element, potentials) = self.get_code_element(
                    scode_reference, code_elements, method_info, log)
            count += gl.save_link(scode_reference, code_element, potentials,
                    self)

            if not log.custom_filtered:
                reclassify_java(code_element, scode_reference)

            progress_monitor.work('Processed method', 1)

        log.close()
        progress_monitor.done()
        print('Associated {0} methods'.format(count))
Esempio n. 6
0
    def _link_methods(self, method_refs, mcount, progress_monitor):
        count = 0
        progress_monitor.start('Parsing methods', mcount)
        log = gl.LinkerLog(self, self.method_kind.kind)

        for scode_reference in method_refs:
            method_info = self._get_method_info(scode_reference)
            code_elements = self._get_method_elements(method_info)

            (code_element,
             potentials) = self.get_code_element(scode_reference,
                                                 code_elements, method_info,
                                                 log)
            count += gl.save_link(scode_reference, code_element, potentials,
                                  self)

            if not log.custom_filtered:
                reclassify_java(code_element, scode_reference)

            progress_monitor.work('Processed method', 1)

        log.close()
        progress_monitor.done()
        print('Associated {0} methods'.format(count))
Esempio n. 7
0
    def _link_enumerations(self, enum_refs, ecount, progress_monitor):
        count = 0
        progress_monitor.start('Parsing enumerations', ecount)
        log = gl.LinkerLog(self, self.enum_kind.kind)

        for scode_reference in enum_refs:
            if scode_reference.declaration:
                progress_monitor.work('Skipped declaration', 1)
                continue

            (simple,
             fqn) = je.get_annotation_name(scode_reference.content,
                                           scode_reference.snippet is not None)

            if simple is not None:
                prefix = '{0}{1}{2}'.format(PREFIX_ENUMERATION_LINKER, EXACT,
                                            cu.get_codebase_key(self.codebase))
                code_elements = cu.get_value(
                    prefix, simple, gl.get_type_code_elements,
                    [simple, self.codebase, self.enum_kind])

                (code_element,
                 potentials) = self.get_code_element(scode_reference,
                                                     code_elements, simple,
                                                     fqn, log)
                count += gl.save_link(scode_reference, code_element,
                                      potentials, self)

                if not log.custom_filtered:
                    reclassify_java(code_element, scode_reference)

            progress_monitor.work('Processed enumeration', 1)

        log.close()
        progress_monitor.done()
        print('Associated {0} enumerations'.format(count))
Esempio n. 8
0
    def _link_enum_values(self, enum_refs, ecount, progress_monitor):
        count = 0
        progress_monitor.start('Parsing enumeration values', ecount)
        log = gl.LinkerLog(self, self.enum_value_kind.kind)

        for scode_reference in enum_refs:
            (field_name, fqn_container) = self._get_field_name(scode_reference)
            code_elements = self._get_field_elements(field_name,
                    PREFIX_ENUM_VAL_LINKER, self.enum_value_kind)

            (code_element, potentials) = self.get_code_element(
                    scode_reference, code_elements, field_name, fqn_container,
                    log)
            count += gl.save_link(scode_reference, code_element, potentials,
                    self)

            if not log.custom_filtered:
                reclassify_java(code_element, scode_reference)

            progress_monitor.work('Processed enum value', 1)

        log.close()
        progress_monitor.done()
        print('Associated {0} enum values'.format(count))
Esempio n. 9
0
    def _link_classes(self, class_refs, ccount, progress_monitor):
        count = 0
        progress_monitor.start('Parsing classes', ccount)
        log = gl.LinkerLog(self, self.class_kind.kind)

        for scode_reference in class_refs:
            if scode_reference.declaration:
                progress_monitor.work('Skipped declaration', 1)
                continue

            (simple,
             fqn) = je.get_annotation_name(scode_reference.content,
                                           scode_reference.snippet is not None)
            case_insensitive = scode_reference.snippet == None and\
                    self.source != 'd'

            if case_insensitive:
                exact = False
                exact_prefix = IEXACT
            else:
                exact = True
                exact_prefix = EXACT

            if simple is not None:
                prefix = '{0}{1}{2}'.format(PREFIX_CLASS_LINKER, exact_prefix,
                                            cu.get_codebase_key(self.codebase))
                code_elements = []
                code_elements.extend(
                    cu.get_value(
                        prefix, simple, gl.get_type_code_elements,
                        [simple, self.codebase, self.class_kind, exact]))

                prefix = '{0}{1}{2}'.format(PREFIX_ANNOTATION_LINKER,
                                            exact_prefix,
                                            cu.get_codebase_key(self.codebase))
                code_elements.extend(
                    cu.get_value(
                        prefix, simple, gl.get_type_code_elements,
                        [simple, self.codebase, self.ann_kind, exact]))

                prefix = '{0}{1}{2}'.format(PREFIX_ENUMERATION_LINKER,
                                            exact_prefix,
                                            cu.get_codebase_key(self.codebase))
                code_elements.extend(
                    cu.get_value(
                        prefix, simple, gl.get_type_code_elements,
                        [simple, self.codebase, self.enum_kind, exact]))

                (code_element,
                 potentials) = self.get_code_element(scode_reference,
                                                     code_elements, simple,
                                                     fqn, log, not exact)
                count += gl.save_link(scode_reference, code_element,
                                      potentials, self)

                if not log.custom_filtered:
                    reclassify_java(code_element, scode_reference)

            progress_monitor.work('Processed class', 1)

        log.close()
        progress_monitor.done()
        print('Associated {0} classes'.format(count))
Esempio n. 10
0
    def _process_tuples(self, class_tuples, progress_monitor):
        method_tuples = []
        field_tuples = []
        count = 0

        for (reference, simple, fqn, class_elements, method_elements,
             field_elements) in class_tuples:
            if len(class_elements) > 0:
                log = gl.LinkerLog(self, 'generic-' + self.class_kind.kind)
                (code_element, potentials) = \
                        self.class_linker.get_code_element(reference,
                                class_elements, simple, fqn, log, True)
                if code_element is not None:
                    count += gl.save_link(reference, code_element, potentials,
                                          self)
                else:
                    method_tuples.append((reference, simple, fqn,
                                          method_elements, field_elements))
                log.close()
            else:
                method_tuples.append(
                    (reference, simple, fqn, method_elements, field_elements))

        for (reference, simple, fqn, method_elements,
             field_elements) in method_tuples:
            if len(method_elements) > 0:
                fqn_container = je.get_package_name(fqn)
                if fqn_container == simple:
                    fqn_container = None
                log = gl.LinkerLog(self, 'generic-' + self.method_kind.kind)
                method_info = MethodInfo(simple, fqn_container, None, None)
                (code_element, potentials) =\
                        self.method_linker.get_code_element(reference,
                                method_elements, method_info, log)
                if code_element is not None:
                    count += gl.save_link(reference, code_element, potentials,
                                          self)
                else:
                    field_tuples.append(
                        (reference, simple, fqn, field_elements))
                log.close()
            else:
                field_tuples.append((reference, simple, fqn, field_elements))

        for (reference, simple, fqn, field_elements) in field_tuples:
            if len(field_elements) > 0:
                fqn_container = je.get_package_name(fqn)
                if fqn_container == simple:
                    fqn_container = None
                log = gl.LinkerLog(self, 'generic-' + self.field_kind.kind)
                (code_element, potentials) =\
                        self.field_linker.get_code_element(reference,
                                field_elements, simple, fqn_container, log)
                if code_element is not None:
                    count += gl.save_link(reference, code_element, potentials,
                                          self)
                else:
                    field_tuples.append(
                        (reference, simple, fqn, field_elements))
                log.close()

        return count
Esempio n. 11
0
    def _link_classes(self, class_refs, ccount, progress_monitor):
        count = 0
        progress_monitor.start('Parsing classes', ccount)
        log = gl.LinkerLog(self, self.class_kind.kind)

        for scode_reference in class_refs:
            if scode_reference.declaration:
                progress_monitor.work('Skipped declaration', 1)
                continue

            (simple, fqn) = je.get_annotation_name(scode_reference.content,
                    scode_reference.snippet is not None)
            case_insensitive = scode_reference.snippet == None and\
                    self.source != 'd'

            if case_insensitive:
                exact = False
                exact_prefix = IEXACT
            else:
                exact = True
                exact_prefix = EXACT

            if simple is not None:
                prefix = '{0}{1}{2}'.format(PREFIX_CLASS_LINKER, exact_prefix,
                    cu.get_codebase_key(self.codebase))
                code_elements = []
                code_elements.extend(cu.get_value(
                        prefix,
                        simple,
                        gl.get_type_code_elements,
                        [simple, self.codebase, self.class_kind, exact]))

                prefix = '{0}{1}{2}'.format(PREFIX_ANNOTATION_LINKER,
                        exact_prefix, cu.get_codebase_key(self.codebase))
                code_elements.extend(cu.get_value(
                        prefix,
                        simple,
                        gl.get_type_code_elements,
                        [simple, self.codebase, self.ann_kind, exact]))

                prefix = '{0}{1}{2}'.format(PREFIX_ENUMERATION_LINKER,
                        exact_prefix, cu.get_codebase_key(self.codebase))
                code_elements.extend(cu.get_value(
                        prefix,
                        simple,
                        gl.get_type_code_elements,
                        [simple, self.codebase, self.enum_kind, exact]))

                (code_element, potentials) = self.get_code_element(
                        scode_reference, code_elements, simple, fqn, log,
                        not exact)
                count += gl.save_link(scode_reference, code_element,
                        potentials, self)

                if not log.custom_filtered:
                    reclassify_java(code_element, scode_reference)

            progress_monitor.work('Processed class', 1)

        log.close()
        progress_monitor.done()
        print('Associated {0} classes'.format(count))
Esempio n. 12
0
    def _process_tuples(self, class_tuples, progress_monitor):
        method_tuples = []
        field_tuples = []
        count = 0

        for (reference, simple, fqn, class_elements, method_elements,
                field_elements) in class_tuples:
            if len(class_elements) > 0:
                log = gl.LinkerLog(self, 'generic-' + self.class_kind.kind)
                (code_element, potentials) = \
                        self.class_linker.get_code_element(reference,
                                class_elements, simple, fqn, log, True)
                if code_element is not None:
                    count += gl.save_link(reference, code_element,
                            potentials, self)
                else:
                    method_tuples.append((reference, simple, fqn,
                        method_elements, field_elements))
                log.close()
            else:
                method_tuples.append((reference, simple, fqn,
                    method_elements, field_elements))

        for (reference, simple, fqn, method_elements,
                field_elements) in method_tuples:
            if len(method_elements) > 0:
                fqn_container = je.get_package_name(fqn)
                if fqn_container == simple:
                    fqn_container = None
                log = gl.LinkerLog(self, 'generic-' + self.method_kind.kind)
                method_info = MethodInfo(simple, fqn_container, None, None)
                (code_element, potentials) =\
                        self.method_linker.get_code_element(reference,
                                method_elements, method_info, log)
                if code_element is not None:
                    count += gl.save_link(reference, code_element,
                            potentials, self)
                else:
                    field_tuples.append((reference, simple, fqn,
                        field_elements))
                log.close()
            else:
                field_tuples.append((reference, simple, fqn, field_elements))

        for (reference, simple, fqn, field_elements) in field_tuples:
            if len(field_elements) > 0:
                fqn_container = je.get_package_name(fqn)
                if fqn_container == simple:
                    fqn_container = None
                log = gl.LinkerLog(self, 'generic-' + self.field_kind.kind)
                (code_element, potentials) =\
                        self.field_linker.get_code_element(reference,
                                field_elements, simple, fqn_container, log)
                if code_element is not None:
                    count += gl.save_link(reference, code_element,
                            potentials, self)
                else:
                    field_tuples.append((reference, simple, fqn,
                        field_elements))
                log.close()

        return count