summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaren Butzke2012-09-05 13:56:55 (EDT)
committerKaren Butzke2012-09-05 13:56:55 (EDT)
commit2604bd43e2f8521b4eb61916f4847d2100b830f0 (patch)
tree58b494d16809e3b06760e982cf37cf5c08475840
parent4c3a402fc4287b06f8941f31d6479d86e0c1ad5b (diff)
downloadwebtools.dali-2604bd43e2f8521b4eb61916f4847d2100b830f0.zip
webtools.dali-2604bd43e2f8521b4eb61916f4847d2100b830f0.tar.gz
webtools.dali-2604bd43e2f8521b4eb61916f4847d2100b830f0.tar.bz2
Revert "Fixed filtering of completion proposals after my recent refactoring - adding quotes as necessary in the proposal computer itself"
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringTools.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbJavaCompletionProposalComputer.java43
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JpaJavaCompletionProposalComputer.java42
3 files changed, 9 insertions, 80 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringTools.java
index 06d8068..093e713 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringTools.java
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringTools.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2011 Oracle. 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 http://www.eclipse.org/legal/epl-v10.html.
@@ -4939,6 +4939,7 @@ public final class StringTools {
*/
private static void convertToJavaStringLiteralOn_(char[] string, StringBuilder sb, int len) {
sb.ensureCapacity(sb.length() + len + 5);
+ sb.append(QUOTE);
for (char c : string) {
switch (c) {
case '\b': // backspace
@@ -4970,6 +4971,7 @@ public final class StringTools {
break;
}
}
+ sb.append(QUOTE);
}
public static void convertToJavaStringLiteralOn(String string, Writer writer) {
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbJavaCompletionProposalComputer.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbJavaCompletionProposalComputer.java
index 35a3a7a..85ca7bd 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbJavaCompletionProposalComputer.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbJavaCompletionProposalComputer.java
@@ -25,10 +25,7 @@ import org.eclipse.jface.text.contentassist.CompletionProposal;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
-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.jaxb.core.JaxbProject;
import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
import org.eclipse.jpt.jaxb.core.context.java.JavaContextNode;
@@ -116,12 +113,6 @@ public class JaxbJavaCompletionProposalComputer
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 JaxbJavaCompletionProposalComputer
// 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,15 @@ public class JaxbJavaCompletionProposalComputer
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
for (JavaContextNode javaNode : javaNodes) {
- for (String proposal : this.getCompletionProposals(javaNode, context.getInvocationOffset(), filter)) {
- if (tokenKind == CompletionContext.TOKEN_KIND_STRING_LITERAL) {//already quoted
- proposals.add(new CompletionProposal(proposal, tokenStart, tokenEnd - tokenStart - 1, proposal.length()));
- }
- else {//add the quotes
- proposals.add(new CompletionProposal("\"" + proposal + "\"", tokenStart, tokenEnd - tokenStart + 1, proposal.length() + 2)); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ for (String proposal : javaNode.getCompletionProposals(context.getInvocationOffset())) {
+ // using proposal.length() -1 as cursor position puts the cursor just inside end quotes
+ // useful for further content assist if necessary
+ proposals.add(new CompletionProposal(proposal, tokenStart, tokenEnd - tokenStart + 1, proposal.length() - 1));
}
}
return proposals;
}
- private Iterable<String> getCompletionProposals(JavaContextNode javaNode, int pos, Filter<String> filter) {
- return new FilteringIterable<String>(javaNode.getCompletionProposals(pos), filter);
- }
-
private IFile getCorrespondingResource(ICompilationUnit cu) {
try {
return (IFile) cu.getCorrespondingResource();
@@ -179,22 +162,4 @@ public class JaxbJavaCompletionProposalComputer
// 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);
- }
- }
}
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 2354605..5afb4eb 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);
- }
- }
}