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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/CompletionContextTests.java (+35 lines)
Lines 4864-4867 Link Here
4864
		"}",
4864
		"}",
4865
		result.context);
4865
		result.context);
4866
}
4866
}
4867
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=226673
4868
public void test0165() throws JavaModelException {
4869
	this.workingCopies = new ICompilationUnit[1];
4870
	this.workingCopies[0] = getWorkingCopy(
4871
		"/Completion/src3/test/X.java",
4872
		"package test;\n" + 
4873
		"public class X {\n" + 
4874
		"  class Y {\n" + 
4875
		"  }\n" +
4876
		"  class Y {\n" + 
4877
		"    int var;\n" +
4878
		"    void foo() {\n" +
4879
		"      var\n" +
4880
		"    }\n" +
4881
		"  }\n" +
4882
		"}");
4883
	
4884
	String str = this.workingCopies[0].getSource();
4885
	int tokenStart = -1;
4886
	int tokenEnd = -1;
4887
	int cursorLocation = str.lastIndexOf("var") + "var".length();
4888
4889
	CompletionResult result = contextComplete(this.workingCopies[0], cursorLocation, false, true, "I");
4890
	
4891
	assertResults(
4892
		"completion offset="+(cursorLocation)+"\n" +
4893
		"completion range=["+(tokenStart)+", "+(tokenEnd)+"]\n" +
4894
		"completion token=null\n" +
4895
		"completion token kind=TOKEN_KIND_UNKNOWN\n" +
4896
		"expectedTypesSignatures=null\n" +
4897
		"expectedTypesKeys=null\n" +
4898
		"completion token location=UNKNOWN\n" +
4899
		"visibleElements={}",
4900
		result.context);
4901
}
4867
}
4902
}
(-)codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionContext.java (+6 lines)
Lines 35-40 Link Here
35
	protected int tokenKind;
35
	protected int tokenKind;
36
	protected int tokenLocation;
36
	protected int tokenLocation;
37
	
37
	
38
	protected boolean isExtended;
38
	protected InternalExtendedCompletionContext extendedContext;
39
	protected InternalExtendedCompletionContext extendedContext;
39
	
40
	
40
	protected void setExpectedTypesKeys(char[][] expectedTypesKeys) {
41
	protected void setExpectedTypesKeys(char[][] expectedTypesKeys) {
Lines 45-50 Link Here
45
		this.expectedTypesSignatures = expectedTypesSignatures;
46
		this.expectedTypesSignatures = expectedTypesSignatures;
46
	}
47
	}
47
	
48
	
49
	protected void setExtended(boolean isExtended) {
50
		this.isExtended = isExtended;
51
	}
52
	
48
	protected void setExtendedData(
53
	protected void setExtendedData(
49
			ITypeRoot typeRoot,
54
			ITypeRoot typeRoot,
50
			CompilationUnitDeclaration compilationUnitDeclaration,
55
			CompilationUnitDeclaration compilationUnitDeclaration,
Lines 53-58 Link Here
53
			ASTNode astNode,
58
			ASTNode astNode,
54
			WorkingCopyOwner owner,
59
			WorkingCopyOwner owner,
55
			CompletionParser parser) {
60
			CompletionParser parser) {
61
		this.isExtended = true;
56
		this.extendedContext =
62
		this.extendedContext =
57
			new InternalExtendedCompletionContext(
63
			new InternalExtendedCompletionContext(
58
					this,
64
					this,
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-2 / +8 lines)
Lines 2311-2317 Link Here
2311
				if(this.noProposal && this.problem != null) {
2311
				if(this.noProposal && this.problem != null) {
2312
					if(!contextAccepted) {
2312
					if(!contextAccepted) {
2313
						contextAccepted = true;
2313
						contextAccepted = true;
2314
						this.requestor.acceptContext(new CompletionContext());
2314
						CompletionContext context = new CompletionContext();
2315
						context.setExtended(this.requestor.isExtendedContextRequired());
2316
						this.requestor.acceptContext(context);
2315
					}
2317
					}
2316
					this.requestor.completionFailure(this.problem);
2318
					this.requestor.completionFailure(this.problem);
2317
					if(DEBUG) {
2319
					if(DEBUG) {
Lines 2344-2350 Link Here
2344
		}
2346
		}
2345
		if(!contextAccepted) {
2347
		if(!contextAccepted) {
2346
			contextAccepted = true;
2348
			contextAccepted = true;
2347
			this.requestor.acceptContext(new CompletionContext());
2349
			CompletionContext context = new CompletionContext();
2350
			context.setExtended(this.requestor.isExtendedContextRequired());
2351
			this.requestor.acceptContext(context);
2348
		}
2352
		}
2349
		if(this.requestor != null){
2353
		if(this.requestor != null){
2350
			this.requestor.endReporting();
2354
			this.requestor.endReporting();
Lines 2565-2570 Link Here
2565
					CompletionContext context = new CompletionContext();
2569
					CompletionContext context = new CompletionContext();
2566
					context.setOffset(completionPosition - this.offset);
2570
					context.setOffset(completionPosition - this.offset);
2567
					context.setTokenKind(CompletionContext.TOKEN_KIND_UNKNOWN);
2571
					context.setTokenKind(CompletionContext.TOKEN_KIND_UNKNOWN);
2572
					context.setExtended(this.requestor.isExtendedContextRequired());
2568
					this.requestor.acceptContext(context);
2573
					this.requestor.acceptContext(context);
2569
				}
2574
				}
2570
				this.requestor.completionFailure(this.problem);
2575
				this.requestor.completionFailure(this.problem);
Lines 2610-2615 Link Here
2610
				CompletionContext context = new CompletionContext();
2615
				CompletionContext context = new CompletionContext();
2611
				context.setTokenKind(CompletionContext.TOKEN_KIND_UNKNOWN);
2616
				context.setTokenKind(CompletionContext.TOKEN_KIND_UNKNOWN);
2612
				context.setOffset(completionPosition - this.offset);
2617
				context.setOffset(completionPosition - this.offset);
2618
				context.setExtended(this.requestor.isExtendedContextRequired());
2613
				this.requestor.acceptContext(context);
2619
				this.requestor.acceptContext(context);
2614
			}
2620
			}
2615
			this.requestor.endReporting();
2621
			this.requestor.endReporting();
(-)model/org/eclipse/jdt/core/CompletionContext.java (-1 / +1 lines)
Lines 123-129 Link Here
123
	 * @since 3.4
123
	 * @since 3.4
124
	 */
124
	 */
125
	public boolean isExtended() {
125
	public boolean isExtended() {
126
		return this.extendedContext != null;
126
		return this.isExtended;
127
	}
127
	}
128
128
129
	/**
129
	/**

Return to bug 231747