-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Hi, thank you very much for implementing this library.
I would like to have more information about its use for the following scenario: given two code snippets, I would like to know the location of the lines and tokens that have been changed or added.
Let's take this case as an example:
Code
output = cd.difference(
'''
String var = "Hello";
int x = x + 1 + 8;
List list = new ArrayList<>();
''',
'''
String var1 = "Hello";
int x = x + 1;
List list = new ArrayList<>();
List list2 = new ArrayList<>();
''',
lang = "java")
As you can see, the difference between the two code snippets lies in line 1 (renaming the variable 'var' to 'var1'), line 2 (adding a new addition), and finally, line 4 (adding a new statement).
The output of this execution is as follows:
Output
[
Insert((local_variable_declaration, N0), (program, line 1:8 - 4:4), 3),
Insert((generic_type, N1), N0, 0),
Insert((variable_declarator, N2), N0, 1),
Insert(;:;, N0, 2),
Update((identifier:var, line 1:15 - 1:18), var1),
Move((binary_expression, line 2:16 - 2:21), (variable_declarator, line 2:12 - 2:25), 2),
Insert(type_identifier:List, N1, 0),
Insert((type_arguments, N3), N1, 1),
Insert(identifier:list2, N2, 0),
Insert(=:=, N2, 1),
Insert((object_creation_expression, N4), N2, 2),
Insert(<:<, N3, 0),
Insert(type_identifier:String, N3, 1),
Insert(>:>, N3, 2),
Insert(new:new, N4, 0),
Insert((generic_type, N5), N4, 1),
Insert((argument_list, N6), N4, 2),
Insert(type_identifier:ArrayList, N5, 0),
Insert((type_arguments, N7), N5, 1),
Insert((:(, N6, 0),
Insert():), N6, 1),
Insert(<:<, N7, 0),
Insert(>:>, N7, 1),
Delete((+:+, line 2:22 - 2:23)),
Delete((decimal_integer_literal:8, line 2:24 - 2:25)),
Delete((binary_expression, line 2:16 - 2:25))
]
From this output, however, I cannot get the information I mentioned above. Does the library support this functionality or is there a way to get this information?
Thanks again for the support.