Skip to content
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

feat: record positions of each node in Tree #325

Merged
merged 7 commits into from
Sep 22, 2024
Merged

Conversation

algomaster99
Copy link
Member

Fixes #323

We record start and end position characters in each node in the Gumtree tree. Thankfully, Spoon nodes provide this information in these two APIs.

Most of the nodes in Spoon are visited in TreeScanner and they are added to Gumtree AST. However, there are many more nodes created in NodeCreator for which I have added the position manually. Hence, they require testing. This is why I am marking this PR as draft right now. I will add some tests soon and then merge. @pouryafard75, please try out this PR and report any bugs in the positions you get. It will also help me write tests. :)

@algomaster99
Copy link
Member Author

No tests fail right now because we never really tested for positions.

@monperrus
Copy link
Contributor

thanks a lot @algomaster99

let's add a new test case then!

@algomaster99
Copy link
Member Author

@pouryafard75, I have added some preliminary tests to ensure things are working. Please try them out with your use case and report bugs. I will work more on this during weekend and then finally merge.

@algomaster99
Copy link
Member Author

algomaster99 commented Sep 22, 2024

I have created tests which checks the following behavior:

  1. child node should be enclosed in the parent node. It is not strict meaning the both nodes can have the same start and end.
  2. no sibling nodes should not overlap.
  3. all nodes should be more than 0 length.

The tests fail for 3 because INRIA/spoon#5980.

EDIT: It can be zero length, see INRIA/spoon#5980 (comment).

@algomaster99 algomaster99 marked this pull request as ready for review September 22, 2024 17:35
@algomaster99
Copy link
Member Author

@monperrus this is ready for merge.

@monperrus monperrus merged commit f5e6ff2 into master Sep 22, 2024
1 check passed
@monperrus monperrus deleted the node-position branch September 22, 2024 18:58
@monperrus
Copy link
Contributor

thanks a lot @algomaster99

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

Successfully merging this pull request may close these issues.

Offsets are all zeros [0,0]
2 participants