mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extract interface PsiDependentFileContent from FileContentImpl with psi-related methods
GitOrigin-RevId: 773ecbc8170d78520fdaab6ebe973bec59acaa22
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d98be8036e
commit
daa8dbe15b
@@ -68,7 +68,7 @@ class JavaSimplePropertyIndex : FileBasedIndexExtension<Int, PropertyIndexValue>
|
||||
|
||||
override fun getIndexer(): DataIndexer<Int, PropertyIndexValue, FileContent> = DataIndexer { inputData ->
|
||||
val result = HashMap<Int, PropertyIndexValue>()
|
||||
val tree = (inputData as FileContentImpl).lighterASTForPsiDependentIndex
|
||||
val tree = (inputData as PsiDependentFileContent).lighterAST
|
||||
|
||||
object : RecursiveLighterASTNodeWalkingVisitor(tree) {
|
||||
var methodIndex = 0
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ public class JavaBinaryPlusExpressionIndex extends FileBasedIndexExtension<Boole
|
||||
int[] offsets = new StringSearcher("+", true, true).findAllOccurrences(text);
|
||||
if (offsets.length == 0) return Collections.emptyMap();
|
||||
|
||||
LighterAST tree = ((FileContentImpl)inputData).getLighterASTForPsiDependentIndex();
|
||||
LighterAST tree = ((PsiDependentFileContent)inputData).getLighterAST();
|
||||
TIntArrayList result = new TIntArrayList(offsets.length);
|
||||
Map<LighterASTNode, Boolean> stringConcatenations = new HashMap<>();
|
||||
LightTreeUtil.processLeavesAtOffsets(offsets, tree, (leaf, offset) -> {
|
||||
|
||||
+1
-1
@@ -373,7 +373,7 @@ public class JavaFunctionalExpressionIndex extends FileBasedIndexExtension<Funct
|
||||
if (offsets.length == 0) return Collections.emptyMap();
|
||||
|
||||
Map<FunctionalExpressionKey, Map<Integer, FunExprOccurrence>> result = new HashMap<>();
|
||||
LighterAST tree = ((FileContentImpl)inputData).getLighterASTForPsiDependentIndex();
|
||||
LighterAST tree = ((PsiDependentFileContent)inputData).getLighterAST();
|
||||
FileLocalResolver resolver = new FileLocalResolver(tree);
|
||||
|
||||
LightTreeUtil.processLeavesAtOffsets(offsets, tree, (leaf, offset) -> {
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class JavaNullMethodArgumentIndex extends ScalarIndexExtension<JavaNullMe
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
LighterAST lighterAst = ((FileContentImpl)inputData).getLighterASTForPsiDependentIndex();
|
||||
LighterAST lighterAst = ((PsiDependentFileContent)inputData).getLighterAST();
|
||||
|
||||
CharSequence text = inputData.getContentAsText();
|
||||
Set<LighterASTNode> calls = findCallsWithNulls(lighterAst, text);
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2000-2019 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.lang.LighterAST;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface PsiDependentFileContent extends FileContent {
|
||||
@Override
|
||||
@NotNull
|
||||
PsiFile getPsiFile();
|
||||
|
||||
@NotNull
|
||||
LighterAST getLighterAST();
|
||||
}
|
||||
@@ -33,6 +33,7 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.indexing.FileContent;
|
||||
import com.intellij.util.indexing.FileContentImpl;
|
||||
import com.intellij.util.indexing.IndexingDataKeys;
|
||||
import com.intellij.util.indexing.PsiDependentFileContent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -65,8 +66,8 @@ public class StubTreeBuilder {
|
||||
}
|
||||
else {
|
||||
CharSequence contentAsText = inputData.getContentAsText();
|
||||
FileContentImpl fileContent = (FileContentImpl)inputData;
|
||||
PsiFile psi = fileContent.getPsiFileForPsiDependentIndex();
|
||||
PsiDependentFileContent fileContent = (PsiDependentFileContent)inputData;
|
||||
PsiFile psi = fileContent.getPsiFile();
|
||||
final FileViewProvider viewProvider = psi.getViewProvider();
|
||||
psi = viewProvider.getStubBindingRoot();
|
||||
psi.putUserData(IndexingDataKeys.FILE_TEXT_CONTENT_KEY, contentAsText);
|
||||
@@ -79,7 +80,7 @@ public class StubTreeBuilder {
|
||||
if (stubFileElementType != null) {
|
||||
final StubBuilder stubBuilder = stubFileElementType.getBuilder();
|
||||
if (stubBuilder instanceof LightStubBuilder) {
|
||||
LightStubBuilder.FORCED_AST.set(fileContent.getLighterASTForPsiDependentIndex());
|
||||
LightStubBuilder.FORCED_AST.set(fileContent.getLighterAST());
|
||||
}
|
||||
data = stubBuilder.buildStubTree(psi);
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ import java.nio.charset.Charset;
|
||||
*
|
||||
* Class is not final since it is overridden in Upsource
|
||||
*/
|
||||
public class FileContentImpl extends UserDataHolderBase implements FileContent {
|
||||
public class FileContentImpl extends UserDataHolderBase implements PsiDependentFileContent {
|
||||
private final VirtualFile myFile;
|
||||
private final String myFileName;
|
||||
private final FileType myFileType;
|
||||
@@ -113,8 +113,9 @@ public class FileContentImpl extends UserDataHolderBase implements FileContent {
|
||||
return psi;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public LighterAST getLighterASTForPsiDependentIndex() {
|
||||
public LighterAST getLighterAST() {
|
||||
LighterAST lighterAST = getUserData(IndexingDataKeys.LIGHTER_AST_NODE_KEY);
|
||||
if (lighterAST == null) {
|
||||
FileASTNode node = getPsiFileForPsiDependentIndex().getNode();
|
||||
|
||||
@@ -122,11 +122,11 @@ public class DuplicatesIndex extends FileBasedIndexExtension<Integer, TIntArrayL
|
||||
if (profile == null || !profile.acceptsContentForIndexing(inputData)) return Collections.emptyMap();
|
||||
|
||||
try {
|
||||
FileContentImpl fileContent = (FileContentImpl)inputData;
|
||||
PsiDependentFileContent fileContent = (PsiDependentFileContent)inputData;
|
||||
|
||||
if (profile instanceof LightDuplicateProfile && ourEnabledLightProfiles) {
|
||||
final THashMap<Integer, TIntArrayList> result = new THashMap<>();
|
||||
LighterAST ast = fileContent.getLighterASTForPsiDependentIndex();
|
||||
LighterAST ast = fileContent.getLighterAST();
|
||||
|
||||
((LightDuplicateProfile)profile).process(ast, new LightDuplicateProfile.Callback() {
|
||||
@Override
|
||||
@@ -144,7 +144,7 @@ public class DuplicatesIndex extends FileBasedIndexExtension<Integer, TIntArrayL
|
||||
MyFragmentsCollector collector = new MyFragmentsCollector(profile, ((LanguageFileType)type).getLanguage());
|
||||
DuplocateVisitor visitor = profile.createVisitor(collector, true);
|
||||
|
||||
visitor.visitNode(fileContent.getPsiFileForPsiDependentIndex());
|
||||
visitor.visitNode(fileContent.getPsiFile());
|
||||
|
||||
return collector.getMap();
|
||||
} catch (StackOverflowError ae) {
|
||||
|
||||
Reference in New Issue
Block a user