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

(-)src/org/eclipse/jdt/core/tests/model/CompletionWithMissingTypesTests.java (+35 lines)
Lines 1558-1561 Link Here
1558
			"",
1558
			"",
1559
			requestor.getResults());
1559
			requestor.getResults());
1560
}
1560
}
1561
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=207929
1562
public void test0038() throws JavaModelException {
1563
	this.workingCopies = new ICompilationUnit[3];
1564
	this.workingCopies[0] = getWorkingCopy(
1565
		"/Completion/src/test/Test.java",
1566
		"package test;"+
1567
		"public class Test {\n" + 
1568
		"  void foo() {\n" + 
1569
		"    MissingType.cla\n" + 
1570
		"  }\n" + 
1571
		"}\n");
1572
	
1573
	this.workingCopies[1] = getWorkingCopy(
1574
		"/Completion/src/missing/MissingType.java",
1575
		"package missing;"+
1576
		"public class MissingType {\n" + 
1577
		"}\n");
1578
1579
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
1580
	requestor.allowAllRequiredProposals();
1581
	String str = this.workingCopies[0].getSource();
1582
	String completeBehind = "cla";
1583
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1584
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1585
1586
	int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_NON_INHERITED + R_NO_PROBLEMS;
1587
	int start1 = str.lastIndexOf("cla") + "".length();
1588
	int end1 = start1 + "cla".length();
1589
	int start2 = str.lastIndexOf("MissingType");
1590
	int end2 = start2 + "MissingType".length();
1591
	assertResults(
1592
			"class[FIELD_REF]{class, null, Ljava.lang.Class;, class, null, ["+start1+", "+end1+"], " + (relevance1) + "}\n" +
1593
			"   MissingType[TYPE_REF]{missing.MissingType, missing, Lmissing.MissingType;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
1594
			requestor.getResults());
1595
}
1561
}
1596
}
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-4 / +41 lines)
Lines 1441-1447 Link Here
1441
1441
1442
				this.completionToken = access.completionIdentifier;
1442
				this.completionToken = access.completionIdentifier;
1443
1443
1444
				findClassField(this.completionToken, (TypeBinding) qualifiedBinding, scope);
1444
				findClassField(
1445
						this.completionToken,
1446
						(TypeBinding) qualifiedBinding,
1447
						scope,
1448
						null,
1449
						null,
1450
						null,
1451
						false);
1445
			}
1452
			}
1446
		} else if (astNode instanceof CompletionOnMethodName) {
1453
		} else if (astNode instanceof CompletionOnMethodName) {
1447
			if (!this.requestor.isIgnored(CompletionProposal.VARIABLE_DECLARATION)) {
1454
			if (!this.requestor.isIgnored(CompletionProposal.VARIABLE_DECLARATION)) {
Lines 2570-2576 Link Here
2570
		}
2577
		}
2571
	}
2578
	}
2572
2579
2573
	private void findClassField(char[] token, TypeBinding receiverType, Scope scope) {
2580
	private void findClassField(
2581
			char[] token,
2582
			TypeBinding receiverType,
2583
			Scope scope,
2584
			Binding[] missingElements,
2585
			int[] missingElementsStarts,
2586
			int[] missingElementsEnds,
2587
			boolean missingElementsHaveProblems) {
2574
2588
2575
		if (token == null) return;
2589
		if (token == null) return;
2576
2590
Lines 2585-2592 Link Here
2585
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); //no access restriction for class field 
2599
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); //no access restriction for class field 
2586
			relevance += R_NON_INHERITED;
2600
			relevance += R_NON_INHERITED;
2587
			
2601
			
2602
			if (missingElements != null) {
2603
				relevance += computeRelevanceForMissingElements(missingElementsHaveProblems);
2604
			}
2605
			
2588
			this.noProposal = false;
2606
			this.noProposal = false;
2589
			if(!this.requestor.isIgnored(CompletionProposal.FIELD_REF)) {
2607
			if(!isIgnored(CompletionProposal.FIELD_REF, missingElements != null)) {
2590
				CompletionProposal proposal = this.createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition);
2608
				CompletionProposal proposal = this.createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition);
2591
				//proposal.setDeclarationSignature(null);
2609
				//proposal.setDeclarationSignature(null);
2592
				char[] signature = 
2610
				char[] signature = 
Lines 2611-2616 Link Here
2611
				proposal.setPackageName(CharOperation.concatWith(JAVA_LANG, '.'));
2629
				proposal.setPackageName(CharOperation.concatWith(JAVA_LANG, '.'));
2612
				proposal.setTypeName(CLASS);
2630
				proposal.setTypeName(CLASS);
2613
				proposal.setName(classField);
2631
				proposal.setName(classField);
2632
				if (missingElements != null) {
2633
					CompletionProposal[] subProposals = new CompletionProposal[missingElements.length];
2634
					for (int i = 0; i < missingElements.length; i++) {
2635
						subProposals[i] =
2636
							createRequiredTypeProposal(
2637
									missingElements[i],
2638
									missingElementsStarts[i],
2639
									missingElementsEnds[i],
2640
									relevance);
2641
					}
2642
					proposal.setRequiredProposals(subProposals);
2643
				}
2614
				proposal.setCompletion(classField);
2644
				proposal.setCompletion(classField);
2615
				proposal.setFlags(Flags.AccStatic | Flags.AccPublic);
2645
				proposal.setFlags(Flags.AccStatic | Flags.AccPublic);
2616
				proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
2646
				proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
Lines 4850-4856 Link Here
4850
					missingElementsHaveProblems);
4880
					missingElementsHaveProblems);
4851
		}
4881
		}
4852
		if (!this.requestor.isIgnored(CompletionProposal.FIELD_REF)) {
4882
		if (!this.requestor.isIgnored(CompletionProposal.FIELD_REF)) {
4853
			findClassField(token, receiverType, scope);
4883
			findClassField(
4884
					token,
4885
					receiverType,
4886
					scope,
4887
					missingElements,
4888
					missingElementsStarts,
4889
					missingElementsEnds,
4890
					missingElementsHaveProblems);
4854
		}
4891
		}
4855
		
4892
		
4856
		MethodScope methodScope = null;
4893
		MethodScope methodScope = null;

Return to bug 207929