1 package com
.intellij
.codeInsight
.completion
;
3 import com
.intellij
.JavaTestUtil
;
4 import com
.intellij
.codeInsight
.CodeInsightSettings
;
5 import com
.intellij
.codeInsight
.lookup
.*;
6 import com
.intellij
.codeInsight
.lookup
.impl
.TestLookupManager
;
7 import com
.intellij
.codeInsight
.template
.SmartCompletionContextType
;
8 import com
.intellij
.codeInsight
.template
.Template
;
9 import com
.intellij
.codeInsight
.template
.TemplateContextType
;
10 import com
.intellij
.codeInsight
.template
.TemplateManager
;
11 import com
.intellij
.codeInsight
.template
.impl
.TemplateImpl
;
12 import com
.intellij
.codeInsight
.template
.impl
.TemplateSettings
;
13 import com
.intellij
.openapi
.roots
.LanguageLevelProjectExtension
;
14 import com
.intellij
.openapi
.util
.Condition
;
15 import com
.intellij
.pom
.java
.LanguageLevel
;
16 import com
.intellij
.psi
.codeStyle
.CodeStyleSettings
;
17 import com
.intellij
.psi
.codeStyle
.CodeStyleSettingsManager
;
18 import com
.intellij
.util
.containers
.ContainerUtil
;
19 import org
.jetbrains
.annotations
.NonNls
;
21 import java
.util
.Arrays
;
23 public class SmartTypeCompletionTest
extends LightCompletionTestCase
{
24 private static final String BASE_PATH
= "/codeInsight/completion/smartType";
25 private LanguageLevel myPrevLanguageLevel
;
28 protected String
getTestDataPath() {
29 return JavaTestUtil
.getJavaTestDataPath();
32 public void testParenAfterCast1() throws Exception
{
33 String path
= BASE_PATH
+ "/parenAfterCast";
35 configureByFile(path
+ "/before1.java");
36 checkResultByFile(path
+ "/after1.java");
39 public void testParenAfterCast2() throws Exception
{
40 String path
= BASE_PATH
+ "/parenAfterCast";
42 configureByFile(path
+ "/before2.java");
43 checkResultByFile(path
+ "/after2.java");
49 public void testParenAfterCast3() throws Exception
{
50 String path
= BASE_PATH
+ "/parenAfterCast";
52 configureByFile(path
+ "/before3.java");
53 checkResultByFile(path
+ "/after3.java");
56 public void testParenAfterCall1() throws Exception
{
57 String path
= BASE_PATH
+ "/parenAfterCall";
59 configureByFile(path
+ "/before1.java");
60 checkResultByFile(path
+ "/after1.java");
63 public void testParenAfterCall2() throws Exception
{
64 String path
= BASE_PATH
+ "/parenAfterCall";
66 configureByFile(path
+ "/before2.java");
67 checkResultByFile(path
+ "/after2.java");
70 public void testParenAfterCall3() throws Exception
{
71 String path
= BASE_PATH
+ "/parenAfterCall";
73 configureByFile(path
+ "/before3.java");
74 checkResultByFile(path
+ "/after3.java");
77 public void testParenAfterCall4() throws Exception
{
78 String path
= BASE_PATH
+ "/parenAfterCall";
80 configureByFile(path
+ "/before4.java");
81 checkResultByFile(path
+ "/after4.java");
84 public void testParenAfterCall5() throws Exception
{
85 String path
= BASE_PATH
+ "/parenAfterCall";
87 configureByFile(path
+ "/before5.java");
88 checkResultByFile(path
+ "/after5.java");
91 public void testParenAfterCall6() throws Exception
{
92 String path
= BASE_PATH
+ "/parenAfterCall";
94 configureByFile(path
+ "/before6.java");
95 checkResultByFile(path
+ "/after6.java");
98 public void testParenAfterCall1_SpaceWithinMethodCallParens() throws Exception
{
99 String path
= BASE_PATH
+ "/parenAfterCall";
101 CodeStyleSettings styleSettings
= CodeStyleSettingsManager
.getSettings(getProject());
102 configureByFileNoComplete(path
+ "/before1.java");
103 styleSettings
.SPACE_WITHIN_METHOD_CALL_PARENTHESES
= true;
108 styleSettings
.SPACE_WITHIN_METHOD_CALL_PARENTHESES
= false;
110 checkResultByFile(path
+ "/after1_space.java");
113 public void testParenAfterIf1() throws Exception
{
114 String path
= BASE_PATH
+ "/parenAfterIf";
116 configureByFile(path
+ "/before1.java");
117 checkResultByFile(path
+ "/after1.java");
120 public void testParenAfterIf2() throws Exception
{
121 String path
= BASE_PATH
+ "/parenAfterIf";
123 configureByFile(path
+ "/before2.java");
124 checkResultByFile(path
+ "/after2.java");
127 public void testForceLookupForAbstractClasses() throws Exception
{
128 String path
= BASE_PATH
+ "/afterNew";
130 configureByFile(path
+ "/before9.java");
131 checkResultByFile(path
+ "/after9.java");
134 public void testAfterNew1() throws Exception
{
135 String path
= BASE_PATH
+ "/afterNew";
137 configureByFile(path
+ "/before1.java");
139 checkResultByFile(path
+ "/after1.java");
142 public void testAfterNew2() throws Exception
{
143 String path
= BASE_PATH
+ "/afterNew";
145 configureByFile(path
+ "/before2.java");
147 checkResultByFile(path
+ "/after2.java");
150 public void testAfterNew3() throws Exception
{
151 String path
= BASE_PATH
+ "/afterNew";
153 configureByFile(path
+ "/before3.java");
155 checkResultByFile(path
+ "/after3.java");
158 public void testAfterNew4() throws Exception
{
159 String path
= BASE_PATH
+ "/afterNew";
161 configureByFile(path
+ "/before4.java");
163 checkResultByFile(path
+ "/after4.java");
166 public void testAfterNew5() throws Exception
{
167 String path
= BASE_PATH
+ "/afterNew";
169 configureByFile(path
+ "/before5.java");
171 checkResultByFile(path
+ "/after5.java");
174 public void testAfterNew6() throws Exception
{
175 String path
= BASE_PATH
+ "/afterNew";
177 configureByFile(path
+ "/before6.java");
179 checkResultByFile(path
+ "/after6.java");
182 public void testAfterNew7() throws Exception
{
183 String path
= BASE_PATH
+ "/afterNew";
185 configureByFile(path
+ "/before7.java");
187 checkResultByFile(path
+ "/after7.java");
190 public void testAfterNew8() throws Exception
{
191 String path
= BASE_PATH
+ "/afterNew";
193 configureByFile(path
+ "/before8.java");
195 checkResultByFile(path
+ "/after8.java");
198 public void testAfterNew9() throws Exception
{
199 String path
= BASE_PATH
+ "/afterNew";
201 configureByFile(path
+ "/before10.java");
203 checkResultByFile(path
+ "/after10.java");
206 public void testAfterNew10() throws Exception
{
207 String path
= BASE_PATH
+ "/afterNew";
209 configureByFile(path
+ "/before12.java");
211 checkResultByFile(path
+ "/after12.java");
214 public void testAfterNew11() throws Exception
{
215 String path
= BASE_PATH
+ "/afterNew";
217 configureByFile(path
+ "/before13.java");
219 checkResultByFile(path
+ "/after13.java");
222 public void testAfterThrowNew1() throws Exception
{
223 String path
= BASE_PATH
+ "/afterNew";
225 configureByFile(path
+ "/before14.java");
227 checkResultByFile(path
+ "/after14.java");
230 public void testAfterThrowNew2() throws Exception
{
231 String path
= BASE_PATH
+ "/afterNew";
233 configureByFile(path
+ "/before15.java");
235 checkResultByFile(path
+ "/after15.java");
238 public void testAfterThrowNew3() throws Exception
{
239 String path
= BASE_PATH
+ "/afterNew";
241 configureByFile(path
+ "/before16.java");
243 checkResultByFile(path
+ "/after16.java");
246 public void testAfterThrow1() throws Exception
{
247 String path
= BASE_PATH
;
249 configureByFile(path
+ "/CastInThrow.java");
251 checkResultByFile(path
+ "/CastInThrow-out.java");
254 public void testParenAfterNewWithinInnerExpr() throws Exception
{
255 String path
= BASE_PATH
+ "/afterNew";
257 configureByFile(path
+ "/LastArgInInnerNewBefore.java");
258 checkResultByFile(path
+ "/LastArgInInnerNewAfter.java");
260 //configureByFile(path + "/LastArgInInnerNewBefore2.java");
262 //checkResultByFile(path + "/LastArgInInnerNewAfter2.java");
264 configureByFile(path
+ "/LastArgInInnerNewBefore3.java");
265 checkResultByFile(path
+ "/LastArgInInnerNewAfter3.java");
267 configureByFile(path
+ "/LastArgInInnerNewBefore4.java");
268 checkResultByFile(path
+ "/LastArgInInnerNewAfter4.java");
271 public void testReturn1() throws Exception
{
272 String path
= BASE_PATH
+ "/return";
273 configureByFile(path
+ "/before1.java");
274 checkResultByFile(path
+ "/after1.java");
277 public void testReturn2() throws Exception
{
278 String path
= BASE_PATH
+ "/return";
280 configureByFile(path
+ "/before2.java");
281 checkResultByFile(path
+ "/after2.java");
284 public void testReturn3() throws Exception
{
285 String path
= BASE_PATH
+ "/return";
287 configureByFile(path
+ "/before3.java");
288 checkResultByFile(path
+ "/after3.java");
291 public void testGenerics1() throws Exception
{
292 String path
= BASE_PATH
+ "/generics";
294 configureByFile(path
+ "/before1.java");
295 checkResultByFile(path
+ "/after1.java");
298 public void testGenerics2() throws Exception
{
299 String path
= BASE_PATH
+ "/generics";
301 configureByFile(path
+ "/before2.java");
302 checkResultByFile(path
+ "/after2.java");
305 public void testGenerics3() throws Exception
{
306 String path
= BASE_PATH
+ "/generics";
308 configureByFile(path
+ "/before3.java");
309 checkResultByFile(path
+ "/after3.java");
312 public void testGenerics4() throws Exception
{
313 String path
= BASE_PATH
+ "/generics";
315 configureByFile(path
+ "/before4.java");
316 checkResultByFile(path
+ "/after4.java");
319 public void testGenerics5() throws Exception
{
320 String path
= BASE_PATH
+ "/generics";
322 configureByFile(path
+ "/before5.java");
323 checkResultByFile(path
+ "/after5.java");
326 public void testAfterInstanceOf1() throws Exception
{
327 String path
= BASE_PATH
+ "/afterInstanceOf";
329 configureByFile(path
+ "/before1.java");
330 checkResultByFile(path
+ "/after1.java");
333 public void testAfterInstanceOf2() throws Exception
{
334 String path
= BASE_PATH
+ "/afterInstanceOf";
336 configureByFile(path
+ "/before2.java");
337 checkResultByFile(path
+ "/after2.java");
340 public void testInsideCatch() throws Exception
{
341 String path
= BASE_PATH
;
343 configureByFile(path
+ "/InsideCatch.java");
344 checkResultByFile(path
+ "/InsideCatch-out.java");
348 public void testGenerics6() throws Exception
{
349 String path
= BASE_PATH
+ "/generics";
351 configureByFile(path
+ "/before6.java");
352 checkResultByFile(path
+ "/after6.java");
355 public void testWildcardNew1() throws Exception
{
356 String path
= BASE_PATH
+ "/generics";
358 configureByFile(path
+ "/before7.java");
359 checkResultByFile(path
+ "/after7.java");
362 public void testWildcardNew2() throws Exception
{
363 String path
= BASE_PATH
+ "/generics";
365 configureByFile(path
+ "/before8.java");
366 checkResultByFile(path
+ "/after8.java");
369 public void testWildcardEliminated() throws Exception
{
370 String path
= BASE_PATH
+ "/generics";
372 configureByFile(path
+ "/before9.java");
373 checkResultByFile(path
+ "/after9.java");
376 public void testBug1() throws Exception
{ doTest(); }
378 public void testQualifiedThis() throws Exception
{ doTest(); }
380 public void testBug2() throws Exception
{
381 configureByFile(BASE_PATH
+ "/Bug2.java");
385 public void testSillyAssignment1() throws Exception
{
386 configureByFile(BASE_PATH
+ "/Silly1.java");
387 checkResultByFile(BASE_PATH
+ "/Silly1.java");
390 public void testVarargs1() throws Exception
{ doTest(); }
392 public void testEnumConstInSwitch() throws Exception
{ doTest(); }
394 public void testEnumConstInSwitchOutside() throws Exception
{ doTest(); }
396 public void testIntConstInSwitch() throws Exception
{ doTest(); }
398 public void testDoubleEmptyArray() throws Exception
{
399 configureByFile(BASE_PATH
+ "/"+getTestName(false)+".java");
400 checkResultByFile(BASE_PATH
+ "/"+getTestName(false) + ".java");
401 assertEquals(2, myItems
.length
);
404 public void testCollectionsEmptySetInMethodCall() throws Throwable
{ doTest(); }
406 public void testCollectionsEmptySetInTernary() throws Throwable
{ doTest(); }
408 public void testStringConstantInAnno() throws Throwable
{ doTest(); }
410 public void testCollectionsEmptySetInTernary2() throws Throwable
{ doTest(); }
412 public void testConstructorOnSeparateLineInMethodCall() throws Throwable
{ doTest(); }
414 public void testConstructorWithExistingParens() throws Throwable
{ doTest(); }
416 public void testMethodAnnotationNamedParameter() throws Throwable
{ doTest(); }
418 public void testInheritedClass() throws Throwable
{ doTest(); }
420 public void testClassLiteralInAnno1() throws Throwable
{ doTest(); }
422 public void testExplicitWildcardParam() throws Throwable
{ doTest(); }
424 public void testExplicitWildcardArrayParam() throws Throwable
{ doTest(); }
426 public void testCatchInAnonymous() throws Throwable
{ doTest(); }
428 public void testThrowRuntimeException() throws Throwable
{ doTest(); }
430 public void testParameterizedConstructor() throws Throwable
{ doTest(); }
432 public void testNewInnerOfParameterizedClass() throws Throwable
{ doTest(); }
434 public void testQualifiedThisInAnonymousConstructor() throws Throwable
{ doTest(); }
436 public void testExceptionTwice() throws Throwable
{ doTest(); }
438 public void testExceptionTwice2() throws Throwable
{ doTest(); }
440 public void testNewInnerRunnable() throws Throwable
{ doTest(); }
442 public void testArrayAccessIndex() throws Throwable
{ doTest(); }
444 public void testThrowExceptionConstructor() throws Throwable
{ doTest(); }
446 public void testJavadocThrows() throws Throwable
{ doTest(); }
448 public void testDoNotExcludeAssignedVariable() throws Throwable
{ doTest(); }
450 public void testArrayIndexTailType() throws Throwable
{ doTest(); }
452 public void testHonorSelection() throws Throwable
{ doTest(); }
454 public void testTypeParametersInheritors() throws Throwable
{
455 configureByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
456 assertStringItems("Foo", "Bar", "Goo");
458 checkResultByFile(BASE_PATH
+ "/" + getTestName(false) + "-out.java");
461 public void testVoidExpectedType() throws Throwable
{
462 configureByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
463 assertStringItems("notify", "notifyAll", "wait", "wait", "wait", "equals", "getClass", "hashCode", "toString");
466 checkResultByFile(BASE_PATH
+ "/" + getTestName(false) + "-out.java");
469 public void testDoubleSemicolonPenetration() throws Throwable
{ doTest(); }
471 public void testTypeParametersInheritorsComma() throws Throwable
{ doTest(); }
473 public void testTypeParametersInheritorsInExpression() throws Throwable
{ doTest(); }
475 //do we need to see all Object inheritors at all?
476 public void _testTypeParametersObjectInheritors() throws Throwable
{ doTest(); }
478 public void testDoubleThis() throws Throwable
{
483 public void testSmartFinish() throws Throwable
{
484 configureByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
485 select(Lookup
.COMPLETE_STATEMENT_SELECT_CHAR
);
486 checkResultByFile(BASE_PATH
+ "/" + getTestName(false) + "-out.java");
489 public void testSillyAssignmentInTernary() throws Throwable
{ doTest(); }
491 public void testSameFieldInAnotherObject() throws Throwable
{ doTest(); }
493 public void testUnqualifiedConstantInSwitch() throws Throwable
{ doTest(); }
495 public void testAmbiguousConstant() throws Throwable
{ doTest(); }
497 public void testSameNamedFieldAndLocal() throws Throwable
{ doTest(); }
499 public void testAbstractClassTwice() throws Throwable
{
500 configureByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
501 final int offset
= myEditor
.getCaretModel().getOffset();
503 myEditor
.getCaretModel().moveToOffset(offset
);
504 assertOneElement(myItems
);
507 public void testConstantTwice() throws Throwable
{ doTest(); }
509 public void testConstantTwice2() throws Throwable
{
510 configureByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
511 assertEquals(2, myItems
.length
);
514 public void testNoKeyConstant() throws Throwable
{
515 configureByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
516 assertEquals(2, myItems
.length
);
517 assertEquals("A_KEY", myItems
[0].getLookupString());
518 assertEquals("Key.create", myItems
[1].getLookupString());
521 public void testUserDataListAddAll() throws Throwable
{
525 public void testStaticSubclass() throws Throwable
{
529 public void testMethodCallDot() throws Throwable
{ doTest(); }
530 public void testNegateVariable() throws Throwable
{ doTest(); }
532 public void testExclamationMethodFinish() throws Throwable
{ doTest('!'); }
533 public void testExclamationVariableFinish() throws Throwable
{ doTest('!'); }
534 public void testExclamationStaticFieldFinish() throws Throwable
{ doTest('!'); }
535 public void testExclamationFinishNonBoolean() throws Throwable
{ doTest('!'); }
537 public void testExcludeDeclaredConstant() throws Throwable
{ doTest(); }
539 public void testTabMethodInBinaryExpression() throws Throwable
{ doTest('\t'); }
541 public void testIfConditionBinaryExpression() throws Throwable
{ doTest(); }
543 public void testDelegationToParent() throws Throwable
{ doTest(); }
545 public void testBeforeBinaryExpressionInMethodCall() throws Throwable
{ doTest(); }
547 public void testAssignableToAfterCast() throws Throwable
{ doTest(); }
549 public void testInstanceMethodParametersFromStaticContext() throws Throwable
{ doTest(); }
551 public void testInstanceMethodParametersFromStaticContext2() throws Throwable
{ doTest(); }
553 public void testBeforeCastToArray() throws Throwable
{ doTest(); }
555 public void testHidingFields() throws Throwable
{ doTest(); }
557 public void testVoidCast() throws Throwable
{ doAntiTest(); }
559 public void testIntPlusLongNotDouble() throws Throwable
{ doTest(); }
561 public void testNestedAssignments() throws Throwable
{ doTest(); }
563 public void testAfterNewInTernary() throws Throwable
{ doTest(); }
565 public void testSuggestAnythingWhenWildcardExpected() throws Throwable
{
566 configureByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
567 assertStringItems("X<java.lang.Object>", "Y", "Z<java.lang.Object>");
570 public void testNewVararg() throws Throwable
{
571 configureByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
572 assertStringItems("Foo", "Foo");
573 assertEquals(0, myItems
[0].as(PsiTypeLookupItem
.class).getBracketsCount());
574 assertEquals(1, myItems
[1].as(PsiTypeLookupItem
.class).getBracketsCount());
577 public void testInsideStringLiteral() throws Throwable
{
578 configureByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
580 checkResultByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
584 public void testDefaultAnnoParam() throws Throwable
{ doTest(); }
586 public void testCastGenericQualifier() throws Throwable
{ doTest(); }
588 public void testEverythingDoubles() throws Throwable
{
589 configureByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
590 assertStringItems("hashCode", "indexOf", "lastIndexOf", "size");
593 public void testNonStaticInnerClass() throws Throwable
{
594 configureByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
596 checkResultByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
599 //todo 2nd completion
600 public void _testDefaultAnnoParam2() throws Throwable
{ doTest(); }
602 public void testLiveTemplate() throws Throwable
{
603 final Template template
= TemplateManager
.getInstance(getProject()).createTemplate("foo", "zzz");
604 template
.addTextSegment("FooFactory.createFoo()");
605 final SmartCompletionContextType completionContextType
=
606 ContainerUtil
.findInstance(TemplateContextType
.EP_NAME
.getExtensions(), SmartCompletionContextType
.class);
607 ((TemplateImpl
)template
).getTemplateContext().setEnabled(completionContextType
, true);
608 TemplateSettings
.getInstance().addTemplate(template
);
613 TemplateSettings
.getInstance().removeTemplate(template
);
617 public void testInThisExpression() throws Throwable
{ doTest(); }
619 public void testSuggestNull() throws Throwable
{ doTest(); }
621 public void testNoNullAfterDot() throws Throwable
{
622 configureByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
624 checkResultByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
627 public void testDefaultAnnoMethodValue() throws Throwable
{ doTest(); }
629 public void testUseIntConstantsFromTargetClass() throws Throwable
{ doTest(); }
630 public void testUseIntConstantsFromTargetClassReturnValue() throws Throwable
{ doTest(); }
631 public void testUseIntConstantsFromConstructedClass() throws Throwable
{ doTest(); }
633 public void testExtraSemicolonAfterMethodParam() throws Throwable
{
634 CodeStyleSettings styleSettings
= CodeStyleSettingsManager
.getSettings(getProject());
635 styleSettings
.SPACE_WITHIN_METHOD_CALL_PARENTHESES
= true;
640 styleSettings
.SPACE_WITHIN_METHOD_CALL_PARENTHESES
= false;
644 public void testAssignFromTheSameFieldOfAnotherObject() throws Throwable
{
648 public void testTailAfterInstanceOf() throws Throwable
{
652 public void testSuggestInstanceofedValue() throws Throwable
{
656 public void testSuggestInstanceofedValueInTernary() throws Throwable
{
660 public void testSuggestInstanceofedValueInComplexIf() throws Throwable
{ doTest(); }
662 public void testSuggestInstanceofedValueInElseNegated() throws Throwable
{ doTest(); }
664 public void testSuggestInstanceofedValueAfterReturn() throws Throwable
{ doTest(); }
666 public void testNoInstanceofedValueWhenBasicSuits() throws Throwable
{ doTest(); }
668 public void testSuggestCastedValueAfterCast() throws Throwable
{ doTest(); }
670 public void testNoInstanceofedValueInElse() throws Throwable
{ doAntiTest(); }
672 public void testNoInstanceofedValueInThenNegated() throws Throwable
{ doAntiTest(); }
674 public void testNoInstanceofedValueInElseWithComplexIf() throws Throwable
{ doAntiTest(); }
676 public void testReplaceWholeReferenceChain() throws Throwable
{ doTest(Lookup
.REPLACE_SELECT_CHAR
); }
678 public void testInstanceofedInsideAnonymous() throws Throwable
{ doTest(Lookup
.REPLACE_SELECT_CHAR
); }
680 public void testDoubleTrueInOverloadedMethodCall() throws Throwable
{ doTest(Lookup
.REPLACE_SELECT_CHAR
); }
682 public void testOneElementArray() throws Throwable
{ doTest(); }
684 public void testCastToArray() throws Throwable
{ doTest(); }
686 public void testDontAutoCastWhenAlreadyCasted() throws Throwable
{
687 configureByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
688 assertEquals("s", myItems
[0].getLookupString());
689 assertEquals("String.copyValueOf", myItems
[1].getLookupString());
691 checkResultByFile(BASE_PATH
+ "/" + getTestName(false) + "-out.java");
694 public void testAutoCastWhenAlreadyCasted() throws Throwable
{ doTest(); }
696 public void testCommaDoublePenetration() throws Throwable
{
697 configureByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
699 checkResultByFile(BASE_PATH
+ "/" + getTestName(false) + "-out.java");
702 public void testSuperMethodArguments() throws Throwable
{
703 configureByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
704 getLookup().setCurrentItem(getLookup().getItems().get(1));
706 checkResultByFile(BASE_PATH
+ "/" + getTestName(false) + "-out.java");
709 public void testDelegateMethodArguments() throws Throwable
{
710 configureByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
711 getLookup().setCurrentItem(getLookup().getItems().get(1));
713 checkResultByFile(BASE_PATH
+ "/" + getTestName(false) + "-out.java");
716 public void testSuperConstructorArguments() throws Throwable
{
717 configureByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
718 getLookup().setCurrentItem(getLookup().getItems().get(2));
720 checkResultByFile(BASE_PATH
+ "/" + getTestName(false) + "-out.java");
723 private void doAntiTest() throws Exception
{
724 configureByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
726 checkResultByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
729 private void doTest() throws Exception
{
730 doTest(Lookup
.NORMAL_SELECT_CHAR
);
733 private void doTest(final char c
) throws Exception
{
734 boolean old
= CodeInsightSettings
.getInstance().AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION
;
735 if (c
!= Lookup
.NORMAL_SELECT_CHAR
) {
736 CodeInsightSettings
.getInstance().AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION
= false;
740 configureByFile(BASE_PATH
+ "/" + getTestName(false) + ".java");
741 if (myItems
!= null && myItems
.length
== 1) {
744 checkResultByFile(BASE_PATH
+ "/" + getTestName(false) + "-out.java");
747 if (c
!= Lookup
.NORMAL_SELECT_CHAR
) {
748 CodeInsightSettings
.getInstance().AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION
= old
;
754 protected void checkResultByFile(@NonNls final String filePath
) throws Exception
{
755 if (myItems
!= null) {
756 System
.out
.println("items = " + Arrays
.asList(myItems
));
758 super.checkResultByFile(filePath
);
761 public void testInnerEnum() throws Exception
{
762 configureByFile(BASE_PATH
+ "/"+getTestName(false)+".java");
764 LookupManager
.getActiveLookup(myEditor
).setCurrentItem(ContainerUtil
.find(myItems
, new Condition
<LookupElement
>() {
765 public boolean value(final LookupElement lookupItem
) {
766 return "Fubar.Bar".equals(lookupItem
.getLookupString());
770 checkResultByFile(BASE_PATH
+ "/"+getTestName(false) + "-out.java");
773 protected void setUp() throws Exception
{
775 myPrevLanguageLevel
= LanguageLevelProjectExtension
.getInstance(getJavaFacade().getProject()).getLanguageLevel();
776 LanguageLevelProjectExtension
.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel
.JDK_1_5
);
777 setType(CompletionType
.SMART
);
780 protected void tearDown() throws Exception
{
781 LookupManager
.getInstance(getProject()).hideActiveLookup();
782 LanguageLevelProjectExtension
.getInstance(getJavaFacade().getProject()).setLanguageLevel(myPrevLanguageLevel
);
786 private void select() {
787 select(Lookup
.NORMAL_SELECT_CHAR
);
790 private void select(final char c
) {
791 if (c
!= '\n' && c
!= '\t' && c
!= Lookup
.COMPLETE_STATEMENT_SELECT_CHAR
) {
796 final TestLookupManager manager
= (TestLookupManager
) LookupManager
.getInstance(getProject());
797 final Lookup lookup
= manager
.getActiveLookup();
799 manager
.forceSelection(c
, lookup
.getCurrentItem());