View | Details | Raw Unified | Return to bug 274557
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/CompletionContextTests_1_5.java (+70 lines)
Lines 1300-1303 Link Here
1300
		"}",
1300
		"}",
1301
		result.context);
1301
		result.context);
1302
}
1302
}
1303
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=274557
1304
public void test0041() throws JavaModelException {
1305
	this.workingCopies = new ICompilationUnit[2];
1306
	this.workingCopies[0] = getWorkingCopy(
1307
		"/Completion/src3/test/X.java",
1308
		"package test;\n" +
1309
		"public class X {\n" +
1310
		"  @TestAnnot(value=\"\")\n" +
1311
		"  public int field = 0;\n" +
1312
		"}");
1313
	
1314
	this.workingCopies[1] = getWorkingCopy(
1315
		"/Completion/src3/test/TestAnnot.java",
1316
		"package test;\n" +
1317
		"public @interface X {\n" +
1318
		"  String value();\n" +
1319
		"}");
1320
1321
	String str = this.workingCopies[0].getSource();
1322
	int tokenStart = str.lastIndexOf("\"\"");
1323
	int tokenEnd = tokenStart + "\"\"".length() - 1;
1324
	int cursorLocation = str.lastIndexOf("value=\"") + "value=\"".length();
1325
1326
	CompletionResult result = contextComplete(this.workingCopies[0], cursorLocation);
1327
1328
	assertResults(
1329
		"completion offset="+(cursorLocation)+"\n" +
1330
		"completion range=["+(tokenStart)+", "+(tokenEnd)+"]\n" +
1331
		"completion token=\"\"\n" +
1332
		"completion token kind=TOKEN_KIND_STRING_LITERAL\n" +
1333
		"expectedTypesSignatures=null\n" +
1334
		"expectedTypesKeys=null\n" +
1335
		"completion token location=UNKNOWN",
1336
		result.context);
1337
}
1338
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=274557
1339
public void test0042() throws JavaModelException {
1340
	this.workingCopies = new ICompilationUnit[2];
1341
	this.workingCopies[0] = getWorkingCopy(
1342
		"/Completion/src3/test/X.java",
1343
		"package test;\n" +
1344
		"public class X {\n" +
1345
		"  @TestAnnot(\"\")\n" +
1346
		"  public int field = 0;\n" +
1347
		"}");
1348
	
1349
	this.workingCopies[1] = getWorkingCopy(
1350
		"/Completion/src3/test/TestAnnot.java",
1351
		"package test;\n" +
1352
		"public @interface X {\n" +
1353
		"  String value();\n" +
1354
		"}");
1355
1356
	String str = this.workingCopies[0].getSource();
1357
	int tokenStart = str.lastIndexOf("\"\"");
1358
	int tokenEnd = tokenStart + "\"\"".length() - 1;
1359
	int cursorLocation = str.lastIndexOf("@TestAnnot(\"") + "@TestAnnot(\"".length();
1360
1361
	CompletionResult result = contextComplete(this.workingCopies[0], cursorLocation);
1362
1363
	assertResults(
1364
		"completion offset="+(cursorLocation)+"\n" +
1365
		"completion range=["+(tokenStart)+", "+(tokenEnd)+"]\n" +
1366
		"completion token=\"\"\n" +
1367
		"completion token kind=TOKEN_KIND_STRING_LITERAL\n" +
1368
		"expectedTypesSignatures=null\n" +
1369
		"expectedTypesKeys=null\n" +
1370
		"completion token location=UNKNOWN",
1371
		result.context);
1372
}
1303
}
1373
}
(-)codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java (-1 / +1 lines)
Lines 386-392 Link Here
386
386
387
						buildMoreAnnotationCompletionContext(memberValueName);
387
						buildMoreAnnotationCompletionContext(memberValueName);
388
						return;
388
						return;
389
					} else if (expression instanceof QualifiedNameReference) {
389
					} else if (expression instanceof QualifiedNameReference || expression instanceof StringLiteral) {
390
						MemberValuePair valuePair =
390
						MemberValuePair valuePair =
391
							new MemberValuePair(VALUE, expression.sourceStart, expression.sourceEnd, expression);
391
							new MemberValuePair(VALUE, expression.sourceStart, expression.sourceEnd, expression);
392
						buildMoreAnnotationCompletionContext(valuePair);
392
						buildMoreAnnotationCompletionContext(valuePair);
(-)src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java (+66 lines)
Lines 11063-11066 Link Here
11063
			expectedReplacedSource,
11063
			expectedReplacedSource,
11064
	"diet ast");
11064
	"diet ast");
11065
}
11065
}
11066
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=274557
11067
public void test0219_Diet() {
11068
11069
	String str =
11070
		"public class X {\n" +
11071
		"	@Annot(value=\"\")\n" +
11072
		"	int field;\n" +
11073
		"}\n";
11074
11075
	String completeBehind = "value=\"";
11076
	int cursorLocation = str.lastIndexOf("value=\"") + completeBehind.length() - 1;
11077
	String expectedCompletionNodeToString = "<CompletionOnString:\"\">";
11078
	String expectedParentNodeToString = "<NONE>";
11079
	String completionIdentifier = "";
11080
	String expectedReplacedSource = "\"\"";
11081
	String expectedUnitDisplayString =
11082
		"public class X {\n" + 
11083
		"  @Annot(value = <CompletionOnString:\"\">)\n" + 
11084
		"  int field;\n" + 
11085
		"  public X() {\n" + 
11086
		"  }\n" + 
11087
		"}\n";
11088
11089
	checkDietParse(
11090
			str.toCharArray(),
11091
			cursorLocation,
11092
			expectedCompletionNodeToString,
11093
			expectedParentNodeToString,
11094
			expectedUnitDisplayString,
11095
			completionIdentifier,
11096
			expectedReplacedSource,
11097
	"diet ast");
11098
}
11099
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=274557
11100
public void test0220_Diet() {
11101
11102
	String str =
11103
		"public class X {\n" +
11104
		"	@Annot(\"\")\n" +
11105
		"	int field;\n" +
11106
		"}\n";
11107
11108
	String completeBehind = "@Annot(\"";
11109
	int cursorLocation = str.lastIndexOf("@Annot(\"") + completeBehind.length() - 1;
11110
	String expectedCompletionNodeToString = "<CompletionOnString:\"\">";
11111
	String expectedParentNodeToString = "<NONE>";
11112
	String completionIdentifier = "";
11113
	String expectedReplacedSource = "\"\"";
11114
	String expectedUnitDisplayString =
11115
		"public class X {\n" + 
11116
		"  @Annot(value = <CompletionOnString:\"\">)\n" + 
11117
		"  int field;\n" + 
11118
		"  public X() {\n" + 
11119
		"  }\n" + 
11120
		"}\n";
11121
11122
	checkDietParse(
11123
			str.toCharArray(),
11124
			cursorLocation,
11125
			expectedCompletionNodeToString,
11126
			expectedParentNodeToString,
11127
			expectedUnitDisplayString,
11128
			completionIdentifier,
11129
			expectedReplacedSource,
11130
	"diet ast");
11131
}
11066
}
11132
}

Return to bug 274557