use of com.intellij.psi.stubs.StubBase in project kotlin by JetBrains.
the class StubClassBuilder method markLastChild.
private void markLastChild(@NotNull JvmDeclarationOrigin origin) {
List children = v.getResult().getChildrenStubs();
StubBase last = (StubBase) children.get(children.size() - 1);
LightElementOrigin oldOrigin = last.getUserData(ClsWrapperStubPsiFactory.ORIGIN);
if (oldOrigin != null) {
PsiElement originalElement = oldOrigin.getOriginalElement();
throw new IllegalStateException("Rewriting origin element: " + (originalElement != null ? originalElement.getText() : null) + " for stub " + last.toString());
}
last.putUserData(ClsWrapperStubPsiFactory.ORIGIN, LightElementOriginKt.toLightMemberOrigin(origin));
last.putUserData(MemberIndex.KEY, new MemberIndex(memberIndex++));
}
use of com.intellij.psi.stubs.StubBase in project kotlin by JetBrains.
the class StubClassBuilder method defineClass.
@Override
public void defineClass(PsiElement origin, int version, int access, @NotNull String name, @Nullable String signature, @NotNull String superName, @NotNull String[] interfaces) {
assert v == null : "defineClass() called twice?";
v = new StubBuildingVisitor<Object>(null, EMPTY_STRATEGY, parent, access, calculateShortName(name));
super.defineClass(origin, version, access, name, signature, superName, interfaces);
if (origin instanceof KtFile) {
FqName packageName = ((KtFile) origin).getPackageFqName();
String packageClassName = OldPackageFacadeClassUtils.getPackageClassName(packageName);
if (name.equals(packageClassName) || name.endsWith("/" + packageClassName)) {
isPackageClass = true;
}
}
if (!isPackageClass) {
parentStack.push(v.getResult());
}
((StubBase) v.getResult()).putUserData(ClsWrapperStubPsiFactory.ORIGIN, LightElementOriginKt.toLightClassOrigin(origin));
}
use of com.intellij.psi.stubs.StubBase in project intellij-community by JetBrains.
the class PsiAnchor method calcStubIndex.
public static int calcStubIndex(@NotNull StubBasedPsiElement psi) {
if (psi instanceof PsiFile) {
return 0;
}
final StubElement liveStub = psi.getStub();
if (liveStub != null) {
return ((StubBase) liveStub).id;
}
PsiFileImpl file = (PsiFileImpl) psi.getContainingFile();
final StubTree stubTree = file.calcStubTree();
for (StubElement<?> stb : stubTree.getPlainList()) {
if (stb.getPsi() == psi) {
return ((StubBase) stb).id;
}
}
// it is possible via custom stub builder intentionally not producing stubs for stubbed elements
return -1;
}
Aggregations