-
-
Notifications
You must be signed in to change notification settings - Fork 357
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
review test(import): compare the computed imports with human imports #1365
Conversation
I started to have a look on this one and I've several questions regarding the usage of
Those errors appeared because we took as a contract to always put an import preferably on the class type, instead of putting a static import on the field or the executable. Here we imported the class, and we did not imported the two fields. Then, in fact the test detected that we don't use inside Spoon the contract we put on ImportScanner. So do we change our contract inside the ImportScanner or do we apply the contract on Spoon? |
I propose to refine this test, to test for "equivalent import" import Foo = import static Foo.FIELD |
OK I'll do that |
Ok now I have another issue: some imports are directly related to the javadoc: for example in ProblemFixer
leads to the import of |
…in autoimport mode. INRIA#1453
…in autoimport mode. INRIA#1453
@@ -1859,6 +1859,10 @@ public void calculate(CompilationUnit sourceCompilationUnit, List<CtType<?>> typ | |||
} | |||
|
|||
Set<CtReference> imports = new HashSet<>(); | |||
if (sourceCompilationUnit != null) { | |||
imports.addAll(sourceCompilationUnit.getImports()); |
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.
Will it work also in cases when AST is refactored and some classes will be removed? Then it will probably produce unused imports, will not?
@@ -185,6 +190,16 @@ public int getTabCount(int index) { | |||
return tabCount; | |||
} | |||
|
|||
@Override | |||
public Set<CtReference> getImports() { | |||
return this.imports; |
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.
return read only collection?
I propose that we change this test to report a warning on the logs instead of a failure to be able to merge it, and to open an issue about that problem. I won't make improvement on how the imports are managed in Spoon in the next weeks, and it does not really help to keep this PR open IMHO. |
As proposed above I changed the test to only check if no import is missing: for the unused imports, I only output a warning. For me the PR is ready. |
No description provided.