-
Is it possible to compare two partial java code fragment with the tool? If not, how to extend and add this feature into gumtreediff? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
Hi! What do you mean by partial? Cheers |
Beta Was this translation helpful? Give feedback.
-
For example ,given the following two partial code fragments, that is
and
How to get the diff between them? |
Beta Was this translation helpful? Give feedback.
-
Thank you for your quick response. According to your hints, i wrote a simple code to compute the difference between two code fragments that uses jtree-sitter backend . The simple code is listed as follows.
However, when running the code above, i got the following error:
I have checked the source code of gen.treesitter and found the error occurred because that the file "tree-sitter-parser.py" is missing. How to solve the problem? The following is the code that references the tree-sitter-parser.py.
|
Beta Was this translation helpful? Give feedback.
-
After adding tree-sitter-parser.py in the system's path, the code runs successfully. However, the tree-sitter backend doesn't seem to work for me. To illustrate, we use the following simple example to show the reason.
Running the example code above will produce the following result: Note that the two code fragments are the followings
Our goal aims to use gumtree tool to extract the high-level code modification pattern. In particular, the code modification pattern of the two code fragments above is modification of condition expression of If statement. Obviously, after the gumtree tool computes the difference between them,three Insert actions are identified. However, based on these Insert actions, it is hard to associate the modification with the condition expression of If statement since the Tree Interface in gumtree does not have attribute such as AST node. on the contrary, we note that gumtree-spoon-ast-diff extends this by adding the attribute CtElement parent in AdditionOperation class. Thus, in order to realize my goal, i have to extend tree generator in the similar way like gumtree-spoon-ast-diff, right? While studying the code of gumtreediff, the gumtreediff also supports the generation of tree by using jdt core parser backend. In fact, Jdt core parser can also parse partial code fragment. Specifically, in Jdt, when replacing the parsing kind ASTParser.K_COMPILATION_UNIT with ASTParser.K_STATEMENTS, the parser can generate the ast tree from the partial code fragment. So i can adopt jdt parser backend instead of tree-sitter-java backend, right? Thanks! |
Beta Was this translation helpful? Give feedback.
After adding tree-sitter-parser.py in the system's path, the code runs successfully. However, the tree-sitter backend doesn't seem to work for me. To illustrate, we use the following simple example to show the reason.