Fix flaky navigation tests by refreshing file system before find
This commit is contained in:
+3
-1
@@ -17,7 +17,9 @@ abstract class AbstractNavigateFromLibrarySourcesTest : LightCodeInsightFixtureT
|
|||||||
protected fun navigationElementForReferenceInLibrarySource(filePath: String, referenceText: String): PsiElement {
|
protected fun navigationElementForReferenceInLibrarySource(filePath: String, referenceText: String): PsiElement {
|
||||||
val libraryOrderEntry = ModuleRootManager.getInstance(myModule!!).orderEntries.first { it is LibraryOrderEntry }
|
val libraryOrderEntry = ModuleRootManager.getInstance(myModule!!).orderEntries.first { it is LibraryOrderEntry }
|
||||||
val libSourcesRoot = libraryOrderEntry.getUrls(OrderRootType.SOURCES)[0]
|
val libSourcesRoot = libraryOrderEntry.getUrls(OrderRootType.SOURCES)[0]
|
||||||
val vf = VirtualFileManager.getInstance().findFileByUrl(libSourcesRoot + "/$filePath")!!
|
val libUrl = "$libSourcesRoot/$filePath"
|
||||||
|
val vf = VirtualFileManager.getInstance().refreshAndFindFileByUrl(libUrl)
|
||||||
|
?: error("Can't find library: $libUrl")
|
||||||
val psiFile = psiManager.findFile(vf)!!
|
val psiFile = psiManager.findFile(vf)!!
|
||||||
val indexOf = psiFile.text!!.indexOf(referenceText)
|
val indexOf = psiFile.text!!.indexOf(referenceText)
|
||||||
val reference = psiFile.findReferenceAt(indexOf)
|
val reference = psiFile.findReferenceAt(indexOf)
|
||||||
|
|||||||
@@ -41,7 +41,11 @@ fun PlatformTestCase.projectLibrary(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val File.jarRoot get() = JarFileSystem.getInstance().getRootByLocal(LocalFileSystem.getInstance().findFileByIoFile(this)!!)!!
|
val File.jarRoot: VirtualFile
|
||||||
|
get() {
|
||||||
|
val virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(this) ?: error("Cannot find file $this")
|
||||||
|
return JarFileSystem.getInstance().getRootByLocal(virtualFile) ?: error("Can't find root by file $virtualFile")
|
||||||
|
}
|
||||||
|
|
||||||
fun Module.addDependency(
|
fun Module.addDependency(
|
||||||
library: Library,
|
library: Library,
|
||||||
|
|||||||
Reference in New Issue
Block a user