Example #1
0
    def match(self, text):
        matches = set()
        for m in SIMPLE_CALL_RE.finditer(text):
            matches.add(
                    create_match(
                        (m.start(), m.end(), 'method', self.priority)))
        for m in METHOD_SIGNATURE_RE.finditer(text):
            matches.add(
                    create_match(
                        (m.start(), m.end(), 'method', self.priority)))
        for m in CALL_CHAIN_RE.finditer(text):
            call_chain = text[m.start():m.end()]
            offset = m.start()
            children = []
            for child_match in SIMPLE_CALL_NO_TARGET_RE.finditer(call_chain):
                children.append(
                        (child_match.start() + offset,
                         child_match.end() + offset,
                         'method',
                         self.priority))

            # Basically, children[0] is == m except that the target
            # would not be there
            matches.add(
                    create_match(
                        (m.start(), m.end(), 'method', self.priority),
                        children[1:]))
        for m in METHOD_DECLARATION_STRICT_RE.finditer(text):
            matches.add(
                    create_match(
                        (m.start(), m.end(), 'method', self.priority)))
        return matches
Example #2
0
 def match(self, text):
     matches = set()
     for m in XML_PATTERN_RE.finditer(text):
         if ANCHOR_URL_PATTERN_RE.search(m.group(0)) or\
             ANCHOR_EMAIL_PATTERN_RE.match(m.group(0)):
             continue
         xml_element = m.group(0)
         offset = m.start()
         children = get_xml_pair(xml_element, offset, self.priority)
         matches.add(
             create_match(
                 (m.start(), m.end(), 'xml element', self.priority),
                 children))
     for m in FUZZY_XML_PATTERN_RE.finditer(text):
         if ANCHOR_URL_PATTERN_RE.match(m.group(0)) or\
             ANCHOR_EMAIL_PATTERN_RE.match(m.group(0)):
             continue
         xml_element = m.group(0)
         offset = m.start()
         children = get_xml_pair(xml_element, offset, self.priority)
         matches.add(
             create_match(
                 (m.start(), m.end(), 'xml element', self.priority),
                 children))
     return matches
Example #3
0
 def match(self, text):
     matches = set()
     for m in XML_PATTERN_RE.finditer(text):
         if ANCHOR_URL_PATTERN_RE.search(m.group(0)) or\
             ANCHOR_EMAIL_PATTERN_RE.match(m.group(0)):
             continue
         xml_element = m.group(0)
         offset = m.start()
         children = get_xml_pair(xml_element,offset,self.priority)
         matches.add(
                 create_match(
                     (m.start(), m.end(), 'xml element', self.priority),
                     children))
     for m in FUZZY_XML_PATTERN_RE.finditer(text):
         if ANCHOR_URL_PATTERN_RE.match(m.group(0)) or\
             ANCHOR_EMAIL_PATTERN_RE.match(m.group(0)):
             continue
         xml_element = m.group(0)
         offset = m.start()
         children = get_xml_pair(xml_element,offset,self.priority)
         matches.add(
                 create_match(
                     (m.start(), m.end(), 'xml element', self.priority),
                     children))
     return matches
Example #4
0
    def match(self, text):
        matches = set()
        for m in SIMPLE_CALL_TARGET_RE.finditer(text):
            matches.add(
                    create_match(
                        (m.start(), m.end(), 'class', self.priority),
                        [(m.start(), m.end(), 'method', self.priority)]))
        for m in METHOD_SIGNATURE_TARGET_RE.finditer(text):
            matches.add(
                    create_match(
                        (m.start(), m.end(), 'class', self.priority),
                        [(m.start(), m.end(), 'method', self.priority)]))
        for m in CALL_CHAIN_TARGET_RE.finditer(text):
            call_chain = text[m.start():m.end()]
            offset = m.start()
            children = []
            for child_match in SIMPLE_CALL_NO_TARGET_RE.finditer(call_chain):
                children.append(
                        (child_match.start() + offset,
                         child_match.end() + offset,
                         'method', self.priority))

            # Basically, the first child should still refer to the container
            first_child = [(m.start(), m.end(), 'method', self.priority)]
            matches.add(
                    create_match(
                        (m.start(), m.end(), 'class', self.priority),
                        first_child + children[1:]))
        return matches
