mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
stub hierarchy: allocate less intermediate objects during reading
This commit is contained in:
+14
-10
@@ -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.<p/>
|
||||
*
|
||||
* 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();
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+2
-4
@@ -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;
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<ClassSymbol> uncompleted = new ArrayList<ClassSymbol>();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<Symbol> 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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<long[]> 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<QualifiedName> superList = new ArrayList<QualifiedName>();
|
||||
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<Declaration> innerDefList = new ArrayList<Declaration>();
|
||||
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<Declaration> defList = new ArrayList<Declaration>();
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-6
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user