-
-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
review: fix LocalVariableScopeFunction - CtFor, CtTryWithResource, Local class, shadow variables, ... #1154
review: fix LocalVariableScopeFunction - CtFor, CtTryWithResource, Local class, shadow variables, ... #1154
Conversation
b07c20e
to
405fd77
Compare
This PR improves implementation of LocalVariableScopeFunction. It now correctly handles CtFor, CtTryWithResource. Tests actually fails because of issue #1159. They will pass after this issue is fixed. I have extracted the tests from QueryTest to VariableReferencesTest, because QueryTest was too complicated and did not covered LocalVariables well. I plan (in another PR) to move remaining stuff from QueryTest to FieldReferenceTest, which needs different structure of test model. And then I will delete QueryTest. Please have a look at ways how variable declarations are used in |
d3964d2
to
07bf832
Compare
1139a97
to
cebeff0
Compare
Here are more things. I am trying it all together, because it shares tests. It would need addition effort to implement separate tests of these fixes/features
This PR is not compilable because it needs #1164 |
cebeff0
to
6c1f1d4
Compare
Travis is ill? |
6c1f1d4
to
486f44b
Compare
I have renamed |
Revapi Analysis resultsOld API: fr.inria.gforge.spoon:spoon-core:jar:5.6.0-20170207.133111-28 New API: fr.inria.gforge.spoon:spoon-core:jar:5.6.0-SNAPSHOT Detected changes: 0. |
What this |
* } | ||
* </pre> | ||
*/ | ||
public class VariableReferencePossibleDeclarationFunction implements CtConsumableFunction<CtElement> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to PotentialVariableDeclarationFunction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Thanks!
import java.util.function.Consumer; | ||
|
||
/* | ||
* The values of the fields must be a sequence starting from 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of this class? I don't really get it from the name and doc, and the "new AllLocalVars()" alone later seems strange.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the class which is used to build spoon model, which is then used for searching for variable declarations and then back their variable definitions. It belongs to package ...testclass...
new AllLocalVars(), runs all the code of this class and checks that all assertions are correct - that all variable references really refers the expected variable declaration - that test model input is valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Basically, you check the behavior of Java itself.
What about putting it as a real test class itself "JavaBehaviorTest" and annotate all methods with @Test
? Together with a good Javadoc/warning, comment it should be maintainable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Basically, you check the behavior of Java itself.
I check that all the numbers which are later used in VariableReferencesTest are assigned well, following java behavior.
"JavaBehaviorTest", annotate methods with @test
ok, sounds good.
What this |pull_request-INRIA-spoon-master-docker| problem means?
it's a job ID on the Inria continuous integration server.
|
Revapi Analysis resultsOld API: fr.inria.gforge.spoon:spoon-core:jar:5.6.0-20170207.234605-29 New API: fr.inria.gforge.spoon:spoon-core:jar:5.6.0-SNAPSHOT Detected changes: 0. |
2653785
to
3f32392
Compare
Revapi Analysis resultsOld API: fr.inria.gforge.spoon:spoon-core:jar:5.6.0-20170209.143117-32 New API: fr.inria.gforge.spoon:spoon-core:jar:5.6.0-SNAPSHOT Detected changes: 0. |
ready for merge? |
yes, I am done with that |
thanks! |
See how ParentFunction #1153 is used in fixed LocalVariableScopeFunction.
This PR will be compilable after #1153 is merged.
I will add tests too, but after #1141 is finished, because there will be conflicts in test class.