Lines 21043-21046
Link Here
|
21043 |
"equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 27}", |
21043 |
"equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 27}", |
21044 |
requestor.getResults()); |
21044 |
requestor.getResults()); |
21045 |
} |
21045 |
} |
|
|
21046 |
|
21047 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=244820 |
21048 |
// To verify that autocast works correctly even when the compilation unit |
21049 |
// has some compilation errors. |
21050 |
public void testBug244820() throws JavaModelException { |
21051 |
this.workingCopies = new ICompilationUnit[1]; |
21052 |
this.workingCopies[0] = getWorkingCopy( |
21053 |
"/Completion/src/test/CompletionAfterInstanceOf.java", |
21054 |
"package test;" + |
21055 |
"class MyString {\n" + |
21056 |
" public String toWelcome() {\n" + |
21057 |
" return \"welcome\";\n" + |
21058 |
" }\n" + |
21059 |
"}\n" + |
21060 |
"public class CompletionAfterInstanceOf {\n" + |
21061 |
" void foo() {\n" + |
21062 |
" Object chars= null;\n" + |
21063 |
" Object ch = null;\n" + |
21064 |
" String lower = null;\n" + |
21065 |
" if (ch instanceof MyString) {\n" + |
21066 |
" ch.t; \n" + |
21067 |
" }\n" + |
21068 |
" if (ch instanceof MyString) {\n" + |
21069 |
" return ch.t; \n" + |
21070 |
" }\n" + |
21071 |
" if (chars instanceof MyString) {\n" + |
21072 |
" lower = chars.to; \n" + |
21073 |
" }\n" + |
21074 |
" if (ch instanceof MyString) {\n" + |
21075 |
" String low = ch.t; \n" + |
21076 |
" }\n" + |
21077 |
" }\n" + |
21078 |
"}\n"); |
21079 |
|
21080 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, true, true, true, true, true); |
21081 |
requestor.allowAllRequiredProposals(); |
21082 |
String str = this.workingCopies[0].getSource(); |
21083 |
String completeBehind = "lower = chars.to"; |
21084 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
21085 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
21086 |
|
21087 |
int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE; |
21088 |
int start1 = str.lastIndexOf("to") + "".length(); |
21089 |
int end1 = start1 + "to".length(); |
21090 |
int start2 = str.lastIndexOf("chars.to"); |
21091 |
int end2 = start2 + "chars.to".length(); |
21092 |
int start3 = str.lastIndexOf("chars."); |
21093 |
int end3 = start3 + "chars".length(); |
21094 |
|
21095 |
assertResults( |
21096 |
"toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, null, null, toString, null, replace[" + start1 + ", " + end1 + "], token[" + start1 + ", " + end1 +"], " + relevance1 + "}\n" + |
21097 |
"toWelcome[METHOD_REF_WITH_CASTED_RECEIVER]{((MyString)chars).toWelcome(), Ltest.MyString;, ()Ljava.lang.String;, Ltest.MyString;, null, null, toWelcome, null, replace[" + start2 +", " + end2 + "], token[" + start1 + ", " + end1 + "], receiver[" + start3 + ", " + end3 + "], " + relevance1 + "}", |
21098 |
requestor.getResults()); |
21099 |
} |
21046 |
} |
21100 |
} |