当前位置: 首页>>代码示例>>Java>>正文


Java PsiUtil.getEnclosingStaticElement方法代码示例

本文整理汇总了Java中com.intellij.psi.util.PsiUtil.getEnclosingStaticElement方法的典型用法代码示例。如果您正苦于以下问题:Java PsiUtil.getEnclosingStaticElement方法的具体用法?Java PsiUtil.getEnclosingStaticElement怎么用?Java PsiUtil.getEnclosingStaticElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.util.PsiUtil的用法示例。


在下文中一共展示了PsiUtil.getEnclosingStaticElement方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isInsideInheritorClass

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static boolean isInsideInheritorClass(PsiElement position) {
  if (position.getParent() instanceof PsiJavaCodeReferenceElement) {
    final PsiElement qualifier = ((PsiJavaCodeReferenceElement)position.getParent()).getQualifier();
    if (qualifier instanceof PsiJavaCodeReferenceElement) {
      final PsiElement qualifierClass = ((PsiJavaCodeReferenceElement)qualifier).resolve();
      if (qualifierClass instanceof PsiClass && ((PsiClass)qualifierClass).isInterface()) {
        PsiElement parent = position;
        while ((parent = PsiTreeUtil.getParentOfType(parent, PsiClass.class, true)) != null) {
          if (PsiUtil.getEnclosingStaticElement(position, (PsiClass)parent) == null && 
              ((PsiClass)parent).isInheritor((PsiClass)qualifierClass, true)) {
            return true;
          }
        }
      }
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JavaKeywordCompletion.java

示例2: isLocatedInStaticContext

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static boolean isLocatedInStaticContext(PsiClass containingClass, PsiMethodReferenceExpression reference) {
  final PsiClass gContainingClass = containingClass.getContainingClass();
  if (gContainingClass == null || !containingClass.hasModifierProperty(PsiModifier.STATIC)) {
    PsiClass aClass = null;
    if (PsiTreeUtil.isAncestor(gContainingClass != null ? gContainingClass : containingClass, reference, false)) {
      aClass = gContainingClass != null ? gContainingClass : containingClass;
    }
    if (PsiUtil.getEnclosingStaticElement(reference, aClass) != null) {
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:MethodReferenceResolver.java

示例3: visitClass

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
  // no call to super, so it doesn't drill down
  if (aClass.isInterface() || aClass.isAnnotationType() || aClass.isEnum()) {
    return;
  }
  if (aClass instanceof PsiTypeParameter) {
    return;
  }
  if (inspection.ignoreAnonymousInnerClasses && aClass instanceof PsiAnonymousClass) {
    return;
  }
  if (aClass.findFieldByName(HardcodedMethodConstants.SERIAL_VERSION_UID, false) != null) {
    return;
  }
  final PsiClass containingClass = PsiTreeUtil.getParentOfType(aClass, PsiClass.class);
  if (containingClass == null) {
    return;
  }
  if (aClass.hasModifierProperty(PsiModifier.STATIC)) {
    return;
  }
  final PsiModifierListOwner staticElement = PsiUtil.getEnclosingStaticElement(aClass, containingClass);
  if (staticElement != null) {
    return;
  }
  if (!SerializationUtils.isSerializable(aClass)) {
    return;
  }
  if (inspection.isIgnoredSubclass(aClass)) {
    return;
  }
  registerClassError(aClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:SerializableInnerClassHasSerialVersionUIDFieldVisitor.java

示例4: visitClass

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
  if (aClass.isInterface() || aClass.isAnnotationType() || aClass.isEnum()) {
    return;
  }
  if (aClass instanceof PsiTypeParameter) {
    return;
  }
  if (inspection.ignoreAnonymousInnerClasses && aClass instanceof PsiAnonymousClass) {
    return;
  }
  final PsiClass containingClass = PsiTreeUtil.getParentOfType(aClass, PsiClass.class);
  if (containingClass == null) {
    return;
  }
  if (aClass.hasModifierProperty(PsiModifier.STATIC)) {
    return;
  }
  final PsiModifierListOwner staticElement = PsiUtil.getEnclosingStaticElement(aClass, containingClass);
  if (staticElement != null) {
    return;
  }
  if (!SerializationUtils.isSerializable(aClass)) {
    return;
  }
  if (SerializationUtils.isSerializable(containingClass)) {
    return;
  }
  if (inspection.isIgnoredSubclass(aClass)) {
    return;
  }
  registerClassError(aClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:SerializableInnerClassWithNonSerializableOuterClassVisitor.java

示例5: isInStaticContext

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
public static boolean isInStaticContext(PsiElement element, @Nullable final PsiClass aClass) {
  return PsiUtil.getEnclosingStaticElement(element, aClass) != null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:AddTypeArgumentsConditionalFix.java


注:本文中的com.intellij.psi.util.PsiUtil.getEnclosingStaticElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。