Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbvosburgh2008-08-28 11:09:14 -0400
committerbvosburgh2008-08-28 11:09:14 -0400
commitf84dccccc6f48ed4d13efbef17378d054d9bfb5a (patch)
treee72ec6c58be60997efbc8f01cd9d719ad46d7417
parent01ec492e993991036399d9b2e627d6fa5b6ce1d6 (diff)
downloadwebtools.dali-f84dccccc6f48ed4d13efbef17378d054d9bfb5a.tar.gz
webtools.dali-f84dccccc6f48ed4d13efbef17378d054d9bfb5a.tar.xz
webtools.dali-f84dccccc6f48ed4d13efbef17378d054d9bfb5a.zip
[241001] code-assist exception
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaJavaCompletionProposalComputer.java15
1 files changed, 10 insertions, 5 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaJavaCompletionProposalComputer.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaJavaCompletionProposalComputer.java
index e2aa454be5..ad6bbbfd6f 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaJavaCompletionProposalComputer.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JpaJavaCompletionProposalComputer.java
@@ -10,6 +10,7 @@
package org.eclipse.jpt.ui.internal;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -73,10 +74,11 @@ public class JpaJavaCompletionProposalComputer implements IJavaCompletionProposa
return Collections.emptyList();
}
- Iterator<JpaStructureNode> rootStructureNodes = jpaFile.rootStructureNodes();
- if (!rootStructureNodes.hasNext()) {
+ Collection<JpaStructureNode> rootStructureNodes = CollectionTools.collection(jpaFile.rootStructureNodes());
+ if (rootStructureNodes.isEmpty()) {
return Collections.emptyList();
}
+
CompletionContext cc = context.getCoreContext();
// the context's "token" is really a sort of "prefix" - it does NOT
@@ -87,19 +89,22 @@ public class JpaJavaCompletionProposalComputer implements IJavaCompletionProposa
int tokenStart = cc.getTokenStart();
// the token "end" is the offset of the token's last character (yuk)
int tokenEnd = cc.getTokenEnd();
+ if (tokenStart == -1) { // not sure why this happens - see bug 242286
+ return Collections.emptyList();
+ }
-// System.out.println("prefix: " + new String(prefix));
+// System.out.println("prefix: " + ((prefix == null) ? "[null]" : new String(prefix)));
// System.out.println("token start: " + tokenStart);
// System.out.println("token end: " + tokenEnd);
// String source = cu.getSource();
-// String token = source.substring(tokenStart, tokenEnd + 1);
+// String token = source.substring(Math.max(0, tokenStart), Math.min(source.length(), tokenEnd + 1));
// System.out.println("token: =>" + token + "<=");
// String snippet = source.substring(Math.max(0, tokenStart - 20), Math.min(source.length(), tokenEnd + 21));
// System.out.println("surrounding snippet: =>" + snippet + "<=");
CompilationUnit astRoot = JDTTools.buildASTRoot(cu);
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
- for (JpaStructureNode structureNode : CollectionTools.iterable(rootStructureNodes)) {
+ for (JpaStructureNode structureNode : rootStructureNodes) {
for (Iterator<String> stream = ((JavaPersistentType) structureNode).javaCompletionProposals(context.getInvocationOffset(), filter, astRoot); stream.hasNext(); ) {
String s = stream.next();
proposals.add(new CompletionProposal(s, tokenStart, tokenEnd - tokenStart + 1, s.length()));

Back to the top