geertjanw closed pull request #331: [NETBEANS-214] Fixing FastImportAction.
URL: https://github.com/apache/incubator-netbeans/pull/331
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/java.editor/src/org/netbeans/modules/java/editor/imports/ComputeImports.java
b/java.editor/src/org/netbeans/modules/java/editor/imports/ComputeImports.java
index 5657c28a7..953e9c744 100644
---
a/java.editor/src/org/netbeans/modules/java/editor/imports/ComputeImports.java
+++
b/java.editor/src/org/netbeans/modules/java/editor/imports/ComputeImports.java
@@ -166,6 +166,10 @@ private synchronized boolean isCancelled() {
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;
@@ -196,7 +200,7 @@ 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) {
@@ -204,7 +208,7 @@ public void run(CompilationController parameter) throws
Exception {
}
} else {
allInfo = info;
- computeCandidates(Collections.<String>emptySet());
+ doComputeCandidates(forcedUnresolved);
}
info.putCachedValue(IMPORT_CANDIDATES_KEY, this,
CacheClearPolicy.ON_CHANGE);
return this;
@@ -215,7 +219,11 @@ public void run(CompilationController parameter) throws
Exception {
}
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;
@@ -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);
@@ -243,17 +251,17 @@ private synchronized void setVisitor(TreeVisitorImpl
visitor) {
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) {
@@ -272,12 +280,12 @@ private synchronized void setVisitor(TreeVisitorImpl
visitor) {
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();
@@ -299,7 +307,7 @@ private synchronized void setVisitor(TreeVisitorImpl
visitor) {
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 ->
@@ -345,8 +353,6 @@ private synchronized void setVisitor(TreeVisitorImpl
visitor) {
}
}
}
-
- return new Pair<Map<String, List<Element>>, Map<String,
List<Element>>>(candidates, notFilteredCandidates);
}
public void addMethodFqn(Element el) {
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists