mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
reduce direct usage count of IndexingDataKeys.PROJECT
GitOrigin-RevId: ab7e8d6627f085402ca8224e5dcbc184cddd31e8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
759b304340
commit
c549b4e5b9
@@ -26,8 +26,7 @@ class JavaBinaryPlusExpressionIndexTest : BasePlatformTestCase() {
|
||||
}
|
||||
}
|
||||
""").virtualFile
|
||||
val content = FileContentImpl.createByFile(file)
|
||||
content.putUserData(IndexingDataKeys.PROJECT, project)
|
||||
val content = FileContentImpl.createByFile(file, project)
|
||||
val data = JavaBinaryPlusExpressionIndex().indexer.map(content).entries.first().value.offsets!!
|
||||
|
||||
assertEquals(5, data.size)
|
||||
|
||||
@@ -87,8 +87,7 @@ class JavaNullMethodArgumentIndexTest : BasePlatformTestCase() {
|
||||
}
|
||||
}
|
||||
""").virtualFile
|
||||
val content = FileContentImpl.createByFile(file)
|
||||
content.putUserData(IndexingDataKeys.PROJECT, project)
|
||||
val content = FileContentImpl.createByFile(file, project)
|
||||
val data = JavaNullMethodArgumentIndex().indexer.map(content).keys
|
||||
|
||||
assertSize(8, data)
|
||||
|
||||
@@ -181,8 +181,7 @@ class JavaPropertyDetectionTest : LightJavaCodeInsightFixtureTestCase() {
|
||||
|
||||
private fun assertJavaSimplePropertyIndex(text: String, expected: TIntObjectHashMap<PropertyIndexValue>) {
|
||||
val file = myFixture.configureByText(JavaFileType.INSTANCE, text)
|
||||
val content = FileContentImpl.createByFile(file.virtualFile)
|
||||
content.putUserData(IndexingDataKeys.PROJECT, project)
|
||||
val content = FileContentImpl.createByFile(file.virtualFile, project)
|
||||
val data = JavaSimplePropertyIndex().indexer.map(content).values.firstOrNull() ?: TIntObjectHashMap()
|
||||
assertEquals(expected, data)
|
||||
}
|
||||
|
||||
@@ -19,45 +19,46 @@ import com.intellij.json.JsonTestCase;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.indexing.FileContentImpl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.jetbrains.jsonSchema.impl.JsonCachedValues.*;
|
||||
|
||||
public class JsonSchemaFileValuesIndexTest extends JsonTestCase {
|
||||
|
||||
public void testEmpty() {
|
||||
public void testEmpty() throws IOException {
|
||||
final VirtualFile file = myFixture.configureByFile("indexing/empty.json").getVirtualFile();
|
||||
Map<String, String> map = new JsonSchemaFileValuesIndex().getIndexer().map(FileContentImpl.createByFile(file));
|
||||
assertAllCacheNulls(map);
|
||||
}
|
||||
|
||||
public void testSimple() {
|
||||
public void testSimple() throws IOException {
|
||||
final VirtualFile file = myFixture.configureByFile("indexing/empty.json").getVirtualFile();
|
||||
Map<String, String> map = new JsonSchemaFileValuesIndex().getIndexer().map(FileContentImpl.createByFile(file));
|
||||
assertAllCacheNulls(map);
|
||||
}
|
||||
|
||||
public void testValid() {
|
||||
public void testValid() throws IOException {
|
||||
final VirtualFile file = myFixture.configureByFile("indexing/valid.json").getVirtualFile();
|
||||
Map<String, String> map = new JsonSchemaFileValuesIndex().getIndexer().map(FileContentImpl.createByFile(file));
|
||||
assertEquals("the-id", map.get(ID_CACHE_KEY));
|
||||
assertCacheNull(map.get(URL_CACHE_KEY));
|
||||
}
|
||||
|
||||
public void testValid2() {
|
||||
public void testValid2() throws IOException {
|
||||
final VirtualFile file = myFixture.configureByFile("indexing/valid2.json5").getVirtualFile();
|
||||
Map<String, String> map = new JsonSchemaFileValuesIndex().getIndexer().map(FileContentImpl.createByFile(file));
|
||||
assertEquals("the-schema", map.get(URL_CACHE_KEY));
|
||||
assertCacheNull(map.get(ID_CACHE_KEY));
|
||||
}
|
||||
|
||||
public void testInvalid() {
|
||||
public void testInvalid() throws IOException {
|
||||
final VirtualFile file = myFixture.configureByFile("indexing/invalid.json").getVirtualFile();
|
||||
Map<String, String> map = new JsonSchemaFileValuesIndex().getIndexer().map(FileContentImpl.createByFile(file));
|
||||
assertAllCacheNulls(map);
|
||||
}
|
||||
|
||||
public void testStopsOnAllFound() {
|
||||
public void testStopsOnAllFound() throws IOException {
|
||||
final VirtualFile file = myFixture.configureByFile("indexing/duplicates.json5").getVirtualFile();
|
||||
Map<String, String> map = new JsonSchemaFileValuesIndex().getIndexer().map(FileContentImpl.createByFile(file));
|
||||
assertEquals("the-schema", map.get(URL_CACHE_KEY));
|
||||
|
||||
@@ -44,8 +44,7 @@ public class CoreStubTreeLoader extends StubTreeLoader {
|
||||
}
|
||||
|
||||
try {
|
||||
final FileContent fc = new FileContentImpl(vFile, vFile.contentsToByteArray());
|
||||
fc.putUserData(IndexingDataKeys.PROJECT, project);
|
||||
final FileContent fc = FileContentImpl.createByFile(vFile, project);
|
||||
final Stub element = StubTreeBuilder.buildStubTree(fc);
|
||||
if (element instanceof PsiFileStub) {
|
||||
return new StubTree((PsiFileStub)element);
|
||||
|
||||
@@ -137,14 +137,16 @@ public class FileContentImpl extends IndexedFileImpl implements PsiDependentFile
|
||||
}
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public static FileContent createByFile(@NotNull VirtualFile file) {
|
||||
try {
|
||||
return new FileContentImpl(file, file.contentsToByteArray());
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
public static FileContent createByFile(@NotNull VirtualFile file) throws IOException {
|
||||
return createByFile(file, null);
|
||||
}
|
||||
|
||||
public static FileContent createByFile(@NotNull VirtualFile file, @Nullable Project project) throws IOException {
|
||||
FileContentImpl content = new FileContentImpl(file, file.contentsToByteArray());
|
||||
if (project != null) {
|
||||
content.putUserData(IndexingDataKeys.PROJECT, project);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -174,8 +174,7 @@ public class StubViewerPsiBasedTree implements ViewerPsiBasedTree {
|
||||
LightVirtualFile file = new LightVirtualFile("stub", rootElement.getLanguage(), textToParse);
|
||||
final FileContentImpl fc;
|
||||
try {
|
||||
fc = new FileContentImpl(file, file.contentsToByteArray());
|
||||
fc.putUserData(IndexingDataKeys.PROJECT, project);
|
||||
fc = (FileContentImpl)FileContentImpl.createByFile(file, project);
|
||||
fc.putUserData(IndexingDataKeys.PSI_FILE, psiFile);
|
||||
stub = StubTreeBuilder.buildStubTree(fc);
|
||||
}
|
||||
|
||||
@@ -138,8 +138,7 @@ public class HashBasedIndexGenerator<K, V> {
|
||||
}
|
||||
myIndexedFilesNumber.incrementAndGet();
|
||||
try {
|
||||
FileContentImpl fc = new FileContentImpl(f, f.contentsToByteArray());
|
||||
fc.putUserData(IndexingDataKeys.PROJECT, project);
|
||||
FileContentImpl fc = (FileContentImpl)FileContentImpl.createByFile(f, project);
|
||||
byte[] hash = IndexedHashesSupport.getOrInitIndexedHash(fc, false);
|
||||
int hashId = Math.abs(hashEnumerator.enumerate(hash));
|
||||
if (!myIndex.update(hashId, fc).compute()) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.util.indexing.FileBasedIndex;
|
||||
import com.intellij.util.indexing.FileContentImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -35,7 +36,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class XmlPropertiesIndexTest extends BasePlatformTestCase {
|
||||
|
||||
public void testIndex() {
|
||||
public void testIndex() throws IOException {
|
||||
PsiFile psiFile = myFixture.configureByFile("foo.xml");
|
||||
final VirtualFile file = psiFile.getVirtualFile();
|
||||
Map<XmlPropertiesIndex.Key, String> map = new XmlPropertiesIndex().map(FileContentImpl.createByFile(file));
|
||||
@@ -58,7 +59,7 @@ public class XmlPropertiesIndexTest extends BasePlatformTestCase {
|
||||
assertEquals("bar", assertOneElement(values));
|
||||
}
|
||||
|
||||
public void testSystemId() {
|
||||
public void testSystemId() throws IOException {
|
||||
PsiFile psiFile = myFixture.configureByFile("wrong.xml");
|
||||
final VirtualFile file = psiFile.getVirtualFile();
|
||||
Map<XmlPropertiesIndex.Key, String> map = new XmlPropertiesIndex().map(FileContentImpl.createByFile(file));
|
||||
|
||||
Reference in New Issue
Block a user