-
-
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
Fix bug #980 with fully qualified names and shadowed variables #1026
Conversation
…ith an or instead of an and. Now the test is failing, proof that the assertion is checked :)
… a local variable in the same block or by a field (or a variable in another block). First detection implemented but patch not satisfying.
…sing autoimport
…rus/spoon into martin" This reverts commit 2609284, reversing changes made to 49d6e68.
…operties. Some choices have been done concerning some set methods in order to pass the test we should discuss.
Fix conflicts by solving imports.
… set to true or when it is set to false. When set to false, the scanner will detect name conflict and automatically import necessary types.
Solve conflict.
…g on CtElement (default behaviour until now).
* A scanner dedicated to import only the necessary packages, @see spoon.test.variable.AccessFullyQualifiedTest | ||
* | ||
*/ | ||
public class ImportScannerWithoutAllImports extends ImportScannerImpl implements ImportScanner { |
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 MinimalImportScanner
?
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.
Done.
@@ -37,63 +37,63 @@ | |||
import org.eclipse.jdt.internal.compiler.ast.TypeReference; |
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.
remove file from PR?
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.
I'll check that.
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.
In fact the file changed a lot because my first patch was in this file which caused the checkstyle mess with imports... Not sure how to remove file from the PR properly.
@@ -58,6 +58,9 @@ | |||
@Override | |||
public <C extends CtTypedElement> C setType(CtTypeReference<T> type) { | |||
if (type != null) { | |||
type.setParent(this); |
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.
not in this PR?
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.
I merged with files of the previous PR to avoid a file conflict.
CtFieldReference parentType = (CtFieldReference) parent; | ||
String qualifiedName = parentType.getQualifiedName(); | ||
|
||
String[] splittedName = qualifiedName.split("(\\.|#)"); |
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.
Why do you need to split the qualified name?
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.
To detect names like spoon.launcher and avoid to detect spoonLauncher.
CtFieldReference parentType = (CtFieldReference) parent; | ||
String qualifiedName = parentType.getQualifiedName(); | ||
|
||
String[] splittedName = qualifiedName.split("(\\.|#)"); |
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.
required?
spoon.addInputResource("src/test/java/spoon/test/variable/testclasses/BurritosFielded.java"); | ||
String output = "target/spooned-" + this.getClass().getSimpleName()+"-Field/"; | ||
spoon.setSourceOutputDirectory(output); | ||
spoon.run(); |
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.
for all replace run by buildModel and then filter + strong assert
Create a new ImportScanner to be used when autoimport is set to false: then all types are checked if they need to be imported in order to avoid shadowed variable.
Tests has been added to check multiple cases.