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 20600-20603
Link Here
|
20600 |
requestor.getResults()); |
20600 |
requestor.getResults()); |
20601 |
} |
20601 |
} |
20602 |
|
20602 |
|
|
|
20603 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=287939 |
20604 |
// To verify that auto complete works after instance of expression when content assist is requested on a field |
20605 |
// Code assist requested in a local variable declaration statement |
20606 |
public void testBug287939a() throws JavaModelException { |
20607 |
this.workingCopies = new ICompilationUnit[1]; |
20608 |
this.workingCopies[0] = getWorkingCopy( |
20609 |
"/Completion/src/test/CompletionAfterInstanceOf.java", |
20610 |
"package test;\n" + |
20611 |
"public class CompletionAfterInstanceOf {\n" + |
20612 |
" public int returnZero(){ return 0;}\n" + |
20613 |
" public Object a;\n" + |
20614 |
" void bar(){\n" + |
20615 |
" if (this.a instanceof CompletionAfterInstanceOf) {\n" + |
20616 |
" int i = this.a.r\n" + |
20617 |
" int j = 0;\n" + |
20618 |
" int k = 2;\n" + |
20619 |
" int p = 12;\n" + |
20620 |
" }\n" + |
20621 |
"}\n"); |
20622 |
|
20623 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, true, true, true); |
20624 |
requestor.allowAllRequiredProposals(); |
20625 |
String str = this.workingCopies[0].getSource(); |
20626 |
String completeBehind = "this.a.r"; |
20627 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
20628 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
20629 |
|
20630 |
int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE; |
20631 |
int start1 = str.lastIndexOf("r") + "".length(); |
20632 |
int end1 = start1 + "r".length(); |
20633 |
int start2 = str.lastIndexOf("this.a.r"); |
20634 |
int end2 = start2 + "this.a.r".length(); |
20635 |
int start3 = str.lastIndexOf("this.a."); |
20636 |
int end3 = start3 + "this.a".length(); |
20637 |
|
20638 |
assertResults( |
20639 |
"expectedTypesSignatures={I}\n" + |
20640 |
"expectedTypesKeys={I}", |
20641 |
requestor.getContext()); |
20642 |
assertResults( |
20643 |
"returnZero[METHOD_REF_WITH_CASTED_RECEIVER]{((CompletionAfterInstanceOf)this.a).returnZero(), Ltest.CompletionAfterInstanceOf;, ()I, Ltest.CompletionAfterInstanceOf;, returnZero, null, replace["+start2+", "+end2+"], token["+start1+", "+end1+"], receiver["+start3+", "+end3+"], " + (relevance1) + "}", |
20644 |
requestor.getResults()); |
20645 |
} |
20646 |
|
20647 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=287939 |
20648 |
// To verify that auto complete works after instance of expression when content assist is requested on a field |
20649 |
// Code assist requested in an assignment statement |
20650 |
public void testBug287939b() throws JavaModelException { |
20651 |
this.workingCopies = new ICompilationUnit[1]; |
20652 |
this.workingCopies[0] = getWorkingCopy( |
20653 |
"/Completion/src/test/CompletionAfterInstanceOf.java", |
20654 |
"package test;\n" + |
20655 |
"public class CompletionAfterInstanceOf {\n" + |
20656 |
" public int returnZero(){ return 0;}\n" + |
20657 |
" public Object a;\n" + |
20658 |
" void bar(){\n" + |
20659 |
" int i;\n" + |
20660 |
" if (this.a instanceof CompletionAfterInstanceOf) {\n" + |
20661 |
" i = this.a.r\n" + |
20662 |
" }\n" + |
20663 |
"}\n"); |
20664 |
|
20665 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, true, true, true); |
20666 |
requestor.allowAllRequiredProposals(); |
20667 |
String str = this.workingCopies[0].getSource(); |
20668 |
String completeBehind = "this.a.r"; |
20669 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
20670 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
20671 |
|
20672 |
int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE; |
20673 |
int start1 = str.lastIndexOf("r") + "".length(); |
20674 |
int end1 = start1 + "r".length(); |
20675 |
int start2 = str.lastIndexOf("this.a.r"); |
20676 |
int end2 = start2 + "this.a.r".length(); |
20677 |
int start3 = str.lastIndexOf("this.a."); |
20678 |
int end3 = start3 + "this.a".length(); |
20679 |
|
20680 |
assertResults( |
20681 |
"expectedTypesSignatures={I}\n" + |
20682 |
"expectedTypesKeys={I}", |
20683 |
requestor.getContext()); |
20684 |
assertResults( |
20685 |
"returnZero[METHOD_REF_WITH_CASTED_RECEIVER]{((CompletionAfterInstanceOf)this.a).returnZero(), Ltest.CompletionAfterInstanceOf;, ()I, Ltest.CompletionAfterInstanceOf;, returnZero, null, replace["+start2+", "+end2+"], token["+start1+", "+end1+"], receiver["+start3+", "+end3+"], " + (relevance1) + "}", |
20686 |
requestor.getResults()); |
20687 |
} |
20688 |
|
20689 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=287939 |
20690 |
// To verify that auto complete works after instance of expression when content assist is requested on a local variable |
20691 |
// Code assist requested in an assignment statement |
20692 |
public void testBug287939c() throws JavaModelException { |
20693 |
this.workingCopies = new ICompilationUnit[1]; |
20694 |
this.workingCopies[0] = getWorkingCopy( |
20695 |
"/Completion/src/test/CompletionAfterInstanceOf.java", |
20696 |
"package test;\n" + |
20697 |
"public class CompletionAfterInstanceOf {\n" + |
20698 |
" public int returnZero(){ return 0;}\n" + |
20699 |
" void bar(Object a){\n" + |
20700 |
" int i;\n" + |
20701 |
" if (a instanceof CompletionAfterInstanceOf) {" + |
20702 |
" i = a.r\n" + |
20703 |
" }\n" + |
20704 |
"}\n"); |
20705 |
|
20706 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, true, true, true); |
20707 |
requestor.allowAllRequiredProposals(); |
20708 |
String str = this.workingCopies[0].getSource(); |
20709 |
String completeBehind = "a.r"; |
20710 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
20711 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
20712 |
|
20713 |
int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE; |
20714 |
int start1 = str.lastIndexOf("r") + "".length(); |
20715 |
int end1 = start1 + "r".length(); |
20716 |
int start2 = str.lastIndexOf("a.r"); |
20717 |
int end2 = start2 + "a.r".length(); |
20718 |
int start3 = str.lastIndexOf("a."); |
20719 |
int end3 = start3 + "a".length(); |
20720 |
|
20721 |
assertResults( |
20722 |
"expectedTypesSignatures={I}\n" + |
20723 |
"expectedTypesKeys={I}", |
20724 |
requestor.getContext()); |
20725 |
assertResults( |
20726 |
"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) + "}", |
20727 |
requestor.getResults()); |
20728 |
} |
20729 |
|
20730 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=287939 |
20731 |
// To verify that auto complete works after instance of expression when content assist is requested on a local variable |
20732 |
// Code assist requested in a local variable declaration statement |
20733 |
public void testBug287939d() throws JavaModelException { |
20734 |
this.workingCopies = new ICompilationUnit[1]; |
20735 |
this.workingCopies[0] = getWorkingCopy( |
20736 |
"/Completion/src/test/CompletionAfterInstanceOf.java", |
20737 |
"package test;\n" + |
20738 |
"public class CompletionAfterInstanceOf {\n" + |
20739 |
" public int returnZero(){ return 0;}\n" + |
20740 |
" void bar(Object a){\n" + |
20741 |
" if (a instanceof CompletionAfterInstanceOf) {" + |
20742 |
" int i = a.r\n" + |
20743 |
" }\n" + |
20744 |
"}\n"); |
20745 |
|
20746 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, true, true, true); |
20747 |
requestor.allowAllRequiredProposals(); |
20748 |
String str = this.workingCopies[0].getSource(); |
20749 |
String completeBehind = "a.r"; |
20750 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
20751 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
20752 |
|
20753 |
int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE; |
20754 |
int start1 = str.lastIndexOf("r") + "".length(); |
20755 |
int end1 = start1 + "r".length(); |
20756 |
int start2 = str.lastIndexOf("a.r"); |
20757 |
int end2 = start2 + "a.r".length(); |
20758 |
int start3 = str.lastIndexOf("a."); |
20759 |
int end3 = start3 + "a".length(); |
20760 |
|
20761 |
assertResults( |
20762 |
"expectedTypesSignatures={I}\n" + |
20763 |
"expectedTypesKeys={I}", |
20764 |
requestor.getContext()); |
20765 |
assertResults( |
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()); |
20768 |
} |
20603 |
} |
20769 |
} |