Commit da30cebf authored by erodrigu's avatar erodrigu
Browse files

Working version using Finder.py find_declaration_line function

parent eccb86b7
......@@ -5,6 +5,7 @@ from AutoRPE.UtilsRPE.CurrentBlock import CurrentBlock
from AutoRPE.UtilsRPE.Inserter import replace_real_declaration
from AutoRPE.UtilsRPE.SourceManager import preprocess_sources, parse_sources, load_vault
from AutoRPE.UtilsRPE.Cleaner import remove_comments
from AutoRPE.UtilsRPE.Finder import find_declaration_line
from os import mkdir
from os.path import join, isdir
......@@ -63,7 +64,7 @@ def replace_subroutine_name(old_name, new_name, code_text):
return pat.sub(replacement, code_text)
def find_declaration_line(variable, routine_lines):
def xfind_declaration_line(variable, routine_lines):
import re
import warnings
# Declaration pattern
......@@ -115,7 +116,6 @@ def replace_routine_name(old_name, new_name, code_text):
replacement = r"\1 %s" % new_name
return pat.sub(replacement, code_text)
if __name__ == "__main__":
# Get command line arguments
......@@ -164,10 +164,16 @@ if __name__ == "__main__":
new_routine_name = "%s_%04i" % (routine.name, c_index)
for index, variable in enumerate(sensitive_variables):
variable_precision = combination[index]
dec_line = find_declaration_line(variable, routine_lines)
original_line = version_lines[dec_line]
new_line = replace_real_declaration(variable, original_line, variable_precision)
version_lines[dec_line] = new_line
# Find the declaration/original lines
d_lines = find_declaration_line(variable, filepath, vault)
for d_line in d_lines:
if d_line >= indices[0] and d_line <= indices[1]:
original_line = version_lines[d_line - indices[0]]
new_line = replace_real_declaration(variable, original_line, variable_precision)
version_lines[d_line - indices[0]] = new_line
version_text = "\n".join(version_lines).strip()
version_text = replace_routine_name(routine.name, new_routine_name, version_text)
code_versions[c_index] = version_text
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment