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 test203060a() 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 |
try { |
19507 |
// Verify that at 1.3 assert is not proposed. |
19508 |
options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_3); |
19509 |
COMPLETION_PROJECT.setOptions(options); |
19510 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
19511 |
assertEquals("", requestor.getResults()); |
19512 |
} finally { |
19513 |
// Restore compliance settings. |
19514 |
options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); |
19515 |
COMPLETION_PROJECT.setOptions(options); |
19516 |
} |
19517 |
} |
19518 |
|
19519 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=203060: Verify that assert keyword gets proposed when |
19520 |
//compliance level is set to 1.4 |
19521 |
public void test203060b() throws JavaModelException { |
19522 |
this.workingCopies = new ICompilationUnit[1]; |
19523 |
this.workingCopies[0] = getWorkingCopy( |
19524 |
"/Completion/src/test/KeywordAssert.java", |
19525 |
"package test;" + |
19526 |
"public class CompletionKeywordAssert1 {\n" + |
19527 |
" void foo() {\n" + |
19528 |
" as\n" + |
19529 |
" }\n" + |
19530 |
"}\n"); |
19531 |
CompletionTestsRequestor requestor = new CompletionTestsRequestor(); |
19532 |
String str = this.workingCopies[0].getSource(); |
19533 |
String completeBehind = "as"; |
19534 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
19535 |
|
19536 |
// Save current compliance settings |
19537 |
Map options = COMPLETION_PROJECT.getOptions(true); |
19538 |
Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance); |
19539 |
|
19540 |
try { |
19541 |
options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4); |
19542 |
COMPLETION_PROJECT.setOptions(options); |
19543 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
19544 |
assertEquals( |
19545 |
"element:assert completion:assert relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED), |
19546 |
requestor.getResults()); |
19547 |
} finally { |
19548 |
// Restore compliance settings. |
19549 |
options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); |
19550 |
COMPLETION_PROJECT.setOptions(options); |
19551 |
} |
19552 |
} |
19553 |
|
19554 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=203060: assert keyword should not be proposed when |
19555 |
//compliance level is set to 1.3 (variation) |
19556 |
public void test203060c() throws JavaModelException { |
19557 |
this.workingCopies = new ICompilationUnit[1]; |
19558 |
this.workingCopies[0] = getWorkingCopy( |
19559 |
"/Completion/src/test/KeywordAssert.java", |
19560 |
"package test;" + |
19561 |
"public class KeywordAssert {\n" + |
19562 |
" void foo() {\n" + |
19563 |
" switch(0) {\n" + |
19564 |
" case 1 :\n" + |
19565 |
" ass\n" + |
19566 |
" }\n" + |
19567 |
" }\n" + |
19568 |
"}\n"); |
19569 |
|
19570 |
CompletionTestsRequestor requestor = new CompletionTestsRequestor(); |
19571 |
String str = this.workingCopies[0].getSource(); |
19572 |
String completeBehind = "as"; |
19573 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
19574 |
|
19575 |
// Save current compliance settings |
19576 |
Map options = COMPLETION_PROJECT.getOptions(true); |
19577 |
Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance); |
19578 |
|
19579 |
try { |
19580 |
// Verify that at 1.3 assert is not proposed. |
19581 |
options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_3); |
19582 |
COMPLETION_PROJECT.setOptions(options); |
19583 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
19584 |
assertEquals("", requestor.getResults()); |
19585 |
} finally { |
19586 |
// Restore compliance settings. |
19587 |
options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); |
19588 |
COMPLETION_PROJECT.setOptions(options); |
19589 |
} |
19590 |
} |
19591 |
|
19592 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=203060: Verify that assert keyword gets proposed when |
19593 |
//compliance level is set to 1.4 (variation) |
19594 |
public void test203060d() throws JavaModelException { |
19595 |
this.workingCopies = new ICompilationUnit[1]; |
19596 |
this.workingCopies[0] = getWorkingCopy( |
19597 |
"/Completion/src/test/KeywordAssert.java", |
19598 |
"package test;" + |
19599 |
"public class KeywordAssert {\n" + |
19600 |
" void foo() {\n" + |
19601 |
" switch(0) {\n" + |
19602 |
" case 1 :\n" + |
19603 |
" ass\n" + |
19604 |
" }\n" + |
19605 |
" }\n" + |
19606 |
"}\n"); |
19607 |
|
19608 |
CompletionTestsRequestor requestor = new CompletionTestsRequestor(); |
19609 |
String str = this.workingCopies[0].getSource(); |
19610 |
String completeBehind = "as"; |
19611 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
19612 |
|
19613 |
// Save current compliance settings |
19614 |
Map options = COMPLETION_PROJECT.getOptions(true); |
19615 |
Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance); |
19616 |
|
19617 |
try { |
19618 |
options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4); |
19619 |
COMPLETION_PROJECT.setOptions(options); |
19620 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
19621 |
assertEquals( |
19622 |
"element:assert completion:assert relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED), |
19623 |
requestor.getResults()); |
19624 |
} finally { |
19625 |
// Restore compliance settings. |
19626 |
options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); |
19627 |
COMPLETION_PROJECT.setOptions(options); |
19628 |
} |
19629 |
} |
19483 |
} |
19630 |
} |