mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
Add initial shared indexes test (not working yet).
GitOrigin-RevId: aec2e87bb4921d4d876ac16027a98a9f186f81e1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
223c33ba51
commit
3b9e7be947
@@ -0,0 +1,54 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.util.indexing
|
||||
|
||||
import com.intellij.internal.DumpIndexAction
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.PathManager
|
||||
import com.intellij.openapi.progress.EmptyProgressIndicator
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.psi.impl.cache.impl.id.IdIndex
|
||||
import com.intellij.psi.impl.cache.impl.id.IdIndexEntry
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.stubs.StubUpdatingIndex
|
||||
import com.intellij.testFramework.SkipSlowTestLocally
|
||||
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
|
||||
import java.nio.file.Path
|
||||
|
||||
@SkipSlowTestLocally
|
||||
class SharedIndexesTest : LightJavaCodeInsightFixtureTestCase() {
|
||||
|
||||
private val tempDirPath: Path by lazy { FileUtil.createTempDirectory("shared-indexes-test", "").toPath() }
|
||||
private val indexZip: Path by lazy { tempDirPath.resolve(tempDirPath.fileName.toString() + ".zip") }
|
||||
|
||||
fun _testSharedIndexesForProject() {
|
||||
val javaPsiFile = myFixture.configureByText("A.java", "public class A { }")
|
||||
val virtualFile = javaPsiFile.virtualFile
|
||||
|
||||
val indexZip = tempDirPath.resolve(tempDirPath.fileName.toString() + ".zip")
|
||||
|
||||
val chunks = arrayListOf<DumpIndexAction.IndexChunk>()
|
||||
chunks += DumpIndexAction.IndexChunk(setOf(virtualFile), "source")
|
||||
|
||||
DumpIndexAction.exportIndices(project, chunks, tempDirPath, EmptyProgressIndicator())
|
||||
|
||||
val indexSwitcher = FileBasedIndexSwitcher(FileBasedIndex.getInstance() as FileBasedIndexImpl)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
indexSwitcher.turnOff()
|
||||
}
|
||||
|
||||
FileUtil.delete(PathManager.getIndexRoot())
|
||||
System.setProperty("prebuilt.hash.index.zip", indexZip.toAbsolutePath().toString())
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
indexSwitcher.turnOn()
|
||||
}
|
||||
|
||||
val fileBasedIndex = FileBasedIndex.getInstance()
|
||||
val map = fileBasedIndex.getFileData(StubUpdatingIndex.INDEX_ID, virtualFile, project)
|
||||
println(map)
|
||||
|
||||
val values = fileBasedIndex.getValues(IdIndex.NAME, IdIndexEntry("A", false), GlobalSearchScope.allScope(project))
|
||||
println(values)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user