Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
authorKaren Butzke2012-09-05 17:56:55 +0000
committerKaren Butzke2012-09-05 17:56:55 +0000
commit2604bd43e2f8521b4eb61916f4847d2100b830f0 (patch)
tree58b494d16809e3b06760e982cf37cf5c08475840 /jpa
parent4c3a402fc4287b06f8941f31d6479d86e0c1ad5b (diff)
downloadwebtools.dali-2604bd43e2f8521b4eb61916f4847d2100b830f0.tar.gz
webtools.dali-2604bd43e2f8521b4eb61916f4847d2100b830f0.tar.xz
webtools.dali-2604bd43e2f8521b4eb61916f4847d2100b830f0.zip
Revert "Fixed filtering of completion proposals after my recent refactoring - adding quotes as necessary in the proposal computer itself"
Diffstat (limited to 'jpa')
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JpaJavaCompletionProposalComputer.java42
1 files changed, 2 insertions, 40 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JpaJavaCompletionProposalComputer.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JpaJavaCompletionProposalComputer.java
index 23546056c3..5afb4eb5b0 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JpaJavaCompletionProposalComputer.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JpaJavaCompletionProposalComputer.java
@@ -23,10 +23,7 @@ import org.eclipse.jdt.ui.text.java.IJavaCompletionProposalComputer;
import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext;
import org.eclipse.jface.text.contentassist.CompletionProposal;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jpt.common.utility.Filter;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
import org.eclipse.jpt.jpa.core.JpaFile;
import org.eclipse.jpt.jpa.core.JpaStructureNode;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
@@ -116,12 +113,6 @@ public class JpaJavaCompletionProposalComputer
CompletionContext cc = context.getCoreContext();
- // the context's "token" is really a sort of "prefix" - it does NOT
- // correspond to the "start" and "end" we get below...
- char[] prefix = cc.getToken();
- Filter<String> filter = this.buildPrefixFilter(prefix);
- // the token "kind" tells us if we are in a String literal already - CompletionContext.TOKEN_KIND_STRING_LITERAL
- int tokenKind = cc.getTokenKind();
// the token "start" is the offset of the token's first character
int tokenStart = cc.getTokenStart();
// the token "end" is the offset of the token's last character (yuk)
@@ -132,7 +123,6 @@ public class JpaJavaCompletionProposalComputer
// System.out.println("token start: " + tokenStart);
// System.out.println("token end: " + tokenEnd);
-// System.out.println("token kind: " + tokenKind);
// String source = cu.getSource();
// String token = source.substring(Math.max(0, tokenStart), Math.min(source.length(), tokenEnd + 1));
// System.out.println("token: =>" + token + "<=");
@@ -141,22 +131,13 @@ public class JpaJavaCompletionProposalComputer
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
for (JpaStructureNode structureNode : rootStructureNodes) {
- for (String s : this.getCompletionProposals((JavaPersistentType) structureNode, context.getInvocationOffset(), filter)) {
- if (tokenKind == CompletionContext.TOKEN_KIND_STRING_LITERAL) {//already quoted
- proposals.add(new CompletionProposal(s, tokenStart + 1, tokenEnd - tokenStart - 1, s.length()));
- }
- else {//add the quotes
- proposals.add(new CompletionProposal("\"" + s + "\"", tokenStart, tokenEnd - tokenStart + 1, s.length() + 2)); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ for (String s : ((JavaPersistentType) structureNode).getCompletionProposals(context.getInvocationOffset())) {
+ proposals.add(new CompletionProposal(s, tokenStart, tokenEnd - tokenStart + 1, s.length()));
}
}
return proposals;
}
- private Iterable<String> getCompletionProposals(JavaPersistentType structureNode, int pos, Filter<String> filter) {
- return new FilteringIterable<String>(structureNode.getCompletionProposals(pos), filter);
- }
-
private IFile getCorrespondingResource(ICompilationUnit cu) {
try {
return (IFile) cu.getCorrespondingResource();
@@ -182,23 +163,4 @@ public class JpaJavaCompletionProposalComputer
public void sessionEnded() {
// do nothing
}
-
- private Filter<String> buildPrefixFilter(char[] prefix) {
- return (prefix == null) ?
- Filter.Transparent.<String>instance() :
- new IgnoreCasePrefixFilter(prefix);
- }
-
- private static class IgnoreCasePrefixFilter
- implements Filter<String>
- {
- private final String prefix;
- IgnoreCasePrefixFilter(char[] prefix) {
- super();
- this.prefix = new String(prefix);
- }
- public boolean accept(String s) {
- return StringTools.stringStartsWithIgnoreCase(s, this.prefix);
- }
- }
}

Back to the top