review: improve PotentialVariableDeclarationFunction, simplify its usage #1194
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is refactoring of
PotentialVariableDeclarationFunction
. There are following changesCtVariable
instances with that name. It simplifies usage ofPotentialVariableDeclarationFunction
, because on all 3 places where I am using that function it is needed to filter by variable name too. See simplified code ofDefaultJavaPrettyPrinter
andCtLocalVariableReferenceImpl
, which are part of this PRCtVariable
. Before it returned allCtElements
, 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.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.