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


Java PsiModifierList.getAnnotations方法代码示例

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


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

示例1: find

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
public static PsiElement find( PsiModifierListOwner resolve, ManifoldPsiClass facade )
{
  PsiModifierList modifierList = resolve.getModifierList();
  if( modifierList == null )
  {
    return null;
  }

  PsiAnnotation[] annotations = modifierList.getAnnotations();
  if( annotations.length > 0 &&
      Objects.equals( annotations[0].getQualifiedName(), SourcePosition.class.getName() ) )
  {
    return findTargetFeature( annotations[0], facade );
  }

  if( !facade.getRawFiles().isEmpty() &&
      DarkJavaTypeManifold.FILE_EXTENSIONS.stream()
        .anyMatch( ext -> ext.equalsIgnoreCase( facade.getRawFiles().get( 0 ).getVirtualFile().getExtension() ) ) )
  {
    // DarkJava is Java
    return facade.getRawFiles().get( 0 ).findElementAt( resolve.getTextOffset() );
  }

  return null;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:26,代码来源:ManGotoDeclarationHandler.java

示例2: findAnnotation

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
static PsiAnnotation findAnnotation(PsiElement element, String annotationName) {
    if (element instanceof PsiModifierListOwner) {
        PsiModifierListOwner listOwner = (PsiModifierListOwner) element;
        PsiModifierList modifierList = listOwner.getModifierList();

        if (modifierList != null) {
            for (PsiAnnotation psiAnnotation : modifierList.getAnnotations()) {
                if (annotationName.equals(psiAnnotation.getQualifiedName())) {
                    return psiAnnotation;
                }
            }
        }

    }
    return null;
}
 
开发者ID:anupcowkur,项目名称:here-be-dragons,代码行数:17,代码来源:AnnotationDetector.java

示例3: invoke

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@Override
public final void invoke(@NotNull final Project project,
                   final Editor editor,
                   final PsiFile file) throws IncorrectOperationException {
  final PsiModifierList modifierList = element.getModifierList();

  if(modifierList == null) {
    return;
  }

  for(final PsiAnnotation annotation : modifierList.getAnnotations()) {
    if(isAnnotation(annotation)) {
      annotation.delete();
    }
  }
}
 
开发者ID:defrac,项目名称:defrac-plugin-intellij,代码行数:17,代码来源:RemoveAnnotationQuickFix.java

示例4: collectAnnotationsToCopy

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@NotNull
public static Collection<String> collectAnnotationsToCopy(@NotNull PsiField psiField, final Pattern... patterns) {
  Collection<String> annotationsToCopy = new ArrayList<String>();
  PsiModifierList modifierList = psiField.getModifierList();
  if (null != modifierList) {
    for (PsiAnnotation psiAnnotation : modifierList.getAnnotations()) {
      final String annotationName = PsiAnnotationSearchUtil.getSimpleNameOf(psiAnnotation);
      for (Pattern pattern : patterns) {
        if (pattern.matcher(annotationName).matches()) {
          annotationsToCopy.add(psiAnnotation.getQualifiedName());
        }
      }
    }
  }
  return annotationsToCopy;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:17,代码来源:PsiAnnotationUtil.java

示例5: getQualifierAnnotations

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
public static Set<String> getQualifierAnnotations(PsiElement element) {
  Set<String> qualifiedClasses = new HashSet<String>();

  if (element instanceof PsiModifierListOwner) {
    PsiModifierListOwner listOwner = (PsiModifierListOwner) element;
    PsiModifierList modifierList = listOwner.getModifierList();

    if (modifierList != null) {
      for (PsiAnnotation psiAnnotation : modifierList.getAnnotations()) {
        if (psiAnnotation != null && psiAnnotation.getQualifiedName() != null) {
          JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(element.getProject());
          PsiClass psiClass = psiFacade.findClass(psiAnnotation.getQualifiedName(),
              GlobalSearchScope.projectScope(element.getProject()));

          if (hasAnnotation(psiClass, CLASS_QUALIFIER)) {
            qualifiedClasses.add(psiAnnotation.getQualifiedName());
          }
        }
      }
    }
  }

  return qualifiedClasses;
}
 
开发者ID:square,项目名称:dagger-intellij-plugin,代码行数:25,代码来源:PsiConsultantImpl.java

示例6: visitNewExpression

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@Override
public void visitNewExpression(PsiNewExpression expression) {
    super.visitNewExpression(expression);

    PsiMethod constructor = expression.resolveConstructor();
    if (constructor == null) return;

    JavaEvaluator evaluator = mContext.getEvaluator();
    PsiClass cls = constructor.getContainingClass();
    boolean isView = evaluator.extendsClass(cls, CLASS_VIEW, true);
    if (!isView) return;

    Location location = this.mContext.getLocation(expression);

    PsiElement psiElement = expression.getParent();

    //创建的变量没有赋值给本地变量,无法指定注解
    if (!(psiElement instanceof PsiLocalVariable)) {
        this.mContext.report(DynamicNewViewDetector.ISSUE, expression, location, "检测到动态创建view操作,new 操作的结果需要赋值给本地变量");
        return;
    }

    PsiLocalVariable localVariable = (PsiLocalVariable) psiElement;
    PsiModifierList modifierList = localVariable.getModifierList();
    if (modifierList == null) {
        this.mContext.report(DynamicNewViewDetector.ISSUE, expression, location, "检测到动态创建view操作,确认是否为view指定了唯一标识");
        return;
    }

    PsiAnnotation[] annotations = modifierList.getAnnotations();
    for (PsiAnnotation annotation : annotations) {
        String fullName = annotation.getQualifiedName();
        if (IDENTIFIER_ANNOTATION.equals(fullName)) {
            return;
        }
    }

    this.mContext.report(DynamicNewViewDetector.ISSUE, expression, location, "检测到动态创建view操作,确认是否为view指定了唯一标识");
}
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:40,代码来源:DynamicNewViewDetector.java

示例7: getAnnotations

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
/**
 * クラスアノテーション取得
 * @param clazz ルートノード
 * @return クラスに付加されたアノテーションのリスト (空要素の場合もあります)
 */
public static @NonNull List<PsiAnnotation> getAnnotations(@NonNull PsiClass clazz) {
    PsiModifierList modifierList = clazz.getModifierList();
    if (modifierList == null) return new ArrayList<>();

    PsiAnnotation[] annotations = modifierList.getAnnotations();
    return Arrays.asList(annotations);
}
 
开发者ID:cch-robo,项目名称:Android_Lint_SRP_Practice_Example,代码行数:13,代码来源:ElementUtil.java

示例8: createAddToSpecialAnnotationFixes

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
public static void createAddToSpecialAnnotationFixes(@NotNull PsiModifierListOwner owner, @NotNull Processor<String> processor) {
  final PsiModifierList modifierList = owner.getModifierList();
  if (modifierList != null) {
    final PsiAnnotation[] psiAnnotations = modifierList.getAnnotations();
    for (PsiAnnotation psiAnnotation : psiAnnotations) {
      @NonNls final String name = psiAnnotation.getQualifiedName();
      if (name == null) continue;
      if (name.startsWith("java.") || name.startsWith("javax.") ||
          name.startsWith("org.jetbrains.") && AnnotationUtil.isJetbrainsAnnotation(StringUtil.getShortName(name))) continue;
      if (!processor.process(name)) break;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:SpecialAnnotationsUtilBase.java

示例9: getTestSize

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@Nullable
public static TestSize getTestSize(PsiClass psiClass) {
  PsiModifierList psiModifierList = psiClass.getModifierList();
  if (psiModifierList == null) {
    return null;
  }
  PsiAnnotation[] annotations = psiModifierList.getAnnotations();
  TestSize testSize = getTestSize(annotations);
  if (testSize == null) {
    return null;
  }
  return testSize;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:14,代码来源:TestSizeAnnotationMap.java

示例10: addApplicableProcessors

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
private void addApplicableProcessors(@NotNull PsiMember psiMember, @NotNull Collection<LombokProcessorData> target) {
  final PsiModifierList psiModifierList = psiMember.getModifierList();
  if (null != psiModifierList) {
    for (PsiAnnotation psiAnnotation : psiModifierList.getAnnotations()) {
      for (Processor processor : getProcessors(psiAnnotation)) {
        target.add(new LombokProcessorData(processor, psiAnnotation));
      }
    }
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:11,代码来源:LombokProcessorProvider.java

示例11: isAnnotatedWith

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
public static boolean isAnnotatedWith(@NotNull PsiModifierListOwner psiModifierListOwner, @NotNull final Pattern annotationPattern) {
  final PsiModifierList psiModifierList = psiModifierListOwner.getModifierList();
  if (psiModifierList != null) {
    for (PsiAnnotation psiAnnotation : psiModifierList.getAnnotations()) {
      final String suspect = getSimpleNameOf(psiAnnotation);
      if (annotationPattern.matcher(suspect).matches()) {
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:13,代码来源:PsiAnnotationSearchUtil.java

示例12: checkAnnotationsSimpleNameExistsIn

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
public static boolean checkAnnotationsSimpleNameExistsIn(@NotNull PsiModifierListOwner modifierListOwner, @NotNull Collection<String> annotationNames) {
  final PsiModifierList modifierList = modifierListOwner.getModifierList();
  if (null != modifierList) {
    for (PsiAnnotation psiAnnotation : modifierList.getAnnotations()) {
      final String simpleName = getSimpleNameOf(psiAnnotation);
      if (annotationNames.contains(simpleName)) {
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:13,代码来源:PsiAnnotationSearchUtil.java

示例13: findTemplatedAnnotation

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
public static PsiAnnotation findTemplatedAnnotation(PsiElement element) {
  final PsiClass topLevelClass;

  if (element.getParent() == null) {
    if (element instanceof PsiClass) {
      topLevelClass = (PsiClass) element;
    }
    else {
      return null;
    }
  }
  else {
    topLevelClass = PsiUtil.getTopLevelClass(element);
  }

  if (topLevelClass == null) {
    return null;
  }

  final PsiModifierList modifierList = topLevelClass.getModifierList();

  if (modifierList == null) {
    return null;
  }

  final PsiAnnotation[] annotations = modifierList.getAnnotations();
  for (PsiAnnotation psiAnnotation : annotations) {
    final String qualifiedName = psiAnnotation.getQualifiedName();
    if (qualifiedName == null) {
      continue;
    }
    if (qualifiedName.equals(Types.TEMPLATED)) {
      return psiAnnotation;
    }
  }
  return null;
}
 
开发者ID:errai,项目名称:errai-intellij-idea-plugin,代码行数:38,代码来源:TemplateUtil.java

示例14: getAnnotationFromElement

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
public static PsiAnnotation getAnnotationFromElement(PsiElement element, String annotationType) {
  if (element instanceof PsiModifierListOwner) {
    final PsiModifierList modifierList = ((PsiModifierListOwner) element).getModifierList();
    if (modifierList != null) {
      for (PsiAnnotation annotation : modifierList.getAnnotations()) {
        if (annotationType.equals(annotation.getQualifiedName())) {
          return annotation;
        }
      }
    }
  }
  return null;
}
 
开发者ID:errai,项目名称:errai-intellij-idea-plugin,代码行数:14,代码来源:Util.java

示例15: typeIsAnnotated

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
public static boolean typeIsAnnotated(PsiClass psiClass, String annotationType) {
  final PsiModifierList modifierList = psiClass.getModifierList();

  if (modifierList != null) {
    for (PsiAnnotation psiAnnotation : modifierList.getAnnotations()) {
      final String qualifiedName = psiAnnotation.getQualifiedName();
      if (qualifiedName != null && qualifiedName.equals(annotationType)) {
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:errai,项目名称:errai-intellij-idea-plugin,代码行数:14,代码来源:Util.java


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