PT #159307292: Autowired reports optics, content specific to AST node
This commit is contained in:
@@ -16,8 +16,12 @@ import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -174,4 +178,40 @@ public final class JandexClasspath implements ClasspathIndex {
|
||||
.collect(CollectorUtil.toImmutableList());
|
||||
}
|
||||
|
||||
private static void updateQueue(Queue<String> queue, Set<String> exclusion, IType type) {
|
||||
for (String t : type.getSuperInterfaceNames()) {
|
||||
if (!exclusion.contains(t)) {
|
||||
queue.add(t);
|
||||
exclusion.add(t);
|
||||
}
|
||||
}
|
||||
String superClass = type.getSuperclassName();
|
||||
if (superClass != null && !exclusion.contains(superClass)) {
|
||||
queue.add(superClass);
|
||||
exclusion.add(superClass);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<IType> allSuperTypesOf(IType type) {
|
||||
Queue<String> queue = new LinkedList<>();
|
||||
HashSet<String> visited = new HashSet<>();
|
||||
updateQueue(queue, visited, type);
|
||||
return Flux.generate(() -> queue, (state, sink) -> {
|
||||
IType nextType = null;
|
||||
while (nextType == null && state.peek() != null) {
|
||||
String typeName = state.poll();
|
||||
nextType = findType(typeName);
|
||||
if (nextType != null) {
|
||||
sink.next(nextType);
|
||||
updateQueue(state, visited, nextType);
|
||||
}
|
||||
}
|
||||
if (state.peek() == null) {
|
||||
sink.complete();
|
||||
}
|
||||
return state;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016-2017 Pivotal, Inc.
|
||||
* Copyright (c) 2016, 2018 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -163,4 +163,15 @@ class TypeImpl implements IType {
|
||||
return info.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuperclassName() {
|
||||
DotName name = info.superName();
|
||||
return name == null ? null : name.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSuperInterfaceNames() {
|
||||
return info.interfaceNames().stream().map(DotName::toString).toArray(String[]::new);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public interface ClasspathIndex extends Disposable {
|
||||
Flux<Tuple2<IType, Double>> fuzzySearchTypes(String searchTerm, Predicate<IType> typeFilter);
|
||||
Flux<Tuple2<String, Double>> fuzzySearchPackages(String searchTerm);
|
||||
Flux<IType> allSubtypesOf(IType type);
|
||||
Flux<IType> allSuperTypesOf(IType type);
|
||||
Optional<File> findClasspathResourceContainer(String fqName);
|
||||
|
||||
//Maybe the stuff below is another interface? Something that provides operations
|
||||
|
||||
@@ -41,6 +41,10 @@ public interface IJavaProject {
|
||||
return getIndex().allSubtypesOf(targetType);
|
||||
}
|
||||
|
||||
default Flux<IType> allSuperTypesOf(IType targetType) {
|
||||
return getIndex().allSuperTypesOf(targetType);
|
||||
}
|
||||
|
||||
default Flux<Tuple2<IType, Double>> fuzzySearchTypes(String searchTerm, Predicate<IType> typeFilter) {
|
||||
return getIndex().fuzzySearchTypes(searchTerm, typeFilter);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public interface IType extends IMember {
|
||||
IField getField(String name);
|
||||
|
||||
/**
|
||||
* Returns the fields declared by this type in the order in which they appear
|
||||
* Returns the fields declared by this type in the order in which they appear
|
||||
* in the source or class file. For binary types, this includes synthetic fields.
|
||||
*
|
||||
* @return the fields declared by this type
|
||||
@@ -71,7 +71,7 @@ public interface IType extends IMember {
|
||||
* The type signatures may be either unresolved (for source types)
|
||||
* or resolved (for binary types), and either basic (for basic types)
|
||||
* or rich (for parameterized types). See {@link Signature} for details.
|
||||
* Note that the parameter type signatures for binary methods are expected
|
||||
* Note that the parameter type signatures for binary methods are expected
|
||||
* to be dot-based.
|
||||
* </p>
|
||||
*
|
||||
@@ -86,13 +86,17 @@ public interface IType extends IMember {
|
||||
* For binary types, this may include the special <code><clinit></code> method
|
||||
* and synthetic methods.
|
||||
* <p>
|
||||
* The results are listed in the order in which they appear in the source or class file.
|
||||
* The results are listed in the order in which they appear in the source or class file.
|
||||
* </p>
|
||||
*
|
||||
* @return the methods and constructors declared by this type
|
||||
*/
|
||||
Stream<IMethod> getMethods();
|
||||
|
||||
String getSuperclassName();
|
||||
|
||||
String[] getSuperInterfaceNames();
|
||||
|
||||
// /**
|
||||
// * Resolves the given type name within the context of this type (depending on the type hierarchy
|
||||
// * and its imports).
|
||||
|
||||
Reference in New Issue
Block a user