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

Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java (-4 lines)
Lines 132-141 Link Here
132
	// a pointer in the expression stack to the qualifier of a invocation
132
	// a pointer in the expression stack to the qualifier of a invocation
133
	int qualifier;
133
	int qualifier;
134
134
135
	// last modifiers info
136
	int lastModifiers = ClassFileConstants.AccDefault;
137
	int lastModifiersStart = -1;
138
139
	// used to find if there is unused modifiers when building completion inside a method or an initializer
135
	// used to find if there is unused modifiers when building completion inside a method or an initializer
140
	boolean hasUnusedModifiers;
136
	boolean hasUnusedModifiers;
141
137
(-)codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java (-3 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 33-39 Link Here
33
public abstract class AssistParser extends Parser {
33
public abstract class AssistParser extends Parser {
34
	public ASTNode assistNode;
34
	public ASTNode assistNode;
35
	public boolean isOrphanCompletionNode;
35
	public boolean isOrphanCompletionNode;
36
36
	// last modifiers info
37
	protected int lastModifiers = ClassFileConstants.AccDefault;
38
	protected int lastModifiersStart = -1;
37
	/* recovery */
39
	/* recovery */
38
	int[] blockStarts = new int[30];
40
	int[] blockStarts = new int[30];
39
41
Lines 1392-1398 Link Here
1392
		return;
1394
		return;
1393
1395
1394
	initialize();
1396
	initialize();
1395
1397
	// set the lastModifiers to reflect the modifiers of the method whose
1398
	// block statements are being parsed
1399
	// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=202634
1400
	this.lastModifiers = md.modifiers;
1401
	this.lastModifiersStart = md.modifiersSourceStart;
1396
	// simulate goForMethodBody except that we don't want to balance brackets because they are not going to be balanced
1402
	// simulate goForMethodBody except that we don't want to balance brackets because they are not going to be balanced
1397
	goForBlockStatementsopt();
1403
	goForBlockStatementsopt();
1398
1404
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (+60 lines)
Lines 20766-20769 Link Here
20766
			"returnZero[METHOD_REF_WITH_CASTED_RECEIVER]{((CompletionAfterInstanceOf)a).returnZero(), Ltest.CompletionAfterInstanceOf;, ()I, Ltest.CompletionAfterInstanceOf;, returnZero, null, replace["+start2+", "+end2+"], token["+start1+", "+end1+"], receiver["+start3+", "+end3+"], " + (relevance1) + "}",
20766
			"returnZero[METHOD_REF_WITH_CASTED_RECEIVER]{((CompletionAfterInstanceOf)a).returnZero(), Ltest.CompletionAfterInstanceOf;, ()I, Ltest.CompletionAfterInstanceOf;, returnZero, null, replace["+start2+", "+end2+"], token["+start1+", "+end1+"], receiver["+start3+", "+end3+"], " + (relevance1) + "}",
20767
			requestor.getResults());
20767
			requestor.getResults());
20768
}
20768
}
20769
20770
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=202634
20771
public void testBug202634a() throws JavaModelException {
20772
	this.workingCopies = new ICompilationUnit[1];
20773
	this.workingCopies[0] = getWorkingCopy(
20774
		"/Completion/src/test/Test.java",
20775
		"package test;\n" +
20776
		"public class Test {\n" +
20777
		"	public static void bar(){" +
20778
		"		System.out.println(\"bar\");\n" +
20779
		"	}\n" +
20780
		"	void foo() {\n" +
20781
		"		sup\n" +
20782
		"	}\n" +
20783
		"}\n");
20784
20785
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, true, true, true);
20786
	requestor.allowAllRequiredProposals();
20787
	String str = this.workingCopies[0].getSource();
20788
	String completeBehind = "sup";
20789
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
20790
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
20791
	
20792
	int start1 = str.lastIndexOf("sup");
20793
	int end1 = start1 + "sup".length();
20794
	
20795
	assertResults(
20796
			"super[KEYWORD]{super, null, null, super, null, replace[" + start1 + ", " + end1 +"], token[" + start1 + ", " + end1 + "], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED) + "}",
20797
			requestor.getResults());
20798
}
20799
20800
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=202634
20801
public void testBug202634b() throws JavaModelException {
20802
	this.workingCopies = new ICompilationUnit[1];
20803
	this.workingCopies[0] = getWorkingCopy(
20804
		"/Completion/src/test/Test.java",
20805
		"package test;\n" +
20806
		"public class Test {\n" +
20807
		"	void foo() {\n" +
20808
		"		sup\n" +
20809
		"	}\n" +
20810
		"	public static void bar(){" +
20811
		"		System.out.println(\"bar\");\n" +
20812
		"	}\n" +
20813
		"}\n");
20814
20815
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, true, true, true);
20816
	requestor.allowAllRequiredProposals();
20817
	String str = this.workingCopies[0].getSource();
20818
	String completeBehind = "sup";
20819
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
20820
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
20821
	
20822
	int start1 = str.lastIndexOf("sup");
20823
	int end1 = start1 + "sup".length();
20824
	
20825
	assertResults(
20826
			"super[KEYWORD]{super, null, null, super, null, replace[" + start1 + ", " + end1 +"], token[" + start1 + ", " + end1 + "], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED) + "}",
20827
			requestor.getResults());
20828
}
20769
}
20829
}

Return to bug 202634