This commit is contained in:
Paul Gauthier 2023-05-24 21:39:36 -07:00
parent 3ecf008478
commit 43b79b0c2d
2 changed files with 26 additions and 12 deletions

View file

@ -3,6 +3,9 @@ import math
from difflib import SequenceMatcher
from pathlib import Path
from pygments.util import ClassNotFound
from pygments.lexers import guess_lexer_for_filename
from pygments.token import Token
# from aider.dump import dump
@ -263,6 +266,17 @@ def find_original_update_blocks(content):
raise ValueError(f"{processed}\n^^^ Error parsing ORIGINAL/UPDATED block.")
def get_name_identifiers(fname):
with open(fname, "r") as f:
content = f.read()
try:
lexer = guess_lexer_for_filename(fname, content)
except ClassNotFound:
return list()
tokens = list(lexer.get_tokens(content))
return set(token[1] for token in tokens if token[0] in Token.Name)
if __name__ == "__main__":
edit = """
Here's the change: