-
-
Notifications
You must be signed in to change notification settings - Fork 353
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: fix wrong import on annotated parameter #3320 #3341
Conversation
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.
Nice!
Congrats on the first contribution! That's really cool.
See comments in PR.
--Martin
pom.xml
Outdated
@@ -159,6 +159,14 @@ | |||
<artifactId>maven-invoker</artifactId> | |||
<version>3.0.1</version> | |||
</dependency> | |||
<!-- https://mvnrepository.com/artifact/javax.validation/validation-api --> |
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.
The test is in noclasspath mode. Remove this or work in fullclasspath?
@@ -1777,4 +1778,22 @@ public void testImportByJavaDoc() throws Exception { | |||
} | |||
} | |||
|
|||
@Test | |||
public void testThatCorrectImportsAreGeneratedForJavaxAnnotatedElements() { |
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 Spoon, the tests come with a one-line contract describing the test intention, something like
// contract: annotations are not added on import statements
could you add the contract that is tested? Thanks!
CompilationUnit compilationUnit = l.getFactory().CompilationUnit().getOrCreate(objectCtType); | ||
|
||
for (CtImport anImport : compilationUnit.getImports()) { | ||
System.out.println(anImport.prettyprint()); |
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 System.out from tests.
Thanks.I have attended to the pr comments |
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.
See comments, rest looks good. Awesome work :)
* @author Gibah Joseph | ||
* Email: [email protected] | ||
* Apr, 2020 | ||
**/ |
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.
Personally i hate reading this. It feels like useless information, which get outdated easily. Git can provide this information better. Maybe remove it?
* @author Gibah Joseph | ||
* Email: [email protected] | ||
* Apr, 2020 | ||
**/ |
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.
see other comment
/** | ||
* @author Gibah Joseph | ||
* email: [email protected] | ||
* Apr, 2020 | ||
**/ |
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.
see other comment
final Launcher l = new Launcher(); | ||
Environment e = l.getEnvironment(); | ||
|
||
e.setNoClasspath(true); | ||
e.setAutoImports(true); | ||
l.addInputResource("src/test/java/spoon/test/imports/testclasses/badimportissue3320/source/TestSource.java"); | ||
l.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.
maybe a pit "picky", but short names like e and l makes reading hard.
CtType<TestSource> objectCtType = l.getFactory().Type().get(TestSource.class); | ||
CompilationUnit compilationUnit = l.getFactory().CompilationUnit().getOrCreate(objectCtType); | ||
|
||
assertEquals(1, compilationUnit.getImports().stream().filter(ctImport -> ctImport.prettyprint().equals("import spoon.test.imports.testclasses.badimportissue3320.source.other.SomeObjectDto;")).count()); |
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.
maybe a linebreak, but not mandatory
LGTM, great work |
Thanks a lot and congrats on your first contribution! |
Thanks |
This is a refinement of INRIA#3341.
This is a refinement of INRIA#3341.
fix #3320