Closed fedorov-s-n closed 8 years ago
Hi,
- Local variables references
f1
,f2
inB.b()
still refer to declarations inA.b()
. The same is true about Catch variable referencee
- Method parameter reference and and class field reference are resolved to declarations in
A.b()
andA
correspondingly because they resolves using type reference that points toA
That's clearly a bug. What is already there before the major clone refactoring? or is it a regression?
- Resolving variables using plain field reference (local and catch variables) and dynamic lookup (field and parameter variables) are different strategies, and that's not clear that different variable types use different strategies.
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.
Developers who use Spoon API should look to sources to understand it.
This is indeed a problem. The end users should never have to look at the source code.
That's clearly a bug. Was is already there before the major clone refactoring? or is it a regression?
It was the same in spoon 5.0
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.
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 ^-^
PR
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 https://github.com/INRIA/spoon/pull/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:
+/-