stub hierarchy: reindex when stubs change; mark as such some cases when we can't reliably resolve supers

This commit is contained in:
peter
2016-07-04 19:37:30 +02:00
parent a95a5c1afe
commit 8aed1499c7
6 changed files with 50 additions and 25 deletions
@@ -28,6 +28,7 @@ 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.impl.source.JavaFileElementType;
import com.intellij.psi.stubs.Stub;
import com.intellij.psi.stubs.StubElement;
import com.intellij.psi.stubs.StubTree;
@@ -47,7 +48,7 @@ public class JavaStubIndexer extends StubHierarchyIndexer {
@Override
public int getVersion() {
return 0;
return JavaFileElementType.STUB_VERSION + 1;
}
@Override
@@ -95,10 +96,7 @@ public class JavaStubIndexer extends StubHierarchyIndexer {
@Nullable
private static Decl processMember(StubElement<?> el, Set<String> namesCache) {
if (el instanceof PsiClassStubImpl) {
PsiClassStubImpl classStub = (PsiClassStubImpl)el;
if (!classStub.isAnonymousInQualifiedNew()) {
return processClassDecl(classStub, namesCache);
}
return processClassDecl((PsiClassStubImpl)el, namesCache);
}
ArrayList<Decl> innerList = new ArrayList<Decl>();
for (StubElement childElement : el.getChildrenStubs()) {
@@ -146,6 +144,9 @@ public class JavaStubIndexer extends StubHierarchyIndexer {
}
int flags = translateFlags(classStub, accessModifiers);
if (classStub.isAnonymousInQualifiedNew()) {
flags |= IndexTree.SUPERS_UNRESOLVED;
}
String[] supers = superList.isEmpty() ? ArrayUtil.EMPTY_STRING_ARRAY : ArrayUtil.toStringArray(superList);
Decl[] inners = innerList.isEmpty() ? Decl.EMPTY_ARRAY : innerList.toArray(new Decl[innerList.size()]);
return new ClassDecl(classStub.id, flags, classStub.getName(), supers, inners);
@@ -96,10 +96,7 @@ public class StubEnter {
}
private ClassSymbol classEnter(IndexTree.ClassDecl tree, UnitInfo info, Symbol owner, @QNameId int ownerName, int fileId) {
int flags = checkFlags(tree.myMods, owner);
if (info.getType() == IndexTree.BYTECODE) {
flags |= IndexTree.COMPILED;
}
int flags = checkFlags(tree.myMods, owner, info.getType() == IndexTree.BYTECODE);
int name = tree.myName;
@QNameId int qname = name == NameEnvironment.NO_NAME || ownerName < 0 ? -1
@@ -155,11 +152,18 @@ public class StubEnter {
uncompleted = null;
}
public static int checkFlags(long flags, Symbol owner) {
private static int checkFlags(long flags, Symbol owner, boolean compiled) {
int mask = 0;
if (owner.isClass() && (owner.myOwner.isPackage() || owner.isStatic())) {
if ((flags & (IndexTree.INTERFACE | IndexTree.ENUM | IndexTree.STATIC)) != 0 )
if ((flags & (IndexTree.INTERFACE | IndexTree.ENUM | IndexTree.STATIC)) != 0) {
mask |= IndexTree.STATIC;
}
}
if ((flags & IndexTree.SUPERS_UNRESOLVED) != 0) {
mask |= IndexTree.SUPERS_UNRESOLVED;
}
if (compiled) {
mask |= IndexTree.COMPILED;
}
return mask;
}
@@ -85,7 +85,6 @@ public abstract class Symbol {
/** A class for class symbols
*/
public static class ClassSymbol extends MemberSymbol {
private static final int HIERARCHY_INCOMPLETE = 1 << 20;
private static final int CONNECT_STARTED = 1 << 21;
public static final ClassSymbol[] EMPTY_ARRAY = new ClassSymbol[0];
@@ -101,8 +100,10 @@ public abstract class Symbol {
@CompactArray(QualifiedName.class) Object supers) {
super(flags | IndexTree.CLASS, owner, name);
this.myAnchorId = anchorId;
this.mySuperClasses = supers;
this.myUnitInfo = unitInfo;
boolean incomplete = isHierarchyIncomplete();
this.mySuperClasses = incomplete ? null : supers;
this.myUnitInfo = incomplete ? null : unitInfo;
}
@Override
@@ -150,7 +151,7 @@ public abstract class Symbol {
void markHierarchyIncomplete() {
setSupers(Collections.emptySet());
myFlags = BitUtil.set(myFlags, HIERARCHY_INCOMPLETE, true);
myFlags = BitUtil.set(myFlags, IndexTree.SUPERS_UNRESOLVED, true);
}
void setSupers(Set<ClassSymbol> supers) {
@@ -161,7 +162,7 @@ public abstract class Symbol {
}
boolean isHierarchyIncomplete() {
return BitUtil.isSet(myFlags, HIERARCHY_INCOMPLETE);
return BitUtil.isSet(myFlags, IndexTree.SUPERS_UNRESOLVED);
}
boolean hasAmbiguousSupers() {