Skip to content

Commit

Permalink
refactor: remove deprecated method computeImports (#1311)
Browse files Browse the repository at this point in the history
Close #1234
  • Loading branch information
surli authored and monperrus committed May 19, 2017
1 parent 4c9a637 commit 9b69b9c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
11 changes: 2 additions & 9 deletions src/main/java/spoon/reflect/visitor/ImportScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@
public interface ImportScanner {

/**
* Computes import of a {@link spoon.reflect.declaration.CtType}
* (represent a class).
* Computes import of a {@link spoon.reflect.declaration.CtElement}
*
* @return class imports computed by Spoon, it does not contain static imports
*/
Collection<CtTypeReference<?>> computeImports(CtType<?> simpleType);
Collection<CtTypeReference<?>> computeImports(CtElement element);

/**
* Computes import of a {@link spoon.reflect.declaration.CtType}
Expand All @@ -44,12 +43,6 @@ public interface ImportScanner {
*/
Collection<CtReference> computeAllImports(CtType<?> simpleType);

/**
* Computes imports for an element.
*/
@Deprecated
void computeImports(CtElement element);

/**
* Checks if the type is already imported.
*/
Expand Down
27 changes: 12 additions & 15 deletions src/main/java/spoon/reflect/visitor/ImportScannerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,26 +216,23 @@ public Collection<CtReference> computeAllImports(CtType<?> simpleType) {
}

@Override
public Collection<CtTypeReference<?>> computeImports(CtType<?> simpleType) {
public Collection<CtTypeReference<?>> computeImports(CtElement element) {
classImports.clear();
fieldImports.clear();
methodImports.clear();
//look for top declaring type of that simpleType
targetType = simpleType.getReference().getTopLevelType();
addClassImport(simpleType.getReference());
scan(simpleType);
return this.classImports.values();
}

@Override
public void computeImports(CtElement element) {
classImports.clear();
fieldImports.clear();
methodImports.clear();
//look for top declaring type of that element
CtType<?> type = element.getParent(CtType.class);
targetType = type == null ? null : type.getReference().getTopLevelType();
scan(element);
if (element instanceof CtType) {
CtType simpleType = (CtType) element;
targetType = simpleType.getReference().getTopLevelType();
addClassImport(simpleType.getReference());
scan(simpleType);
} else {
CtType<?> type = element.getParent(CtType.class);
targetType = type == null ? null : type.getReference().getTopLevelType();
scan(element);
}
return this.classImports.values();
}

@Override
Expand Down

0 comments on commit 9b69b9c

Please sign in to comment.