View | Details | Raw Unified | Return to bug 106450 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java (-2 / +292 lines)
Lines 8429-8435 Link Here
8429
			expectedReplacedSource,
8429
			expectedReplacedSource,
8430
	"diet ast");
8430
	"diet ast");
8431
	
8431
	
8432
	expectedCompletionNodeToString = "<CompleteOnName:fo>";
8432
	expectedCompletionNodeToString = "<CompleteOnMessageSendName:zzz.<String>fo()>";
8433
	expectedParentNodeToString = "<NONE>";
8433
	expectedParentNodeToString = "<NONE>";
8434
	completionIdentifier = "fo";
8434
	completionIdentifier = "fo";
8435
	expectedReplacedSource = "foo";
8435
	expectedReplacedSource = "foo";
Lines 8438-8444 Link Here
8438
		"  public Test() {\n" + 
8438
		"  public Test() {\n" + 
8439
		"  }\n" + 
8439
		"  }\n" + 
8440
		"  void bar() {\n" + 
8440
		"  void bar() {\n" + 
8441
		"    <CompleteOnName:fo>;\n" + 
8441
		"    <CompleteOnMessageSendName:zzz.<String>fo()>;\n" + 
8442
		"  }\n" + 
8442
		"  }\n" + 
8443
		"}\n";
8443
		"}\n";
8444
8444
Lines 9073-9076 Link Here
9073
			expectedReplacedSource,
9073
			expectedReplacedSource,
9074
	"diet ast");
9074
	"diet ast");
9075
}
9075
}
9076
/*
9077
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450
9078
 */
9079
public void test0206(){
9080
	String str =
9081
		"public class Test {\n"+
9082
		"	void foo() {\n"+
9083
		"	  Collections.<B>zzz\n"+
9084
		"	}\n"+
9085
		"}\n";
9086
9087
	String completeBehind = "zzz";
9088
	int cursorLocation = str.indexOf("zzz") + completeBehind.length() - 1;
9089
	String expectedCompletionNodeToString = "<NONE>";
9090
	String expectedParentNodeToString = "<NONE>";
9091
	String completionIdentifier = "<NONE>";
9092
	String expectedReplacedSource = "<NONE>";
9093
	String expectedUnitDisplayString =
9094
		"public class Test {\n" + 
9095
		"  public Test() {\n" + 
9096
		"  }\n" + 
9097
		"  void foo() {\n" + 
9098
		"  }\n" + 
9099
		"}\n";
9100
9101
	checkDietParse(
9102
			str.toCharArray(),
9103
			cursorLocation,
9104
			expectedCompletionNodeToString,
9105
			expectedParentNodeToString,
9106
			expectedUnitDisplayString,
9107
			completionIdentifier,
9108
			expectedReplacedSource,
9109
	"diet ast");
9110
	
9111
	expectedCompletionNodeToString = "<CompleteOnMessageSendName:Collections.<B>zzz()>";
9112
	expectedParentNodeToString = "<NONE>";
9113
	completionIdentifier = "zzz";
9114
	expectedReplacedSource = "zzz";
9115
	expectedUnitDisplayString =
9116
		"public class Test {\n" + 
9117
		"  public Test() {\n" + 
9118
		"  }\n" + 
9119
		"  void foo() {\n" + 
9120
		"    <CompleteOnMessageSendName:Collections.<B>zzz()>;\n" + 
9121
		"  }\n" + 
9122
		"}\n";
9123
9124
	checkMethodParse(
9125
			str.toCharArray(),
9126
			cursorLocation,
9127
			expectedCompletionNodeToString,
9128
			expectedParentNodeToString,
9129
			expectedUnitDisplayString,
9130
			completionIdentifier,
9131
			expectedReplacedSource,
9132
			"full ast");
9133
}
9134
/*
9135
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450
9136
 */
9137
public void test0207(){
9138
	String str =
9139
		"public class Test {\n"+
9140
		"	void foo() {\n"+
9141
		"	  bar().<B>zzz\n"+
9142
		"	}\n"+
9143
		"}\n";
9144
9145
	String completeBehind = "zzz";
9146
	int cursorLocation = str.indexOf("zzz") + completeBehind.length() - 1;
9147
	String expectedCompletionNodeToString = "<NONE>";
9148
	String expectedParentNodeToString = "<NONE>";
9149
	String completionIdentifier = "<NONE>";
9150
	String expectedReplacedSource = "<NONE>";
9151
	String expectedUnitDisplayString =
9152
		"public class Test {\n" + 
9153
		"  public Test() {\n" + 
9154
		"  }\n" + 
9155
		"  void foo() {\n" + 
9156
		"  }\n" + 
9157
		"}\n";
9158
9159
	checkDietParse(
9160
			str.toCharArray(),
9161
			cursorLocation,
9162
			expectedCompletionNodeToString,
9163
			expectedParentNodeToString,
9164
			expectedUnitDisplayString,
9165
			completionIdentifier,
9166
			expectedReplacedSource,
9167
	"diet ast");
9168
	
9169
	expectedCompletionNodeToString = "<CompleteOnMessageSendName:bar().<B>zzz()>";
9170
	expectedParentNodeToString = "<NONE>";
9171
	completionIdentifier = "zzz";
9172
	expectedReplacedSource = "zzz";
9173
	expectedUnitDisplayString =
9174
		"public class Test {\n" + 
9175
		"  public Test() {\n" + 
9176
		"  }\n" + 
9177
		"  void foo() {\n" + 
9178
		"    <CompleteOnMessageSendName:bar().<B>zzz()>;\n" + 
9179
		"  }\n" + 
9180
		"}\n";
9181
9182
	checkMethodParse(
9183
			str.toCharArray(),
9184
			cursorLocation,
9185
			expectedCompletionNodeToString,
9186
			expectedParentNodeToString,
9187
			expectedUnitDisplayString,
9188
			completionIdentifier,
9189
			expectedReplacedSource,
9190
			"full ast");
9191
}
9192
/*
9193
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450
9194
 */
