Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 44627
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/CompletionWithMissingTypesTests.java (-1 / +147 lines)
Lines 1305-1311 Link Here
1305
			requestor.getResults());
1305
			requestor.getResults());
1306
}
1306
}
1307
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=44984
1307
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=44984
1308
public void test031() throws JavaModelException {
1308
public void test0031() throws JavaModelException {
1309
	this.workingCopies = new ICompilationUnit[3];
1309
	this.workingCopies = new ICompilationUnit[3];
1310
	this.workingCopies[0] = getWorkingCopy(
1310
	this.workingCopies[0] = getWorkingCopy(
1311
		"/Completion/src/test/Test.java",
1311
		"/Completion/src/test/Test.java",
Lines 1412-1415 Link Here
1412
			"",
1412
			"",
1413
			requestor.getResults());
1413
			requestor.getResults());
1414
}
1414
}
1415
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=44627
1416
public void test0034() throws JavaModelException {
1417
	this.workingCopies = new ICompilationUnit[3];
1418
	this.workingCopies[0] = getWorkingCopy(
1419
		"/Completion/src/test/Test.java",
1420
		"package test;"+
1421
		"public class Test {\n" + 
1422
		"  void foo() {\n" + 
1423
		"    MissingType.foo\n" + 
1424
		"  }\n" + 
1425
		"}\n");
1426
	
1427
	this.workingCopies[1] = getWorkingCopy(
1428
		"/Completion/src/missing/MissingType.java",
1429
		"package missing;"+
1430
		"public class MissingType {\n" + 
1431
		"  public void foo1()\n" + 
1432
		"  public static void foo2()\n" + 
1433
		"}\n");
1434
1435
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
1436
	requestor.allowAllRequiredProposals();
1437
	String str = this.workingCopies[0].getSource();
1438
	String completeBehind = "foo";
1439
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1440
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1441
1442
	int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_NON_INHERITED + R_NO_PROBLEMS;
1443
	int start1 = str.lastIndexOf("foo") + "".length();
1444
	int end1 = start1 + "foo".length();
1445
	int start2 = str.lastIndexOf("MissingType");
1446
	int end2 = start2 + "MissingType".length();
1447
	assertResults(
1448
			"foo2[METHOD_REF]{foo2(), Lmissing.MissingType;, ()V, foo2, null, ["+start1+", "+end1+"], " + (relevance1) + "}\n" +
1449
			"   MissingType[TYPE_REF]{missing.MissingType, missing, Lmissing.MissingType;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
1450
			requestor.getResults());
1451
}
1452
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=44627
1453
public void test0035() throws JavaModelException {
1454
	this.workingCopies = new ICompilationUnit[3];
1455
	this.workingCopies[0] = getWorkingCopy(
1456
		"/Completion/src/test/Test.java",
1457
		"package test;"+
1458
		"public class Test {\n" + 
1459
		"  void foo() {\n" + 
1460
		"    MissingType.foo\n" + 
1461
		"  }\n" + 
1462
		"}\n");
1463
	
1464
	this.workingCopies[1] = getWorkingCopy(
1465
		"/Completion/src/missing/MissingType.java",
1466
		"package missing;"+
1467
		"public class MissingType {\n" + 
1468
		"  public int foo1;\n" + 
1469
		"  public static int foo2;\n" + 
1470
		"}\n");
1471
1472
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
1473
	requestor.allowAllRequiredProposals();
1474
	String str = this.workingCopies[0].getSource();
1475
	String completeBehind = "foo";
1476
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1477
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1478
1479
	int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_NON_INHERITED + R_NO_PROBLEMS;
1480
	int start1 = str.lastIndexOf("foo") + "".length();
1481
	int end1 = start1 + "foo".length();
1482
	int start2 = str.lastIndexOf("MissingType");
1483
	int end2 = start2 + "MissingType".length();
1484
	assertResults(
1485
			"foo2[FIELD_REF]{foo2, Lmissing.MissingType;, I, foo2, null, ["+start1+", "+end1+"], " + (relevance1) + "}\n" +
1486
			"   MissingType[TYPE_REF]{missing.MissingType, missing, Lmissing.MissingType;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
1487
			requestor.getResults());
1488
}
1489
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=44627
1490
public void test0036() throws JavaModelException {
1491
	this.workingCopies = new ICompilationUnit[3];
1492
	this.workingCopies[0] = getWorkingCopy(
1493
		"/Completion/src/test/Test.java",
1494
		"package test;"+
1495
		"public class Test {\n" + 
1496
		"  void foo() {\n" + 
1497
		"    MissingType.foo\n" + 
1498
		"  }\n" + 
1499
		"}\n");
1500
	
1501
	this.workingCopies[1] = getWorkingCopy(
1502
		"/Completion/src/missing/MissingType.java",
1503
		"package missing;"+
1504
		"public class MissingType {\n" + 
1505
		"  public class foo1 {}\n" + 
1506
		"  public static class foo2 {}\n" + 
1507
		"}\n");
1508
1509
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
1510
	requestor.allowAllRequiredProposals();
1511
	String str = this.workingCopies[0].getSource();
1512
	String completeBehind = "foo";
1513
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1514
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1515
1516
	int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_NON_INHERITED + R_NO_PROBLEMS;
1517
	int start1 = str.lastIndexOf("foo") + "".length();
1518
	int end1 = start1 + "foo".length();
1519
	int start2 = str.lastIndexOf("MissingType");
1520
	int end2 = start2 + "MissingType".length();
1521
	assertResults(
1522
			"MissingType.foo1[TYPE_REF]{foo1, missing, Lmissing.MissingType$foo1;, null, null, ["+start1+", "+end1+"], " + (relevance1) + "}\n" +
1523
			"   MissingType[TYPE_REF]{missing.MissingType, missing, Lmissing.MissingType;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n"+
1524
			"MissingType.foo2[TYPE_REF]{foo2, missing, Lmissing.MissingType$foo2;, null, null, ["+start1+", "+end1+"], " + (relevance1) + "}\n" +
1525
			"   MissingType[TYPE_REF]{missing.MissingType, missing, Lmissing.MissingType;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
1526
			requestor.getResults());
1527
}
1528
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=44627
1529
public void test0037() throws JavaModelException {
1530
	this.workingCopies = new ICompilationUnit[3];
1531
	this.workingCopies[0] = getWorkingCopy(
1532
		"/Completion/src/test/Test.java",
1533
		"package test;"+
1534
		"public class Test {\n" + 
1535
		"  void foo() {\n" + 
1536
		"    MissingType.MissingType2.foo\n" + 
1537
		"  }\n" + 
1538
		"}\n");
1539
	
1540
	this.workingCopies[1] = getWorkingCopy(
1541
		"/Completion/src/missing/MissingType.java",
1542
		"package missing;"+
1543
		"public class MissingType {\n" + 
1544
		"  public class MissingType2 {\n" + 
1545
		"    public void foo1()\n" + 
1546
		"    public static void foo2()\n" + 
1547
		"  }\n" + 
1548
		"}\n");
1549
1550
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
1551
	requestor.allowAllRequiredProposals();
1552
	String str = this.workingCopies[0].getSource();
1553
	String completeBehind = "foo";
1554
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1555
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1556
	
1557
	assertResults(
1558
			"",
1559
			requestor.getResults());
1560
}
1415
}
1561
}
(-)model/org/eclipse/jdt/core/CompletionProposal.java (+6 lines)
Lines 1767-1772 Link Here
1767
	 *    <li><code>METHOD_IMPORT</code></li>
