review test(import): compare the computed imports with human imports#1365
review test(import): compare the computed imports with human imports#1365monperrus merged 28 commits intoINRIA:masterfrom
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
|
|
||
| Set<CtReference> imports = new HashSet<>(); | ||
| if (sourceCompilationUnit != null) { | ||
| imports.addAll(sourceCompilationUnit.getImports()); |
There was a problem hiding this comment.
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?
|
|
||
| @Override | ||
| public Set<CtReference> getImports() { | ||
| return this.imports; |
There was a problem hiding this comment.
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.