### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/CompletionContextTests_1_5.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionContextTests_1_5.java,v retrieving revision 1.12 diff -u -r1.12 CompletionContextTests_1_5.java --- src/org/eclipse/jdt/core/tests/model/CompletionContextTests_1_5.java 9 Sep 2008 12:43:37 -0000 1.12 +++ src/org/eclipse/jdt/core/tests/model/CompletionContextTests_1_5.java 5 May 2009 14:08:17 -0000 @@ -1300,4 +1300,74 @@ "}", result.context); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=274557 +public void test0041() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/X.java", + "package test;\n" + + "public class X {\n" + + " @TestAnnot(value=\"\")\n" + + " public int field = 0;\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/TestAnnot.java", + "package test;\n" + + "public @interface X {\n" + + " String value();\n" + + "}"); + + String str = this.workingCopies[0].getSource(); + int tokenStart = str.lastIndexOf("\"\""); + int tokenEnd = tokenStart + "\"\"".length() - 1; + int cursorLocation = str.lastIndexOf("value=\"") + "value=\"".length(); + + CompletionResult result = contextComplete(this.workingCopies[0], cursorLocation); + + assertResults( + "completion offset="+(cursorLocation)+"\n" + + "completion range=["+(tokenStart)+", "+(tokenEnd)+"]\n" + + "completion token=\"\"\n" + + "completion token kind=TOKEN_KIND_STRING_LITERAL\n" + + "expectedTypesSignatures=null\n" + + "expectedTypesKeys=null\n" + + "completion token location=UNKNOWN", + result.context); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=274557 +public void test0042() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/X.java", + "package test;\n" + + "public class X {\n" + + " @TestAnnot(\"\")\n" + + " public int field = 0;\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/TestAnnot.java", + "package test;\n" + + "public @interface X {\n" + + " String value();\n" + + "}"); + + String str = this.workingCopies[0].getSource(); + int tokenStart = str.lastIndexOf("\"\""); + int tokenEnd = tokenStart + "\"\"".length() - 1; + int cursorLocation = str.lastIndexOf("@TestAnnot(\"") + "@TestAnnot(\"".length(); + + CompletionResult result = contextComplete(this.workingCopies[0], cursorLocation); + + assertResults( + "completion offset="+(cursorLocation)+"\n" + + "completion range=["+(tokenStart)+", "+(tokenEnd)+"]\n" + + "completion token=\"\"\n" + + "completion token kind=TOKEN_KIND_STRING_LITERAL\n" + + "expectedTypesSignatures=null\n" + + "expectedTypesKeys=null\n" + + "completion token location=UNKNOWN", + result.context); +} } #P org.eclipse.jdt.core Index: codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java,v retrieving revision 1.206 diff -u -r1.206 CompletionParser.java --- codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java 16 Apr 2009 13:34:36 -0000 1.206 +++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java 5 May 2009 14:08:20 -0000 @@ -386,7 +386,7 @@ buildMoreAnnotationCompletionContext(memberValueName); return; - } else if (expression instanceof QualifiedNameReference) { + } else if (expression instanceof QualifiedNameReference || expression instanceof StringLiteral) { MemberValuePair valuePair = new MemberValuePair(VALUE, expression.sourceStart, expression.sourceEnd, expression); buildMoreAnnotationCompletionContext(valuePair); #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java,v retrieving revision 1.38 diff -u -r1.38 GenericsCompletionParserTest.java --- src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java 28 Apr 2009 17:17:30 -0000 1.38 +++ src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java 5 May 2009 14:08:22 -0000 @@ -11063,4 +11063,70 @@ expectedReplacedSource, "diet ast"); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=274557 +public void test0219_Diet() { + + String str = + "public class X {\n" + + " @Annot(value=\"\")\n" + + " int field;\n" + + "}\n"; + + String completeBehind = "value=\""; + int cursorLocation = str.lastIndexOf("value=\"") + completeBehind.length() - 1; + String expectedCompletionNodeToString = ""; + String expectedParentNodeToString = ""; + String completionIdentifier = ""; + String expectedReplacedSource = "\"\""; + String expectedUnitDisplayString = + "public class X {\n" + + " @Annot(value = )\n" + + " int field;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=274557 +public void test0220_Diet() { + + String str = + "public class X {\n" + + " @Annot(\"\")\n" + + " int field;\n" + + "}\n"; + + String completeBehind = "@Annot(\""; + int cursorLocation = str.lastIndexOf("@Annot(\"") + completeBehind.length() - 1; + String expectedCompletionNodeToString = ""; + String expectedParentNodeToString = ""; + String completionIdentifier = ""; + String expectedReplacedSource = "\"\""; + String expectedUnitDisplayString = + "public class X {\n" + + " @Annot(value = )\n" + + " int field;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} }