diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy index b7a4e0e75780..ac8e45e7e25b 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,11 +52,7 @@ import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.progress.ProgressManager import com.intellij.openapi.util.Computable import com.intellij.openapi.util.Disposer -import com.intellij.psi.NavigatablePsiElement -import com.intellij.psi.PsiClass -import com.intellij.psi.PsiFile -import com.intellij.psi.PsiJavaFile -import com.intellij.psi.PsiMethod +import com.intellij.psi.* import com.intellij.psi.statistics.StatisticsManager import com.intellij.psi.statistics.impl.StatisticsManagerImpl import com.intellij.testFramework.fixtures.CodeInsightTestUtil @@ -65,6 +61,7 @@ import org.jetbrains.annotations.NotNull import java.awt.event.KeyEvent +import static com.intellij.testFramework.EdtTestUtil.runInEdtAndWait /** * @author peter */ @@ -158,7 +155,7 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { assertContains "iterable", "iterable2" assertEquals 'iterable', lookup.currentItem.lookupString - edt { myFixture.performEditorAction IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN } + runInEdtAndWaitrunInEdtAndWait { myFixture.performEditorAction IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN } assert lookup.currentItem.lookupString == 'iterable2' type "r" @@ -180,7 +177,7 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { assertContains "iterable", "iterable2" assertEquals 'iterable', lookup.currentItem.lookupString - edt { lookup.currentItem = lookup.items[1] } + runInEdtAndWait { lookup.currentItem = lookup.items[1] } assertEquals 'iterable2', lookup.currentItem.lookupString type "r" @@ -227,7 +224,7 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { assertContains 'abcd', 'abce' assertEquals 'abcd', lookup.currentItem.lookupString - edt { lookup.currentItem = lookup.items[1] } + runInEdtAndWait { lookup.currentItem = lookup.items[1] } assertEquals 'abce', lookup.currentItem.lookupString type '\t' @@ -340,7 +337,7 @@ class Foo { } """) type 'ite' - edt { + runInEdtAndWait { myFixture.type 'r' lookup.markReused() lookup.currentItem = lookup.items[0] @@ -361,7 +358,7 @@ class Foo { } """) type 'ite' - edt { + runInEdtAndWait { myFixture.type 'r' lookup.markReused() myFixture.type '\b\b' @@ -382,7 +379,7 @@ class Foo { } """) type 'th' - edt { myFixture.type 'r\t'} + runInEdtAndWait { myFixture.type 'r\t'} myFixture.checkResult """ class A { { throw new } @@ -397,10 +394,10 @@ class Foo { { } } """) - edt { myFixture.type 'A' } + runInEdtAndWait { myFixture.type 'A' } joinAutopopup() // completion started boolean tooQuick = false - edt { + runInEdtAndWait { tooQuick = lookup == null myFixture.type 'IO' } @@ -412,7 +409,7 @@ class Foo { if (!tooQuick) { return } - edt { + runInEdtAndWait { LookupManager.getInstance(project).hideActiveLookup() CompletionProgressIndicator.cleanupForNextTest() } @@ -427,7 +424,7 @@ class Foo { } """) myFixture.complete CompletionType.SMART - edt { myFixture.type 'Thr' } + runInEdtAndWait { myFixture.type 'Thr' } joinCompletion() assert lookup assert 'Thread' in myFixture.lookupElementStrings @@ -492,12 +489,12 @@ class Foo { assert lookup lookup.focusDegree = focusDegree - edt { myFixture.performEditorAction(action) } + runInEdtAndWait { myFixture.performEditorAction(action) } if (lookup) { assert lookup.focused assert expectedIndex >= 0 assert lookup.items[expectedIndex] == lookup.currentItem - edt { lookup.hide() } + runInEdtAndWait { lookup.hide() } } else { assert expectedIndex == -1 } @@ -594,11 +591,11 @@ class Aaaaaaa {} public interface Test { }""" - edt { myFixture.type 'A' } + runInEdtAndWait { myFixture.type 'A' } joinAutopopup() def first = lookup assert first - edt { + runInEdtAndWait { assert first == lookup lookup.hide() myFixture.type 'a' @@ -630,14 +627,14 @@ public interface Test { public void testDuringCompletionMustFinish() { registerContributor(LongReplacementOffsetContributor) - edt { myFixture.addFileToProject 'directory/foo.txt', '' } + runInEdtAndWait { myFixture.addFileToProject 'directory/foo.txt', '' } myFixture.configureByText "a.java", 'public interface Test { RuntiExcexxx }' myFixture.completeBasic() while (!lookup.items) { Thread.sleep(10) - edt { lookup.refreshUi(false, false) } + runInEdtAndWait { lookup.refreshUi(false, false) } } - edt { myFixture.type '\t' } + runInEdtAndWait { myFixture.type '\t' } myFixture.checkResult 'public interface Test { RuntimeExceptionx }' } @@ -663,7 +660,7 @@ public interface Test { def offset = myFixture.editor.caretModel.offset assertContains "iterable", "if", "int" - edt { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_RIGHT) } + runInEdtAndWait { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_RIGHT) } assert myFixture.editor.caretModel.offset == offset + 1 joinAutopopup() joinCompletion() @@ -671,7 +668,7 @@ public interface Test { assertContains "iterable" assertEquals 'iterable', lookup.currentItem.lookupString - edt { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_LEFT) } + runInEdtAndWait { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_LEFT) } assert myFixture.editor.caretModel.offset == offset joinAutopopup() joinCompletion() @@ -679,14 +676,14 @@ public interface Test { assertContains "iterable", "if", "int" assertEquals 'iterable', lookup.currentItem.lookupString - edt { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_LEFT) } + runInEdtAndWait { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_LEFT) } joinAutopopup() joinCompletion() assert !lookup.calculating assert lookup.items.size() > 3 for (i in 0.."iter".size()) { - edt { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_RIGHT) } + runInEdtAndWait { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_RIGHT) } } assert !lookup } @@ -703,7 +700,7 @@ public interface Test { type('i') assert lookup - edt { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_RIGHT) } + runInEdtAndWait { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_RIGHT) } myFixture.checkResult """ class Foo { void foo(String iterable) { @@ -717,7 +714,7 @@ public interface Test { assert lookup assert !lookup.calculating - edt { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_LEFT) } + runInEdtAndWait { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_LEFT) } myFixture.checkResult """ class Foo { void foo(String iterable) { @@ -740,7 +737,7 @@ public interface Test { } } """) - edt { + runInEdtAndWait { int primaryCaretOffset = myFixture.editor.document.text.indexOf("ter x"); myFixture.editor.caretModel.addCaret(myFixture.editor.offsetToVisualPosition(primaryCaretOffset)) } @@ -748,7 +745,7 @@ public interface Test { type('i') assert lookup - edt { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_RIGHT) } + runInEdtAndWait { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_RIGHT) } myFixture.checkResult """ class Foo { void foo(String iterable) { @@ -772,7 +769,7 @@ public interface Test { } try { - edt { + runInEdtAndWait { assert !lookup.calculating lookup.hide() def file = myFixture.addFileToProject("b.java", "") @@ -796,7 +793,7 @@ public interface Test { assert lookup } finally { - edt { EditorFactory.instance.releaseEditor(another) } + runInEdtAndWait { EditorFactory.instance.releaseEditor(another) } } } @@ -865,7 +862,7 @@ class Foo { public void testNoAutopopupAfterSpace() { myFixture.configureByText("a.java", """ class Foo { { int newa; } } """) - edt { myFixture.type('new ') } + runInEdtAndWait { myFixture.type('new ') } joinAutopopup() joinCompletion() assert !lookup @@ -923,7 +920,7 @@ class Foo { myFixture.type 'a' joinAutopopup() assert lookup - edt { myFixture.type 'bc' } + runInEdtAndWait { myFixture.type 'bc' } joinAutopopup() joinAutopopup() joinCompletion() @@ -940,7 +937,7 @@ class Foo { Thread.sleep(1) } def l = lookup - edt { + runInEdtAndWait { if (!lookup.calculating) println "testRestartWithVisibleLookup couldn't be faster than LongContributor" myFixture.type 'c' } @@ -960,7 +957,7 @@ class Foo { if (degree == 1) return joinCommit() if (degree == 2) return - edt {} + runInEdtAndWait {} if (degree == 3) return joinCompletion() } @@ -1003,7 +1000,7 @@ class Foo { for (a1 in 0..actions) { myFixture.configureByText("$a1 if .java", src) - edt { myFixture.type 'if' } + runInEdtAndWait { myFixture.type 'if' } joinSomething(a1) myFixture.type ' ' @@ -1025,7 +1022,7 @@ class Foo { myFixture.type 'i' joinSomething(a1) - edt { myFixture.type 'f ' } + runInEdtAndWait { myFixture.type 'f ' } joinAutopopup() joinCompletion() @@ -1138,7 +1135,7 @@ class Foo { def goo = methods[2] type('x') assertContains 'x__foo', 'x__goo' - edt { + runInEdtAndWait { assert foo == TargetElementUtil.instance.findTargetElement(myFixture.editor, TargetElementUtil.LOOKUP_ITEM_ACCEPTED) myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN) assert goo == TargetElementUtil.instance.findTargetElement(myFixture.editor, TargetElementUtil.LOOKUP_ITEM_ACCEPTED) @@ -1146,7 +1143,7 @@ class Foo { type('_') myFixture.assertPreferredCompletionItems 1, 'x__foo', 'x__goo' - edt { + runInEdtAndWait { assert goo == TargetElementUtil.instance.findTargetElement(myFixture.editor, TargetElementUtil.LOOKUP_ITEM_ACCEPTED) myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_UP) assert foo == TargetElementUtil.instance.findTargetElement(myFixture.editor, TargetElementUtil.LOOKUP_ITEM_ACCEPTED) @@ -1158,7 +1155,7 @@ class Foo { type 'ext' CompletionAutoPopupHandler.ourTestingAutopopup = false - edt { + runInEdtAndWait { myFixture.completeBasic() } assert !lookup : myFixture.lookupElementStrings @@ -1170,7 +1167,7 @@ class Foo { type 'pr' CompletionAutoPopupHandler.ourTestingAutopopup = false - edt { + runInEdtAndWait { myFixture.completeBasic() } myFixture.checkResult 'class Foo {pr}' @@ -1273,7 +1270,7 @@ public class Test { private FileEditor openEditorForUndo() { FileEditor editor; - edt { editor = FileEditorManager.getInstance(project).openFile(myFixture.file.virtualFile, false)[0] } + runInEdtAndWait { editor = FileEditorManager.getInstance(project).openFile(myFixture.file.virtualFile, false)[0] } def manager = (UndoManagerImpl) UndoManager.getInstance(project) def old = manager.editorProvider manager.editorProvider = new CurrentEditorProvider() { @@ -1290,7 +1287,7 @@ public class Test { myFixture.configureByText "a.java", "class Foo {{ }}" def editor = openEditorForUndo(); type 'aioobeeee' - edt { UndoManager.getInstance(project).undo(editor) } + runInEdtAndWait { UndoManager.getInstance(project).undo(editor) } assert !myFixture.editor.document.text.contains('aioo') } @@ -1365,7 +1362,7 @@ class Foo {{ myFixture.configureByText 'a.java', 'class Foo extends ' type 'Abcde' assert lookup.items.size() == 2 - edt { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN) } + runInEdtAndWait { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN) } type ' ' myFixture.checkResult '''import foo.Abcdefg; @@ -1389,7 +1386,7 @@ class Foo extends Abcdefg ''' assert myFixture.lookupElementStrings.size() >= 2 type '.' assert lookup - edt { myFixture.editor.caretModel.moveToOffset(myFixture.editor.document.text.indexOf('lang')) } + runInEdtAndWait { myFixture.editor.caretModel.moveToOffset(myFixture.editor.document.text.indexOf('lang')) } assert !lookup type 'i' assert 'io' in myFixture.lookupElementStrings @@ -1606,7 +1603,7 @@ class Foo { ''' type 'sette' myFixture.assertPreferredCompletionItems 1, 'setHorizontalText', 'setText' - edt { myFixture.performEditorAction IdeActions.ACTION_EDITOR_MOVE_CARET_UP } + runInEdtAndWait { myFixture.performEditorAction IdeActions.ACTION_EDITOR_MOVE_CARET_UP } myFixture.assertPreferredCompletionItems 0, 'setHorizontalText', 'setText' } @@ -1634,7 +1631,7 @@ class Foo { myFixture.configureByText "a.java", "class Foo {{ }}" myFixture.type('a') joinAutopopup() - edt { ApplicationManager.application.runWriteAction {} } + runInEdtAndWait { ApplicationManager.application.runWriteAction {} } joinCompletion() assert lookup } @@ -1662,7 +1659,7 @@ class Foo { final Template template = manager.createTemplate("m", "user", 'void foo(String $V1$) {}'); template.addVariable("V1", "", '"s"', true); - edt { + runInEdtAndWait { CommandProcessor.instance.executeCommand project, {manager.startTemplate(myFixture.editor, template)}, null, null } @@ -1770,7 +1767,7 @@ class Foo { class Foo {{ }}""" - edt { ((EditorEx)myFixture.editor).setColumnMode(true) } + runInEdtAndWait { ((EditorEx)myFixture.editor).setColumnMode(true) } type 'toStr' assert lookup } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy index 49aea69b68bc..59f01a204a6a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy @@ -40,6 +40,8 @@ import org.jdom.Element import org.jetbrains.annotations.NotNull import static com.intellij.codeInsight.template.Template.Property.USE_STATIC_IMPORT_IF_POSSIBLE +import static com.intellij.testFramework.EdtTestUtil.runInEdtAndWait + /** * @author spleaner */ @@ -811,7 +813,7 @@ class A {{ } private void moveCaret(final int offset) { - edt { + runInEdtAndWait { getEditor().getCaretModel().moveToOffset(offset); } } diff --git a/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy b/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy index fe9acaa3b7fe..e96efbd23593 100644 --- a/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy +++ b/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,9 @@ import com.intellij.util.concurrency.Semaphore import org.jetbrains.annotations.NotNull import org.jetbrains.plugins.groovy.lang.psi.GroovyFile -import javax.swing.SwingUtilities +import javax.swing.* + +import static com.intellij.testFramework.EdtTestUtil.runInEdtAndWait /** * @author peter @@ -111,7 +113,7 @@ class Intf { def xxx1 def xxx2 - edt { + runInEdtAndWait { xxx1 = intf.findMethodsByName('_xxx1', false) xxx2 = intf.findMethodsByName('xxx2', false) } @@ -184,7 +186,7 @@ class Intf { def fooDir def barDir - edt { + runInEdtAndWait { fooDir = fooIndex.containingDirectory barDir = barIndex.containingDirectory } @@ -280,7 +282,7 @@ class Intf { def clazz = myFixture.addClass("package foo.bar; class Goo implements Runnable { public void run() {} }") def ourRun def sdkRun - edt { + runInEdtAndWait { ourRun = clazz.methods[0] sdkRun = ourRun.containingClass.interfaces[0].methods[0] } @@ -300,7 +302,7 @@ class Intf { def base def sub - edt { + runInEdtAndWait { base = baseClass.methods[0] sub = subClass.methods[0] } @@ -314,7 +316,7 @@ class Intf { GroovyFile file2 = myFixture.addFileToProject('foo-bar.groovy', '') def variants = getPopupElements(new GotoSymbolModel2(project), 'foo', false) - edt { assert variants == [file1.scriptClass, file2.scriptClass] } + runInEdtAndWait { assert variants == [file1.scriptClass, file2.scriptClass] } } private List getPopupElements(ChooseByNameModel model, String text, boolean checkboxState = false) { @@ -343,7 +345,7 @@ class Intf { myPopup.close(false) } - edt { + runInEdtAndWait { def popup = myPopup = ChooseByNamePopup.createPopup(project, model, (PsiElement)context, "") Disposer.register(testRootDisposable, { popup.close(false) } as Disposable) } diff --git a/platform/platform-impl/src/com/intellij/openapi/components/service.kt b/platform/platform-impl/src/com/intellij/openapi/components/service.kt index d08305472981..9015e39b5962 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/service.kt +++ b/platform/platform-impl/src/com/intellij/openapi/components/service.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,5 +29,5 @@ val ComponentManager.stateStore: IComponentStore return picoContainer.getComponentInstance(key) as IComponentStore } -@Suppress("DEPRECATED_SYMBOL_WITH_MESSAGE") +@Suppress("DEPRECATION") fun ComponentManager.getComponents(baseClass: Class) = (this as ComponentManagerEx).getComponentInstancesOfType(baseClass) \ No newline at end of file diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyAutoPopupTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyAutoPopupTest.groovy index 909052ae47f6..79024fdd6acb 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyAutoPopupTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyAutoPopupTest.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,9 @@ import com.intellij.openapi.actionSystem.IdeActions import com.intellij.testFramework.LightProjectDescriptor import org.jetbrains.annotations.NotNull import org.jetbrains.plugins.groovy.GroovyLightProjectDescriptor + +import static com.intellij.testFramework.EdtTestUtil.runInEdtAndWait + /** * @author peter */ @@ -48,7 +51,7 @@ class GroovyAutoPopupTest extends CompletionAutoPopupTestCase { return xx } """) - edt { myFixture.doHighlighting() } + runInEdtAndWait { myFixture.doHighlighting() } type 'x' assert lookup.focused } @@ -159,7 +162,7 @@ class GroovyAutoPopupTest extends CompletionAutoPopupTestCase { myFixture.configureByText 'a.groovy', 'class Foo extends ' type 'Abcde' assert lookup.items.size() == 2 - edt { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN) } + runInEdtAndWait { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN) } type ' ' myFixture.checkResult '''import foo.Abcdefg