diff --git a/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/HierarchyServiceImpl.java b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/HierarchyServiceImpl.java index 57adaa322744..159a4f6c1db2 100644 --- a/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/HierarchyServiceImpl.java +++ b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/HierarchyServiceImpl.java @@ -15,39 +15,28 @@ */ package com.intellij.psi.stubsHierarchy.impl; +import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressIndicatorProvider; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ProjectFileIndex; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS; +import com.intellij.openapi.vfs.VirtualFileWithId; import com.intellij.psi.impl.java.stubs.hierarchy.IndexTree; -import com.intellij.psi.impl.java.stubs.index.JavaStubIndexKeys; -import com.intellij.psi.stubs.StubIndex; +import com.intellij.psi.search.DelegatingGlobalSearchScope; +import com.intellij.psi.search.EverythingGlobalScope; +import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.stubsHierarchy.HierarchyService; -import com.intellij.psi.stubsHierarchy.stubs.Unit; import com.intellij.psi.util.CachedValue; import com.intellij.psi.util.CachedValueProvider; import com.intellij.psi.util.CachedValuesManager; import com.intellij.psi.util.PsiModificationTracker; import com.intellij.reference.SoftReference; import com.intellij.util.CachedValueBase; -import gnu.trove.THashSet; -import gnu.trove.TObjectHashingStrategy; +import com.intellij.util.indexing.FileBasedIndex; import org.jetbrains.annotations.NotNull; -import java.util.Set; - public class HierarchyServiceImpl extends HierarchyService { - private static final TObjectHashingStrategy UNIT_HASHING_STRATEGY = new TObjectHashingStrategy() { - @Override - public int computeHashCode(Unit object) { - return object.myClasses[0].myClassAnchor.myFileId; - } - - @Override - public boolean equals(Unit o1, Unit o2) { - return computeHashCode(o1) == computeHashCode(o2); - } - }; private static final SingleClassHierarchy EMPTY_HIERARCHY = new SingleClassHierarchy(Symbol.ClassSymbol.EMPTY_ARRAY); private final Project myProject; private final ProjectFileIndex myFileIndex; @@ -99,32 +88,35 @@ public class HierarchyServiceImpl extends HierarchyService { private void loadSymbols(NameEnvironment names, Symbols symbols) { StubEnter stubEnter = new StubEnter(names, symbols); - loadUnits(false, names).forEach(stubEnter::unitEnter); + loadUnits(false, names, stubEnter); stubEnter.connect1(); - loadUnits(true, names).forEach(stubEnter::unitEnter); + loadUnits(true, names, stubEnter); stubEnter.connect2(); } - private Set loadUnits(boolean sourceMode, NameEnvironment names) { - Set result = new THashSet<>(UNIT_HASHING_STRATEGY); - StubIndex.getInstance().processAllKeys(JavaStubIndexKeys.UNITS, myProject, unit -> { - Unit compact = shouldProcess(sourceMode, unit.myFileId) ? Translator.translate(names, unit) : null; - if (compact != null && compact.myClasses.length > 0) { - result.remove(compact); // there can be several (outdated) stub keys for the same file id, only the last one counts - result.add(compact); + private void loadUnits(boolean sourceMode, NameEnvironment names, StubEnter stubEnter) { + GlobalSearchScope scope = new DelegatingGlobalSearchScope(new EverythingGlobalScope(myProject)) { + @Override + public boolean contains(@NotNull VirtualFile file) { + return sourceMode ? myFileIndex.isInSourceContent(file) : myFileIndex.isInLibraryClasses(file); } - return true; - }); - return result; - } + }; + ProgressIndicator indicator = ProgressIndicatorProvider.getGlobalProgressIndicator(); + FileBasedIndex index = FileBasedIndex.getInstance(); + for (String packageName : index.getAllKeys(StubHierarchyIndex.INDEX_ID, myProject)) { + QualifiedName pkg = StringUtil.isEmpty(packageName) ? null : names.fromString(packageName, true); + index.processValues(StubHierarchyIndex.INDEX_ID, packageName, null, new FileBasedIndex.ValueProcessor() { + int count = 0; - private boolean shouldProcess(boolean sourceMode, final int fileId) { - VirtualFile file = PersistentFS.getInstance().findFileById(fileId); - if (file == null) { - return false; + @Override + public boolean process(VirtualFile file, IndexTree.Unit unit) { + if (indicator != null && ++count % 128 == 0) indicator.checkCanceled(); + stubEnter.unitEnter(Translator.internNames(names, unit, ((VirtualFileWithId)file).getId(), pkg)); + return true; + } + }, scope); } - return sourceMode ? myFileIndex.isInSourceContent(file) : myFileIndex.isInLibraryClasses(file); } } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/hierarchy/JavaStubIndexer.java b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/JavaStubIndexer.java similarity index 80% rename from java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/hierarchy/JavaStubIndexer.java rename to java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/JavaStubIndexer.java index 42f30dc08724..b685d2863800 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/hierarchy/JavaStubIndexer.java +++ b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/JavaStubIndexer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,28 +13,55 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.psi.impl.java.stubs.hierarchy; +package com.intellij.psi.stubsHierarchy.impl; +import com.intellij.ide.highlighter.JavaClassFileType; +import com.intellij.ide.highlighter.JavaFileType; +import com.intellij.openapi.fileTypes.FileType; +import com.intellij.openapi.util.Pair; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiModifier; import com.intellij.psi.PsiNameHelper; import com.intellij.psi.PsiReferenceList; import com.intellij.psi.impl.cache.ModifierFlags; import com.intellij.psi.impl.java.stubs.*; +import com.intellij.psi.impl.java.stubs.hierarchy.IndexTree; import com.intellij.psi.impl.java.stubs.hierarchy.IndexTree.*; import com.intellij.psi.impl.java.stubs.impl.PsiClassStubImpl; +import com.intellij.psi.stubs.Stub; import com.intellij.psi.stubs.StubElement; +import com.intellij.psi.stubs.StubTree; +import com.intellij.psi.stubs.StubTreeBuilder; +import com.intellij.psi.stubsHierarchy.StubHierarchyIndexer; import com.intellij.util.ArrayUtil; +import com.intellij.util.indexing.FileContent; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; -public class JavaStubIndexer { +public class JavaStubIndexer extends StubHierarchyIndexer { + + @Override + public int getVersion() { + return 0; + } + + @Override + public boolean handlesFile(@NotNull VirtualFile file) { + FileType fileType = file.getFileType(); + return fileType == JavaFileType.INSTANCE || fileType == JavaClassFileType.INSTANCE; + } @Nullable - public static Unit translate(int fileId, PsiJavaFileStub javaFileStub) { + @Override + public List> indexFile(@NotNull FileContent content) { + Stub stubTree = StubTreeBuilder.buildStubTree(content); + if (!(stubTree instanceof PsiJavaFileStub)) return null; + + PsiJavaFileStub javaFileStub = (PsiJavaFileStub)stubTree; + new StubTree(javaFileStub, false); + ArrayList classList = new ArrayList(); Set usedNames = new HashSet(); for (StubElement el : javaFileStub.getChildrenStubs()) { @@ -54,7 +81,7 @@ public class JavaStubIndexer { ClassDecl[] classes = classList.isEmpty() ? ClassDecl.EMPTY_ARRAY : classList.toArray(new ClassDecl[classList.size()]); Import[] imports = importList.isEmpty() ? Import.EMPTY_ARRAY : importList.toArray(new Import[importList.size()]); byte type = javaFileStub.isCompiled() ? IndexTree.BYTECODE : IndexTree.JAVA; - return new Unit(fileId, javaFileStub.getPackageName(), type, imports, classes); + return Collections.singletonList(Pair.create(javaFileStub.getPackageName(), new Unit(type, imports, classes))); } @Nullable diff --git a/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/StubHierarchyIndex.java b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/StubHierarchyIndex.java new file mode 100644 index 000000000000..f09aea027c2a --- /dev/null +++ b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/StubHierarchyIndex.java @@ -0,0 +1,92 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.stubsHierarchy.impl; + +import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.psi.impl.java.stubs.hierarchy.IndexTree; +import com.intellij.psi.impl.java.stubs.index.JavaUnitDescriptor; +import com.intellij.psi.stubsHierarchy.StubHierarchyIndexer; +import com.intellij.util.indexing.*; +import com.intellij.util.io.DataExternalizer; +import com.intellij.util.io.EnumeratorStringDescriptor; +import com.intellij.util.io.KeyDescriptor; +import org.jetbrains.annotations.NotNull; + +import java.util.*; + +/** + * @author peter + */ +public class StubHierarchyIndex extends FileBasedIndexExtension implements PsiDependentIndex { + static final ID INDEX_ID = ID.create("jvm.hierarchy"); + private static final StubHierarchyIndexer[] ourIndexers = StubHierarchyIndexer.EP_NAME.getExtensions(); + + @NotNull + @Override + public ID getName() { + return INDEX_ID; + } + + @NotNull + @Override + public DataIndexer getIndexer() { + return inputData -> { + for (StubHierarchyIndexer indexer : ourIndexers) { + List> pairs = indexer.handlesFile(inputData.getFile()) ? indexer.indexFile(inputData) : null; + if (pairs != null && !pairs.isEmpty()) { + Map answer = new HashMap<>(); + for (Pair entry : pairs) { + if (entry.second.myDecls.length > 0) { + answer.put(StringUtil.notNullize(entry.first), entry.second); + } + } + return answer; + } + } + return Collections.emptyMap(); + }; + } + + @NotNull + @Override + public KeyDescriptor getKeyDescriptor() { + return EnumeratorStringDescriptor.INSTANCE; + } + + @NotNull + @Override + public DataExternalizer getValueExternalizer() { + return JavaUnitDescriptor.INSTANCE; + } + + @Override + public int getVersion() { + return IndexTree.STUB_HIERARCHY_ENABLED ? 1 + Arrays.stream(ourIndexers).mapToInt(StubHierarchyIndexer::getVersion).sum() : 0; + } + + @NotNull + @Override + public FileBasedIndex.InputFilter getInputFilter() { + return file -> IndexTree.STUB_HIERARCHY_ENABLED && Arrays.stream(ourIndexers).anyMatch(indexer -> indexer.handlesFile(file)); + } + + @Override + public boolean dependsOnFileContent() { + return true; + } + +} diff --git a/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/Translator.java b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/Translator.java index b7617a2860c2..0ad3c8b8d831 100644 --- a/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/Translator.java +++ b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/Translator.java @@ -21,7 +21,7 @@ import com.intellij.psi.PsiNameHelper; import com.intellij.psi.impl.java.stubs.hierarchy.IndexTree; import com.intellij.psi.stubsHierarchy.stubs.*; import com.intellij.util.BitUtil; -import gnu.trove.TLongArrayList; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -75,24 +75,19 @@ public class Translator { return Import.EMPTY_ARRAY; } - public static Unit translate(NameEnvironment nameEnvironment, IndexTree.Unit unit) { - if (unit.myDecls.length == 0) { - return null; - } - QualifiedName pid = StringUtil.isEmpty(unit.myPackageId) ? null : nameEnvironment.fromString(unit.myPackageId, true); - ArrayList classesList = new ArrayList(); - for (IndexTree.ClassDecl def : unit.myDecls) { - ClassDeclaration classDecl = processClassDecl(nameEnvironment, unit.myFileId, def); - classesList.add(classDecl); - } - TLongArrayList importList = new TLongArrayList(); - for (IndexTree.Import anImport : unit.imports) { - importList.add(processImport(nameEnvironment, anImport)); + @NotNull + public static Unit internNames(NameEnvironment nameEnvironment, IndexTree.Unit unit, int fileId, QualifiedName pkg) { + ClassDeclaration[] classes = new ClassDeclaration[unit.myDecls.length]; + for (int i = 0; i < unit.myDecls.length; i++) { + classes[i] = processClassDecl(nameEnvironment, fileId, unit.myDecls[i]); } - long[] imports = importList.isEmpty() ? Import.EMPTY_ARRAY : importList.toNativeArray(); - ClassDeclaration[] classes = classesList.toArray(new ClassDeclaration[classesList.size()]); - return new Unit(pid, imports, classes, unit.myUnitType); + long[] imports = unit.imports.length == 0 ? Import.EMPTY_ARRAY : new long[unit.imports.length]; + for (int i = 0; i < unit.imports.length; i++) { + imports[i] = processImport(nameEnvironment, unit.imports[i]); + } + + return new Unit(pkg, imports, classes, unit.myUnitType); } private static ClassDeclaration processClassDecl(NameEnvironment nameEnvironment, int fileId, IndexTree.ClassDecl def) { diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaUnitKeyDescriptor.java b/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaUnitDescriptor.java similarity index 86% rename from java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaUnitKeyDescriptor.java rename to java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaUnitDescriptor.java index 44d4b4e187f7..bc8d742039b6 100644 --- a/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaUnitKeyDescriptor.java +++ b/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaUnitDescriptor.java @@ -16,22 +16,19 @@ package com.intellij.psi.impl.java.stubs.index; import com.intellij.psi.impl.java.stubs.hierarchy.IndexTree; +import com.intellij.util.io.DataExternalizer; import com.intellij.util.io.DataInputOutputUtil; -import com.intellij.util.io.KeyDescriptor; import org.jetbrains.annotations.NotNull; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; -public class JavaUnitKeyDescriptor implements KeyDescriptor { - public static JavaUnitKeyDescriptor INSTANCE = new JavaUnitKeyDescriptor(); +public class JavaUnitDescriptor implements DataExternalizer { + public static final JavaUnitDescriptor INSTANCE = new JavaUnitDescriptor(); @Override public void save(@NotNull DataOutput out, IndexTree.Unit value) throws IOException { - out.writeInt(value.myFileId); - String pidToWrite = value.myPackageId == null ? "" : value.myPackageId; - out.writeUTF(pidToWrite); out.writeByte(value.myUnitType); if (value.myUnitType != IndexTree.BYTECODE) { DataInputOutputUtil.writeINT(out, value.imports.length); @@ -78,11 +75,6 @@ public class JavaUnitKeyDescriptor implements KeyDescriptor { @Override public IndexTree.Unit read(@NotNull DataInput in) throws IOException { - int fileId = in.readInt(); - String pid = in.readUTF(); - if (pid.isEmpty()) { - pid = null; - } byte type = in.readByte(); IndexTree.Import[] imports = IndexTree.Import.EMPTY_ARRAY; if (type != IndexTree.BYTECODE) { @@ -95,7 +87,7 @@ public class JavaUnitKeyDescriptor implements KeyDescriptor { for (int i = 0; i < classes.length; i++) { classes[i] = readClassDecl(in); } - return new IndexTree.Unit(fileId, pid, type, imports, classes); + return new IndexTree.Unit(type, imports, classes); } private IndexTree.ClassDecl readClassDecl(DataInput in) throws IOException { @@ -130,13 +122,4 @@ public class JavaUnitKeyDescriptor implements KeyDescriptor { } } - @Override - public int getHashCode(IndexTree.Unit value) { - return value.hashCode(); - } - - @Override - public boolean isEqual(IndexTree.Unit val1, IndexTree.Unit val2) { - return val1.equals(val2); - } } diff --git a/java/java-indexing-impl/src/com/intellij/psi/stubsHierarchy/StubHierarchyIndexer.java b/java/java-indexing-impl/src/com/intellij/psi/stubsHierarchy/StubHierarchyIndexer.java new file mode 100644 index 000000000000..ce9d16602224 --- /dev/null +++ b/java/java-indexing-impl/src/com/intellij/psi/stubsHierarchy/StubHierarchyIndexer.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.stubsHierarchy; + +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.openapi.util.Pair; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.impl.java.stubs.hierarchy.IndexTree; +import com.intellij.util.indexing.FileContent; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +/** + * @author peter + */ +public abstract class StubHierarchyIndexer { + public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.hierarchy.indexer"); + + public abstract int getVersion(); + + /** + * @return a list of pairs for a specified file content + */ + @Nullable + public abstract List> indexFile(@NotNull FileContent content); + + public abstract boolean handlesFile(@NotNull VirtualFile file); + +} diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/hierarchy/IndexTree.java b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/hierarchy/IndexTree.java index f7029e757d57..faf27c3a2d7b 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/hierarchy/IndexTree.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/hierarchy/IndexTree.java @@ -37,15 +37,11 @@ public class IndexTree { public static final byte GROOVY = 2; public static class Unit { - public final int myFileId; - public final String myPackageId; public final byte myUnitType; public final Import[] imports; public final ClassDecl[] myDecls; - public Unit(int fileId, String packageId, byte unitType, Import[] imports, ClassDecl[] decls) { - this.myFileId = fileId; - this.myPackageId = packageId; + public Unit(byte unitType, Import[] imports, ClassDecl[] decls) { this.myUnitType = unitType; this.imports = imports; this.myDecls = decls; @@ -58,8 +54,6 @@ public class IndexTree { Unit unit = (Unit)o; - if (myFileId != unit.myFileId) return false; - if (myPackageId != null ? !myPackageId.equals(unit.myPackageId) : unit.myPackageId != null) return false; if (!Arrays.equals(imports, unit.imports)) return false; if (!Arrays.equals(myDecls, unit.myDecls)) return false; @@ -68,11 +62,7 @@ public class IndexTree { @Override public int hashCode() { - int result = myFileId; - result = 31 * result + (myPackageId != null ? myPackageId.hashCode() : 0); - result = 31 * result + Arrays.hashCode(imports); - result = 31 * result + Arrays.hashCode(myDecls); - return result; + return Arrays.hashCode(myDecls); } } @@ -133,6 +123,7 @@ public class IndexTree { public ClassDecl(int stubId, int mods, String name, String[] supers, Decl[] decls) { super(decls); + assert stubId > 0; this.myStubId = stubId; this.myMods = mods; this.myName = name; @@ -158,8 +149,6 @@ public class IndexTree { int result = myStubId; result = 31 * result + myMods; result = 31 * result + (myName != null ? myName.hashCode() : 0); - result = 31 * result + Arrays.hashCode(mySupers); - result = 31 * result + Arrays.hashCode(myDecls); return result; } } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/stubs/hierarchy/GrStubIndexer.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/stubs/hierarchy/GrStubIndexer.java index 427f8dfc5b0f..2a9303c09d62 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/stubs/hierarchy/GrStubIndexer.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/stubs/hierarchy/GrStubIndexer.java @@ -15,25 +15,46 @@ */ package org.jetbrains.plugins.groovy.lang.psi.stubs.hierarchy; +import com.intellij.openapi.util.Pair; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiNameHelper; import com.intellij.psi.impl.java.stubs.hierarchy.IndexTree; import com.intellij.psi.impl.java.stubs.hierarchy.IndexTree.*; +import com.intellij.psi.stubs.Stub; import com.intellij.psi.stubs.StubElement; +import com.intellij.psi.stubs.StubTree; +import com.intellij.psi.stubs.StubTreeBuilder; +import com.intellij.psi.stubsHierarchy.StubHierarchyIndexer; import com.intellij.util.ArrayUtil; +import com.intellij.util.indexing.FileContent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.plugins.groovy.GroovyFileType; import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes; import org.jetbrains.plugins.groovy.lang.psi.stubs.*; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; -public class GrStubIndexer { +public class GrStubIndexer extends StubHierarchyIndexer { + @Override + public int getVersion() { + return 0; + } + + @Override + public boolean handlesFile(@NotNull VirtualFile file) { + return file.getFileType() == GroovyFileType.GROOVY_FILE_TYPE; + } + + @Nullable + @Override + public List> indexFile(@NotNull FileContent content) { + Stub stubTree = StubTreeBuilder.buildStubTree(content); + if (!(stubTree instanceof GrFileStub)) return null; + + GrFileStub grFileStub = (GrFileStub)stubTree; + new StubTree(grFileStub, false); - @NotNull - public static Unit translate(int fileId, GrFileStub grFileStub) { String pid = null; ArrayList classList = new ArrayList(); Set usedNames = new HashSet(); @@ -61,8 +82,7 @@ public class GrStubIndexer { } ClassDecl[] classes = classList.isEmpty() ? ClassDecl.EMPTY_ARRAY : classList.toArray(new ClassDecl[classList.size()]); Import[] imports = importList.isEmpty() ? Import.EMPTY_ARRAY : importList.toArray(new Import[importList.size()]); - return new Unit(fileId, pid, IndexTree.GROOVY, imports, classes); - + return Collections.singletonList(Pair.create(pid, new Unit(IndexTree.GROOVY, imports, classes))); } @Nullable diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml index dee1183f4f9a..a82e2d5a89b1 100644 --- a/plugins/groovy/src/META-INF/plugin.xml +++ b/plugins/groovy/src/META-INF/plugin.xml @@ -573,6 +573,8 @@ + + diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index 3075fc008d19..3e6979b3c443 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -180,6 +180,8 @@ + + @@ -1542,7 +1544,6 @@ - @@ -1736,6 +1737,9 @@ serviceImplementation="com.intellij.codeInspection.bytecodeAnalysis.ProjectBytecodeAnalysis"/> + + +