9195
public void test0208(){
9196
	String str =
9197
		"public class Test {\n"+
9198
		"	void foo() {\n"+
9199
		"	  int.<B>zzz\n"+
9200
		"	}\n"+
9201
		"}\n";
9202
9203
	String completeBehind = "zzz";
9204
	int cursorLocation = str.indexOf("zzz") + completeBehind.length() - 1;
9205
	String expectedCompletionNodeToString = "<NONE>";
9206
	String expectedParentNodeToString = "<NONE>";
9207
	String completionIdentifier = "<NONE>";
9208
	String expectedReplacedSource = "<NONE>";
9209
	String expectedUnitDisplayString =
9210
		"public class Test {\n" + 
9211
		"  public Test() {\n" + 
9212
		"  }\n" + 
9213
		"  void foo() {\n" + 
9214
		"  }\n" + 
9215
		"}\n";
9216
9217
	checkDietParse(
9218
			str.toCharArray(),
9219
			cursorLocation,
9220
			expectedCompletionNodeToString,
9221
			expectedParentNodeToString,
9222
			expectedUnitDisplayString,
9223
			completionIdentifier,
9224
			expectedReplacedSource,
9225
	"diet ast");
9226
	
9227
	expectedCompletionNodeToString = "<CompleteOnName:zzz>";
9228
	expectedParentNodeToString = "<NONE>";
9229
	completionIdentifier = "zzz";
9230
	expectedReplacedSource = "zzz";
9231
	expectedUnitDisplayString =
9232
		"public class Test {\n" + 
9233
		"  public Test() {\n" + 
9234
		"  }\n" + 
9235
		"  void foo() {\n" + 
9236
		"    <CompleteOnName:zzz>;\n" + 
9237
		"  }\n" + 
9238
		"}\n";
9239
9240
	checkMethodParse(
9241
			str.toCharArray(),
9242
			cursorLocation,
9243
			expectedCompletionNodeToString,
9244
			expectedParentNodeToString,
9245
			expectedUnitDisplayString,
9246
			completionIdentifier,
9247
			expectedReplacedSource,
9248
			"full ast");
9249
}
9250
/*
9251
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450
9252
 */
9253
public void test0209(){
9254
	String str =
9255
		"public class Test {\n"+
9256
		"	void foo() {\n"+
9257
		"	  this.<B>zzz\n"+
9258
		"	}\n"+
9259
		"}\n";
9260
9261
	String completeBehind = "zzz";
9262
	int cursorLocation = str.indexOf("zzz") + completeBehind.length() - 1;
9263
	String expectedCompletionNodeToString = "<NONE>";
9264
	String expectedParentNodeToString = "<NONE>";
9265
	String completionIdentifier = "<NONE>";
9266
	String expectedReplacedSource = "<NONE>";
9267
	String expectedUnitDisplayString =
9268
		"public class Test {\n" + 
9269
		"  public Test() {\n" + 
9270
		"  }\n" + 
9271
		"  void foo() {\n" + 
9272
		"  }\n" + 
9273
		"}\n";
9274
9275
	checkDietParse(
9276
			str.toCharArray(),
9277
			cursorLocation,
9278
			expectedCompletionNodeToString,
9279
			expectedParentNodeToString,
9280
			expectedUnitDisplayString,
9281
			completionIdentifier,
9282
			expectedReplacedSource,
9283
	"diet ast");
9284
	
9285
	expectedCompletionNodeToString = "<CompleteOnMessageSendName:this.<B>zzz()>";
9286
	expectedParentNodeToString = "<NONE>";
9287
	completionIdentifier = "zzz";
9288
	expectedReplacedSource = "zzz";
9289
	expectedUnitDisplayString =
9290
		"public class Test {\n" + 
9291
		"  public Test() {\n" + 
9292
		"  }\n" + 
9293
		"  void foo() {\n" + 
9294
		"    <CompleteOnMessageSendName:this.<B>zzz()>;\n" + 
9295
		"  }\n" + 
9296
		"}\n";
9297
9298
	checkMethodParse(
9299
			str.toCharArray(),
9300
			cursorLocation,
9301
			expectedCompletionNodeToString,
9302
			expectedParentNodeToString,
9303
			expectedUnitDisplayString,
9304
			completionIdentifier,
9305
			expectedReplacedSource,
9306
			"full ast");
9307
}
9308
/*
9309
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450
9310
 */
9311
public void test0210(){
9312
	String str =
9313
		"public class Test {\n"+
9314
		"	void foo() {\n"+
9315
		"	  super.<B>zzz\n"+
9316
		"	}\n"+
9317
		"}\n";
9318
9319
	String completeBehind = "zzz";
9320
	int cursorLocation = str.indexOf("zzz") + completeBehind.length() - 1;
9321
	String expectedCompletionNodeToString = "<NONE>";
9322
	String expectedParentNodeToString = "<NONE>";
9323
	String completionIdentifier = "<NONE>";
9324
	String expectedReplacedSource = "<NONE>";
9325
	String expectedUnitDisplayString =
9326
		"public class Test {\n" + 
9327
		"  public Test() {\n" + 
9328
		"  }\n" + 
9329
		"  void foo() {\n" + 
9330
		"  }\n" + 
9331
		"}\n";
9332
9333
	checkDietParse(
9334
			str.toCharArray(),
9335
			cursorLocation,
9336
			expectedCompletionNodeToString,
9337
			expectedParentNodeToString,
9338
			expectedUnitDisplayString,
9339
			completionIdentifier,
9340
			expectedReplacedSource,
9341
	"diet ast");
9342
	
9343
	expectedCompletionNodeToString = "<CompleteOnMessageSendName:super.<B>zzz()>";
9344
	expectedParentNodeToString = "<NONE>";
9345
	completionIdentifier = "zzz";
9346
	expectedReplacedSource = "zzz";
9347
	expectedUnitDisplayString =
9348
		"public class Test {\n" + 
9349
		"  public Test() {\n" + 
9350
		"  }\n" + 
9351
		"  void foo() {\n" + 
9352
		"    <CompleteOnMessageSendName:super.<B>zzz()>;\n" + 
9353
		"  }\n" + 
9354
		"}\n";
9355
9356
	checkMethodParse(
9357
			str.toCharArray(),
9358
			cursorLocation,
9359
			expectedCompletionNodeToString,
9360
			expectedParentNodeToString,
9361
			expectedUnitDisplayString,
9362
			completionIdentifier,
9363
			expectedReplacedSource,
9364
			"full ast");
9365
}
9076
}
9366
}
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java (+424 lines)
Lines 8196-8199 Link Here
8196
			"Test270[TYPE_REF]{Test270, test, Ltest.Test270;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_EXACT_NAME + R_NON_RESTRICTED) + "}",
8196
			"Test270[TYPE_REF]{Test270, test, Ltest.Test270;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_EXACT_NAME + R_NON_RESTRICTED) + "}",
8197
			requestor.getResults());
8197
			requestor.getResults());