1767
	 *    <li><code>METHOD_IMPORT</code></li>
1768
	 *   </ul>
1768
	 *   </ul>
1769
	 *  </li>
1769
	 *  </li>
1770
	 * </li>
1771
	 * 	<li><code>TYPE_REF</code> - The allowed required proposals for this kind are:
1772
	 *   <ul>
1773
	 *    <li><code>TYPE_REF</code></li>
1774
	 *   </ul>
1775
	 *  </li>
1770
	 * </ul>
1776
	 * </ul>
1771
	 * </p>
1777
	 * </p>
1772
	 * <p>
1778
	 * <p>
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-102 / +338 lines)
Lines 1038-1044 Link Here
1038
					false,
1038
					false,
1039
					!this.assistNodeIsConstructor,
1039
					!this.assistNodeIsConstructor,
1040
					null,
1040
					null,
1041
					new ObjectVector());
1041
					new ObjectVector(),
1042
					null,
1043
					null,
1044
					null,
1045
					false);
1042
			}
1046
			}
1043
		} else if (astNode instanceof CompletionOnQualifiedNameReference) {
1047
		} else if (astNode instanceof CompletionOnQualifiedNameReference) {
1044
1048
Lines 1061-1067 Link Here
1061
						(this.requestor.isAllowingRequiredProposals(CompletionProposal.FIELD_REF, CompletionProposal.TYPE_REF) || 
1065
						(this.requestor.isAllowingRequiredProposals(CompletionProposal.FIELD_REF, CompletionProposal.TYPE_REF) || 
1062
								this.requestor.isAllowingRequiredProposals(CompletionProposal.METHOD_REF, CompletionProposal.TYPE_REF))) {
1066
								this.requestor.isAllowingRequiredProposals(CompletionProposal.METHOD_REF, CompletionProposal.TYPE_REF))) {
1063
					if(ref.tokens.length == 1) {
1067
					if(ref.tokens.length == 1) {
1064
						findFieldsAndMethodsFromMissingFieldType(ref.tokens[0], scope, ref, insideTypeAnnotation);
1068
						boolean foundSomeFields = findFieldsAndMethodsFromMissingFieldType(ref.tokens[0], scope, ref, insideTypeAnnotation);
1069
						
1070
						if (!foundSomeFields) {
1071
							findMembersFromMissingType(
1072
									ref.tokens[0],
1073
									ref.sourcePositions[0],
1074
									null,
1075
									scope,
1076
									ref,
1077
									ref.isInsideAnnotationAttribute);
1078
						}
1065
					}
1079
					}
1066
				}
1080
				}
1067
			} else if (qualifiedBinding instanceof VariableBinding) {
1081
			} else if (qualifiedBinding instanceof VariableBinding) {
Lines 1100-1188 Link Here
1100
				ReferenceBinding receiverType = (ReferenceBinding) qualifiedBinding;
1114
				ReferenceBinding receiverType = (ReferenceBinding) qualifiedBinding;
1101
				setSourceRange((int) (completionPosition >>> 32), (int) completionPosition);
1115
				setSourceRange((int) (completionPosition >>> 32), (int) completionPosition);
1102
1116
1103
				if (!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
1117
				findMembers(
1104
					findMemberTypes(
1105
							this.completionToken,
1106
							receiverType,
1107
							scope,
1108
							scope.enclosingSourceType(),
1109
							false,
1110
							true,
1111
							new ObjectVector());
1112
				}
1113
				if (!this.requestor.isIgnored(CompletionProposal.FIELD_REF)) {
1114
					findClassField(this.completionToken, (TypeBinding) qualifiedBinding, scope);
1115
				}
1116
				
1117
				MethodScope methodScope = null;
1118
				if (!isInsideAnnotationAttribute &&
1119
						!this.requestor.isIgnored(CompletionProposal.KEYWORD) &&
1120
						((scope instanceof MethodScope && !((MethodScope)scope).isStatic)
1121
						|| ((methodScope = scope.enclosingMethodScope()) != null && !methodScope.isStatic))) {
1122
					if (this.completionToken.length > 0) {
1123
						findKeywords(this.completionToken, new char[][]{Keywords.THIS}, false, true);
1124
					} else {
1125
						int relevance = computeBaseRelevance();
1126
						relevance += computeRelevanceForResolution();
1127
						relevance += computeRelevanceForInterestingProposal();
1128
						relevance += computeRelevanceForCaseMatching(this.completionToken, Keywords.THIS);
1129
						relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for keywords
1130
						relevance += R_NON_INHERITED;
1131
						
1132
						this.noProposal = false;
1133
						if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
1134
							CompletionProposal proposal = this.createProposal(CompletionProposal.KEYWORD, this.actualCompletionPosition);
1135
							proposal.setName(Keywords.THIS);
1136
							proposal.setCompletion(Keywords.THIS);
1137
							proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
1138
							proposal.setRelevance(relevance);
1139
							this.requestor.accept(proposal);
1140
							if (DEBUG) {
1141
								this.printDebug(proposal);
1142
							}
1143
						}
1144
					}
1145
				}
1146
1147
				if (!this.requestor.isIgnored(CompletionProposal.FIELD_REF)) {
1148
					findFields(
1149
						this.completionToken,
1150
						receiverType,
1151
						scope,
1152
						new ObjectVector(),
1153
						new ObjectVector(),
1154
						true,
1155
						ref,
1156
						scope,
1157
						false,
1158
						false,
1159
						null,
1160
						null,
1161
						null,
1162
						false);
1163
				}
1164
1165
				if (!isInsideAnnotationAttribute && !this.requestor.isIgnored(CompletionProposal.METHOD_REF)) {
1166
					findMethods(
1167
						this.completionToken,
1118
						this.completionToken,
1168
						null,
1169
						null,
1170
						receiverType,
1119
						receiverType,
1171
						scope,
1120
						scope,
1172
						new ObjectVector(),
1173
						true,
1174
						false,
1175
						false,
1176
						ref,
1121
						ref,
1177
						scope,
1122
						isInsideAnnotationAttribute,
1178
						false,
1179
						false,
1180
						false,
1181
						null,
1123
						null,
1182
						null,
1124
						null,
1183
						null,
1125
						null,
1184
						false);
1126
						false);
1185
				}
1186
1127
1187
			} else if (qualifiedBinding instanceof PackageBinding) {
1128
			} else if (qualifiedBinding instanceof PackageBinding) {
1188
1129
Lines 1228-1234 Link Here
1228
						scope.enclosingSourceType(),
1169
						scope.enclosingSourceType(),
1229
						false,
1170
						false,
1230
						false,
1171
						false,
1231
						typesFound);
1172
						typesFound,
1173
						null,
1174
						null,
1175
						null,
1176
						false);
1232
				}
1177
				}
1233
			} else if (qualifiedBinding instanceof PackageBinding) {
1178
			} else if (qualifiedBinding instanceof PackageBinding) {
1234
1179
Lines 1463-1469 Link Here
1463
					scope.enclosingSourceType(),
1408
					scope.enclosingSourceType(),
1464
					false,
1409
					false,
1465
					false,
1410
					false,
1466
					typesFound);
1411
					typesFound,
1412
					null,
1413
					null,
1414
					null,
1415
					false);
1467
			}
1416
			}
1468
		} else if (astNode instanceof CompletionOnMarkerAnnotationName) {
1417
		} else if (astNode instanceof CompletionOnMarkerAnnotationName) {
1469
			CompletionOnMarkerAnnotationName annot = (CompletionOnMarkerAnnotationName) astNode;
1418
			CompletionOnMarkerAnnotationName annot = (CompletionOnMarkerAnnotationName) astNode;
Lines 1506-1512 Link Here
1506
						scope.enclosingSourceType(),
1455
						scope.enclosingSourceType(),
1507
						false,
1456
						false,
1508
						false,
1457
						false,
1509
						new ObjectVector());
1458
						new ObjectVector(),
1459
						null,
1460
						null,
1461
						null,
1462
						false);
1510
				}
1463
				}
1511
			}
1464
			}
1512
		} else if (astNode instanceof CompletionOnMemberValueName) {
1465
		} else if (astNode instanceof CompletionOnMemberValueName) {
Lines 1625-1637 Link Here
1625
							((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF))) {
1578
							((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF))) {
1626
						int rangeStart = typeRef.completeInText() ? typeRef.sourceStart : (int) (completionPosition >>> 32);
1579
						int rangeStart = typeRef.completeInText() ? typeRef.sourceStart : (int) (completionPosition >>> 32);
1627
						setSourceRange(rangeStart, (int) completionPosition);
1580
						setSourceRange(rangeStart, (int) completionPosition);
1628
						findMemberTypes(this.completionToken,
1581
						findMemberTypes(
1582
							this.completionToken,
1629
							(ReferenceBinding) qualifiedBinding,
1583
							(ReferenceBinding) qualifiedBinding,
1630
							scope,
1584
							scope,
1631
							scope.enclosingSourceType(),
1585
							scope.enclosingSourceType(),
1632
							false,
1586
							false,
1633
							false,
1587
							false,
1634
							new ObjectVector());
1588
							new ObjectVector(),
1589
							null,
1590
							null,
1591
							null,
1592
							false);
1635
					}
1593
					}
1636
				} else if (qualifiedBinding instanceof PackageBinding) {
1594
				} else if (qualifiedBinding instanceof PackageBinding) {
1637
1595
Lines 2597-2603 Link Here
2597
			
2555
			
2598
		this.noProposal = false;
2556
		this.noProposal = false;
2599
		if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
2557
		if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
2600
			createTypeProposal(exceptionType, exceptionType.qualifiedSourceName(), IAccessRule.K_ACCESSIBLE, completionName, relevance);
2558
			createTypeProposal(
2559
					exceptionType,
2560
					exceptionType.qualifiedSourceName(),
2561
					IAccessRule.K_ACCESSIBLE,
2562
					completionName,
2563
					relevance,
2564
					null,
2565
					null,
2566
					null,
2567
					false);
2601
		}
2568
		}
2602
	}
2569
	}
2603
	
2570
	
Lines 3532-3543 Link Here
3532
		}
3499
		}
3533
	}
3500
	}
3534
	
3501
	
3535
	private void findFieldsAndMethodsFromMissingFieldType(
3502
	private boolean findFieldsAndMethodsFromMissingFieldType(
3536
		char[] token,
3503
		char[] token,
3537
		Scope scope,
3504
		Scope scope,
3538
		InvocationSite invocationSite,
3505
		InvocationSite invocationSite,
3539
		boolean insideTypeAnnotation) {
3506
		boolean insideTypeAnnotation) {
3540
3507
3508
		boolean foundSomeFields = false;
3509
		
3541
		boolean staticsOnly = false;
3510
		boolean staticsOnly = false;
3542
		Scope currentScope = scope;
3511
		Scope currentScope = scope;
3543
3512
Lines 3565-3570 Link Here
3565
							FieldDeclaration fieldDeclaration = fields[i];
3534
							FieldDeclaration fieldDeclaration = fields[i];
3566
							if (CharOperation.equals(fieldDeclaration.name, token)) {
3535
							if (CharOperation.equals(fieldDeclaration.name, token)) {
3567
								if (fieldDeclaration.binding == null) {
3536
								if (fieldDeclaration.binding == null) {
3537
									foundSomeFields = true;
3568
									findFieldsAndMethodsFromMissingType(
3538
									findFieldsAndMethodsFromMissingType(
3569
											this.completionToken,
3539
											this.completionToken,
3570
											fieldDeclaration.type, 
3540
											fieldDeclaration.type, 
Lines 3584-3589 Link Here
3584
			}
3554
			}
3585
			currentScope = currentScope.parent;
3555
			currentScope = currentScope.parent;
3586
		}
3556
		}
3557
		return foundSomeFields;
3587
	}
3558
	}
3588
	
3559
	
3589
	private void findFieldsAndMethodsFromMissingReturnType(
3560
	private void findFieldsAndMethodsFromMissingReturnType(
Lines 3925-3931 Link Here
3925
			}
3896
			}
3926
			this.noProposal = false;
3897
			this.noProposal = false;
3927
			if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
3898
			if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
3928
				createTypeProposal(memberType, memberType.qualifiedSourceName(), IAccessRule.K_ACCESSIBLE, completionName, relevance);
3899
				createTypeProposal(
3900
						memberType,
3901
						memberType.qualifiedSourceName(),
3902
						IAccessRule.K_ACCESSIBLE,
3903
						completionName,
3904
						relevance,
3905
						null,
3906
						null,
3907
						null,
3908
						false);
3929
			}
3909
			}
3930
		}
3910
		}
3931
	}
3911
	}
Lines 4286-4291 Link Here
4286
		findKeywords(token, keywords, false, false);
4266
		findKeywords(token, keywords, false, false);
4287
	}
4267
	}
4288
4268
4269
	protected void findMembers(
4270
			char[] token,
4271
			ReferenceBinding receiverType,
4272
			Scope scope,
4273
			InvocationSite invocationSite,
4274
			boolean isInsideAnnotationAttribute,
4275
			Binding[] missingElements,
4276
			int[] missingElementsStarts,
4277
			int[] missingElementsEnds,
4278
			boolean missingElementsHaveProblems) {
4279
		
4280
		if (!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
4281
			findMemberTypes(
4282
					token,
4283
					receiverType,
4284
					scope,
4285
					scope.enclosingSourceType(),
4286
					false,
4287
					true,
4288
					new ObjectVector(),
4289
					missingElements,
4290
					missingElementsStarts,
4291
					missingElementsEnds,
4292
					missingElementsHaveProblems);
4293
		}
4294
		if (!this.requestor.isIgnored(CompletionProposal.FIELD_REF)) {
4295
			findClassField(token, receiverType, scope);
4296
		}
4297
		
4298
		MethodScope methodScope = null;
4299
		if (!isInsideAnnotationAttribute &&
4300
				!this.requestor.isIgnored(CompletionProposal.KEYWORD) &&
4301
				((scope instanceof MethodScope && !((MethodScope)scope).isStatic)
4302
				|| ((methodScope = scope.enclosingMethodScope()) != null && !methodScope.isStatic))) {
4303
			if (token.length > 0) {
4304
				findKeywords(token, new char[][]{Keywords.THIS}, false, true);
4305
			} else {
4306
				int relevance = computeBaseRelevance();
4307
				relevance += computeRelevanceForResolution();
4308
				relevance += computeRelevanceForInterestingProposal();
4309
				relevance += computeRelevanceForCaseMatching(this.completionToken, Keywords.THIS);
4310
				relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for keywords
4311
				relevance += R_NON_INHERITED;
4312
				
4313
				this.noProposal = false;
4314
				if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
4315
					CompletionProposal proposal = this.createProposal(CompletionProposal.KEYWORD, this.actualCompletionPosition);
4316
					proposal.setName(Keywords.THIS);
4317
					proposal.setCompletion(Keywords.THIS);
4318
					proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
4319
					proposal.setRelevance(relevance);
4320
					this.requestor.accept(proposal);
4321
					if (DEBUG) {
4322
						this.printDebug(proposal);
4323
					}
4324
				}
4325
			}
4326
		}
4327
4328
		if (!this.requestor.isIgnored(CompletionProposal.FIELD_REF)) {
4329
			findFields(
4330
				token,
4331
				receiverType,
4332
				scope,
4333
				new ObjectVector(),
4334
				new ObjectVector(),
4335
				true,
4336
				invocationSite,
4337
				scope,
4338
				false,
4339
				false,
4340
				missingElements,
4341
				missingElementsStarts,
4342
				missingElementsEnds,
4343
				missingElementsHaveProblems);
4344
		}
4345
4346
		if (!isInsideAnnotationAttribute && !this.requestor.isIgnored(CompletionProposal.METHOD_REF)) {
4347
			findMethods(
4348
				token,
4349
				null,
4350
				null,
4351
				receiverType,
4352
				scope,
4353
				new ObjectVector(),
4354
				true,
4355
				false,
4356
				false,
4357
				invocationSite,
4358
				scope,
4359
				false,
4360
				false,
4361
				false,
4362
				missingElements,
4363
				missingElementsStarts,
4364
				missingElementsEnds,
4365
				missingElementsHaveProblems);
4366
		}
4367
	}
4368
	
4369
	private void findMembersFromMissingType(
4370
			final char[] token,
4371
			final long pos,
4372
			TypeBinding resolveType,
4373
			final Scope scope,
4374
			final InvocationSite invocationSite,
4375
			final boolean isInsideAnnotationAttribute) {
4376
		MissingTypesGuesser missingTypesConverter = new MissingTypesGuesser(this);
4377
		MissingTypesGuesser.GuessedTypeRequestor substitutionRequestor =
4378
			new MissingTypesGuesser.GuessedTypeRequestor() {
4379
				public void accept(
4380
						TypeBinding guessedType,
4381
						Binding[] missingElements,
4382
						int[] missingElementsStarts,
4383
						int[] missingElementsEnds,
4384
						boolean hasProblems) {
4385
					if (guessedType instanceof ReferenceBinding) {
4386
						findMembers(
4387
								CompletionEngine.this.completionToken,
4388
								(ReferenceBinding)guessedType,
4389
								scope,
4390
								invocationSite,
4391
								isInsideAnnotationAttribute,
4392
								missingElements,
4393
								missingElementsStarts,
4394
								missingElementsEnds,
4395
								hasProblems);
4396
					}
4397
				}
4398
			};
4399
		SingleTypeReference typeRef = new SingleTypeReference(token, pos);
4400
		typeRef.resolvedType = new ProblemReferenceBinding(token, null, ProblemReasons.NotFound);
4401
		missingTypesConverter.guess(typeRef, scope, substitutionRequestor);
4402
	}
