summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaren Butzke2012-09-05 17:05:28 (EDT)
committerKaren Butzke2012-09-06 10:05:19 (EDT)
commitd1074325f2fb45d2d996ca555f40b09533a11d30 (patch)
tree97aadf18683a3fdab7de3b012b89ec949147926c
parent310c14b5db2728dce4d42f103b2c1935a3445d64 (diff)
downloadwebtools.dali-d1074325f2fb45d2d996ca555f40b09533a11d30.zip
webtools.dali-d1074325f2fb45d2d996ca555f40b09533a11d30.tar.gz
webtools.dali-d1074325f2fb45d2d996ca555f40b09533a11d30.tar.bz2
Correctly fixed java code completion filtering
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringTools.java120
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/StringToolsTests.java78
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaClassMapping.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlNs.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSchema.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdSchema.java8
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdSimpleTypeDefinition.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdTypeDefinition.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlInverseReferenceMapping.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlJoinNode.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/xpath/java/XPath.java2
-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.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBaseColumn.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaNamedColumn.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaOverride.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaSequenceGenerator.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTable.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappedByRelationshipStrategy.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaJoinColumn.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPrimaryKeyJoinColumn.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTableGenerator.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaUniqueConstraint.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaMapsIdDerivedIdentityStrategy2_0.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaTenantDiscriminatorColumn2_3.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkConvert.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JpaJavaCompletionProposalComputer.java42
29 files changed, 304 insertions, 47 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 093e713..6e27dbe 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, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2012 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.
@@ -35,7 +35,7 @@ public final class StringTools {
public static final char QUOTE = '"';
/** XML double quote */
- public static final String XML_QUOTE = """;
+ public static final String XML_QUOTE = """; //$NON-NLS-1$
/** parenthesis */
public static final char OPEN_PARENTHESIS = '(';
@@ -4815,6 +4815,16 @@ public final class StringTools {
return sb.toString();
}
+ public static String convertToJavaStringLiteralContent(String string) {
+ int len = string.length();
+ if (len == 0) {
+ return EMPTY_JAVA_STRING_LITERAL;
+ }
+ StringBuilder sb = new StringBuilder(len + 5);
+ convertToJavaStringLiteralContentOn_(string.toCharArray(), sb, len);
+ return sb.toString();
+ }
+
public static char[] convertToJavaStringLiteral(char[] string) {
int len = string.length;
if (len == 0) {
@@ -4828,10 +4838,27 @@ public final class StringTools {
return result;
}
+ public static char[] convertToJavaStringLiteralContent(char[] string) {
+ int len = string.length;
+ if (len == 0) {
+ return EMPTY_JAVA_STRING_LITERAL_CHAR_ARRAY;
+ }
+ StringBuilder sb = new StringBuilder(len + 5);
+ convertToJavaStringLiteralContentOn_(string, sb, len);
+ len = sb.length();
+ char[] result = new char[len];
+ sb.getChars(0, len, result, 0);
+ return result;
+ }
+
public static Iterable<String> convertToJavaStringLiterals(Iterable<String> strings) {
return new TransformationIterable<String, String>(strings, STRING_TO_JAVA_STRING_LITERAL_TRANSFORMER);
}
+ public static Iterable<String> convertToJavaStringLiteralContents(Iterable<String> strings) {
+ return new TransformationIterable<String, String>(strings, STRING_TO_JAVA_STRING_LITERAL_CONTENT_TRANSFORMER);
+ }
+
public static Iterator<String> convertToJavaStringLiterals(Iterator<String> strings) {
return new TransformationIterator<String, String>(strings, STRING_TO_JAVA_STRING_LITERAL_TRANSFORMER);
}
@@ -4842,6 +4869,12 @@ public final class StringTools {
}
};
+ private static final Transformer<String, String> STRING_TO_JAVA_STRING_LITERAL_CONTENT_TRANSFORMER = new Transformer<String, String>() {
+ public String transform(String string) {
+ return StringTools.convertToJavaStringLiteralContent(string);
+ }
+ };
+
// cannot name method simply 'convertToJavaStringLiterals' because of type-erasure...
public static Iterable<char[]> convertToJavaCharArrayLiterals(Iterable<char[]> strings) {
return new TransformationIterable<char[], char[]>(strings, CHAR_ARRAY_TO_JAVA_STRING_LITERAL_TRANSFORMER);
@@ -4867,6 +4900,15 @@ public final class StringTools {
}
}
+ public static void convertToJavaStringLiteralContentOn(String string, StringBuffer sb) {
+ int len = string.length();
+ if (len == 0) {
+ sb.append(EMPTY_JAVA_STRING_LITERAL);
+ } else {
+ convertToJavaStringLiteralContentOn_(string.toCharArray(), sb, len);
+ }
+ }
+
public static void convertToJavaStringLiteralOn(char[] string, StringBuffer sb) {
int len = string.length;
if (len == 0) {
@@ -4876,12 +4918,30 @@ public final class StringTools {
}
}
+ public static void convertToJavaStringLiteralContentOn(char[] string, StringBuffer sb) {
+ int len = string.length;
+ if (len == 0) {
+ sb.append(EMPTY_JAVA_STRING_LITERAL);
+ } else {
+ convertToJavaStringLiteralContentOn_(string, sb, len);
+ }
+ }
+
/*
* no length checks
*/
private static void convertToJavaStringLiteralOn_(char[] string, StringBuffer sb, int len) {
sb.ensureCapacity(sb.length() + len + 5);
sb.append(QUOTE);
+ convertToJavaStringLiteralContentOn_(string, sb, len);
+ sb.append(QUOTE);
+ }
+
+ /*
+ * no length checks
+ */
+ private static void convertToJavaStringLiteralContentOn_(char[] string, StringBuffer sb, int len) {
+ sb.ensureCapacity(sb.length() + len + 5);
for (char c : string) {
switch (c) {
case '\b': // backspace
@@ -4913,7 +4973,6 @@ public final class StringTools {
break;
}
}
- sb.append(QUOTE);
}
public static void convertToJavaStringLiteralOn(String string, StringBuilder sb) {
@@ -4934,12 +4993,39 @@ public final class StringTools {
}
}
+ public static void convertToJavaStringLiteralContentOn(String string, StringBuilder sb) {
+ int len = string.length();
+ if (len == 0) {
+ sb.append(EMPTY_JAVA_STRING_LITERAL);
+ } else {
+ convertToJavaStringLiteralContentOn_(string.toCharArray(), sb, len);
+ }
+ }
+
+ public static void convertToJavaStringLiteralContentOn(char[] string, StringBuilder sb) {
+ int len = string.length;
+ if (len == 0) {
+ sb.append(EMPTY_JAVA_STRING_LITERAL);
+ } else {
+ convertToJavaStringLiteralContentOn_(string, sb, len);
+ }
+ }
+
/*
* no length checks
*/
private static void convertToJavaStringLiteralOn_(char[] string, StringBuilder sb, int len) {
sb.ensureCapacity(sb.length() + len + 5);
sb.append(QUOTE);
+ convertToJavaStringLiteralContentOn_(string, sb, len);
+ sb.append(QUOTE);
+ }
+
+ /*
+ * no length checks
+ */
+ private static void convertToJavaStringLiteralContentOn_(char[] string, StringBuilder sb, int len) {
+ sb.ensureCapacity(sb.length() + len + 5);
for (char c : string) {
switch (c) {
case '\b': // backspace
@@ -4971,7 +5057,6 @@ public final class StringTools {
break;
}
}
- sb.append(QUOTE);
}
public static void convertToJavaStringLiteralOn(String string, Writer writer) {
@@ -4990,11 +5075,35 @@ public final class StringTools {
}
}
+ public static void convertToJavaStringLiteralContentOn(String string, Writer writer) {
+ if (string.length() == 0) {
+ writeStringOn(EMPTY_JAVA_STRING_LITERAL, writer);
+ } else {
+ convertToJavaStringLiteralContentOn_(string.toCharArray(), writer);
+ }
+ }
+
+ public static void convertToJavaStringLiteralContentOn(char[] string, Writer writer) {
+ if (string.length == 0) {
+ writeStringOn(EMPTY_JAVA_STRING_LITERAL, writer);
+ } else {
+ convertToJavaStringLiteralContentOn_(string, writer);
+ }
+ }
+
/*
* no length checks
*/
private static void convertToJavaStringLiteralOn_(char[] string, Writer writer) {
writeCharOn(QUOTE, writer);
+ convertToJavaStringLiteralContentOn_(string, writer);
+ writeCharOn(QUOTE, writer);
+ }
+
+ /*
+ * no length checks
+ */
+ private static void convertToJavaStringLiteralContentOn_(char[] string, Writer writer) {
for (char c : string) {
switch (c) {
case '\b': // backspace
@@ -5026,7 +5135,6 @@ public final class StringTools {
break;
}
}
- writeCharOn(QUOTE, writer);
}
// ********** convert to XML string literal **********
@@ -5048,7 +5156,7 @@ public final class StringTools {
for (char c : string) {
switch (c) {
case '"': // double-quote
- sb.append(XML_QUOTE); //$NON-NLS-1$
+ sb.append(XML_QUOTE);
break;
default:
sb.append(c);
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/StringToolsTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/StringToolsTests.java
index b34bab2..9af1578 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/StringToolsTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/StringToolsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2012 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.
@@ -1868,4 +1868,80 @@ public class StringToolsTests extends TestCase {
assertEquals(expected, writer.toString());
}
+ // ********** converting to Java string literal content **********
+
+ public void testConvertToJavaStringLiteralContent() {
+ this.verifyConvertToJavaStringLiteralContent("", "\"\"");
+ this.verifyConvertToJavaStringLiteralContent("\"\"", "\\\"\\\"");
+ this.verifyConvertToJavaStringLiteralContent("'foo'", "'foo'");
+ this.verifyConvertToJavaStringLiteralContent("foo\bbar", "foo\\bbar");
+ this.verifyConvertToJavaStringLiteralContent("foo\n\tbar", "foo\\n\\tbar");
+ this.verifyConvertToJavaStringLiteralContent("foo\"bar", "foo\\\"bar");
+ this.verifyConvertToJavaStringLiteralContent("foo\\bar", "foo\\\\bar");
+ }
+
+ private void verifyConvertToJavaStringLiteralContent(String s, String expected) {
+ assertEquals(expected, StringTools.convertToJavaStringLiteralContent(s));
+ assertEquals(expected, StringTools.convertToJavaStringLiteralContent(s.toCharArray()));
+ }
+
+ public void testConvertToJavaStringLiteralContentOnStringBuffer() {
+ this.verifyConvertToJavaStringLiteralContentOnStringBuffer("", "\"\"");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuffer("\"\"", "\\\"\\\"");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuffer("'foo'", "'foo'");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuffer("foo\bbar", "foo\\bbar");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuffer("foo\n\tbar", "foo\\n\\tbar");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuffer("foo\"bar", "foo\\\"bar");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuffer("foo\\bar", "foo\\\\bar");
+ }
+
+ private void verifyConvertToJavaStringLiteralContentOnStringBuffer(String s, String expected) {
+ StringBuffer sb = new StringBuffer();
+ StringTools.convertToJavaStringLiteralContentOn(s, sb);
+ assertEquals(expected, sb.toString());
+
+ sb = new StringBuffer();
+ StringTools.convertToJavaStringLiteralContentOn(s.toCharArray(), sb);
+ assertEquals(expected, sb.toString());
+ }
+
+ public void testConvertToJavaStringLiteralContentOnStringBuilder() {
+ this.verifyConvertToJavaStringLiteralContentOnStringBuilder("", "\"\"");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuilder("\"\"", "\\\"\\\"");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuilder("'foo'", "'foo'");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuilder("foo\bbar", "foo\\bbar");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuilder("foo\n\tbar", "foo\\n\\tbar");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuilder("foo\"bar", "foo\\\"bar");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuilder("foo\\bar", "foo\\\\bar");
+ }
+
+ private void verifyConvertToJavaStringLiteralContentOnStringBuilder(String s, String expected) {
+ StringBuilder sb = new StringBuilder();
+ StringTools.convertToJavaStringLiteralContentOn(s, sb);
+ assertEquals(expected, sb.toString());
+
+ sb = new StringBuilder();
+ StringTools.convertToJavaStringLiteralContentOn(s.toCharArray(), sb);
+ assertEquals(expected, sb.toString());
+ }
+
+ public void testConvertToJavaStringLiteralContentOnWriter() {
+ this.verifyConvertToJavaStringLiteralContentOnWriter("", "\"\"");
+ this.verifyConvertToJavaStringLiteralContentOnWriter("\"\"", "\\\"\\\"");
+ this.verifyConvertToJavaStringLiteralContentOnWriter("'foo'", "'foo'");
+ this.verifyConvertToJavaStringLiteralContentOnWriter("foo\bbar", "foo\\bbar");
+ this.verifyConvertToJavaStringLiteralContentOnWriter("foo\n\tbar", "foo\\n\\tbar");
+ this.verifyConvertToJavaStringLiteralContentOnWriter("foo\"bar", "foo\\\"bar");
+ this.verifyConvertToJavaStringLiteralContentOnWriter("foo\\bar", "foo\\\\bar");
+ }
+
+ private void verifyConvertToJavaStringLiteralContentOnWriter(String s, String expected) {
+ Writer writer = new StringWriter();
+ StringTools.convertToJavaStringLiteralContentOn(s, writer);
+ assertEquals(expected, writer.toString());
+
+ writer = new StringWriter();
+ StringTools.convertToJavaStringLiteralContentOn(s.toCharArray(), writer);
+ assertEquals(expected, writer.toString());
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaClassMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaClassMapping.java
index f98a1f8..f63c8da 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaClassMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaClassMapping.java
@@ -757,7 +757,7 @@ public class GenericJavaClassMapping
}
protected Iterable<String> getPropProposals() {
- return StringTools.convertToJavaStringLiterals(
+ return StringTools.convertToJavaStringLiteralContents(
new TransformationIterable<JaxbPersistentAttribute, String>(getAllLocallyDefinedAttributes()) {
@Override
protected String transform(JaxbPersistentAttribute o) {
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlNs.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlNs.java
index 2d30d4d..25ef901 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlNs.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlNs.java
@@ -128,7 +128,7 @@ public class GenericJavaXmlNs
protected Iterable<String> getNamespaceURICompletionProposals(int pos) {
String packageNamespace = getJaxbPackageInfo().getJaxbPackage().getNamespace();
Iterable<String> result = (StringTools.stringIsEmpty(packageNamespace)) ?
- EmptyIterable.instance() : new SingleElementIterable(StringTools.convertToJavaStringLiteral(packageNamespace));
+ EmptyIterable.instance() : new SingleElementIterable(StringTools.convertToJavaStringLiteralContent(packageNamespace));
XsdSchema schema = getJaxbPackageInfo().getJaxbPackage().getXsdSchema();
if (schema != null) {
result = new CompositeIterable<String>(result, schema.getNamespaceProposals());
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSchema.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSchema.java
index fa57eba..f078f68 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSchema.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSchema.java
@@ -272,7 +272,7 @@ public class GenericJavaXmlSchema
}
protected Iterable<String> getNamespaceProposals() {
- return StringTools.convertToJavaStringLiterals(
+ return StringTools.convertToJavaStringLiteralContents(
new TransformationIterable<SchemaEntry, String>(
getJaxbProject().getSchemaLibrary().getSchemaEntries()) {
@Override
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdSchema.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdSchema.java
index fc98c55..b23b2fd 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdSchema.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdSchema.java
@@ -180,11 +180,11 @@ public class XsdSchema
}
public Iterable<String> getNamespaceProposals() {
- return StringTools.convertToJavaStringLiterals(getNamespaces());
+ return StringTools.convertToJavaStringLiteralContents(getNamespaces());
}
public Iterable<String> getTypeNameProposals(String namespace) {
- return StringTools.convertToJavaStringLiterals(
+ return StringTools.convertToJavaStringLiteralContents(
new TransformationIterable<XsdTypeDefinition, String>(this.getTypeDefinitions(namespace)) {
@Override
protected String transform(XsdTypeDefinition o) {
@@ -194,7 +194,7 @@ public class XsdSchema
}
public Iterable<String> getSimpleTypeNameProposals(String namespace) {
- return StringTools.convertToJavaStringLiterals(
+ return StringTools.convertToJavaStringLiteralContents(
new TransformationIterable<XsdSimpleTypeDefinition, String>(this.getSimpleTypeDefinitions(namespace)) {
@Override
protected String transform(XsdSimpleTypeDefinition o) {
@@ -204,7 +204,7 @@ public class XsdSchema
}
public Iterable<String> getElementNameProposals(String namespace) {
- return StringTools.convertToJavaStringLiterals(
+ return StringTools.convertToJavaStringLiteralContents(
new TransformationIterable<XsdElementDeclaration, String>(this.getElementDeclarations(namespace)) {
@Override
protected String transform(XsdElementDeclaration o) {
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdSimpleTypeDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdSimpleTypeDefinition.java
index ab70c88..320a18f 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdSimpleTypeDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdSimpleTypeDefinition.java
@@ -95,7 +95,7 @@ public class XsdSimpleTypeDefinition
}
public Iterable<String> getEnumValueProposals() {
- return StringTools.convertToJavaStringLiterals(
+ return StringTools.convertToJavaStringLiteralContents(
new TransformationIterable<XSDEnumerationFacet, String>(getXSDComponent().getEnumerationFacets()) {
@Override
protected String transform(XSDEnumerationFacet enumFacet) {
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdTypeDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdTypeDefinition.java
index 05ad2a3..155ffe4 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdTypeDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdTypeDefinition.java
@@ -67,7 +67,7 @@ public abstract class XsdTypeDefinition<A extends XSDTypeDefinition>
public abstract XsdAttributeUse getAttribute(String namespace, String name);
public Iterable<String> getAttributeNameProposals(String namespace) {
- return StringTools.convertToJavaStringLiterals(getAttributeNames(namespace));
+ return StringTools.convertToJavaStringLiteralContents(getAttributeNames(namespace));
}
public abstract Iterable<String> getAttributeNames(String namespace);
@@ -83,7 +83,7 @@ public abstract class XsdTypeDefinition<A extends XSDTypeDefinition>
}
public Iterable<String> getElementNameProposals(String namespace, boolean recurseChildren) {
- return StringTools.convertToJavaStringLiterals(getElementNames(namespace, recurseChildren));
+ return StringTools.convertToJavaStringLiteralContents(getElementNames(namespace, recurseChildren));
}
public abstract Iterable<String> getElementNames(String namespace, boolean recurseChildren);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlInverseReferenceMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlInverseReferenceMapping.java
index 45c9b85..da7158f 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlInverseReferenceMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlInverseReferenceMapping.java
@@ -146,7 +146,7 @@ public class ELJavaXmlInverseReferenceMapping
return EmptyIterable.instance();
}
- return StringTools.convertToJavaStringLiterals(
+ return StringTools.convertToJavaStringLiteralContents(
new TransformationIterable<JaxbPersistentAttribute, String>(referencedClassMapping.getAllLocallyDefinedAttributes()) {
@Override
protected String transform(JaxbPersistentAttribute o) {
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlJoinNode.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlJoinNode.java
index 132b5c5..62309ef 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlJoinNode.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlJoinNode.java
@@ -155,7 +155,7 @@ public class ELJavaXmlJoinNode
if (referencedClassMapping != null) {
result = new CompositeIterable<String>(
result,
- StringTools.convertToJavaStringLiterals(referencedClassMapping.getKeyXPaths()));
+ StringTools.convertToJavaStringLiteralContents(referencedClassMapping.getKeyXPaths()));
}
return CollectionTools.sortedSet(result);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/xpath/java/XPath.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/xpath/java/XPath.java
index 18e581d..37ea63f 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/xpath/java/XPath.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/xpath/java/XPath.java
@@ -495,7 +495,7 @@ public class XPath {
final String prefix, int pos) {
if (getTextRange(context).includes(pos) || getNextStep() == null) {
- return StringTools.convertToJavaStringLiterals(
+ return StringTools.convertToJavaStringLiteralContents(
new TransformationIterable<String, String>(
new CompositeIterable<String>(
getTextProposals(context, previousType),
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 85ca7bd..35a3a7a 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,7 +25,10 @@ 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;
@@ -113,6 +116,12 @@ 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)
@@ -123,6 +132,7 @@ 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 + "<=");
@@ -131,15 +141,22 @@ public class JaxbJavaCompletionProposalComputer
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
for (JavaContextNode javaNode : javaNodes) {
- 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));
+ 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$
+ }
}
}
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();
@@ -162,4 +179,22 @@ 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.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBaseColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBaseColumn.java
index 366eaee..2e8f969 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBaseColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBaseColumn.java
@@ -343,7 +343,7 @@ public abstract class AbstractJavaBaseColumn<A extends BaseColumnAnnotation, O e
}
protected Iterable<String> getJavaCandidateTableNames() {
- return StringTools.convertToJavaStringLiterals(this.getCandidateTableNames());
+ return StringTools.convertToJavaStringLiteralContents(this.getCandidateTableNames());
}
public Iterable<String> getCandidateTableNames() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
index c1fff2a..36e3c02 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
@@ -921,7 +921,7 @@ public abstract class AbstractJavaMultiRelationshipMapping<A extends Relationshi
}
protected Iterable<String> getJavaCandidateMapKeyNames() {
- return StringTools.convertToJavaStringLiterals(this.getCandidateMapKeyNames());
+ return StringTools.convertToJavaStringLiteralContents(this.getCandidateMapKeyNames());
}
public Iterable<String> getCandidateMapKeyNames() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaNamedColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaNamedColumn.java
index dfd73b8..74b8443 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaNamedColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaNamedColumn.java
@@ -226,7 +226,7 @@ public abstract class AbstractJavaNamedColumn<A extends NamedColumnAnnotation, O
}
protected Iterable<String> getJavaCandidateNames() {
- return StringTools.convertToJavaStringLiterals(this.getCandidateNames());
+ return StringTools.convertToJavaStringLiteralContents(this.getCandidateNames());
}
protected Iterable<String> getCandidateNames() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaOverride.java
index ca38f18..95f632b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaOverride.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaOverride.java
@@ -197,7 +197,7 @@ public abstract class AbstractJavaOverride<C extends JavaOverrideContainer, A ex
}
protected Iterable<String> getJavaCandidateNames() {
- return StringTools.convertToJavaStringLiterals(this.getCandidateNames());
+ return StringTools.convertToJavaStringLiteralContents(this.getCandidateNames());
}
protected abstract Iterable<String> getCandidateNames();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaSequenceGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaSequenceGenerator.java
index 185506f..5fcab0b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaSequenceGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaSequenceGenerator.java
@@ -119,7 +119,7 @@ public abstract class AbstractJavaSequenceGenerator<A extends SequenceGeneratorA
}
protected Iterable<String> getJavaCandidateSequences() {
- return StringTools.convertToJavaStringLiterals(this.getCandidateSequences());
+ return StringTools.convertToJavaStringLiteralContents(this.getCandidateSequences());
}
protected Iterable<String> getCandidateSequences() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTable.java
index 25cb1ae..bc460ad 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTable.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTable.java
@@ -431,7 +431,7 @@ public abstract class AbstractJavaTable<A extends BaseTableAnnotation>
}
protected Iterable<String> getJavaCandidateNames() {
- return StringTools.convertToJavaStringLiterals(this.getCandidateNames());
+ return StringTools.convertToJavaStringLiteralContents(this.getCandidateNames());
}
protected Iterable<String> getCandidateNames() {
@@ -444,7 +444,7 @@ public abstract class AbstractJavaTable<A extends BaseTableAnnotation>
}
protected Iterable<String> getJavaCandidateSchemata() {
- return StringTools.convertToJavaStringLiterals(this.getCandidateSchemata());
+ return StringTools.convertToJavaStringLiteralContents(this.getCandidateSchemata());
}
protected Iterable<String> getCandidateSchemata() {
@@ -456,7 +456,7 @@ public abstract class AbstractJavaTable<A extends BaseTableAnnotation>
}
protected Iterable<String> getJavaCandidateCatalogs() {
- return StringTools.convertToJavaStringLiterals(this.getCandidateCatalogs());
+ return StringTools.convertToJavaStringLiteralContents(this.getCandidateCatalogs());
}
protected Iterable<String> getCandidateCatalogs() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappedByRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappedByRelationshipStrategy.java
index 8427255..2b3b40d 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappedByRelationshipStrategy.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappedByRelationshipStrategy.java
@@ -184,7 +184,7 @@ public class GenericJavaMappedByRelationshipStrategy
}
protected Iterable<String> getJavaCandidateMappedByAttributeNames() {
- return StringTools.convertToJavaStringLiterals(this.getCandidateMappedByAttributeNames());
+ return StringTools.convertToJavaStringLiteralContents(this.getCandidateMappedByAttributeNames());
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java
index 6b3243e..b80d5c2 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java
@@ -175,7 +175,7 @@ public class GenericJavaGeneratedValue
}
protected Iterable<String> getJavaCandidateGeneratorNames() {
- return StringTools.convertToJavaStringLiterals(this.getCandidateGeneratorNames());
+ return StringTools.convertToJavaStringLiteralContents(this.getCandidateGeneratorNames());
}
protected Iterable<String> getCandidateGeneratorNames() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaJoinColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaJoinColumn.java
index 1fcefbf..31256f4 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaJoinColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaJoinColumn.java
@@ -169,7 +169,7 @@ public class GenericJavaJoinColumn
}
protected Iterable<String> getJavaCandidateReferencedColumnNames() {
- return StringTools.convertToJavaStringLiterals(this.getCandidateReferencedColumnNames());
+ return StringTools.convertToJavaStringLiteralContents(this.getCandidateReferencedColumnNames());
}
protected Iterable<String> getCandidateReferencedColumnNames() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPrimaryKeyJoinColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPrimaryKeyJoinColumn.java
index 080de3f..bb0e182 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPrimaryKeyJoinColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPrimaryKeyJoinColumn.java
@@ -165,7 +165,7 @@ public class GenericJavaPrimaryKeyJoinColumn
}
protected Iterable<String> getJavaCandidateReferencedColumnNames() {
- return StringTools.convertToJavaStringLiterals(this.getCandidateReferencedColumnNames());
+ return StringTools.convertToJavaStringLiteralContents(this.getCandidateReferencedColumnNames());
}
protected Iterable<String> getCandidateReferencedColumnNames() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTableGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTableGenerator.java
index aabe2d8..38f8077 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTableGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTableGenerator.java
@@ -473,7 +473,7 @@ public class GenericJavaTableGenerator
}
protected Iterable<String> getJavaCandidateTables() {
- return StringTools.convertToJavaStringLiterals(this.getCandidateTables());
+ return StringTools.convertToJavaStringLiteralContents(this.getCandidateTables());
}
protected Iterable<String> getCandidateTables() {
@@ -488,7 +488,7 @@ public class GenericJavaTableGenerator
}
protected Iterable<String> getJavaCandidateSchemata() {
- return StringTools.convertToJavaStringLiterals(this.getCandidateSchemata());
+ return StringTools.convertToJavaStringLiteralContents(this.getCandidateSchemata());
}
protected Iterable<String> getCandidateSchemata() {
@@ -503,7 +503,7 @@ public class GenericJavaTableGenerator
}
protected Iterable<String> getJavaCandidateCatalogs(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.getCandidateCatalogs(filter));
+ return StringTools.convertToJavaStringLiteralContents(this.getCandidateCatalogs(filter));
}
protected Iterable<String> getCandidateCatalogs(Filter<String> filter) {
@@ -522,7 +522,7 @@ public class GenericJavaTableGenerator
}
protected Iterable<String> getJavaCandidateColumnNames() {
- return StringTools.convertToJavaStringLiterals(this.getCandidateColumnNames());
+ return StringTools.convertToJavaStringLiteralContents(this.getCandidateColumnNames());
}
protected Iterable<String> getCandidateColumnNames() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaUniqueConstraint.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaUniqueConstraint.java
index ca35d3e..e2d8fc3 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaUniqueConstraint.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaUniqueConstraint.java
@@ -99,7 +99,7 @@ public class GenericJavaUniqueConstraint
}
protected Iterable<String> getJavaCandidateColumnNames() {
- return StringTools.convertToJavaStringLiterals(this.getCandidateColumnNames());
+ return StringTools.convertToJavaStringLiteralContents(this.getCandidateColumnNames());
}
protected Iterable<String> getCandidateColumnNames() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java
index 517a490..69201af 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java
@@ -1409,7 +1409,7 @@ public abstract class AbstractJavaElementCollectionMapping2_0
}
protected Iterable<String> getJavaCandidateMapKeyNames() {
- return StringTools.convertToJavaStringLiterals(this.getCandidateMapKeyNames());
+ return StringTools.convertToJavaStringLiteralContents(this.getCandidateMapKeyNames());
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaMapsIdDerivedIdentityStrategy2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaMapsIdDerivedIdentityStrategy2_0.java
index 0f626f7..7911ec6 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaMapsIdDerivedIdentityStrategy2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaMapsIdDerivedIdentityStrategy2_0.java
@@ -274,7 +274,7 @@ public class GenericJavaMapsIdDerivedIdentityStrategy2_0
}
protected Iterable<String> getSortedJavaValueChoices() {
- return StringTools.convertToJavaStringLiterals(this.getSortedCandidateIdAttributeNames());
+ return StringTools.convertToJavaStringLiteralContents(this.getSortedCandidateIdAttributeNames());
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaTenantDiscriminatorColumn2_3.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaTenantDiscriminatorColumn2_3.java
index 2977a29..19c80e6 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaTenantDiscriminatorColumn2_3.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaTenantDiscriminatorColumn2_3.java
@@ -250,7 +250,7 @@ public class EclipseLinkJavaTenantDiscriminatorColumn2_3
}
protected Iterable<String> getJavaCandidateTableNames() {
- return StringTools.convertToJavaStringLiterals(this.getCandidateTableNames());
+ return StringTools.convertToJavaStringLiteralContents(this.getCandidateTableNames());
}
public Iterable<String> getCandidateTableNames() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkConvert.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkConvert.java
index acf02ac..df784df 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkConvert.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkConvert.java
@@ -132,7 +132,7 @@ public class JavaEclipseLinkConvert
}
protected Iterable<String> getJavaCandidateConverterNames() {
- return StringTools.convertToJavaStringLiterals(this.getConverterNames());
+ return StringTools.convertToJavaStringLiteralContents(this.getConverterNames());
}
/**
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 5afb4eb..f80687a 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,7 +23,10 @@ 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;
@@ -113,6 +116,12 @@ 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)
@@ -123,6 +132,7 @@ 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 + "<=");
@@ -131,13 +141,22 @@ public class JpaJavaCompletionProposalComputer
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
for (JpaStructureNode structureNode : rootStructureNodes) {
- for (String s : ((JavaPersistentType) structureNode).getCompletionProposals(context.getInvocationOffset())) {
- proposals.add(new CompletionProposal(s, tokenStart, tokenEnd - tokenStart + 1, s.length()));
+ 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$
+ }
}
}
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();
@@ -163,4 +182,23 @@ 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);
+ }
+ }
}