mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
added read action in tests
This commit is contained in:
+8
-1
@@ -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<PsiClass>() {
|
||||
@Override
|
||||
public PsiClass compute() {
|
||||
return ((PsiJavaFile)myFixture.file).getClasses()[0];
|
||||
}
|
||||
});
|
||||
def foo = cls.methods[0]
|
||||
def goo = cls.methods[2]
|
||||
type('x')
|
||||
|
||||
@@ -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]
|
||||
}
|
||||
|
||||
@@ -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..<parameters.size()) {
|
||||
|
||||
Reference in New Issue
Block a user