4403
	
4289
	// Helper method for findMemberTypes(char[], ReferenceBinding, Scope)
4404
	// Helper method for findMemberTypes(char[], ReferenceBinding, Scope)
4290
	private void findMemberTypes(
4405
	private void findMemberTypes(
4291
		char[] typeName,
4406
		char[] typeName,
Lines 4297-4303 Link Here
4297
		boolean staticFieldsAndMethodOnly,
4412
		boolean staticFieldsAndMethodOnly,
4298
		boolean fromStaticImport,
4413
		boolean fromStaticImport,
4299
		boolean checkQualification,
4414
		boolean checkQualification,
4300
		Scope scope) {
4415
		Scope scope,
4416
		Binding[] missingElements,
4417
		int[] missingElementsStarts,
4418
		int[] missingElementsEnds,
4419
		boolean missingElementsHaveProblems) {
4301
4420
4302
		// Inherited member types which are hidden by subclasses are filtered out
4421
		// Inherited member types which are hidden by subclasses are filtered out
4303
		// No visibility checks can be performed without the scope & invocationSite
4422
		// No visibility checks can be performed without the scope & invocationSite
Lines 4411-4419 Link Here
4411
			} else if(memberType.isInterface()) {
4530
			} else if(memberType.isInterface()) {
4412
				relevance += computeRelevanceForInterface();
4531
				relevance += computeRelevanceForInterface();
4413
			}
4532
			}
4533
			
4534
			if (missingElements != null) {
4535
				relevance += computeRelevanceForMissingElements(missingElementsHaveProblems);
4536
			}
4414
				
4537
				
4415
			this.noProposal = false;
4538
			this.noProposal = false;
4416
			createTypeProposal(memberType, memberType.qualifiedSourceName(), IAccessRule.K_ACCESSIBLE, completionName, relevance);
4539
			createTypeProposal(
4540
					memberType,
4541
					memberType.qualifiedSourceName(),
4542
					IAccessRule.K_ACCESSIBLE,
4543
					completionName,
4544
					relevance,
4545
					missingElements,
4546
					missingElementsStarts,
4547
					missingElementsEnds,
4548
					missingElementsHaveProblems);
4417
		}
4549
		}
4418
	}
4550
	}
4419
4551
Lines 4424-4430 Link Here
4424
		SourceTypeBinding typeInvocation,
4556
		SourceTypeBinding typeInvocation,
4425
		boolean staticOnly,
4557
		boolean staticOnly,
4426
		boolean staticFieldsAndMethodOnly,
4558
		boolean staticFieldsAndMethodOnly,
4427
		ObjectVector typesFound)  {
4559
		ObjectVector typesFound,
4560
		Binding[] missingElements,
4561
		int[] missingElementsStarts,
4562
		int[] missingElementsEnds,
4563
		boolean missingElementsHaveProblems)  {
4428
		findMemberTypes(
4564
		findMemberTypes(
4429
				typeName,
4565
				typeName,
4430
				receiverType,
4566
				receiverType,
Lines 4436-4442 Link Here
4436
				false,
4572
				false,
4437
				false,
4573
				false,
4438
				null,
4574
				null,
4439
				typesFound);
4575
				typesFound,
4576
				missingElements,
4577
				missingElementsStarts,
4578
				missingElementsEnds,
4579
				missingElementsHaveProblems);
4440
	}
4580
	}
4441
	private void findMemberTypes(
4581
	private void findMemberTypes(
4442
		char[] typeName,
4582
		char[] typeName,
Lines 4449-4455 Link Here
4449
		boolean checkQualification,
4589
		boolean checkQualification,
4450
		boolean proposeAllMemberTypes,
4590
		boolean proposeAllMemberTypes,
4451
		SourceTypeBinding typeToIgnore,
4591
		SourceTypeBinding typeToIgnore,
4452
		ObjectVector typesFound) {
4592
		ObjectVector typesFound,
4593
		Binding[] missingElements,
4594
		int[] missingElementsStarts,
4595
		int[] missingElementsEnds,
4596
		boolean missingElementsHaveProblems) {
4453
4597
4454
		ReferenceBinding currentType = receiverType;
4598
		ReferenceBinding currentType = receiverType;
4455
		if (typeName == null)
4599
		if (typeName == null)
Lines 4472-4478 Link Here
4472
				staticFieldsAndMethodOnly,
4616
				staticFieldsAndMethodOnly,
4473
				fromStaticImport,
4617
				fromStaticImport,
4474
				checkQualification,
4618
				checkQualification,
4475
				scope);
4619
				scope,
4620
				missingElements,
4621
				missingElementsStarts,
4622
				missingElementsEnds,
4623
				missingElementsHaveProblems);
