(filename, includeMod=False)
| 148 | |
| 149 | |
| 150 | def findImpl(filename, includeMod=False) -> list: |
| 151 | results = [] |
| 152 | with open(filename, "r") as file: |
| 153 | string = re.sub(r" +//[^\n]+\n", "\n", file.read()) |
| 154 | # while '\n\n\n' in string: |
| 155 | # string = re.sub(r'\n\s+\n', r'\n\n', string) |
| 156 | # string = re.sub(r'#\[cfg\(test\)\]\n+mod\s+\w+\s*\{(.|\s)+\n\}', '', string) |
| 157 | |
| 158 | pattern = r"(impl" + (r"|mod" if includeMod else r"") + r")\s+((?P<trait>[^\s]+)\s+for\s+)?(?P<struct>[^\s]+)\s*\{" |
| 159 | # for func in re.findall(pattern, re.sub('/\\*.+\\*/', '', re.sub('//.+\n', '\n', file.read()))): # remove comment |
| 160 | # for func in re.findall(pattern, re.sub('//.+\n', '\n', file.read())): # remove comment |
| 161 | |
| 162 | matches = re.compile(pattern, re.MULTILINE | re.DOTALL) |
| 163 | for match in matches.finditer(string): |
| 164 | results.append( |
| 165 | { |
| 166 | "struct": match.groupdict()["struct"] if match.groupdict()["struct"] else "", |
| 167 | "trait": match.groupdict()["trait"] if match.groupdict()["trait"] else "", |
| 168 | "file": filename, |
| 169 | "line_number": string[0 : match.start()].count("\n") + 1, |
| 170 | } |
| 171 | ) |
| 172 | return results |
| 173 | |
| 174 | |
| 175 | def findFunc(filename, ignoreTest=False) -> list: |
no test coverage detected