-
-
Notifications
You must be signed in to change notification settings - Fork 352
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
Bug with variable declaration resolving after clone #756
Comments
Hi,
That's clearly a bug. What is already there before the major clone refactoring? or is it a regression?
The design intent is clearly to only have dynamic lookup. It should also be the case for local and catch variables (so as to move and clone all elements easily, and even make some dynamic checks about scoping issues in setters. We'll have a look at this.
This is indeed a problem. The end users should never have to look at the source code. |
It was the same in spoon 5.0
Then it looks like I propose to change things back to 'as designed' :) |
What about caching? |
Let's first get it correct and then we'll study how to optimize for instance with caching :-). PR welcome of course ^-^ |
hmm, sorry, don't know this shortcut. what did you mean? |
PR = Pull Request :-)
|
@GerardPaligot FYI I have some changes I'm going to contribute |
Please consider #765 as well because it contains resolving of fields in case of entire class cloning |
Problem
After cloning AST subtree variable references are resolved to wrong declaration that makes it difficult to perform further modifications.
Example
Suppose there's a code:
Goal is to clone class
A
, rename copy toB
and perform some modifications withB
.Problems with example
f1
,f2
inB.b()
still refer to declarations inA.b()
. The same is true about Catch variable referencee
A.b()
andA
correspondingly because they resolves using type reference that points toA
Proposed solution
setDeclaringType
andsetDeclaringExecutable
methods, references are not declared! (fields and parameters are)setDeclaration
method toCtVariableReference
Prototype code:
+/-
The text was updated successfully, but these errors were encountered: