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

review: improve PotentialVariableDeclarationFunction, simplify its usage #1194

Merged
merged 2 commits into from
Mar 11, 2017

Conversation

pvojtechovsky
Copy link
Collaborator

@pvojtechovsky pvojtechovsky commented Feb 21, 2017

This PR is refactoring of PotentialVariableDeclarationFunction. There are following changes

  1. There is new constructor which accepts variable name. Such mapping function then returns only CtVariable instances with that name. It simplifies usage of PotentialVariableDeclarationFunction, because on all 3 places where I am using that function it is needed to filter by variable name too. See simplified code of DefaultJavaPrettyPrinter and CtLocalVariableReferenceImpl, which are part of this PR
  2. It now returns only instances of CtVariable. Before it returned all CtElements, which were on the way from mapping function input to the found variable declaration. It is change in behavior! I hope it is OK, because the PotentialVariableDeclarationFunction is not in spoon for long time, so it does not have many clients. I am open to rollback this change (2), if you think it is wrong step. But I think it is more consistent now.
  3. There is new method boolean PotentialVariableDeclarationFunction#isTypeOnTheWay(), which can be called by another mapping function or after query is finished and returns true if there is a local class between input element and returned variable declaration. That information can be used to decide whether variable represented by input element can shadow found variable declaration or whether it is in conflict.

These improvements are needed by #1005.

@monperrus monperrus changed the title review: improve PotentialVariableDeclarationFunction, simplify it's usage review: improve PotentialVariableDeclarationFunction, simplify its usage Mar 11, 2017
@monperrus monperrus merged commit b715c39 into INRIA:master Mar 11, 2017
@pvojtechovsky pvojtechovsky deleted the improvePotVarDeclFnc branch March 11, 2017 17:53
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.

None yet

2 participants