本文整理汇总了Java中com.intellij.psi.stubs.StubElement.getParentStub方法的典型用法代码示例。如果您正苦于以下问题:Java StubElement.getParentStub方法的具体用法?Java StubElement.getParentStub怎么用?Java StubElement.getParentStub使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.stubs.StubElement
的用法示例。
在下文中一共展示了StubElement.getParentStub方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isGroovyStaticMemberStub
import com.intellij.psi.stubs.StubElement; //导入方法依赖的package包/类
public static boolean isGroovyStaticMemberStub(StubElement<?> stub) {
StubElement<?> modifierOwner = stub instanceof GrMethodStub ? stub : stub.getParentStub();
StubElement<GrModifierList> type = modifierOwner.findChildStubByType(GroovyElementTypes.MODIFIERS);
if (!(type instanceof GrModifierListStub)) {
return false;
}
int mask = ((GrModifierListStub)type).getModifiersFlags();
if (GrModifierListImpl.hasMaskExplicitModifier(PsiModifier.PRIVATE, mask)) {
return false;
}
if (GrModifierListImpl.hasMaskExplicitModifier(PsiModifier.STATIC, mask)) {
return true;
}
StubElement parent = modifierOwner.getParentStub();
StubElement classStub = parent == null ? null : parent.getParentStub();
if (classStub instanceof GrTypeDefinitionStub &&
(((GrTypeDefinitionStub)classStub).isAnnotationType() || ((GrTypeDefinitionStub)classStub).isInterface())) {
return true;
}
return false;
}
示例2: getContainingStubFile
import com.intellij.psi.stubs.StubElement; //导入方法依赖的package包/类
public static FileStub getContainingStubFile(StubElement e) {
StubElement parent = e.getParentStub();
while (parent != null) {
if (parent instanceof FileStub) {
return (FileStub) parent;
}
parent = parent.getParentStub();
}
return null;
}
示例3: getFileStub
import com.intellij.psi.stubs.StubElement; //导入方法依赖的package包/类
private PsiJavaFileStub getFileStub(StubT stub) {
StubElement parent = stub;
while (!(parent instanceof PsiFileStub)) {
parent = parent.getParentStub();
}
return (PsiJavaFileStub)parent;
}
示例4: getContainingFile
import com.intellij.psi.stubs.StubElement; //导入方法依赖的package包/类
@Override
public PsiFile getContainingFile() {
StubElement p = myStub;
while (!(p instanceof PsiFileStub)) {
p = p.getParentStub();
}
return (PsiFile)p.getPsi();
}
示例5: getContainerByStub
import com.intellij.psi.stubs.StubElement; //导入方法依赖的package包/类
@Nullable
private static PsiElement getContainerByStub(@NotNull StubBasedPsiElement element) {
final StubElement stub = element.getStub();
if (stub != null) {
final StubElement parentStub = stub.getParentStub();
if (parentStub != null) {
return parentStub.getPsi();
}
}
return null;
}
示例6: isTopLevel
import com.intellij.psi.stubs.StubElement; //导入方法依赖的package包/类
public static boolean isTopLevel(@NotNull PsiElement element) {
if (element instanceof StubBasedPsiElement) {
final StubElement stub = ((StubBasedPsiElement)element).getStub();
if (stub != null) {
final StubElement parentStub = stub.getParentStub();
if (parentStub != null) {
return parentStub.getPsi() instanceof PsiFile;
}
}
}
return ScopeUtil.getScopeOwner(element) instanceof PsiFile;
}
示例7: getContainingClass
import com.intellij.psi.stubs.StubElement; //导入方法依赖的package包/类
@Override
public PyClass getContainingClass() {
final PyTargetExpressionStub stub = getStub();
if (stub != null) {
final StubElement parentStub = stub.getParentStub();
if (parentStub instanceof PyClassStub) {
return ((PyClassStub)parentStub).getPsi();
}
if (parentStub instanceof PyFunctionStub) {
final StubElement functionParent = parentStub.getParentStub();
if (functionParent instanceof PyClassStub) {
return ((PyClassStub) functionParent).getPsi();
}
}
return null;
}
final PsiElement parent = PsiTreeUtil.getParentOfType(this, PyFunction.class, PyClass.class);
if (parent instanceof PyClass) {
return (PyClass)parent;
}
if (parent instanceof PyFunction) {
return ((PyFunction)parent).getContainingClass();
}
return null;
}
示例8: packModifierList
import com.intellij.psi.stubs.StubElement; //导入方法依赖的package包/类
public static int packModifierList(@NotNull LighterAST tree, @NotNull LighterASTNode modList, @NotNull StubElement parent) {
int packed = 0;
final LighterASTNode modListOwner = tree.getParent(modList);
if (modListOwner != null && modListOwner.getTokenType() == parent.getStubType()) {
final StubElement grandParent = parent.getParentStub();
if (parent instanceof PsiClassStub) {
if (grandParent instanceof PsiClassStub && ((PsiClassStub)grandParent).isInterface()) {
packed |= ModifierFlags.PUBLIC_MASK;
packed |= ModifierFlags.STATIC_MASK;
}
if (((PsiClassStub)parent).isInterface()) {
packed |= ModifierFlags.ABSTRACT_MASK;
if (grandParent instanceof PsiClassStub) {
packed |= ModifierFlags.STATIC_MASK;
}
}
else if (((PsiClassStub)parent).isEnum()) {
if (!(grandParent instanceof PsiFileStub)) {
packed |= ModifierFlags.STATIC_MASK;
}
boolean isFinal = true;
final List<LighterASTNode> enumConstants = LightTreeUtil.getChildrenOfType(tree, modListOwner, JavaElementType.ENUM_CONSTANT);
for (final LighterASTNode constant : enumConstants) {
if (LightTreeUtil.firstChildOfType(tree, constant, JavaElementType.ENUM_CONSTANT_INITIALIZER) != null) {
isFinal = false;
break;
}
}
if (isFinal) {
packed |= ModifierFlags.FINAL_MASK;
}
final List<LighterASTNode> methods = LightTreeUtil.getChildrenOfType(tree, modListOwner, JavaElementType.METHOD);
for (final LighterASTNode method : methods) {
final LighterASTNode mods = LightTreeUtil.requiredChildOfType(tree, method, JavaElementType.MODIFIER_LIST);
if (LightTreeUtil.firstChildOfType(tree, mods, JavaTokenType.ABSTRACT_KEYWORD) != null) {
packed |= ModifierFlags.ABSTRACT_MASK;
break;
}
}
}
}
else if (parent instanceof PsiMethodStub) {
if (grandParent instanceof PsiClassStub && ((PsiClassStub)grandParent).isInterface()) {
packed |= ModifierFlags.PUBLIC_MASK;
packed |= ModifierFlags.ABSTRACT_MASK;
}
}
else if (parent instanceof PsiFieldStub) {
if (parent.getStubType() == JavaElementType.ENUM_CONSTANT ||
grandParent instanceof PsiClassStub && ((PsiClassStub)grandParent).isInterface()) {
packed |= ModifierFlags.PUBLIC_MASK;
packed |= ModifierFlags.STATIC_MASK;
packed |= ModifierFlags.FINAL_MASK;
}
}
}
for (final LighterASTNode child : tree.getChildren(modList)) {
final int flag = ModifierFlags.KEYWORD_TO_MODIFIER_FLAG_MAP.get(child.getTokenType());
if (flag != 0) {
packed |= flag;
}
}
if ((packed & ModifierFlags.DEFENDER_MASK) != 0) {
packed &= ~ModifierFlags.ABSTRACT_MASK;
}
if ((packed & (ModifierFlags.PRIVATE_MASK | ModifierFlags.PROTECTED_MASK | ModifierFlags.PUBLIC_MASK)) == 0) {
packed |= ModifierFlags.PACKAGE_LOCAL_MASK;
}
return packed;
}
示例9: reason
import com.intellij.psi.stubs.StubElement; //导入方法依赖的package包/类
@NonNls
@NotNull
private static String reason(@NotNull PsiElement root) {
if (root == PsiUtilCore.NULL_PSI_ELEMENT) return "NULL_PSI_ELEMENT";
PsiElement element = root instanceof PsiFile ? root : root.getParent();
if (element == null) {
String m = "parent is null";
if (root instanceof StubBasedPsiElement) {
StubElement stub = ((StubBasedPsiElement)root).getStub();
while (stub != null) {
m += "\n each stub=" + stub;
if (stub instanceof PsiFileStub) {
m += "; fileStub.psi=" + stub.getPsi() + "; reason=" + ((PsiFileStub)stub).getInvalidationReason();
}
stub = stub.getParentStub();
}
}
return m;
}
while (element != null && !(element instanceof PsiFile)) element = element.getParent();
PsiFile file = (PsiFile)element;
if (file == null) return "containing file is null";
FileViewProvider provider = file.getViewProvider();
VirtualFile vFile = provider.getVirtualFile();
if (!vFile.isValid()) return vFile + " is invalid";
if (!provider.isPhysical()) {
PsiElement context = file.getContext();
if (context != null && !context.isValid()) {
return "invalid context: " + reason(context);
}
}
PsiManager manager = file.getManager();
if (manager.getProject().isDisposed()) return "project is disposed";
Language language = file.getLanguage();
if (language != provider.getBaseLanguage()) return "File language:" + language + " != Provider base language:" + provider.getBaseLanguage();
FileViewProvider p = manager.findViewProvider(vFile);
if (provider != p) return "different providers: " + provider + "(" + id(provider) + "); " + p + "(" + id(p) + ")";
if (!provider.isPhysical()) return "non-physical provider: " + provider; // "dummy" file?
return "psi is outdated";
}