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 (-5 / +19 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 1269-1275 Link Here
1269
	//convert bugs into parse error
1271
	//convert bugs into parse error
1270
1272
1271
	initialize();
1273
	initialize();
1272
1274
	// set the lastModifiers to reflect the modifiers of the constructor whose
1275
	// block statements are being parsed
1276
	// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=202634
1277
	this.lastModifiers = cd.modifiers;
1278
	this.lastModifiersStart = cd.modifiersSourceStart;
1273
	// simulate goForConstructorBody except that we don't want to balance brackets because they are not going to be balanced
1279
	// simulate goForConstructorBody except that we don't want to balance brackets because they are not going to be balanced
1274
	goForBlockStatementsopt();
1280
	goForBlockStatementsopt();
1275
1281
Lines 1335-1341 Link Here
1335
	CompilationUnitDeclaration unit) {
1341
	CompilationUnitDeclaration unit) {
1336
1342
1337
	initialize();
1343
	initialize();
1338
1344
	// set the lastModifiers to reflect the modifiers of the initializer whose
1345
	// block statements are being parsed
1346
	// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=202634
1347
	this.lastModifiers = initializer.modifiers;
1348
	this.lastModifiersStart = initializer.modifiersSourceStart;
1339
	// simulate goForInitializer except that we don't want to balance brackets because they are not going to be balanced
1349
	// simulate goForInitializer except that we don't want to balance brackets because they are not going to be balanced
1340
	goForBlockStatementsopt();
1350
	goForBlockStatementsopt();
1341
1351
Lines 1392-1398 Link Here
1392
		return;
1402
		return;
1393
1403
1394
	initialize();
1404
	initialize();
1395
1405
	// set the lastModifiers to reflect the modifiers of the method whose
1406
	// block statements are being parsed
1407
	// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=202634
1408
	this.lastModifiers = md.modifiers;
1409
	this.lastModifiersStart = md.modifiersSourceStart;
1396
	// simulate goForMethodBody except that we don't want to balance brackets because they are not going to be balanced
1410
	// simulate goForMethodBody except that we don't want to balance brackets because they are not going to be balanced
1397
	goForBlockStatementsopt();
1411
	goForBlockStatementsopt();
1398
1412
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (+181 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
}
20829
20830
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=202634
20831
public void testBug202634c() throws JavaModelException {
20832
	this.workingCopies = new ICompilationUnit[1];
20833
	this.workingCopies[0] = getWorkingCopy(
20834
		"/Completion/src/test/Test.java",
20835
		"package test;\n" +
20836
		"public class Test {\n" +
20837
		"	public static void bar(){" +
20838
		"		System.out.println(\"bar\");\n" +
20839
		"	}\n" +
20840
		"	{" +
20841
		"		sup" +
20842
		"	}" +
20843
		"}\n");
20844
20845
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, true, true, true);
20846
	requestor.allowAllRequiredProposals();
20847
	String str = this.workingCopies[0].getSource();
20848
	String completeBehind = "sup";
20849
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
20850
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
20851
	
20852
	int start1 = str.lastIndexOf("sup");
20853
	int end1 = start1 + "sup".length();
20854
	
20855
	assertResults(
20856
			"super[KEYWORD]{super, null, null, super, null, replace[" + start1 + ", " + end1 +"], token[" + start1 + ", " + end1 + "], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED) + "}",
20857
			requestor.getResults());
20858
}
20859
20860
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=202634
20861
public void testBug202634d() throws JavaModelException {
20862
	this.workingCopies = new ICompilationUnit[1];
20863
	this.workingCopies[0] = getWorkingCopy(
20864
		"/Completion/src/test/Test.java",
20865
		"package test;\n" +
20866
		"public class Test {\n" +
20867
		"	public static void bar(){" +
20868
		"		System.out.println(\"bar\");\n" +
20869
		"	}\n" +
20870
		"	Test() {" +
20871
		"		sup" +
20872
		"	}" +
20873
		"}\n");
20874
20875
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, true, true, true);
20876
	requestor.allowAllRequiredProposals();
20877
	String str = this.workingCopies[0].getSource();
20878
	String completeBehind = "sup";
20879
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
20880
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
20881
	
20882
	int start1 = str.lastIndexOf("sup");
20883
	int end1 = start1 + "sup".length();
20884
	
20885
	assertResults(
20886
			"super[KEYWORD]{super, null, null, super, null, replace[" + start1 + ", " + end1 +"], token[" + start1 + ", " + end1 + "], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED) + "}\n" +
20887
			"super[METHOD_REF<CONSTRUCTOR>]{super(), Ljava.lang.Object;, ()V, super, null, replace[" + start1 + ", " + end1 + "], token[" + start1 + ", " + end1 + "], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED) + "}",
20888
			requestor.getResults());
20889
}
20890
20891
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=202634
20892
public void testBug202634e() throws JavaModelException {
20893
	this.workingCopies = new ICompilationUnit[1];
20894
	this.workingCopies[0] = getWorkingCopy(
20895
		"/Completion/src/test/Test.java",
20896
		"package test;\n" +
20897
		"public class Test {\n" +
20898
		"	public static void bar(){" +
20899
		"		System.out.println(\"bar\");\n" +
20900
		"	}\n" +
20901
		"	{" +
20902
		"		thi" +
20903
		"	}" +
20904
		"}\n");
20905
20906
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, true, true, true);
20907
	requestor.allowAllRequiredProposals();
20908
	String str = this.workingCopies[0].getSource();
20909
	String completeBehind = "thi";
20910
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
20911
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
20912
	
20913
	int start1 = str.lastIndexOf("thi");
20914
	int end1 = start1 + "thi".length();
20915
	
20916
	assertResults(
20917
			"this[KEYWORD]{this, null, null, this, null, replace[" + start1 + ", " + end1 +"], token[" + start1 + ", " + end1 + "], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED) + "}",
20918
			requestor.getResults());
20919
}
20920
20921
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=202634
20922
public void testBug202634f() throws JavaModelException {
20923
	this.workingCopies = new ICompilationUnit[1];
20924
	this.workingCopies[0] = getWorkingCopy(
20925
		"/Completion/src/test/Test.java",
20926
		"package test;\n" +
20927
		"public class Test {\n" +
20928
		"	public static void bar(){" +
20929
		"		System.out.println(\"bar\");\n" +
20930
		"	}\n" +
20931
		"	Test() {" +
20932
		"		thi" +
20933
		"	}" +
20934
		"}\n");
20935
20936
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, true, true, true);
20937
	requestor.allowAllRequiredProposals();
20938
	String str = this.workingCopies[0].getSource();
20939
	String completeBehind = "thi";
20940
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
20941
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
20942
	
20943
	int start1 = str.lastIndexOf("thi");
20944
	int end1 = start1 + "thi".length();
20945
	
20946
	assertResults(
20947
			"this[KEYWORD]{this, null, null, this, null, replace[" + start1 + ", " + end1 +"], token[" + start1 + ", " + end1 + "], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED) + "}",
20948
			requestor.getResults());
20949
}
20769
}
20950
}

Return to bug 202634