Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ public List<Element> getRawCandidates(String simpleName) {
private static final Object IMPORT_CANDIDATES_KEY = new Object();

public ComputeImports computeCandidatesEx() {
return computeCandidatesEx(Collections.emptySet());
}

private ComputeImports computeCandidatesEx(Set<String> forcedUnresolved) {
ComputeImports cache = (ComputeImports)info.getCachedValue(IMPORT_CANDIDATES_KEY);
if (cache != null) {
return cache;
Expand Down Expand Up @@ -196,15 +200,15 @@ public ComputeImports computeCandidatesEx() {
public void run(CompilationController parameter) throws Exception {
allInfo = parameter;
parameter.toPhase(JavaSource.Phase.RESOLVED);
computeCandidates(Collections.<String>emptySet());
doComputeCandidates(forcedUnresolved);
}
}, true);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
} else {
allInfo = info;
computeCandidates(Collections.<String>emptySet());
doComputeCandidates(forcedUnresolved);
}
info.putCachedValue(IMPORT_CANDIDATES_KEY, this, CacheClearPolicy.ON_CHANGE);
return this;
Expand All @@ -215,7 +219,11 @@ public Pair<Map<String, List<Element>>, Map<String, List<Element>>> getSimpleCan
}

public Pair<Map<String, List<Element>>, Map<String, List<Element>>> computeCandidates() {
return computeCandidatesEx().getSimpleCandidates();
return computeCandidates(Collections.emptySet());
}

public Pair<Map<String, List<Element>>, Map<String, List<Element>>> computeCandidates(Set<String> forcedUnresolved) {
return computeCandidatesEx(forcedUnresolved).getSimpleCandidates();
}

private TreeVisitorImpl visitor;
Expand All @@ -224,7 +232,7 @@ private synchronized void setVisitor(TreeVisitorImpl visitor) {
this.visitor = visitor;
}

Pair<Map<String, List<Element>>, Map<String, List<Element>>> computeCandidates(Set<String> forcedUnresolved) {
private void doComputeCandidates(Set<String> forcedUnresolved) {
final CompilationUnitTree cut = info.getCompilationUnit();
ClasspathInfo cpInfo = allInfo.getClasspathInfo();
final TreeVisitorImpl v = new TreeVisitorImpl(info);
Expand All @@ -243,17 +251,17 @@ Pair<Map<String, List<Element>>, Map<String, List<Element>>> computeCandidates(S

for (String unresolved : unresolvedNames) {
if (isCancelled())
return null;
return;

List<Element> classes = new ArrayList<Element>();
Set<ElementHandle<TypeElement>> typeNames = cpInfo.getClassIndex().getDeclaredTypes(unresolved, NameKind.SIMPLE_NAME,EnumSet.allOf(ClassIndex.SearchScope.class));
if (typeNames == null) {
//Canceled
return null;
return;
}
for (ElementHandle<TypeElement> typeName : typeNames) {
if (isCancelled())
return null;
return;
TypeElement te = typeName.resolve(allInfo);

if (te == null) {
Expand All @@ -272,12 +280,12 @@ Pair<Map<String, List<Element>>, Map<String, List<Element>>> computeCandidates(S

if (simpleNames == null) {
//Canceled:
return null;
return;
}

for (final Symbols p : simpleNames) {
if (isCancelled())
return null;
return;

final TypeElement te = p.getEnclosingType().resolve(allInfo);
final Set<String> idents = p.getSymbols();
Expand All @@ -299,7 +307,7 @@ Pair<Map<String, List<Element>>, Map<String, List<Element>>> computeCandidates(S

while (wasChanged) {
if (isCancelled())
return new Pair(Collections.emptyMap(), Collections.emptyMap());
return;

wasChanged = false;
// reset possible FQNs, since the set of acessible stuff may have changed ->
Expand Down Expand Up @@ -345,8 +353,6 @@ Pair<Map<String, List<Element>>, Map<String, List<Element>>> computeCandidates(S
}
}
}

return new Pair<Map<String, List<Element>>, Map<String, List<Element>>>(candidates, notFilteredCandidates);
}

public void addMethodFqn(Element el) {
Expand Down