8198
}
8198
}
8199
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450
8200
public void test0271() throws JavaModelException {
8201
	this.workingCopies = new ICompilationUnit[2];
8202
	this.workingCopies[0] = getWorkingCopy(
8203
		"/Completion/src/test/Test.java",
8204
		"package test;\n"+
8205
		"public class Test {\n"+
8206
		"	void foo() {\n"+
8207
		"	  TestCollections.<Object>zzz\n"+
8208
		"	}\n"+
8209
		"}\n");
8210
	
8211
	this.workingCopies[1] = getWorkingCopy(
8212
		"/Completion/src/test/TestCollections.java",
8213
		"package test;\n"+
8214
		"public class TestCollections {\n"+
8215
		"  public <T> void zzz1(T t) {}\n"+
8216
		"  public static <T> void zzz2(T t) {}\n"+
8217
		"}");
8218
8219
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
8220
	
8221
	String str = this.workingCopies[0].getSource();
8222
	String completeBehind = "zzz";
8223
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8224
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
8225
8226
	assertResults(
8227
			"zzz2[METHOD_REF]{zzz2(), Ltest.TestCollections;, (Ljava.lang.Object;)V, zzz2, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
8228
			requestor.getResults());
8229
}
8230
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450
8231
public void test0272() throws JavaModelException {
8232
	this.workingCopies = new ICompilationUnit[2];
8233
	this.workingCopies[0] = getWorkingCopy(
8234
		"/Completion/src/test/Test.java",
8235
		"package test;\n"+
8236
		"public class Test {\n"+
8237
		"	void foo(TestCollections t) {\n"+
8238
		"	  t.<Object>zzz\n"+
8239
		"	}\n"+
8240
		"}\n");
8241
	
8242
	this.workingCopies[1] = getWorkingCopy(
8243
		"/Completion/src/test/TestCollections.java",
8244
		"package test;\n"+
8245
		"public class TestCollections {\n"+
8246
		"  public <T> void zzz1(T t) {}\n"+
8247
		"  public static <T> void zzz2(T t) {}\n"+
8248
		"}");
8249
8250
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
8251
	
8252
	String str = this.workingCopies[0].getSource();
8253
	String completeBehind = "zzz";
8254
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8255
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
8256
8257
	assertResults(
8258
			"zzz2[METHOD_REF]{zzz2(), Ltest.TestCollections;, (Ljava.lang.Object;)V, zzz2, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
8259
			"zzz1[METHOD_REF]{zzz1(), Ltest.TestCollections;, (Ljava.lang.Object;)V, zzz1, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}",
8260
			requestor.getResults());
8261
}
8262
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450
8263
public void test0273() throws JavaModelException {
8264
	this.workingCopies = new ICompilationUnit[2];
8265
	this.workingCopies[0] = getWorkingCopy(
8266
		"/Completion/src/test/Test.java",
8267
		"package test;\n"+
8268
		"public class Test {\n"+
8269
		"	TestCollections bar() {\n"+
8270
		"	  return null;\n"+
8271
		"	}\n"+
8272
		"	void foo() {\n"+
8273
		"	  bar().<Object>zzz\n"+
8274
		"	}\n"+
8275
		"}\n");
8276
	
8277
	this.workingCopies[1] = getWorkingCopy(
8278
		"/Completion/src/test/TestCollections.java",
8279
		"package test;\n"+
8280
		"public class TestCollections {\n"+
8281
		"  public <T> void zzz1(T t) {}\n"+
8282
		"  public static <T> void zzz2(T t) {}\n"+
8283
		"}");
8284
8285
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
8286
	
8287
	String str = this.workingCopies[0].getSource();
8288
	String completeBehind = "zzz";
8289
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8290
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
8291
8292
	assertResults(
8293
			"zzz2[METHOD_REF]{zzz2(), Ltest.TestCollections;, (Ljava.lang.Object;)V, zzz2, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
8294
			"zzz1[METHOD_REF]{zzz1(), Ltest.TestCollections;, (Ljava.lang.Object;)V, zzz1, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}",
8295
			requestor.getResults());
8296
}
8297
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450
8298
public void test0274() throws JavaModelException {
8299
	this.workingCopies = new ICompilationUnit[2];
8300
	this.workingCopies[0] = getWorkingCopy(
8301
		"/Completion/src/test/Test.java",
8302
		"package test;\n"+
8303
		"public class Test {\n"+
8304
		"	void foo() {\n"+
8305
		"	  int.<Object>zzz\n"+
8306
		"	}\n"+
8307
		"}\n");
8308
	
8309
	this.workingCopies[1] = getWorkingCopy(
8310
		"/Completion/src/test/TestCollections.java",
8311
		"package test;\n"+
8312
		"public class TestCollections {\n"+
8313
		"  public <T> void zzz1(T t) {}\n"+
8314
		"  public static <T> void zzz2(T t) {}\n"+
8315
		"}");
8316
8317
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
8318
	
8319
	String str = this.workingCopies[0].getSource();
8320
	String completeBehind = "zzz";
8321
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8322
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
8323
8324
	assertResults(
8325
			"",
8326
			requestor.getResults());
8327
}
8328
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450
8329
public void test0275() throws JavaModelException {
8330
	this.workingCopies = new ICompilationUnit[2];
8331
	this.workingCopies[0] = getWorkingCopy(
8332
		"/Completion/src/test/Test.java",
8333
		"package test;\n"+
8334
		"public class Test {\n"+
8335
		"	void foo(int t) {\n"+
8336
		"	  t.<Object>zzz\n"+
8337
		"	}\n"+
8338
		"}\n");
8339
	
8340
	this.workingCopies[1] = getWorkingCopy(
8341
		"/Completion/src/test/TestCollections.java",
8342
		"package test;\n"+
8343
		"public class TestCollections {\n"+
8344
		"  public <T> void zzz1(T t) {}\n"+
8345
		"  public static <T> void zzz2(T t) {}\n"+
8346
		"}");
8347
8348
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
8349
	
8350
	String str = this.workingCopies[0].getSource();
8351
	String completeBehind = "zzz";
8352
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8353
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
8354
8355
	assertResults(
8356
			"",
8357
			requestor.getResults());
8358
}
8359
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450
8360
public void test0276() throws JavaModelException {
8361
	this.workingCopies = new ICompilationUnit[2];
8362
	this.workingCopies[0] = getWorkingCopy(
8363
		"/Completion/src/test/Test.java",
8364
		"package test;\n"+
8365
		"public class Test {\n"+
8366
		"	int bar() {\n"+
8367
		"	  return 0;\n"+
8368
		"	}\n"+
8369
		"	void foo() {\n"+
8370
		"	  bar().<Object>zzz\n"+
8371
		"	}\n"+
8372
		"}\n");
8373
	
8374
	this.workingCopies[1] = getWorkingCopy(
8375
		"/Completion/src/test/TestCollections.java",
8376
		"package test;\n"+
8377
		"public class TestCollections {\n"+
8378
		"  public <T> void zzz1(T t) {}\n"+
8379
		"  public static <T> void zzz2(T t) {}\n"+
8380
		"}");
8381
8382
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
8383
	
8384
	String str = this.workingCopies[0].getSource();
8385
	String completeBehind = "zzz";
8386
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8387
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
8388
8389
	assertResults(
8390
			"",
8391
			requestor.getResults());
8392
}
8393
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450
8394
public void test0277() throws JavaModelException {
8395
	this.workingCopies = new ICompilationUnit[2];
8396
	this.workingCopies[0] = getWorkingCopy(
8397
		"/Completion/src/test/Test.java",
8398
		"package test;\n"+
8399
		"public class Test {\n"+
8400
		"	void foo(TestCollections[] o) {\n"+
8401
		"	  o.<Object>zzz\n"+
8402
		"	}\n"+
8403
		"}\n");
8404
	
8405
	this.workingCopies[1] = getWorkingCopy(
8406
		"/Completion/src/test/TestCollections.java",
8407
		"package test;\n"+
8408
		"public class TestCollections {\n"+
8409
		"  public <T> void zzz1(T t) {}\n"+
8410
		"  public static <T> void zzz2(T t) {}\n"+
8411
		"}");
8412
8413
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
8414
	
8415
	String str = this.workingCopies[0].getSource();
8416
	String completeBehind = "zzz";
8417
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8418
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
8419
8420
	assertResults(
8421
			"",
8422
			requestor.getResults());
8423
}
8424
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450
8425
public void test0278() throws JavaModelException {
8426
	this.workingCopies = new ICompilationUnit[1];
8427
	this.workingCopies[0] = getWorkingCopy(
8428
		"/Completion/src/test/Test.java",
8429
		"package test;\n"+
8430
		"public class Test {\n"+
8431
		"  public <T> void zzz1(T t) {}\n"+
8432
		"  public static <T> void zzz2(T t) {}\n"+
8433
		"  void foo(TestCollections[] o) {\n"+
8434
		"    this.<Object>zzz\n"+
8435
		"  }\n"+
8436
		"}\n");
8437
8438
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
8439
	
8440
	String str = this.workingCopies[0].getSource();
8441
	String completeBehind = "zzz";
8442
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8443
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
8444
8445
	assertResults(
8446
			"zzz2[METHOD_REF]{zzz2(), Ltest.Test;, (Ljava.lang.Object;)V, zzz2, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
8447
			requestor.getResults());
8448
}
8449
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450
8450
public void test0279() throws JavaModelException {
8451
	this.workingCopies = new ICompilationUnit[2];
8452
	this.workingCopies[0] = getWorkingCopy(
8453
		"/Completion/src/test/Test.java",
8454
		"package test;\n"+
8455
		"public class Test extends TestCollections {\n"+
8456
		"	void foo() {\n"+
8457
		"	  super.<Object>zzz\n"+
8458
		"	}\n"+
8459
		"}\n");
8460
	
8461
	this.workingCopies[1] = getWorkingCopy(
8462
		"/Completion/src/test/TestCollections.java",
8463
		"package test;\n"+
8464
		"public class TestCollections {\n"+
8465
		"  public <T> void zzz1(T t) {}\n"+
8466
		"  public static <T> void zzz2(T t) {}\n"+
8467
		"}");
8468
8469
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
8470
	
8471
	String str = this.workingCopies[0].getSource();
8472
	String completeBehind = "zzz";
8473
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8474
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
8475
8476
	assertResults(
8477
			"zzz2[METHOD_REF]{zzz2(), Ltest.TestCollections;, (Ljava.lang.Object;)V, zzz2, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
8478
			requestor.getResults());
8479
}
8480
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450
8481
public void test0280() throws JavaModelException {
8482
	this.workingCopies = new ICompilationUnit[2];
8483
	this.workingCopies[0] = getWorkingCopy(
8484
		"/Completion/src/test/Test.java",
8485
		"package test;\n"+
8486
		"public class Test {\n"+
8487
		"	void foo() {\n"+
8488
		"	  TestCollections.<Object, Object>zzz\n"+
8489
		"	}\n"+
8490
		"}\n");
8491
	
8492
	this.workingCopies[1] = getWorkingCopy(
8493
		"/Completion/src/test/TestCollections.java",
8494
		"package test;\n"+
8495
		"public class TestCollections {\n"+
8496
		"  public <T> void zzz1(T t) {}\n"+
8497
		"  public static <T> void zzz2(T t) {}\n"+
8498
		"}");
8499
8500
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
8501
	
8502
	String str = this.workingCopies[0].getSource();
8503
	String completeBehind = "zzz";
8504
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8505
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
8506
8507
	assertResults(
8508
			"",
8509
			requestor.getResults());
8510
}
8511
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450
8512
public void test0281() throws JavaModelException {
8513
	this.workingCopies = new ICompilationUnit[2];
8514
	this.workingCopies[0] = getWorkingCopy(
8515
		"/Completion/src/test/Test.java",
8516
		"package test;\n"+
8517
		"public class Test {\n"+
8518
		"	void foo() {\n"+
8519
		"	  TestCollections.zzz\n"+
8520
		"	}\n"+
8521
		"}\n");
8522
	
8523
	this.workingCopies[1] = getWorkingCopy(
8524
		"/Completion/src/test/TestCollections.java",
8525
		"package test;\n"+
8526
		"public class TestCollections {\n"+
8527
		"  public <T> void zzz1(T t) {}\n"+
8528
		"  public static <T> void zzz2(T t) {}\n"+
8529
		"}");
8530
8531
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
8532
	
8533
	String str = this.workingCopies[0].getSource();
8534
	String completeBehind = "zzz";
8535
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8536
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
8537
8538
	assertResults(
8539
			"zzz2[METHOD_REF]{zzz2(), Ltest.TestCollections;, <T:Ljava.lang.Object;>(TT;)V, zzz2, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
8540
			requestor.getResults());
8541
}
8542
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450
8543
public void test0282() throws JavaModelException {
8544
	this.workingCopies = new ICompilationUnit[1];
8545
	this.workingCopies[0] = getWorkingCopy(
8546
		"/Completion/src/test/Test.java",
8547
		"package test;\n"+
8548
		"public class Test {\n"+
8549
		"  public <T> void zzz1(T t) {}\n"+
8550
		"  public static <T> void zzz2(T t) {}\n"+
8551
		"  void foo() {\n"+
8552
		"    this.<Unknown>zzz\n"+
8553
		"  }\n"+
8554
		"}\n");
8555
8556
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
8557
	
8558
	String str = this.workingCopies[0].getSource();
8559
	String completeBehind = "zzz";
8560
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8561
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
8562
8563
	assertResults(
8564
			"",
8565
			requestor.getResults());
8566
}
8567
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450
8568
public void test0283() throws JavaModelException {
8569
	this.workingCopies = new ICompilationUnit[1];
8570
	this.workingCopies[0] = getWorkingCopy(
8571
		"/Completion/src/test/Test.java",
8572
		"package test;\n"+
8573
		"public class Test {\n"+
8574
		"  public <T, U> void zzz1(T t) {}\n"+
8575
		"  public static <T> void zzz2(T t) {}\n"+
8576
		"  void foo() {\n"+
8577
		"    this.<Unknown, Object>zzz\n"+
8578
		"  }\n"+
8579
		"}\n");
8580
8581
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
8582
	
8583
	String str = this.workingCopies[0].getSource();
8584
	String completeBehind = "zzz";
8585
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8586
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
8587
8588
	assertResults(
8589
			"",
8590
			requestor.getResults());
8591
}
8592
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450
8593
public void test0284() throws JavaModelException {
8594
	this.workingCopies = new ICompilationUnit[2];
8595
	this.workingCopies[0] = getWorkingCopy(
8596
		"/Completion/src/test/Test.java",
8597
		"package test;\n"+
8598
		"public class Test {\n"+
8599
		"  public <T extends Test2> void zzz1(T t) {}\n"+
8600
		"  public static <T extends Test2> void zzz2(T t) {}\n"+
8601
		"  void foo() {\n"+
8602
		"    this.<Object>zzz\n"+
8603
		"  }\n"+
8604
		"}\n");
8605
	
8606
	this.workingCopies[1] = getWorkingCopy(
8607
		"/Completion/src/test/Test2.java",
8608
		"package test;\n"+
8609
		"public class Test2 {\n"+
8610
		"}\n");
8611
8612
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
8613
	
8614
	String str = this.workingCopies[0].getSource();
8615
	String completeBehind = "zzz";
8616
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8617
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
8618
8619
	assertResults(
8620
			"zzz2[METHOD_REF]{zzz2(), Ltest.Test;, (Ljava.lang.Object;)V, zzz2, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
8621
			requestor.getResults());
8622
}
8199
}
8623
}
(-)codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java (-3 / +88 lines)
Lines 109-114 Link Here
109
	static final int LPAREN_NOT_CONSUMED = 1;
