Skip to content

The target node information is not available in update operation #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mohayemin opened this issue Nov 27, 2023 · 1 comment
Open

Comments

@mohayemin
Copy link

mohayemin commented Nov 27, 2023

I have a use case where I need the information of the target nodes in the EditScript. However, only the target node text is passed to the Update objects. For example the code at code_diff/__init__.py:L200 is

if source_ast.type == target_ast.type and len(source_ast.children) == 0 and len(target_ast.children) == 0:
  # Both nodes are tokens of the same type 
  # Only an update is required
  return EditScript([Update(source_ast, target_ast.text)])

I suggest that the last line to be replaced with:

return EditScript([Update(source_ast, target_ast)])
@mohayemin mohayemin changed the title The target node information is not available in edit script The target node information is not available in update operation Nov 27, 2023
@cedricrupb
Copy link
Owner

I am not a fan of referencing the target tree in the edit script. I would prefer if the edit script is only dependent on the tree for which it was computed for.

In addition, finding the subtree which is related to specific operation is not always possible (e.g. what is the related subtree for Move or Delete operations?)

If you are only interested in the update operation, you could compute the edit map (see code_diff/gumtree/init.py#L23 ). Whenever there are two nodes with different labels in the edit map, we would generate an update operation (+ some adjustments of the child nodes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants