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


Java PsiAnnotation.getNameReferenceElement方法代码示例

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


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

示例1: targetTypesForDefault

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
@Nullable
private static Set<PsiAnnotation.TargetType> targetTypesForDefault(PsiAnnotation annotation) {
    PsiJavaCodeReferenceElement element = annotation.getNameReferenceElement();
    PsiElement declaration = element == null ? null : element.resolve();

    if (!(declaration instanceof PsiClass)) {
        return Collections.emptySet();
    }

    PsiClass classDeclaration = (PsiClass) declaration;
    PsiAnnotation tqDefault = AnnotationUtil.findAnnotation(classDeclaration, true, TYPE_QUALIFIER_DEFAULT);

    if (tqDefault == null) {
        return Collections.emptySet();
    }

    return extractRequiredAnnotationTargets(tqDefault.findAttributeValue(null));
}
 
开发者ID:stylismo,项目名称:nullability-annotations-inspection,代码行数:19,代码来源:AddPackageInfoWithNullabilityDefaultsFix.java

示例2: isNullabilityAnnotationForTypeQualifierDefault

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
private static boolean isNullabilityAnnotationForTypeQualifierDefault(PsiAnnotation annotation,
                                                                      boolean nullable,
                                                                      PsiAnnotation.TargetType[] targetTypes) {
    PsiJavaCodeReferenceElement element = annotation.getNameReferenceElement();
    PsiElement declaration = element == null ? null : element.resolve();
    if (!(declaration instanceof PsiClass)) {
        return false;
    }

    String fqn = nullable ? JAVAX_ANNOTATION_NULLABLE : JAVAX_ANNOTATION_NONNULL;
    PsiClass classDeclaration = (PsiClass) declaration;
    if (!AnnotationUtil.isAnnotated(classDeclaration, fqn, false, true)) {
        return false;
    }

    PsiAnnotation tqDefault = AnnotationUtil.findAnnotation(classDeclaration, true, TYPE_QUALIFIER_DEFAULT);
    if (tqDefault == null) {
        return false;
    }

    Set<PsiAnnotation.TargetType> required = extractRequiredAnnotationTargets(tqDefault.findAttributeValue(null));
    return required != null
            && (required.isEmpty() || ContainerUtil.intersects(required, Arrays.asList(targetTypes)));
}
 
开发者ID:stylismo,项目名称:nullability-annotations-inspection,代码行数:25,代码来源:NullabilityAnnotationsWithTypeQualifierDefault.java

示例3: isGuardType

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
private static boolean isGuardType(@NotNull Set<PsiClass> seen, @Nullable PsiClass psiClass) {
    if ( psiClass == null || !seen.add(psiClass) || !psiClass.isAnnotationType() ) {
        return false;
    }
    if ( psiClass.getModifierList() == null ) {
        return false;
    }
    if ( AnnotationUtil.isAnnotated(psiClass, C_GUARD, false) ) {
        return true;
    }
    for( PsiAnnotation annotation : psiClass.getModifierList().getAnnotations() ) {
        if ( annotation.getNameReferenceElement() != null ) {
            if ( isGuardType(seen, resolve(PsiClass.class, annotation.getNameReferenceElement())) ) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:Abnaxos,项目名称:guards,代码行数:20,代码来源:PsiGuardType.java

示例4: visitAnnotation

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
@Override
public void visitAnnotation(PsiAnnotation annotation) {
  super.visitAnnotation(annotation);
  final PsiJavaCodeReferenceElement reference =
    annotation.getNameReferenceElement();
  if (reference == null) {
    return;
  }
  @NonNls final String text = reference.getText();
  if ("SuppressWarnings".equals(text) ||
      BatchSuppressManager.SUPPRESS_INSPECTIONS_ANNOTATION_NAME.equals(text)) {
    registerError(annotation);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:SuppressionAnnotationInspection.java

示例5: findAnnotationQuick

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
@Nullable
private static PsiAnnotation findAnnotationQuick(@Nullable PsiAnnotationOwner annotationOwner, @NotNull String qualifiedName) {
  if (annotationOwner == null) {
    return null;
  }

  PsiAnnotation[] annotations = annotationOwner.getAnnotations();
  if (annotations.length == 0) {
    return null;
  }

  final String shortName = StringUtil.getShortName(qualifiedName);

  for (PsiAnnotation annotation : annotations) {
    PsiJavaCodeReferenceElement referenceElement = annotation.getNameReferenceElement();
    if (null != referenceElement) {
      final String referenceName = referenceElement.getReferenceName();
      if (shortName.equals(referenceName)) {

        if (referenceElement.isQualified() && referenceElement instanceof SourceJavaCodeReference) {
          String possibleFullQualifiedName = ((SourceJavaCodeReference) referenceElement).getClassNameText();
          if (qualifiedName.equals(possibleFullQualifiedName)) {
            return annotation;
          }
        }

        final String annotationQualifiedName = getAndCacheFQN(annotation, referenceName);
        if (qualifiedName.equals(annotationQualifiedName)) {
          return annotation;
        }
      }
    }
  }

  return null;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:37,代码来源:PsiAnnotationSearchUtil.java

示例6: isBindingAnnotation

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
public static boolean isBindingAnnotation(PsiAnnotation annotation){
    final PsiJavaCodeReferenceElement referenceElement = annotation.getNameReferenceElement();
    if(referenceElement == null){
        return false;
    }
    final PsiElement element = referenceElement.resolve();
    if(!(element instanceof PsiClass)){
        return false;
    }
    final PsiClass annotationClass = (PsiClass) element;
    return AnnotationUtil.isAnnotated(annotationClass, "com.google.inject.BindingAnnotation", true);
}
 
开发者ID:consulo,项目名称:consulo-google-guice,代码行数:13,代码来源:BindingAnnotationWithoutInjectInspection.java

示例7: visitAnnotation

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
@Override
public void visitAnnotation(PsiAnnotation annotation) {
  super.visitAnnotation(annotation);
  final PsiJavaCodeReferenceElement reference =
    annotation.getNameReferenceElement();
  if (reference == null) {
    return;
  }
  @NonNls final String text = reference.getText();
  if ("SuppressWarnings".equals(text) ||
      SuppressManager.SUPPRESS_INSPECTIONS_ANNOTATION_NAME.equals(text)) {
    registerError(annotation);
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:15,代码来源:SuppressionAnnotationInspection.java

示例8: getSimpleNameOf

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
@NotNull
public static String getSimpleNameOf(@NotNull PsiAnnotation psiAnnotation) {
  PsiJavaCodeReferenceElement referenceElement = psiAnnotation.getNameReferenceElement();
  return StringUtil.notNullize(null == referenceElement ? null : referenceElement.getReferenceName());
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:6,代码来源:PsiAnnotationSearchUtil.java


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