109
	static final int LPAREN_NOT_CONSUMED = 1;
110
	static final int LPAREN_CONSUMED = 2;
110
	static final int LPAREN_CONSUMED = 2;
111
	
111
	
112
	// K_PARAMETERIZED_METHOD_INVOCATION arguments
113
	static final int INSIDE_NAME = 1;
112
114
113
	// the type of the current invocation (one of the invocation type constants)
115
	// the type of the current invocation (one of the invocation type constants)
114
	int invocationType;
116
	int invocationType;
Lines 856-863 Link Here
856
						}
858
						}
857
						break nextElement;
859
						break nextElement;
858
					case K_PARAMETERIZED_METHOD_INVOCATION :
860
					case K_PARAMETERIZED_METHOD_INVOCATION :
859
						currentElement = currentElement.add((TypeReference)node, 0);
861
						if(topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER, 1) == 0) {
860
						break nextElement;
862
							currentElement = currentElement.add((TypeReference)node, 0);
863
							break nextElement;
864
						}
861
				}
865
				}
862
				if(info == LESS && node instanceof TypeReference) {
866
				if(info == LESS && node instanceof TypeReference) {
863
					if(this.identifierLengthPtr > -1 && this.identifierLengthStack[this.identifierLengthPtr]!= 0) {
867
					if(this.identifierLengthPtr > -1 && this.identifierLengthStack[this.identifierLengthPtr]!= 0) {
Lines 1321-1326 Link Here
1321
	this.isOrphanCompletionNode = true;
1325
	this.isOrphanCompletionNode = true;
1322
	return true;
1326
	return true;
1323
}
1327
}
1328
private boolean checkParemeterizedMethodName() {
1329
	if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_PARAMETERIZED_METHOD_INVOCATION &&
1330
			topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) == INSIDE_NAME) {
1331
		if(this.identifierLengthPtr > -1 && this.genericsLengthPtr > -1 && this.genericsIdentifiersLengthPtr == -1) {
1332
			CompletionOnMessageSendName m = null;
1333
			switch (this.invocationType) {
1334
				case EXPLICIT_RECEIVER:
1335
				case NO_RECEIVER: // this case occurs with 'bar().foo'
1336
					if(this.expressionPtr > -1 && this.expressionLengthStack[this.expressionLengthPtr] == 1) {
1337
						char[] selector = this.identifierStack[this.identifierPtr];
1338
						long position = this.identifierPositionStack[identifierPtr--];
1339
						this.identifierLengthPtr--;
1340
						int end = (int) position;
1341
						int start = (int) (position >>> 32);
1342
						m = new CompletionOnMessageSendName(selector, start, end);
1343
						
1344
						// handle type arguments
1345
						int length = this.genericsLengthStack[this.genericsLengthPtr--];
1346
						this.genericsPtr -= length;
1347
						System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length);
1348
						intPtr--;
1349
						
1350
						m.receiver = this.expressionStack[this.expressionPtr--];
1351
						this.expressionLengthPtr--;
1352
					}
1353
					break;
1354
				case NAME_RECEIVER:
1355
					if(this.identifierPtr > 0) {
1356
						char[] selector = this.identifierStack[this.identifierPtr];
1357
						long position = this.identifierPositionStack[identifierPtr--];
1358
						this.identifierLengthPtr--;
1359
						int end = (int) position;
1360
						int start = (int) (position >>> 32);
1361
						m = new CompletionOnMessageSendName(selector, start, end);
1362
						
1363
						// handle type arguments
1364
						int length = this.genericsLengthStack[this.genericsLengthPtr--];
1365
						this.genericsPtr -= length;
1366
						System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length);
1367
						intPtr--;
1368
						
1369
						m.receiver = getUnspecifiedReference();
1370
					}
1371
					break;
1372
				case SUPER_RECEIVER:
1373
					char[] selector = this.identifierStack[this.identifierPtr];
1374
					long position = this.identifierPositionStack[identifierPtr--];
1375
					this.identifierLengthPtr--;
1376
					int end = (int) position;
1377
					int start = (int) (position >>> 32);
1378
					m = new CompletionOnMessageSendName(selector, start, end);
1379
					
1380
					// handle type arguments
1381
					int length = this.genericsLengthStack[this.genericsLengthPtr--];
1382
					this.genericsPtr -= length;
1383
					System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length);
1384
					intPtr--;
1385
					
1386
					m.receiver = new SuperReference(start, end);
1387
					break;
1388
			}
