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

Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java (-4 / +6 lines)
Lines 4018-4025 Link Here
4018
				if(this.canBeExplicitConstructor == YES) {
4018
				if(this.canBeExplicitConstructor == YES) {
4019
					canBeExplicitConstructorCall = true;
4019
					canBeExplicitConstructorCall = true;
4020
				}
4020
				}
4021
4021
				if (this.options.complianceLevel >= ClassFileConstants.JDK1_4) {
4022
				keywords[count++]= Keywords.ASSERT;
4022
					keywords[count++]= Keywords.ASSERT;
4023
				}
4023
				keywords[count++]= Keywords.DO;
4024
				keywords[count++]= Keywords.DO;
4024
				keywords[count++]= Keywords.FOR;
4025
				keywords[count++]= Keywords.FOR;
4025
				keywords[count++]= Keywords.IF;
4026
				keywords[count++]= Keywords.IF;
Lines 4061-4068 Link Here
4061
					}
4062
					}
4062
					keywords[count++]= Keywords.BREAK;
4063
					keywords[count++]= Keywords.BREAK;
4063
					keywords[count++]= Keywords.CASE;
4064
					keywords[count++]= Keywords.CASE;
4064
4065
					if (this.options.complianceLevel >= ClassFileConstants.JDK1_4) {
4065
					keywords[count++]= Keywords.ASSERT;
4066
						keywords[count++]= Keywords.ASSERT;
4067
					}
4066
					keywords[count++]= Keywords.DO;
4068
					keywords[count++]= Keywords.DO;
4067
					keywords[count++]= Keywords.FOR;
4069
					keywords[count++]= Keywords.FOR;
4068
					keywords[count++]= Keywords.IF;
4070
					keywords[count++]= Keywords.IF;
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (+42 lines)
Lines 12-17 Link Here
12
12
13
import java.io.IOException;
13
import java.io.IOException;
14
import java.util.Hashtable;
14
import java.util.Hashtable;
15
import java.util.Map;
15
16
16
import junit.framework.Test;
17
import junit.framework.Test;
17
18
Lines 30-35 Link Here
30
import org.eclipse.jdt.core.Signature;
31
import org.eclipse.jdt.core.Signature;
31
import org.eclipse.jdt.core.eval.IEvaluationContext;
32
import org.eclipse.jdt.core.eval.IEvaluationContext;
32
import org.eclipse.jdt.internal.codeassist.CompletionEngine;
33
import org.eclipse.jdt.internal.codeassist.CompletionEngine;
34
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
33
import org.eclipse.jdt.internal.core.eval.EvaluationContextWrapper;
35
import org.eclipse.jdt.internal.core.eval.EvaluationContextWrapper;
34
36
35
public class CompletionTests extends AbstractJavaModelCompletionTests {
37
public class CompletionTests extends AbstractJavaModelCompletionTests {
Lines 19480-19483 Link Here
19480
			requestor.getResults());
19482
			requestor.getResults());
19481
}
19483
}
19482
19484
19485
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=203060: assert keyword should not be proposed when
19486
// compliance level is set to 1.3
19487
public void test203060() throws JavaModelException {
19488
	this.workingCopies = new ICompilationUnit[1];
19489
	this.workingCopies[0] = getWorkingCopy(
19490
		"/Completion/src/test/KeywordAssert.java",
19491
		"package test;" +
19492
		"public class CompletionKeywordAssert1 {\n" +
19493
		"	void foo() {\n" +
19494
		"		as\n" +
19495
		"	}\n" +
19496
		"}\n");
19497
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
19498
	String str = this.workingCopies[0].getSource();
19499
	String completeBehind = "as";
19500
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
19501
	
19502
	// Save current compliance settings
19503
	Map options = COMPLETION_PROJECT.getOptions(true);
19504
	Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance);
19505
	
19506
	// Verify that at 1.3 assert is not proposed.
19507
	options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_3);
19508
	COMPLETION_PROJECT.setOptions(options);
19509
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
19510
	assertEquals("", requestor.getResults());
19511
	
19512
	// Verify that at 1.4 assert IS proposed.
19513
	options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4);
19514
	COMPLETION_PROJECT.setOptions(options);
19515
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
19516
	assertEquals(
19517
			"element:assert    completion:assert    relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
19518
			requestor.getResults());
19519
	
19520
	// Restore compliance settings.
19521
	options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance);
19522
	COMPLETION_PROJECT.setOptions(options);
19523
}
19524
19483
}
19525
}

Return to bug 203060