From 141aec46d7ce4e35d8bf406d4435146d2e540e9a Mon Sep 17 00:00:00 2001 From: peter Date: Sat, 25 Jun 2016 17:06:45 +0200 Subject: [PATCH] stub hierarchy: allocate less intermediate objects during reading --- .../{ClassAnchor.java => CompactArray.java} | 24 +++-- .../impl/HierarchyServiceImpl.java | 3 +- .../{stubs/Import.java => impl/Imports.java} | 6 +- .../stubsHierarchy/impl/NameEnvironment.java | 4 +- .../stubsHierarchy/impl/StubClassAnchor.java | 6 +- .../psi/stubsHierarchy/impl/StubEnter.java | 96 +++++++++++++------ .../psi/stubsHierarchy/impl/StubResolver.java | 12 +-- .../psi/stubsHierarchy/impl/Symbol.java | 18 +--- .../psi/stubsHierarchy/impl/Symbols.java | 18 ++-- .../psi/stubsHierarchy/impl/Translator.java | 83 ++-------------- .../{stubs => impl}/UnitInfo.java | 12 +-- .../stubs/ClassDeclaration.java | 39 -------- .../psi/stubsHierarchy/stubs/Declaration.java | 27 ------ .../stubs/MemberDeclaration.java | 22 ----- .../psi/stubsHierarchy/stubs/Unit.java | 31 ------ 15 files changed, 122 insertions(+), 279 deletions(-) rename java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/{ClassAnchor.java => CompactArray.java} (52%) rename java/java-impl/src/com/intellij/psi/stubsHierarchy/{stubs/Import.java => impl/Imports.java} (90%) rename java/java-impl/src/com/intellij/psi/stubsHierarchy/{stubs => impl}/UnitInfo.java (87%) delete mode 100644 java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/ClassDeclaration.java delete mode 100644 java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/Declaration.java delete mode 100644 java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/MemberDeclaration.java delete mode 100644 java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/Unit.java diff --git a/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/ClassAnchor.java b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/CompactArray.java similarity index 52% rename from java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/ClassAnchor.java rename to java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/CompactArray.java index 7b8f46e932ac..3ef96d52169c 100644 --- a/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/ClassAnchor.java +++ b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/CompactArray.java @@ -15,15 +15,19 @@ */ package com.intellij.psi.stubsHierarchy.impl; -public class ClassAnchor { - final int myFileId; - final int myStubId; - - public static final ClassAnchor[] EMPTY_ARRAY = new ClassAnchor[0]; - - ClassAnchor(int fileId, int stubId) { - myFileId = fileId; - myStubId = stubId; - } +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +/** + * This annotation exists for documentation purposes only.

+ * + * The value annotated with this annotation is used to save memory when storing mostly-singular or empty collections. + * For empty collection, 'null' value is used. For one-element collection, the value is the single element. Otherwise, + * an array is used. Possible component types are specified in the annotation value. + * + * @author peter + */ +@Retention(RetentionPolicy.SOURCE) +public @interface CompactArray { + Class[] value(); } 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 2583ea48770b..ae95dc7c283a 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 @@ -88,8 +88,7 @@ public class HierarchyServiceImpl extends HierarchyService { public boolean process(int fileId, IndexTree.Unit unit) { if (indicator != null && ++count % 128 == 0) indicator.checkCanceled(); if (files.get(fileId)) { - QualifiedName pkg = unit.myPackageName.length == 0 ? null : names.myNamesEnumerator.getFullName(unit.myPackageName, true); - stubEnter.unitEnter(Translator.internNames(names, unit, fileId, pkg)); + stubEnter.unitEnter(unit, fileId); } return true; } diff --git a/java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/Import.java b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/Imports.java similarity index 90% rename from java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/Import.java rename to java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/Imports.java index ea74f0383e83..c5b45aa8287f 100644 --- a/java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/Import.java +++ b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/Imports.java @@ -13,14 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.psi.stubsHierarchy.stubs; +package com.intellij.psi.stubsHierarchy.impl; -import com.intellij.psi.stubsHierarchy.impl.NameEnvironment; -import com.intellij.psi.stubsHierarchy.impl.QualifiedName; import com.intellij.util.ArrayUtil; import com.intellij.util.BitUtil; -public class Import { +public class Imports { public final static long[] EMPTY_ARRAY = ArrayUtil.EMPTY_LONG_ARRAY; public static final int onDemandMask = 1 << 29; diff --git a/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/NameEnvironment.java b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/NameEnvironment.java index 0d5e4144ff5c..4a2d5f3402a9 100644 --- a/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/NameEnvironment.java +++ b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/NameEnvironment.java @@ -26,7 +26,7 @@ public class NameEnvironment extends UserDataHolderBase { public final QualifiedName empty; public final QualifiedName java_lang; public final QualifiedName java_lang_Enum; - public final QualifiedName[] annotation; + public final QualifiedName annotation; public final NamesEnumerator myNamesEnumerator; public NameEnvironment() { @@ -34,7 +34,7 @@ public class NameEnvironment extends UserDataHolderBase { empty = myNamesEnumerator.getFullName(new int[]{}, true); java_lang = fromString("java.lang", true); java_lang_Enum = fromString("java.lang.Enum", true); - annotation = new QualifiedName[]{fromString("java.lang.annotation.Annotation", true)}; + annotation = fromString("java.lang.annotation.Annotation", true); } @Nullable diff --git a/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/StubClassAnchor.java b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/StubClassAnchor.java index 53b5067f2d90..940e734038ba 100644 --- a/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/StubClassAnchor.java +++ b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/StubClassAnchor.java @@ -40,10 +40,10 @@ public class StubClassAnchor extends SmartClassAnchor { public final int myFileId; final int myStubId; - StubClassAnchor(int symbolId, ClassAnchor classAnchor) { + StubClassAnchor(int symbolId, int fileId, int stubId) { myId = symbolId; - myFileId = classAnchor.myFileId; - myStubId = classAnchor.myStubId; + myFileId = fileId; + myStubId = stubId; } @Override diff --git a/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/StubEnter.java b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/StubEnter.java index 5d1b7d94904b..9dd9c22425b9 100644 --- a/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/StubEnter.java +++ b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/StubEnter.java @@ -16,7 +16,7 @@ package com.intellij.psi.stubsHierarchy.impl; import com.intellij.psi.impl.java.stubs.hierarchy.IndexTree; -import com.intellij.psi.stubsHierarchy.stubs.*; +import com.intellij.util.BitUtil; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -25,9 +25,9 @@ import java.util.Arrays; import static com.intellij.psi.stubsHierarchy.impl.Symbol.*; public class StubEnter { - private NameEnvironment myNameEnvironment; - private Symbols mySymbols; - private StubHierarchyConnector myStubHierarchyConnector; + private final NameEnvironment myNameEnvironment; + private final Symbols mySymbols; + private final StubHierarchyConnector myStubHierarchyConnector; private ArrayList uncompleted = new ArrayList(); @@ -37,22 +37,37 @@ public class StubEnter { myStubHierarchyConnector = new StubHierarchyConnector(myNameEnvironment, symbols); } - void unitEnter(Unit tree) { - PackageSymbol pkg = tree.myPackageId != null ? mySymbols.enterPackage(tree.myPackageId) : mySymbols.myRootPackage; - enter(tree.myClasses, tree.myUnitInfo, pkg, pkg.myQualifiedName); + void unitEnter(IndexTree.Unit unit, int fileId) { + PackageSymbol pkg = unit.myPackageName.length > 0 + ? mySymbols.enterPackage(myNameEnvironment.myNamesEnumerator.getFullName(unit.myPackageName, true)) + : mySymbols.myRootPackage; + enter(unit.myDecls, UnitInfo.mkUnitInfo(unit.myUnitType, internImports(unit)), pkg, pkg.myQualifiedName, fileId); } - private void enter(ClassDeclaration[] trees, UnitInfo info, Symbol owner, @Nullable QualifiedName ownerName) { - for (ClassDeclaration tree : trees) { - enter(tree, info, owner, ownerName); + private long[] internImports(IndexTree.Unit unit) { + long[] imports = unit.imports.length == 0 ? Imports.EMPTY_ARRAY : new long[unit.imports.length]; + for (int i = 0; i < unit.imports.length; i++) { + imports[i] = processImport(unit.imports[i]); + } + return imports; + } + + private long processImport(IndexTree.Import anImport) { + QualifiedName fullname = myNameEnvironment.myNamesEnumerator.getFullName(anImport.myFullname, true); + return Imports.mkImport(fullname, anImport.myStaticImport, anImport.myOnDemand, anImport.myAlias); + } + + private void enter(IndexTree.ClassDecl[] trees, UnitInfo info, Symbol owner, @Nullable QualifiedName ownerName, int fileId) { + for (IndexTree.ClassDecl tree : trees) { + enter(tree, info, owner, ownerName, fileId); } } - private ClassSymbol[] enter(Declaration[] trees, UnitInfo info, Symbol owner, @Nullable QualifiedName ownerName) { + private ClassSymbol[] enter(IndexTree.Decl[] trees, UnitInfo info, Symbol owner, @Nullable QualifiedName ownerName, int fileId) { ClassSymbol[] members = new ClassSymbol[trees.length]; int i = 0; - for (Declaration tree : trees) { - ClassSymbol member = enter(tree, info, owner, ownerName); + for (IndexTree.Decl tree : trees) { + ClassSymbol member = enter(tree, info, owner, ownerName, fileId); if (member != null && member.myShortName != 0) { members[i++] = member; } @@ -66,47 +81,68 @@ public class StubEnter { return members; } - private ClassSymbol enter(Declaration tree, UnitInfo info, Symbol owner, QualifiedName ownerName) { - if (tree instanceof ClassDeclaration) { - return classEnter((ClassDeclaration)tree, info, owner, ownerName); + private ClassSymbol enter(IndexTree.Decl tree, UnitInfo info, Symbol owner, QualifiedName ownerName, int fileId) { + if (tree instanceof IndexTree.ClassDecl) { + return classEnter((IndexTree.ClassDecl)tree, info, owner, ownerName, fileId); } - if (tree instanceof MemberDeclaration) { - memberEnter((MemberDeclaration)tree, info, owner, ownerName); + if (tree instanceof IndexTree.MemberDecl) { + memberEnter((IndexTree.MemberDecl)tree, info, owner, ownerName, fileId); return null; } return null; } - private void memberEnter(MemberDeclaration tree, UnitInfo info, Symbol owner, @Nullable QualifiedName ownerName) { + private void memberEnter(IndexTree.MemberDecl tree, UnitInfo info, Symbol owner, @Nullable QualifiedName ownerName, int fileId) { MemberSymbol mc = new MemberSymbol(owner); - ClassSymbol[] members = enter(tree.myDeclarations, info, mc, ownerName); - mc.setMembers(members); + mc.setMembers(enter(tree.myDecls, info, mc, ownerName, fileId)); } - private ClassSymbol classEnter(ClassDeclaration tree, UnitInfo info, Symbol owner, @Nullable QualifiedName ownerName) { - int flags = checkFlags(tree.mods, owner); + private ClassSymbol classEnter(IndexTree.ClassDecl tree, UnitInfo info, Symbol owner, @Nullable QualifiedName ownerName, int fileId) { + int flags = checkFlags(tree.myMods, owner); if (info.getType() == IndexTree.BYTECODE) { flags |= IndexTree.COMPILED; } - QualifiedName[] supers = tree.mySupers; - if ((tree.mods & IndexTree.ANNOTATION) != 0) { - supers = myNameEnvironment.annotation; - } int name = tree.myName; QualifiedName qname = name == NamesEnumerator.NO_NAME || ownerName == null ? null : myNameEnvironment.qualifiedName(ownerName, name, true); - ClassSymbol classSymbol = mySymbols.enterClass(tree.myClassAnchor, flags, name, owner, info, supers, qname); + @CompactArray(QualifiedName.class) Object supers = internSupers(tree.myMods, tree.mySupers); + ClassSymbol classSymbol = mySymbols.enterClass(fileId, tree.myStubId, flags, name, owner, info, supers, qname); if (uncompleted != null) { uncompleted.add(classSymbol); } - if (tree.myDeclarations.length > 0) { - classSymbol.setMembers(enter(tree.myDeclarations, info, classSymbol, qname)); + if (tree.myDecls.length > 0) { + classSymbol.setMembers(enter(tree.myDecls, info, classSymbol, qname, fileId)); } return classSymbol; } + @Nullable + @CompactArray(QualifiedName.class) + private Object internSupers(int flags, int[][] superNames) { + if (BitUtil.isSet(flags, IndexTree.ANNOTATION)) { + return myNameEnvironment.annotation; + } + + boolean isEnum = BitUtil.isSet(flags, IndexTree.ENUM); + if (superNames.length == 0) { + return isEnum ? myNameEnvironment.java_lang_Enum : null; + } + if (superNames.length == 1 && !isEnum) { + return myNameEnvironment.concat(superNames[0], true); + } + + QualifiedName[] array = new QualifiedName[superNames.length + (isEnum ? 1 : 0)]; + for (int i = 0; i < superNames.length; i++) { + array[i] = myNameEnvironment.concat(superNames[i], true); + } + if (isEnum) { + array[array.length - 1] = myNameEnvironment.java_lang_Enum; + } + return array; + } + public void connect1() { for (ClassSymbol classSymbol : uncompleted) { classSymbol.connect(myStubHierarchyConnector); diff --git a/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/StubResolver.java b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/StubResolver.java index 6ebfce8b5f0b..49737500f391 100644 --- a/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/StubResolver.java +++ b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/StubResolver.java @@ -16,8 +16,6 @@ package com.intellij.psi.stubsHierarchy.impl; import com.intellij.psi.impl.java.stubs.hierarchy.IndexTree; -import com.intellij.psi.stubsHierarchy.stubs.Import; -import com.intellij.psi.stubsHierarchy.stubs.UnitInfo; import com.intellij.util.BitUtil; import org.jetbrains.annotations.NotNull; @@ -130,9 +128,9 @@ public class StubResolver { } public void handleImport(long tree, int name, Set symbols) throws IncompleteHierarchyException { - QualifiedName fullname = Import.getFullName(tree, myNameEnvironment); - if (Import.isOnDemand(tree)) { - if (Import.isStatic(tree)) { + QualifiedName fullname = Imports.getFullName(tree, myNameEnvironment); + if (Imports.isOnDemand(tree)) { + if (Imports.isStatic(tree)) { for (Symbol.ClassSymbol p : findGlobalType(fullname)) importNamedStatic(p, name, symbols); } @@ -146,11 +144,11 @@ public class StubResolver { return; } int shortName = myNameEnvironment.shortName(fullname); - int alias = Import.getAlias(tree); + int alias = Imports.getAlias(tree); boolean shouldImport = ((alias & name) == name) || shortName == name; if (!shouldImport) return; - if (Import.isStatic(tree)) { + if (Imports.isStatic(tree)) { for (Symbol.ClassSymbol s : findGlobalType(prefix)) importNamedStatic(s, shortName, symbols); } diff --git a/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/Symbol.java b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/Symbol.java index 4eb2f6f81d5e..500d777c159a 100644 --- a/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/Symbol.java +++ b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/Symbol.java @@ -16,7 +16,6 @@ package com.intellij.psi.stubsHierarchy.impl; import com.intellij.psi.impl.java.stubs.hierarchy.IndexTree; -import com.intellij.psi.stubsHierarchy.stubs.UnitInfo; import com.intellij.util.BitUtil; import gnu.trove.TIntHashSet; import org.jetbrains.annotations.NotNull; @@ -90,13 +89,7 @@ public abstract class Symbol { public static final ClassSymbol[] EMPTY_ARRAY = new ClassSymbol[0]; final StubClassAnchor myClassAnchor; - - /** - * null for empty 'supers' list - * ClassSymbol/QualifiedName for a single resolved/unresolved super - * ClassSymbol[]/QualifiedName[] for multiple resolved/unresolved supers - */ - Object mySuperClasses; + @CompactArray({QualifiedName.class, ClassSymbol.class}) Object mySuperClasses; UnitInfo myUnitInfo; ClassSymbol(StubClassAnchor classAnchor, @@ -104,10 +97,10 @@ public abstract class Symbol { Symbol owner, int name, UnitInfo unitInfo, - QualifiedName[] supers) { + @CompactArray(QualifiedName.class) Object supers) { super(flags | IndexTree.CLASS, owner, name); this.myClassAnchor = classAnchor; - this.mySuperClasses = supers.length == 0 ? null : supers.length == 1 ? supers[0] : supers; + this.mySuperClasses = supers; this.myUnitInfo = unitInfo; } @@ -183,10 +176,7 @@ public abstract class Symbol { * Represents methods, fields and other constructs that may contain anonymous or local classes. */ public static class MemberSymbol extends Symbol { - /** - * null when no members, or a single ClassSymbol, or ClassSymbol[] - */ - private Object myMembers = null; + @CompactArray(ClassSymbol.class) private Object myMembers = null; MemberSymbol(Symbol owner) { super(IndexTree.MEMBER, owner, NamesEnumerator.NO_NAME); diff --git a/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/Symbols.java b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/Symbols.java index 5b026932de72..dbd581f0dab9 100644 --- a/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/Symbols.java +++ b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/Symbols.java @@ -2,7 +2,6 @@ package com.intellij.psi.stubsHierarchy.impl; import com.intellij.psi.stubsHierarchy.impl.Symbol.ClassSymbol; import com.intellij.psi.stubsHierarchy.impl.Symbol.PackageSymbol; -import com.intellij.psi.stubsHierarchy.stubs.UnitInfo; import gnu.trove.TIntObjectHashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -63,14 +62,15 @@ public class Symbols { return (ClassSymbol[])cs; } - public ClassSymbol enterClass(ClassAnchor classAnchor, - int flags, - int shortName, - Symbol owner, - UnitInfo info, - QualifiedName[] supers, - @Nullable QualifiedName qualifiedName) { - StubClassAnchor stubClassAnchor = new StubClassAnchor(myClassSymbols.size(), classAnchor); + ClassSymbol enterClass(int fileId, + int stubId, + int flags, + int shortName, + Symbol owner, + UnitInfo info, + @CompactArray(QualifiedName.class) Object supers, + @Nullable QualifiedName qualifiedName) { + StubClassAnchor stubClassAnchor = new StubClassAnchor(myClassSymbols.size(), fileId, stubId); ClassSymbol c = new ClassSymbol(stubClassAnchor, flags, owner, shortName, info, supers); myClassSymbols.add(c); if (qualifiedName != null) { 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 1367d003dd4e..9baa9d08e2e0 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 @@ -17,11 +17,6 @@ package com.intellij.psi.stubsHierarchy.impl; import com.intellij.openapi.util.Key; import com.intellij.psi.impl.java.stubs.hierarchy.IndexTree; -import com.intellij.psi.stubsHierarchy.stubs.*; -import com.intellij.util.BitUtil; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; public class Translator { private static final Key DEFAULT_JAVA_IMPORTS_KEY = Key.create("java_imports"); @@ -38,7 +33,7 @@ public class Translator { private static long[] createDefaultJavaImports(NameEnvironment nameEnvironment) { return new long[]{ - Import.mkImport(nameEnvironment.fromString("java.lang", true), false, true, 0) + Imports.mkImport(nameEnvironment.fromString("java.lang", true), false, true, 0) }; } @@ -53,14 +48,14 @@ public class Translator { private static long[] createDefaultGroovyImports(NameEnvironment nameEnvironment) { return new long[] { - Import.mkImport(nameEnvironment.fromString("java.lang", true), false, true, 0), - Import.mkImport(nameEnvironment.fromString("java.util", true), false, true, 0), - Import.mkImport(nameEnvironment.fromString("java.io", true), false, true, 0), - Import.mkImport(nameEnvironment.fromString("java.net", true), false, true, 0), - Import.mkImport(nameEnvironment.fromString("groovy.lang", true), false, true, 0), - Import.mkImport(nameEnvironment.fromString("groovy.util", true), false, true, 0), - Import.mkImport(nameEnvironment.fromString("java.math.BigInteger", true), false, true, 0), - Import.mkImport(nameEnvironment.fromString("java.math.BigDecimal", true), false, true, 0), + Imports.mkImport(nameEnvironment.fromString("java.lang", true), false, true, 0), + Imports.mkImport(nameEnvironment.fromString("java.util", true), false, true, 0), + Imports.mkImport(nameEnvironment.fromString("java.io", true), false, true, 0), + Imports.mkImport(nameEnvironment.fromString("java.net", true), false, true, 0), + Imports.mkImport(nameEnvironment.fromString("groovy.lang", true), false, true, 0), + Imports.mkImport(nameEnvironment.fromString("groovy.util", true), false, true, 0), + Imports.mkImport(nameEnvironment.fromString("java.math.BigInteger", true), false, true, 0), + Imports.mkImport(nameEnvironment.fromString("java.math.BigDecimal", true), false, true, 0), }; } @@ -69,65 +64,7 @@ public class Translator { return getDefaultJavaImports(nameEnvironment); if (type == IndexTree.GROOVY) return getDefaultGroovyImports(nameEnvironment); - return Import.EMPTY_ARRAY; - } - - @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 = 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) { - int name = def.myName; - ArrayList superList = new ArrayList(); - for (int[] aSuper : def.mySupers) { - superList.add(nameEnvironment.concat(aSuper, true)); - } - if (BitUtil.isSet(def.myMods, IndexTree.ENUM)) { - superList.add(nameEnvironment.java_lang_Enum); - } - ArrayList innerDefList = new ArrayList(); - for (IndexTree.Decl decl : def.myDecls) { - Declaration hTree = processMember(nameEnvironment, fileId, decl); - if (hTree != null) { - innerDefList.add(hTree); - } - } - - ClassAnchor anchor = new ClassAnchor(fileId, def.myStubId); - QualifiedName[] supers = superList.isEmpty() ? QualifiedName.EMPTY_ARRAY : superList.toArray(new QualifiedName[superList.size()]); - Declaration[] innerDefs = innerDefList.isEmpty() ? Declaration.EMPTY_ARRAY : innerDefList.toArray(new Declaration[innerDefList.size()]); - return new ClassDeclaration(anchor, def.myMods, name, supers, innerDefs); - } - - private static Declaration processMember(NameEnvironment nameEnvironment, int fileId, IndexTree.Decl decl) { - if (decl instanceof IndexTree.ClassDecl) { - return processClassDecl(nameEnvironment, fileId, (IndexTree.ClassDecl)decl); - } - ArrayList defList = new ArrayList(); - for (IndexTree.Decl def : ((IndexTree.MemberDecl)decl).myDecls) { - Declaration hTree = processMember(nameEnvironment, fileId, def); - if (hTree != null) { - defList.add(hTree); - } - } - Declaration[] defs = defList.toArray(new Declaration[defList.size()]); - return new MemberDeclaration(defs); - } - - private static long processImport(NameEnvironment nameEnvironment, IndexTree.Import anImport) { - QualifiedName fullname = nameEnvironment.myNamesEnumerator.getFullName(anImport.myFullname, true); - return Import.mkImport(fullname, anImport.myStaticImport, anImport.myOnDemand, anImport.myAlias); + return Imports.EMPTY_ARRAY; } } diff --git a/java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/UnitInfo.java b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/UnitInfo.java similarity index 87% rename from java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/UnitInfo.java rename to java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/UnitInfo.java index 79b506eed7b4..6106dc19a4ec 100644 --- a/java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/UnitInfo.java +++ b/java/java-impl/src/com/intellij/psi/stubsHierarchy/impl/UnitInfo.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,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.psi.stubsHierarchy.stubs; +package com.intellij.psi.stubsHierarchy.impl; import com.intellij.psi.impl.java.stubs.hierarchy.IndexTree; public abstract class UnitInfo { private static final UnitInfo[] EMPTY_INFOS = new UnitInfo[]{ - new LongUnitInfo(IndexTree.BYTECODE, Import.EMPTY_ARRAY), - new LongUnitInfo(IndexTree.JAVA, Import.EMPTY_ARRAY), - new LongUnitInfo(IndexTree.GROOVY, Import.EMPTY_ARRAY) + new LongUnitInfo(IndexTree.BYTECODE, Imports.EMPTY_ARRAY), + new LongUnitInfo(IndexTree.JAVA, Imports.EMPTY_ARRAY), + new LongUnitInfo(IndexTree.GROOVY, Imports.EMPTY_ARRAY) }; static UnitInfo mkUnitInfo(byte unitType, long[] imports) { @@ -29,7 +29,7 @@ public abstract class UnitInfo { return EMPTY_INFOS[unitType]; } for (long anImport : imports) { - if (Import.getAlias(anImport) != 0) { + if (Imports.getAlias(anImport) != 0) { return new LongUnitInfo(unitType, imports); } } diff --git a/java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/ClassDeclaration.java b/java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/ClassDeclaration.java deleted file mode 100644 index 1d880bf75c05..000000000000 --- a/java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/ClassDeclaration.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2000-2015 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.stubs; - -import com.intellij.psi.stubsHierarchy.impl.ClassAnchor; -import com.intellij.psi.stubsHierarchy.impl.QualifiedName; - -public final class ClassDeclaration extends Declaration { - public final int mods; - public final int myName; - public final ClassAnchor myClassAnchor; - public QualifiedName[] mySupers; - - public ClassDeclaration(ClassAnchor classAnchor, - int mods, - int name, - QualifiedName[] supers, - Declaration[] declarations) - { - super(declarations); - this.myClassAnchor = classAnchor; - this.mods = mods; - this.myName = name; - this.mySupers = supers; - } -} diff --git a/java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/Declaration.java b/java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/Declaration.java deleted file mode 100644 index bc55a481fea4..000000000000 --- a/java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/Declaration.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2000-2015 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.stubs; - -public abstract class Declaration { - - public static final Declaration[] EMPTY_ARRAY = new Declaration[0]; - - public final Declaration[] myDeclarations; - - protected Declaration(Declaration[] declarations) { - this.myDeclarations = declarations; - } -} diff --git a/java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/MemberDeclaration.java b/java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/MemberDeclaration.java deleted file mode 100644 index b5c9bab02f42..000000000000 --- a/java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/MemberDeclaration.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2000-2015 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.stubs; - -public final class MemberDeclaration extends Declaration { - public MemberDeclaration(Declaration[] declarations) { - super(declarations); - } -} diff --git a/java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/Unit.java b/java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/Unit.java deleted file mode 100644 index 3bddf9a4eee0..000000000000 --- a/java/java-impl/src/com/intellij/psi/stubsHierarchy/stubs/Unit.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2000-2015 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.stubs; - -import com.intellij.psi.stubsHierarchy.impl.QualifiedName; - -public class Unit { - public final QualifiedName myPackageId; - public final UnitInfo myUnitInfo; - public final ClassDeclaration[] myClasses; - - public Unit(QualifiedName packageId, long[] imports, ClassDeclaration[] classes, byte unitType) { - this.myPackageId = packageId; - this.myUnitInfo = UnitInfo.mkUnitInfo(unitType, imports); - this.myClasses = classes; - } - -}