Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jaxb
diff options
context:
space:
mode:
authorKaren Butzke2012-09-05 13:56:55 -0400
committerKaren Butzke2012-09-05 13:56:55 -0400
commit2604bd43e2f8521b4eb61916f4847d2100b830f0 (patch)
tree58b494d16809e3b06760e982cf37cf5c08475840 /jaxb
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 'jaxb')
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbJavaCompletionProposalComputer.java43
1 files changed, 4 insertions, 39 deletions
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 35a3a7a773..85ca7bd50e 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);
- }
- }
}

Back to the top