4476
			return;
4624
			return;
4477
		}
4625
		}
4478
4626
Lines 4508-4514 Link Here
4508
				staticFieldsAndMethodOnly,
4656
				staticFieldsAndMethodOnly,
4509
				fromStaticImport,
4657
				fromStaticImport,
4510
				checkQualification,
4658
				checkQualification,
4511
				scope);
4659
				scope,
4660
				missingElements,
4661
				missingElementsStarts,
4662
				missingElementsEnds,
4663
				missingElementsHaveProblems);
4512
			
4664
			
4513
			currentType = currentType.superclass();
4665
			currentType = currentType.superclass();
4514
		} while (currentType != null);
4666
		} while (currentType != null);
Lines 4543-4549 Link Here
4543
					staticFieldsAndMethodOnly,
4695
					staticFieldsAndMethodOnly,
4544
					fromStaticImport,
4696
					fromStaticImport,
4545
					checkQualification,
4697
					checkQualification,
4546
					scope);
4698
					scope,
4699
					missingElements,
4700
					missingElementsStarts,
4701
					missingElementsEnds,
4702
					missingElementsHaveProblems);
4547
						
4703
						
4548
				ReferenceBinding[] itsInterfaces = anInterface.superInterfaces();
4704
				ReferenceBinding[] itsInterfaces = anInterface.superInterfaces();
4549
				if (itsInterfaces != Binding.NO_SUPERINTERFACES) {
4705
				if (itsInterfaces != Binding.NO_SUPERINTERFACES) {
Lines 4626-4632 Link Here
4626
				staticFieldsAndMethodOnly,
4782
				staticFieldsAndMethodOnly,
4627
				fromStaticImport,
4783
				fromStaticImport,
4628
				true,
4784
				true,
4629
				scope);
4785
				scope,
4786
				null,
4787
				null,
4788
				null,
4789
				false);
4630
		
4790
		
4631
		ReferenceBinding[] memberTypes = receiverType.memberTypes();
4791
		ReferenceBinding[] memberTypes = receiverType.memberTypes();
4632
		next : for (int i = 0; i < memberTypes.length; i++) {
4792
		next : for (int i = 0; i < memberTypes.length; i++) {
Lines 6358-6364 Link Here
6358
								
6518
								
6359
								this.noProposal = false;
6519
								this.noProposal = false;
6360
								if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
6520
								if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
6361
									createTypeProposal(localType, localType.sourceName, IAccessRule.K_ACCESSIBLE, localType.sourceName, relevance);
6521
									createTypeProposal(
6522
											localType,
6523
											localType.sourceName,
6524
											IAccessRule.K_ACCESSIBLE,
6525
											localType.sourceName,
6526
											relevance,
6527
											null,
6528
											null,
6529
											null,
6530
											false);
6362
								}
6531
								}
6363
							}
6532
							}
6364
						}
6533
						}
Lines 6367-6373 Link Here
6367
6536
6368
				case Scope.CLASS_SCOPE :
6537
				case Scope.CLASS_SCOPE :
6369
					SourceTypeBinding enclosingSourceType = scope.enclosingSourceType();
6538
					SourceTypeBinding enclosingSourceType = scope.enclosingSourceType();
6370
					findMemberTypes(typeName, enclosingSourceType, scope, currentType, false, false, false, false, proposeAllMemberTypes, nextTypeToIgnore, typesFound);
6539
					findMemberTypes(
6540
							typeName,
6541
							enclosingSourceType,
6542
							scope,
6543
							currentType,
6544
							false,
6545
							false,
6546
							false,
6547
							false,
6548
							proposeAllMemberTypes,
6549
							nextTypeToIgnore,
6550
							typesFound,
6551
							null,
6552
							null,
6553
							null,
6554
							false);
6371
					nextTypeToIgnore = enclosingSourceType;
6555
					nextTypeToIgnore = enclosingSourceType;
6372
					if (typeLength == 0)
6556
					if (typeLength == 0)
6373
						return; // do not search outside the class scope if no prefix was provided
6557
						return; // do not search outside the class scope if no prefix was provided
Lines 6428-6434 Link Here
6428
			relevance += computeRelevanceForRestrictions(accessibility); // no access restriction for type in the current unit
6612
			relevance += computeRelevanceForRestrictions(accessibility); // no access restriction for type in the current unit
6429
			
6613
			
6430
			if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
6614
			if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
6431
				createTypeProposal(refBinding, refBinding.qualifiedSourceName(), IAccessRule.K_ACCESSIBLE, CharOperation.NO_CHAR, relevance);
