com.intellij.psi.stubs.StubBase Java Examples
The following examples show how to use
com.intellij.psi.stubs.StubBase.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PsiTreeUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nullable @Contract("null -> null") public static PsiElement getStubOrPsiParent(@Nullable PsiElement element) { if (element instanceof StubBasedPsiElement) { StubBase stub = (StubBase)((StubBasedPsiElement)element).getStub(); if (stub != null) { //noinspection unchecked final StubElement parentStub = stub.getParentStub(); return parentStub != null ? parentStub.getPsi() : null; } } return element != null ? element.getParent() : null; }
Example #2
Source File: PsiTreeUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nullable @Contract("null, _ -> null") public static <E extends PsiElement> E getStubOrPsiParentOfType(@Nullable PsiElement element, @Nonnull Class<E> parentClass) { if (element instanceof StubBasedPsiElement) { StubBase stub = (StubBase)((StubBasedPsiElement)element).getStub(); if (stub != null) { //noinspection unchecked return (E)stub.getParentStubOfType(parentClass); } } return getParentOfType(element, parentClass); }
Example #3
Source File: PsiAnchor.java From consulo with Apache License 2.0 | 5 votes |
public static int calcStubIndex(@Nonnull StubBasedPsiElement psi) { if (psi instanceof PsiFile) { return 0; } StubElement liveStub = psi instanceof StubBasedPsiElementBase ? ((StubBasedPsiElementBase)psi).getGreenStub() : psi.getStub(); if (liveStub != null) { return ((StubBase)liveStub).getStubId(); } return ((PsiFileImpl)psi.getContainingFile()).calcTreeElement().getStubbedSpine().getStubIndex(psi); }