1389
			
1390
			if(m != null) {
1391
				pushOnExpressionStack(m);
1392
						
1393
				this.assistNode = m;
1394
				this.lastCheckPoint = this.assistNode.sourceEnd + 1;
1395
				this.isOrphanCompletionNode = true;
1396
				return true;
1397
			}
1398
		}
1399
	}
1400
	return false;
1401
}
1324
private boolean checkParemeterizedType() {
1402
private boolean checkParemeterizedType() {
1325
	if(this.identifierLengthPtr > -1 && this.genericsLengthPtr > -1 && this.genericsIdentifiersLengthPtr > -1) {
1403
	if(this.identifierLengthPtr > -1 && this.genericsLengthPtr > -1 && this.genericsIdentifiersLengthPtr > -1) {
1326
		int length = this.identifierLengthStack[this.identifierLengthPtr];
1404
		int length = this.identifierLengthStack[this.identifierLengthPtr];
Lines 1557-1562 Link Here
1557
	if (checkInvocation()) return;
1635
	if (checkInvocation()) return;
1558
1636
1559
	if (checkParemeterizedType()) return;
1637
	if (checkParemeterizedType()) return;
1638
	if (checkParemeterizedMethodName()) return;
1560
	if (checkLabelStatement()) return;
1639
	if (checkLabelStatement()) return;
1561
	if (checkNameCompletion()) return;
1640
	if (checkNameCompletion()) return;
1562
}
1641
}
Lines 2432-2438 Link Here
2432
	if (isInsideMethod() || isInsideFieldInitialization() || isInsideAnnotation()) {
2511
	if (isInsideMethod() || isInsideFieldInitialization() || isInsideAnnotation()) {
2433
		switch(token) {
2512
		switch(token) {
2434
			case TokenNameLPAREN:
2513
			case TokenNameLPAREN:
2435
				popElement(K_BETWEEN_NEW_AND_LEFT_BRACKET);
2514
				if(previous == TokenNameIdentifier &&
2515
						topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_PARAMETERIZED_METHOD_INVOCATION) {
2516
					popElement(K_PARAMETERIZED_METHOD_INVOCATION);
2517
				} else {
2518
					popElement(K_BETWEEN_NEW_AND_LEFT_BRACKET);
2519
				}
2436
				break;
2520
				break;
2437
			case TokenNameLBRACE:
2521
			case TokenNameLBRACE:
2438
				popElement(K_BETWEEN_NEW_AND_LEFT_BRACKET);
2522
				popElement(K_BETWEEN_NEW_AND_LEFT_BRACKET);
Lines 2864-2869 Link Here
2864
	popElement(K_BINARY_OPERATOR);
2948
	popElement(K_BINARY_OPERATOR);
2865
	if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_PARAMETERIZED_METHOD_INVOCATION) {
2949
	if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_PARAMETERIZED_METHOD_INVOCATION) {
2866
		popElement(K_PARAMETERIZED_METHOD_INVOCATION);
2950
		popElement(K_PARAMETERIZED_METHOD_INVOCATION);
2951
		pushOnElementStack(K_PARAMETERIZED_METHOD_INVOCATION, INSIDE_NAME);
2867
	} else {
2952
	} else {
2868
		popElement(K_PARAMETERIZED_ALLOCATION);
2953
		popElement(K_PARAMETERIZED_ALLOCATION);
2869
	}
2954
	}
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-2 / +77 lines)
Lines 743-749 Link Here
743
				SourceTypeBinding enclosingType = scope.enclosingSourceType();
743
				SourceTypeBinding enclosingType = scope.enclosingSourceType();
744
				if (!enclosingType.isAnnotationType()) {
744
				if (!enclosingType.isAnnotationType()) {
745
					if (!this.requestor.isIgnored(CompletionProposal.METHOD_DECLARATION)) {
745
					if (!this.requestor.isIgnored(CompletionProposal.METHOD_DECLARATION)) {
746
						findMethods(this.completionToken,null,enclosingType,scope,new ObjectVector(),false,false,true,null,null,false,false,true);
746
						findMethods(this.completionToken,null,null,enclosingType,scope,new ObjectVector(),false,false,true,null,null,false,false,true);
747
					}
747
					}
748
					if (!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) {
748
					if (!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) {
749
						proposeNewMethod(this.completionToken, enclosingType);
749
						proposeNewMethod(this.completionToken, enclosingType);
Lines 765-771 Link Here
765
				SourceTypeBinding enclosingType = scope.enclosingSourceType();
765
				SourceTypeBinding enclosingType = scope.enclosingSourceType();
766
				if (!enclosingType.isAnnotationType()) {
766
				if (!enclosingType.isAnnotationType()) {
767
					if (!this.requestor.isIgnored(CompletionProposal.METHOD_DECLARATION)) {
767
					if (!this.requestor.isIgnored(CompletionProposal.METHOD_DECLARATION)) {
768
						findMethods(this.completionToken,null,scope.enclosingSourceType(),scope,new ObjectVector(),false,false,true,null,null,false,false,true);
768
						findMethods(this.completionToken,null,null,scope.enclosingSourceType(),scope,new ObjectVector(),false,false,true,null,null,false,false,true);
769
					}
769
					}
770
					if (!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) {
770
					if (!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) {
771
						proposeNewMethod(this.completionToken, scope.enclosingSourceType());
771
						proposeNewMethod(this.completionToken, scope.enclosingSourceType());
Lines 928-933 Link Here
928
					findMethods(
928
					findMethods(
929
						this.completionToken,
929
						this.completionToken,
930
						null,
930
						null,
931
						null,
931
						receiverType,
932
						receiverType,
932
						scope,
933
						scope,
933
						new ObjectVector(),
934
						new ObjectVector(),
Lines 1013-1018 Link Here
1013
			} else  if (!this.requestor.isIgnored(CompletionProposal.METHOD_REF)) {
1014
			} else  if (!this.requestor.isIgnored(CompletionProposal.METHOD_REF)) {
1014
				findMethods(
1015
				findMethods(
1015
					this.completionToken,
1016
					this.completionToken,
1017
					null,
1016
					argTypes,
1018
					argTypes,
1017
					(ReferenceBinding)((ReferenceBinding) qualifiedBinding).capture(scope, messageSend.receiver.sourceEnd),
1019
					(ReferenceBinding)((ReferenceBinding) qualifiedBinding).capture(scope, messageSend.receiver.sourceEnd),
1018
					scope,
1020
					scope,
Lines 1237-1242 Link Here
1237
				
1239
				
1238
				this.findLabels(this.completionToken, label.possibleLabels);
1240
				this.findLabels(this.completionToken, label.possibleLabels);
1239
			}
1241
			}
1242
		} else if(astNode instanceof CompletionOnMessageSendName) {
1243
			if (!this.requestor.isIgnored(CompletionProposal.METHOD_REF)) {
1244
				CompletionOnMessageSendName messageSend = (CompletionOnMessageSendName) astNode;
1245
				
1246
				this.insideQualifiedReference = true;
1247
				this.completionToken = messageSend.selector;
1248
				boolean onlyStatic = false;
1249
				TypeBinding receiverType = null;
1250
				if(qualifiedBinding instanceof VariableBinding) {
1251
					receiverType = ((VariableBinding)qualifiedBinding).type;
1252
				} else if(qualifiedBinding instanceof MethodBinding) {
1253
					receiverType = ((MethodBinding)qualifiedBinding).returnType;
1254
				} else if(qualifiedBinding instanceof ReferenceBinding && !(qualifiedBinding instanceof TypeVariableBinding)) {
1255
					onlyStatic = true;
1256
					receiverType = (TypeBinding)qualifiedBinding;
1257
				}
1258
				if(receiverType != null && receiverType instanceof ReferenceBinding) {
1259
					TypeBinding[] typeArgTypes = computeTypesIfCorrect(messageSend.typeArguments);
1260
					if(typeArgTypes != null) {
1261
						this.findMethods(
1262
								this.completionToken,
1263
								typeArgTypes,
1264
								null,
1265
								(ReferenceBinding)receiverType.capture(scope, messageSend.receiver.sourceEnd),
1266
								scope,
1267
								new ObjectVector(),
1268
								onlyStatic,
1269
								false,
1270
								false,
1271
								messageSend,
1272
								scope,
1273
								false,
1274
								false,
1275
								true);
1276
					}
1277
				}
1278
			}
1240
		// Completion on Javadoc nodes
1279
		// Completion on Javadoc nodes
1241
		} else if ((astNode.bits & ASTNode.InsideJavadoc) != 0) {
1280
		} else if ((astNode.bits & ASTNode.InsideJavadoc) != 0) {
1242
			if (astNode instanceof CompletionOnJavadocSingleTypeReference) {
1281
			if (astNode instanceof CompletionOnJavadocSingleTypeReference) {
Lines 1312-1317 Link Here
1312
							|| !this.requestor.isIgnored(CompletionProposal.JAVADOC_METHOD_REF)) {
1351
							|| !this.requestor.isIgnored(CompletionProposal.JAVADOC_METHOD_REF)) {
1313
						findMethods(this.completionToken,
1352
						findMethods(this.completionToken,
1314
							null,
1353
							null,
1354
							null,
1315
							receiverType,
1355
							receiverType,
1316
							scope,
1356
							scope,
1317
							new ObjectVector(),
1357
							new ObjectVector(),
Lines 1357-1362 Link Here
1357
					}
1397
					}
1358
				} else if (!this.requestor.isIgnored(CompletionProposal.METHOD_REF)) {
1398
				} else if (!this.requestor.isIgnored(CompletionProposal.METHOD_REF)) {
1359
					findMethods(this.completionToken,
1399
					findMethods(this.completionToken,
1400
						null,
1360
						argTypes,
1401
						argTypes,
1361
						(ReferenceBinding) ((ReferenceBinding) qualifiedBinding).capture(scope, messageSend.receiver.sourceEnd),
1402
						(ReferenceBinding) ((ReferenceBinding) qualifiedBinding).capture(scope, messageSend.receiver.sourceEnd),
1362
						scope,
1403
						scope,
Lines 1795-1800 Link Here
1795
		return argTypes;
1836
		return argTypes;
1796
	}
1837
	}
1797
	
1838
	
1839
	private TypeBinding[] computeTypesIfCorrect(Expression[] arguments) {
1840
		if (arguments == null) return null;
1841
		int argsLength = arguments.length;
1842
		TypeBinding[] argTypes = new TypeBinding[argsLength];
1843
		for (int a = argsLength; --a >= 0;) {
1844
			TypeBinding typeBinding = arguments[a].resolvedType;
1845
			if(typeBinding == null || !typeBinding.isValidBinding()) return null;
1846
			argTypes[a] = typeBinding;
1847
		}
1848
		return argTypes;
1849
	}
1850
	
1798
	private void findAnnotationAttributes(char[] token, MemberValuePair[] attributesFound, ReferenceBinding annotation) {
1851
	private void findAnnotationAttributes(char[] token, MemberValuePair[] attributesFound, ReferenceBinding annotation) {
1799
		MethodBinding[] methods = annotation.availableMethods();
1852
		MethodBinding[] methods = annotation.availableMethods();
1800
		nextAttribute: for (int i = 0; i < methods.length; i++) {
1853
		nextAttribute: for (int i = 0; i < methods.length; i++) {
Lines 2793-2798 Link Here
2793
			findMethods(
2846
			findMethods(
2794
				token,
2847
				token,
2795
				null,
2848
				null,
2849
				null,
2796
				(ReferenceBinding) receiverType,
2850
				(ReferenceBinding) receiverType,
2797
				scope,
2851
				scope,
2798
				methodsFound,
2852
				methodsFound,
Lines 3620-3625 Link Here
3620
3674
3621
	private void findInterfacesMethods(
3675
	private void findInterfacesMethods(
3622
		char[] selector,
3676
		char[] selector,
3677
		TypeBinding[] typeArgTypes,
3623
		TypeBinding[] argTypes,
3678
		TypeBinding[] argTypes,
3624
		ReferenceBinding receiverType,
3679
		ReferenceBinding receiverType,
3625
		ReferenceBinding[] itsInterfaces,
3680
		ReferenceBinding[] itsInterfaces,
Lines 3668-3673 Link Here
3668
	
3723
	
3669
								findLocalMethods(
3724
								findLocalMethods(
3670
									selector,
3725
									selector,
3726
									typeArgTypes,
3671
									argTypes,
3727
									argTypes,
3672
									methods,
3728
									methods,
3673
									scope,
3729
									scope,
Lines 3739-3744 Link Here
3739
					SourceTypeBinding enclosingType = classScope.referenceContext.binding;
3795
					SourceTypeBinding enclosingType = classScope.referenceContext.binding;
3740
					findMethods(
3796
					findMethods(
3741
						token,
3797
						token,
3798
						null,
3742
						argTypes,
3799
						argTypes,
3743
						enclosingType,
3800
						enclosingType,
3744
						classScope,
3801
						classScope,
Lines 3764-3769 Link Here
3764
	// Helper method for findMethods(char[], TypeBinding[], ReferenceBinding, Scope, ObjectVector, boolean, boolean, boolean)
3821
	// Helper method for findMethods(char[], TypeBinding[], ReferenceBinding, Scope, ObjectVector, boolean, boolean, boolean)
3765
	private void findLocalMethods(
3822
	private void findLocalMethods(
3766
		char[] methodName,
3823
		char[] methodName,
3824
		TypeBinding[] typeArgTypes,
3767
		TypeBinding[] argTypes,
3825
		TypeBinding[] argTypes,
3768
		MethodBinding[] methods,
3826
		MethodBinding[] methods,
3769
		Scope scope,
3827
		Scope scope,
Lines 3782-3787 Link Here
3782
		// No visibility checks can be performed without the scope & invocationSite
3840
		// No visibility checks can be performed without the scope & invocationSite
3783
3841
3784
		int methodLength = methodName.length;
3842
		int methodLength = methodName.length;
3843
		int minTypeArgLength = typeArgTypes == null ? 0 : typeArgTypes.length;
3785
		int minArgLength = argTypes == null ? 0 : argTypes.length;
3844
		int minArgLength = argTypes == null ? 0 : argTypes.length;
3786
3845
3787
		next : for (int f = methods.length; --f >= 0;) {
3846
		next : for (int f = methods.length; --f >= 0;) {
Lines 3822-3827 Link Here
3822
					continue next;
3881
					continue next;
3823
				}
3882
				}
3824
			}
3883
			}
3884
			
3885
			if (minTypeArgLength != 0 && minTypeArgLength != method.typeVariables.length)
3886
				continue next;
3887
			
3888
			if (minTypeArgLength != 0) {
3889
				method = new ParameterizedGenericMethodBinding(method, typeArgTypes, scope.environment());
3890
			}
3891
			
3825
			if (minArgLength > method.parameters.length)
3892
			if (minArgLength > method.parameters.length)
3826
				continue next;
3893
				continue next;
3827
3894
Lines 4586-4591 Link Here
4586
4653
4587
	private void findMethods(
4654
	private void findMethods(
4588
		char[] selector,
4655
		char[] selector,
4656
		TypeBinding[] typeArgTypes,
4589
		TypeBinding[] argTypes,
4657
		TypeBinding[] argTypes,
4590
		ReferenceBinding receiverType,
4658
		ReferenceBinding receiverType,
4591
		Scope scope,
4659
		Scope scope,
Lines 4621-4626 Link Here
4621
				if (isCompletingDeclaration) {
4689
				if (isCompletingDeclaration) {
4622
					findInterfacesMethods(
4690
					findInterfacesMethods(
4623
						selector,
4691
						selector,
4692
						typeArgTypes,
4624
						argTypes,
4693
						argTypes,
4625
						receiverType,
4694
						receiverType,
4626
						currentType.superInterfaces(),
4695
						currentType.superInterfaces(),
Lines 4637-4642 Link Here
4637
				} else {
4706
				} else {
4638
					findInterfacesMethods(
4707
					findInterfacesMethods(
4639
						selector,
4708
						selector,
4709
						typeArgTypes,
4640
						argTypes,
4710
						argTypes,
4641
						receiverType,
4711
						receiverType,
4642
						new ReferenceBinding[]{currentType},
4712
						new ReferenceBinding[]{currentType},
Lines 4657-4662 Link Here
4657
				if (isCompletingDeclaration){
4727
				if (isCompletingDeclaration){
4658
					findInterfacesMethods(
4728
					findInterfacesMethods(
4659
						selector,
4729
						selector,
4730
						typeArgTypes,
4660
						argTypes,
4731
						argTypes,
4661
						receiverType,
4732
						receiverType,
4662
						currentType.superInterfaces(),
4733
						currentType.superInterfaces(),
Lines 4691-4696 Link Here
4691
				} else{
4762
				} else{
4692
					findLocalMethods(
4763
					findLocalMethods(
4693
						selector,
4764
						selector,
4765
						typeArgTypes,
4694
						argTypes,
4766
						argTypes,
4695
						methods,
4767
						methods,
4696
						scope,
4768
						scope,
Lines 4709-4714 Link Here
4709
			if (notInJavadoc && hasPotentialDefaultAbstractMethods && (currentType.isAbstract() || currentType.isTypeVariable())){
4781
			if (notInJavadoc && hasPotentialDefaultAbstractMethods && (currentType.isAbstract() || currentType.isTypeVariable())){
4710
				findInterfacesMethods(
4782
				findInterfacesMethods(
4711
					selector,
4783
					selector,
4784
					typeArgTypes,
4712
					argTypes,
4785
					argTypes,
4713
					receiverType,
4786
					receiverType,
4714
					currentType.superInterfaces(),
4787
					currentType.superInterfaces(),
Lines 5561-5566 Link Here
5561
								findMethods(
5634
								findMethods(
5562
									token,
5635
									token,
5563
									null,
5636
									null,
5637
									null,
5564
									enclosingType,
5638
									enclosingType,
5565
									classScope,
5639
									classScope,
5566
									methodsFound,
5640
									methodsFound,
Lines 5610-5615 Link Here
5610
									findMethods(
5684
									findMethods(
5611
										token,
5685
										token,
5612
										null,
5686
										null,
5687
										null,
5613
										(ReferenceBinding)binding,
5688
										(ReferenceBinding)binding,
5614
										scope,
5689
										scope,
5615
										methodsFound,
5690
										methodsFound,
(-)codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMessageSendName.java (+70 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.codeassist.complete;
12
13
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
14
import org.eclipse.jdt.internal.compiler.ast.NameReference;
15
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
16
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
17
18
public class CompletionOnMessageSendName extends MessageSend {
19
	public CompletionOnMessageSendName(char[] selector, int start, int end) {
20
		super();
21
		this.selector = selector;
22
		this.sourceStart = start;
23
		this.sourceEnd = end;
24
		this.nameSourcePosition = end;
25
	}
26
27
	public TypeBinding resolveType(BlockScope scope) {
28
		
29
		if (receiver.isImplicitThis())
30
			throw new CompletionNodeFound();
31
32
		this.actualReceiverType = receiver.resolveType(scope);
33
		if (this.actualReceiverType == null || this.actualReceiverType.isBaseType() || this.actualReceiverType.isArrayType())
34
			throw new CompletionNodeFound();
35
		
36
		// resolve type arguments
37
		if (this.typeArguments != null) {
38
			int length = this.typeArguments.length;
39
			this.genericTypeArguments = new TypeBinding[length];
40
			for (int i = 0; i < length; i++) {
41
				this.genericTypeArguments[i] = this.typeArguments[i].resolveType(scope, true /* check bounds*/);
42
			}
43
		}
44
	
45
		if(this.receiver instanceof NameReference) {
46
			throw new CompletionNodeFound(this, ((NameReference)this.receiver).binding, scope);
47
		} else if(this.receiver instanceof MessageSend) {
48
			throw new CompletionNodeFound(this, ((MessageSend)this.receiver).binding, scope);
49
		}
50
		throw new CompletionNodeFound(this, this.actualReceiverType, scope);
51
	}
52
	
53
	public StringBuffer printExpression(int indent, StringBuffer output) {
54
55
		output.append("<CompleteOnMessageSendName:"); //$NON-NLS-1$
56
		if (!receiver.isImplicitThis()) receiver.printExpression(0, output).append('.');
57
		if (this.typeArguments != null) {
58
			output.append('<');
59
			int max = typeArguments.length - 1;
60
			for (int j = 0; j < max; j++) {
61
				typeArguments[j].print(0, output);
62
				output.append(", ");//$NON-NLS-1$
63
			}
64
			typeArguments[max].print(0, output);
65
			output.append('>');
66
		}
67
		output.append(selector).append('(');
68
		return output.append(")>"); //$NON-NLS-1$
69
	}
70
}

Return to bug 106450