6615
				createTypeProposal(
6616
						refBinding,
6617
						refBinding.qualifiedSourceName(),
6618
						IAccessRule.K_ACCESSIBLE,
6619
						CharOperation.NO_CHAR,
6620
						relevance,
6621
						null,
6622
						null,
6623
						null,
6624
						false);
6432
			}
6625
			}
6433
		}
6626
		}
6434
	}
6627
	}
Lines 6599-6605 Link Here
6599
				this.noProposal = false;
6792
				this.noProposal = false;
6600
				if(proposeType) {
6793
				if(proposeType) {
6601
					char[] typeName = sourceType.sourceName();
6794
					char[] typeName = sourceType.sourceName();
6602
					createTypeProposal(sourceType, typeName, IAccessRule.K_ACCESSIBLE, typeName, relevance);
6795
					createTypeProposal(
6796
							sourceType,
6797
							typeName,
6798
							IAccessRule.K_ACCESSIBLE,
6799
							typeName,
6800
							relevance,
6801
							null,
6802
							null,
6803
							null,
6804
							false);
6603
				}
6805
				}
6604
			}
6806
			}
6605
		}
6807
		}
Lines 6852-6858 Link Here
6852
				this.noProposal = false;
7054
				this.noProposal = false;
6853
				if(proposeType) {
7055
				if(proposeType) {
6854
					char[] typeName = sourceType.sourceName();
7056
					char[] typeName = sourceType.sourceName();
6855
					createTypeProposal(sourceType, typeName, IAccessRule.K_ACCESSIBLE, typeName, relevance);
7057
					createTypeProposal(
7058
							sourceType,
7059
							typeName,
7060
							IAccessRule.K_ACCESSIBLE,
7061
							typeName,
7062
							relevance,
7063
							null,
7064
							null,
7065
							null,
7066
							false);
6856
				}
7067
				}
6857
			}
7068
			}
6858
		}
7069
		}
Lines 6901-6907 Link Here
6901
									true,
7112
									true,
6902
									proposeAllMemberTypes,
7113
									proposeAllMemberTypes,
6903
									null,
7114
									null,
6904
									typesFound);
7115
									typesFound,
7116
									null,
7117
									null,
7118
									null,
7119
									false);
6905
						}
7120
						}
6906
					} else {
7121
					} else {
6907
						if ((binding.kind() & Binding.TYPE) != 0) {
7122
						if ((binding.kind() & Binding.TYPE) != 0) {
Lines 8627-8636 Link Here
8627
	/*
8842
	/*
8628
	 * Create a completion proposal for a member type.
8843
	 * Create a completion proposal for a member type.
8629
	 */
8844
	 */
8630
	private void createTypeProposal(ReferenceBinding refBinding, char[] typeName, int accessibility, char[] completionName, int relevance) {
8845
	private void createTypeProposal(
8846
			ReferenceBinding refBinding,
8847
			char[] typeName,
8848
			int accessibility,
8849
			char[] completionName,
8850
			int relevance,
8851
			Binding[] missingElements,
8852
			int[] missingElementsStarts,
8853
			int[] missingElementsEnds,
8854
			boolean missingElementsHaveProblems) {
8631
8855
8632
		// Create standard type proposal
8856
		// Create standard type proposal
8633
		if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) {
8857
		if(!this.isIgnored(CompletionProposal.TYPE_REF, missingElements != null) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) {
8634
			CompletionProposal proposal = CompletionProposal.create(CompletionProposal.TYPE_REF, this.actualCompletionPosition - this.offset);
8858
			CompletionProposal proposal = CompletionProposal.create(CompletionProposal.TYPE_REF, this.actualCompletionPosition - this.offset);
8635
			proposal.nameLookup = this.nameEnvironment.nameLookup;
8859
			proposal.nameLookup = this.nameEnvironment.nameLookup;
8636
			proposal.completionEngine = this;
8860
			proposal.completionEngine = this;
Lines 8638-8643 Link Here
8638
			proposal.setSignature(getSignature(refBinding));
8862
			proposal.setSignature(getSignature(refBinding));
8639
			proposal.setPackageName(refBinding.qualifiedPackageName());
8863
			proposal.setPackageName(refBinding.qualifiedPackageName());
8640
			proposal.setTypeName(typeName);
8864
			proposal.setTypeName(typeName);
8865
			if (missingElements != null) {
8866
				CompletionProposal[] subProposals = new CompletionProposal[missingElements.length];
8867
				for (int i = 0; i < missingElements.length; i++) {
8868
					subProposals[i] =
8869
						createRequiredTypeProposal(
8870
								missingElements[i],
8871
								missingElementsStarts[i],
8872
								missingElementsEnds[i],
8873
								relevance);
8874
				}
8875
				proposal.setRequiredProposals(subProposals);
8876
			}
8641
			proposal.setCompletion(completionName);
8877
			proposal.setCompletion(completionName);
8642
			proposal.setFlags(refBinding.modifiers);
8878
			proposal.setFlags(refBinding.modifiers);
8643
			proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
8879
			proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);

Return to bug 44627