mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
revive stub hierarchy, controlled by a registry property
This commit is contained in:
@@ -17,7 +17,6 @@ package com.intellij.psi.stubsHierarchy.impl;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.psi.PsiClassOwner;
|
||||
import com.intellij.psi.impl.java.stubs.hierarchy.IndexTree;
|
||||
import com.intellij.psi.stubsHierarchy.stubs.Unit;
|
||||
@@ -28,7 +27,6 @@ public class HierarchyService {
|
||||
|
||||
public static boolean PROCESS_PSI = true;
|
||||
public static boolean IGNORE_LOCAL_CLASSES = true;
|
||||
public static final String HIERARCHY_SERVICE = "java.hierarchy.service";
|
||||
|
||||
private NameEnvironment myNameEnvironment;
|
||||
private SoftReference<NameEnvironment> myNamesCache = new SoftReference<NameEnvironment>(null);
|
||||
@@ -42,10 +40,6 @@ public class HierarchyService {
|
||||
return ServiceManager.getService(project, HierarchyService.class);
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
return Registry.is(HIERARCHY_SERVICE);
|
||||
}
|
||||
|
||||
public HierarchyService() {
|
||||
clear();
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@ package com.intellij.psi.stubsHierarchy.impl.test;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.psi.stubsHierarchy.impl.HierarchyService;
|
||||
import com.intellij.psi.impl.java.stubs.hierarchy.IndexTree;
|
||||
|
||||
public abstract class InheritanceAction extends AnAction {
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
e.getPresentation().setVisible(HierarchyService.isEnabled());
|
||||
e.getPresentation().setVisible(IndexTree.STUB_HIERARCHY_ENABLED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.psi.impl.java.stubs.hierarchy;
|
||||
|
||||
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.psi.impl.java.stubs.JavaClassElementType;
|
||||
import com.intellij.psi.stubs.IStubElementType;
|
||||
import com.intellij.util.BitUtil;
|
||||
@@ -23,6 +24,8 @@ import com.intellij.util.BitUtil;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class IndexTree {
|
||||
public static final boolean STUB_HIERARCHY_ENABLED = Registry.is("java.hierarchy.service");
|
||||
|
||||
public final static int PACKAGE = 1 << 0;
|
||||
public final static int CLASS = 1 << 1;
|
||||
public static final int STATIC = 1 << 3;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class JavaFileElementType extends ILightStubFileElementType<PsiJavaFileSt
|
||||
|
||||
@Override
|
||||
public int getStubVersion() {
|
||||
return STUB_VERSION;
|
||||
return STUB_VERSION + (IndexTree.STUB_HIERARCHY_ENABLED ? 1 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,11 +111,12 @@ public class JavaFileElementType extends ILightStubFileElementType<PsiJavaFileSt
|
||||
|
||||
@Override
|
||||
public void indexStub(@NotNull final PsiJavaFileStub stub, @NotNull final IndexSink sink) {
|
||||
Integer fileId = stub.getUserData(IndexingDataKeys.VIRTUAL_FILE_ID);
|
||||
if (fileId == null) return;
|
||||
IndexTree.Unit unit = JavaStubIndexer.translate(fileId, stub);
|
||||
if (unit != null) {
|
||||
sink.occurrence(JavaStubIndexKeys.UNITS, unit);
|
||||
if (IndexTree.STUB_HIERARCHY_ENABLED) {
|
||||
Integer fileId = stub.getUserData(IndexingDataKeys.VIRTUAL_FILE_ID);
|
||||
IndexTree.Unit unit = fileId == null ? null : JavaStubIndexer.translate(fileId, stub);
|
||||
if (unit != null) {
|
||||
sink.occurrence(JavaStubIndexKeys.UNITS, unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-10
@@ -88,7 +88,7 @@ public class GrStubFileElementType extends IStubFileElementType<GrFileStub> {
|
||||
|
||||
@Override
|
||||
public int getStubVersion() {
|
||||
return super.getStubVersion() + 28;
|
||||
return super.getStubVersion() + 28 + (IndexTree.STUB_HIERARCHY_ENABLED ? 1 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,11 +97,6 @@ public class GrStubFileElementType extends IStubFileElementType<GrFileStub> {
|
||||
return "groovy.FILE";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void indexStub(@NotNull PsiFileStub stub, @NotNull IndexSink sink) {
|
||||
super.indexStub(stub, sink);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(@NotNull final GrFileStub stub, @NotNull final StubOutputStream dataStream) throws IOException {
|
||||
dataStream.writeName(stub.getName().toString());
|
||||
@@ -131,10 +126,12 @@ public class GrStubFileElementType extends IStubFileElementType<GrFileStub> {
|
||||
sink.occurrence(GrAnnotatedMemberIndex.KEY, anno);
|
||||
}
|
||||
|
||||
Integer fileId = stub.getUserData(IndexingDataKeys.VIRTUAL_FILE_ID);
|
||||
if (fileId == null) return;
|
||||
IndexTree.Unit unit = GrStubIndexer.translate(fileId, stub);
|
||||
sink.occurrence(JavaStubIndexKeys.UNITS, unit);
|
||||
if (IndexTree.STUB_HIERARCHY_ENABLED) {
|
||||
Integer fileId = stub.getUserData(IndexingDataKeys.VIRTUAL_FILE_ID);
|
||||
if (fileId == null) return;
|
||||
IndexTree.Unit unit = GrStubIndexer.translate(fileId, stub);
|
||||
sink.occurrence(JavaStubIndexKeys.UNITS, unit);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.java.stubs.hierarchy.IndexTree;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.PsiElementProcessor;
|
||||
import com.intellij.psi.search.PsiElementProcessorAdapter;
|
||||
@@ -39,7 +40,6 @@ import com.intellij.psi.stubsHierarchy.impl.HierarchyService;
|
||||
import com.intellij.psi.stubsHierarchy.impl.SingleClassHierarchy;
|
||||
import com.intellij.psi.stubsHierarchy.impl.SmartClassAnchor;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -55,7 +55,7 @@ public class ConfigurationUtil {
|
||||
GlobalSearchScope projectScopeWithoutLibraries = GlobalSearchScope.projectScope(project);
|
||||
final GlobalSearchScope scope = projectScopeWithoutLibraries.intersectWith(testClassFilter.getScope());
|
||||
|
||||
SingleClassHierarchy symbols = HierarchyService.isEnabled() ? HierarchyService.instance(project).getSingleClassHierarchy() : null;
|
||||
SingleClassHierarchy symbols = IndexTree.STUB_HIERARCHY_ENABLED ? HierarchyService.instance(project).getSingleClassHierarchy() : null;
|
||||
|
||||
if (symbols != null) {
|
||||
SmartClassAnchor[] candidates = symbols.getAllSubtypes(testClassFilter.getBase());
|
||||
|
||||
Reference in New Issue
Block a user