use of com.intellij.extapi.psi.StubBasedPsiElementBase in project intellij-community by JetBrains.
the class ClassPresentationUtil method getFunctionalExpressionPresentation.
public static String getFunctionalExpressionPresentation(PsiFunctionalExpression functionalExpression, boolean qualified) {
final StubElement stub = ((StubBasedPsiElementBase<?>) functionalExpression).getGreenStub();
final String lambdaText = stub instanceof FunctionalExpressionStub ? ((FunctionalExpressionStub) stub).getPresentableText() : PsiExpressionTrimRenderer.render(functionalExpression);
return PsiBundle.message("class.context.display", lambdaText, getContextName(functionalExpression, qualified));
}
use of com.intellij.extapi.psi.StubBasedPsiElementBase in project intellij-community by JetBrains.
the class JavaStubPsiElement method cloneImpl.
protected StubBasedPsiElementBase cloneImpl(@NotNull CompositeElement treeElementClone) {
StubBasedPsiElementBase clone = (StubBasedPsiElementBase) super.clone();
clone.setNode(treeElementClone);
treeElementClone.setPsi(clone);
return clone;
}
use of com.intellij.extapi.psi.StubBasedPsiElementBase in project intellij-community by JetBrains.
the class TreeUtil method bindStubsToTree.
public static void bindStubsToTree(@NotNull PsiFileImpl file, @NotNull StubTree stubTree, @NotNull FileElement tree) throws StubBindingException {
final ListIterator<StubElement<?>> stubs = stubTree.getPlainList().listIterator();
// skip file root stub
stubs.next();
final IStubFileElementType type = file.getElementTypeForStubBuilder();
assert type != null;
final StubBuilder builder = type.getBuilder();
tree.acceptTree(new RecursiveTreeElementWalkingVisitor() {
@Override
protected void visitNode(TreeElement node) {
CompositeElement parent = node.getTreeParent();
if (parent != null && builder.skipChildProcessingWhenBuildingStubs(parent, node)) {
return;
}
IElementType type = node.getElementType();
if (type instanceof IStubElementType && ((IStubElementType) type).shouldCreateStub(node)) {
final StubElement stub = stubs.hasNext() ? stubs.next() : null;
if (stub == null || stub.getStubType() != type) {
throw new StubBindingException("stub:" + stub + ", AST:" + type);
}
StubBasedPsiElementBase psi = (StubBasedPsiElementBase) node.getPsi();
//noinspection unchecked
((StubBase) stub).setPsi(psi);
psi.setStubIndex(stubs.previousIndex());
}
super.visitNode(node);
}
});
}
use of com.intellij.extapi.psi.StubBasedPsiElementBase in project intellij-community by JetBrains.
the class PsiClassImpl method calcBasesResolveContext.
@Nullable
private static PsiElement calcBasesResolveContext(@NotNull PsiElement scope, String baseClassName, boolean isInitialClass, final PsiElement defaultResolveContext) {
final StubElement stub = scope instanceof StubBasedPsiElementBase ? ((StubBasedPsiElementBase<?>) scope).getStub() : null;
if (stub == null || stub instanceof PsiClassStub && ((PsiClassStub) stub).isAnonymousInQualifiedNew()) {
return scope.getParent();
}
if (scope instanceof PsiClass) {
if (!isAnonymousOrLocal((PsiClass) scope)) {
return isInitialClass ? defaultResolveContext : scope;
}
if (!isInitialClass) {
if (((PsiClass) scope).findInnerClassByName(baseClassName, true) != null)
return scope;
}
}
final StubElement parentStub = stub.getParentStub();
PsiElement psi = parentStub.getPsi();
if (!(psi instanceof StubBasedPsiElementBase)) {
LOG.error(stub + " parent is " + parentStub);
return null;
}
if (hasChildClassStub(parentStub, baseClassName, scope)) {
return scope.getParent();
}
if (psi instanceof PsiClass || psi instanceof PsiFunctionalExpression) {
return calcBasesResolveContext(psi, baseClassName, false, defaultResolveContext);
}
if (psi instanceof PsiMember) {
PsiClass containingClass = ((PsiMember) psi).getContainingClass();
return containingClass != null ? calcBasesResolveContext(containingClass, baseClassName, false, defaultResolveContext) : psi;
}
LOG.error(parentStub);
return psi;
}
use of com.intellij.extapi.psi.StubBasedPsiElementBase in project intellij-community by JetBrains.
the class PsiFileImpl method switchFromStubToAst.
private void switchFromStubToAst(List<Pair<StubBasedPsiElementBase, AstPath>> bindings, FileTrees trees) {
if (!bindings.isEmpty() && trees.useStrongRefs) {
List<String> psiStrings = ContainerUtil.map(bindings, pair -> pair.first.getClass().getName());
LOG.error(this + " of " + getClass() + "; " + psiStrings);
}
for (int i = 0; i < bindings.size(); i++) {
Pair<StubBasedPsiElementBase, AstPath> pair = bindings.get(i);
StubBasedPsiElementBase psi = pair.first;
AstPath path = pair.second;
path.getNode().setPsi(psi);
myRefToPsi.cachePsi(path, psi);
psi.setStubIndex(i + 1);
}
}
Aggregations