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 |
} |