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 a5397a2de68b..b8dff64bdf14 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy @@ -47,7 +47,9 @@ import com.intellij.openapi.extensions.LoadingOrder import com.intellij.openapi.fileEditor.FileEditor 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.PsiClass import com.intellij.psi.PsiFile import com.intellij.psi.PsiJavaFile import com.intellij.psi.statistics.StatisticsManager @@ -967,7 +969,12 @@ class Foo { void x__goo() {} } ''' - def cls = ((PsiJavaFile)myFixture.file).getClasses()[0] + PsiClass cls = ApplicationManager.getApplication().runReadAction(new Computable() { + @Override + public PsiClass compute() { + return ((PsiJavaFile)myFixture.file).getClasses()[0]; + } + }); def foo = cls.methods[0] def goo = cls.methods[2] type('x') diff --git a/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy b/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy index fad8e4fd94e9..6b97c59fbe59 100644 --- a/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy +++ b/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy @@ -1,14 +1,25 @@ +/* + * Copyright 2000-2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.navigation -import com.intellij.ide.util.gotoByName.ChooseByNameBase -import com.intellij.ide.util.gotoByName.ChooseByNameModel -import com.intellij.ide.util.gotoByName.ChooseByNamePopup -import com.intellij.ide.util.gotoByName.GotoClassModel2 -import com.intellij.ide.util.gotoByName.GotoFileModel -import com.intellij.ide.util.gotoByName.GotoSymbolModel2 +import com.intellij.ide.util.gotoByName.* import com.intellij.openapi.Disposable import com.intellij.openapi.application.ModalityState import com.intellij.openapi.util.Disposer import com.intellij.psi.PsiElement +import com.intellij.psi.PsiFile import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase import com.intellij.util.Consumer import com.intellij.util.concurrency.Semaphore @@ -135,24 +146,32 @@ class Intf { } public void "test goto file can go to dir"() { - def fooIndex = myFixture.addFileToProject("foo/index.html", "foo") - def barIndex = myFixture.addFileToProject("bar.txt/bar.txt", "foo") + PsiFile fooIndex = myFixture.addFileToProject("foo/index.html", "foo") + PsiFile barIndex = myFixture.addFileToProject("bar.txt/bar.txt", "foo") def popup = createPopup(new GotoFileModel(project), fooIndex) - assert calcPopupElements(popup, "foo/") == [fooIndex.containingDirectory] - assert calcPopupElements(popup, "foo\\") == [fooIndex.containingDirectory] - assert calcPopupElements(popup, "/foo") == [fooIndex.containingDirectory] - assert calcPopupElements(popup, "\\foo") == [fooIndex.containingDirectory] + + def fooDir + def barDir + edt { + fooDir = fooIndex.containingDirectory + barDir = barIndex.containingDirectory + } + + assert calcPopupElements(popup, "foo/") == [fooDir] + assert calcPopupElements(popup, "foo\\") == [fooDir] + assert calcPopupElements(popup, "/foo") == [fooDir] + assert calcPopupElements(popup, "\\foo") == [fooDir] assert calcPopupElements(popup, "foo") == [] assert calcPopupElements(popup, "/index.html") == [fooIndex] assert calcPopupElements(popup, "\\index.html") == [fooIndex] assert calcPopupElements(popup, "index.html/") == [fooIndex] assert calcPopupElements(popup, "index.html\\") == [fooIndex] - assert calcPopupElements(popup, "bar.txt/") == [barIndex.containingDirectory] - assert calcPopupElements(popup, "bar.txt\\") == [barIndex.containingDirectory] - assert calcPopupElements(popup, "/bar.txt") == [barIndex.containingDirectory] - assert calcPopupElements(popup, "\\bar.txt") == [barIndex.containingDirectory] + assert calcPopupElements(popup, "bar.txt/") == [barDir] + assert calcPopupElements(popup, "bar.txt\\") == [barDir] + assert calcPopupElements(popup, "/bar.txt") == [barDir] + assert calcPopupElements(popup, "\\bar.txt") == [barDir] assert calcPopupElements(popup, "bar.txt") == [barIndex] popup.close(false) } @@ -178,7 +197,10 @@ class Intf { public void "test super method in jdk"() { def ourRun = myFixture.addClass("package foo.bar; class Goo implements Runnable { public void run() {} }").methods[0] - def sdkRun = ourRun.containingClass.interfaces[0].methods[0] + def sdkRun + edt { + sdkRun = ourRun.containingClass.interfaces[0].methods[0] + } assert getPopupElements(new GotoSymbolModel2(project), 'run ', true) == [sdkRun] assert getPopupElements(new GotoSymbolModel2(project), 'run ', false) == [ourRun] } diff --git a/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy b/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy index c9153983344a..021f7f95c480 100644 --- a/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy +++ b/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy @@ -73,7 +73,13 @@ class StubAstSwitchTest extends LightCodeInsightFixtureTestCase { } CountDownLatch latch = new CountDownLatch(count) for (c in classList) { - ApplicationManager.application.executeOnPooledThread { Thread.yield(); c.text; latch.countDown() } + ApplicationManager.application.executeOnPooledThread { + Thread.yield(); + ApplicationManager.application.runReadAction { + c.text; + } + latch.countDown() + } for (m in c.methods) { def parameters = m.parameterList.parameters for (i in 0.. future = ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { @Override public void run() { - myManager.getMainSplitters().openFiles(); + ApplicationManager.getApplication().runReadAction(new Runnable() { + @Override + public void run() { + myManager.getMainSplitters().openFiles(); + } + }); } }); while (true) { diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index 890d69b4cda0..e7479425cff3 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -1316,9 +1316,9 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig @Override public PsiFile configureByText(@NotNull final String fileName, @NotNull @NonNls final String text) { assertInitialized(); - new WriteCommandAction(getProject()) { + return new WriteCommandAction(getProject()) { @Override - protected void run(@NotNull Result result) throws Throwable { + protected void run(@NotNull Result result) throws Throwable { final VirtualFile vFile; if (myTempDirFixture instanceof LightTempDirTestFixtureImpl) { final VirtualFile root = LightPlatformTestCase.getSourceRoot(); @@ -1343,9 +1343,9 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig VfsUtil.saveText(vFile, text); configureInner(vFile, SelectionAndCaretMarkupLoader.fromFile(vFile)); + result.setResult(getFile()); } - }.execute(); - return getFile(); + }.execute().getResultObject(); } @Override @@ -1594,7 +1594,12 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig @Override public PsiFile getFile() { - return myFile == null ? null : PsiManager.getInstance(getProject()).findFile(myFile); + return myFile == null ? null : ApplicationManager.getApplication().runReadAction(new Computable() { + @Override + public PsiFile compute() { + return PsiManager.getInstance(getProject()).findFile(myFile); + } + }); } public static List getAvailableIntentions(@NotNull final Editor editor, @NotNull final PsiFile file) {