more efficient use of indices in stub hierarchy

This commit is contained in:
peter
2016-06-24 14:57:56 +02:00
parent 74276d773a
commit 95b3d482d9
7 changed files with 92 additions and 63 deletions
@@ -29,6 +29,7 @@ public class JavaUnitDescriptor implements DataExternalizer<IndexTree.Unit> {
@Override
public void save(@NotNull DataOutput out, IndexTree.Unit value) throws IOException {
out.writeUTF(value.myPackageId);
out.writeByte(value.myUnitType);
if (value.myUnitType != IndexTree.BYTECODE) {
DataInputOutputUtil.writeINT(out, value.imports.length);
@@ -75,6 +76,7 @@ public class JavaUnitDescriptor implements DataExternalizer<IndexTree.Unit> {
@Override
public IndexTree.Unit read(@NotNull DataInput in) throws IOException {
String pid = in.readUTF();
byte type = in.readByte();
IndexTree.Import[] imports = IndexTree.Import.EMPTY_ARRAY;
if (type != IndexTree.BYTECODE) {
@@ -87,7 +89,7 @@ public class JavaUnitDescriptor implements DataExternalizer<IndexTree.Unit> {
for (int i = 0; i < classes.length; i++) {
classes[i] = readClassDecl(in);
}
return new IndexTree.Unit(type, imports, classes);
return new IndexTree.Unit(pid, type, imports, classes);
}
private IndexTree.ClassDecl readClassDecl(DataInput in) throws IOException {
@@ -16,15 +16,12 @@
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
*/
@@ -37,7 +34,7 @@ public abstract class StubHierarchyIndexer {
* @return a list of pairs <packageName, compilation unit> for a specified file content
*/
@Nullable
public abstract List<Pair<String, IndexTree.Unit>> indexFile(@NotNull FileContent content);
public abstract IndexTree.Unit indexFile(@NotNull FileContent content);
public abstract boolean handlesFile(@NotNull VirtualFile file);