Example #5
0
 def match(self, text):
     matches = set()
     for m in XML_FILE_RE.finditer(text):
         matches.add(create_match(
             (m.start(), m.end(), 'xml file', self.priority)))
     for m in CONF_FILE_RE.finditer(text):
         matches.add(create_match(
             (m.start(), m.end(), 'conf file', self.priority)))
     for m in INI_FILE_RE.finditer(text):
         matches.add(create_match(
             (m.start(), m.end(), 'ini file', self.priority)))
     for m in PROPERTIES_FILE_RE.finditer(text):
         matches.add(create_match(
             (m.start(), m.end(), 'properties file', self.priority)))
     for m in LOG_FILE_RE.finditer(text):
         matches.add(create_match(
             (m.start(), m.end(), 'log file', self.priority)))
     for m in JAR_FILE_RE.finditer(text):
         matches.add(create_match(
             (m.start(), m.end(), 'jar file', self.priority)))
     for m in JAVA_FILE_RE.finditer(text):
         matches.add(create_match(
             (m.start(), m.end(), 'java file', self.priority)))
     for m in PYTHON_FILE_RE.finditer(text):
         matches.add(create_match(
             (m.start(), m.end(), 'python file', self.priority)))
     for m in HBM_FILE_RE.finditer(text):
         matches.add(create_match(
             (m.start(), m.end(), 'hbm file', self.priority)))
     return matches
Example #6
0
 def match(self, text):
     matches = set()
     for m in FQN_RE.finditer(text):
         (simple, _) = clean_java_name(m.group(0))
         if len(simple) > 0:
             if simple[0].islower() or CONSTANT_RE.match(simple):
                 matches.add(
                     create_match(
                         (m.start(), m.end(), 'class', self.priority),
                         [(m.start(), m.end(), 'field', self.priority)]))
     for m in CONSTANT_RE.finditer(text):
         matches.add(
                 create_match(
                     (m.start(), m.end(), 'field', self.priority)))
     return matches
Example #7
0
 def match(self, text):
     matches = set()
     for m in ANNOTATION_RE.finditer(text):
         matches.add(
                 create_match(
                     (m.start(), m.end(), 'annotation', self.priority)))
     return matches
Example #8
0
 def match(self, text):
     matches = set()
     for regex in self.regexes:
         for m in regex.finditer(text):
             #print('IGNORED: %s' % m.group(0))
             matches.add(
                     create_match(
                         (m.start(), m.end(), IGNORE_KIND, self.priority)))
     return matches
Example #9
0
def parse_text_code_words(text, code_words):
    # Because there is a chance that the FQN will match...
    priority = 1
    matches = []
    words = split_pos(text)
    for (word, start, end) in words:
        if word in code_words:
            # Because at this stage, we force it to choose one only...
            matches.append(create_match((start, end, 'class', priority)))
    return matches
Example #10
0
def parse_text_code_words(text, code_words):
    # Because there is a chance that the FQN will match...
    priority = 1
    matches = []
    words = split_pos(text)
    for (word, start, end) in words:
        if word in code_words:
            # Because at this stage, we force it to choose one only...
            matches.append(create_match((start, end, 'class', priority)))
    return matches
Example #11
0
    def match(self, text):
        matches = set()
        for m in FQN_RE.finditer(text):
            matches.add(
                    create_match((m.start(), m.end(), 'class', self.priority)))
        for m in CAMEL_CASE_1_RE.finditer(text):
            matches.add(
                    create_match((m.start(), m.end(), 'class', self.priority)))
        for m in CAMEL_CASE_2_RE.finditer(text):
            matches.add(
                    create_match((m.start(), m.end(), 'class', self.priority)))
        for m in CAMEL_CASE_3_RE.finditer(text):
            matches.add(
                    create_match((m.start(), m.end(), 'class', self.priority)))
        for m in CAMEL_CASE_4_RE.finditer(text):
            matches.add(
                    create_match((m.start(), m.end(), 'class', self.priority)))
        for m in TYPE_IN_MIDDLE_RE.finditer(text):
            if m.group('dot') is None:
                matches.add(create_match(
                    (m.start('class'), m.end('class'), 'class', self.priority))
                    )

        return matches
Example #12
0
 def match(self, text):
     matches = set()
     for m in DEFINITION_ELEMENT_RE.finditer(text):
         matches.add(create_match(
             (m.start(1), m.end(1), 'unknown', self.priority)))
     return matches