Examples of PsiAnnotation


Examples of com.intellij.psi.PsiAnnotation

  @Override
  @NotNull
  public PsiAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) {
    final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
    final PsiAnnotation psiAnnotation = elementFactory.createAnnotationFromText('@' + qualifiedName, null);
    myAnnotations.put(qualifiedName, psiAnnotation);
    return psiAnnotation;
  }
View Full Code Here

Examples of com.intellij.psi.PsiAnnotation

  @NotNull
  @Override
  public List<? super PsiElement> process(@NotNull PsiClass psiClass) {
    List<? super PsiElement> result = new ArrayList<PsiElement>();

    PsiAnnotation psiAnnotation = AnnotationUtil.findAnnotation(psiClass, Collections.singleton(getSupportedAnnotation()), true);
    if (null != psiAnnotation) {
      process(psiClass, psiAnnotation, result);
    }

    return result;
View Full Code Here

Examples of com.intellij.psi.PsiAnnotation

* @author Plushnikov Michail
*/
public class PsiQuickFixFactory {
  public static LocalQuickFix createAddAnnotationQuickFix(@NotNull PsiClass psiClass, @NotNull String annotationFQN, @Nullable String annotationParam) {
    PsiElementFactory elementFactory = JavaPsiFacade.getInstance(psiClass.getProject()).getElementFactory();
    PsiAnnotation newAnnotation = elementFactory.createAnnotationFromText("@" + annotationFQN + "(" + StringUtil.notNullize(annotationParam) + ")", psiClass);
    final PsiNameValuePair[] attributes = newAnnotation.getParameterList().getAttributes();

    return new AddAnnotationFix(annotationFQN, psiClass, attributes);
  }
View Full Code Here

Examples of com.intellij.psi.PsiAnnotation

  @NotNull
  @Override
  public List<? super PsiElement> process(@NotNull PsiClass psiClass) {
    List<? super PsiElement> result = new ArrayList<PsiElement>();
    for (PsiField psiField : PsiClassUtil.collectClassFieldsIntern(psiClass)) {
      PsiAnnotation psiAnnotation = AnnotationUtil.findAnnotation(psiField, Collections.singleton(getSupportedAnnotation()), true);
      if (null != psiAnnotation) {
        process(psiField, psiAnnotation, result);
      }
    }
    return result;
View Full Code Here

Examples of com.intellij.psi.PsiAnnotation

    this.chain = chainValue;
    this.prefixes = null == prefixes ? new String[0] : prefixes;
  }

  public static AccessorsInfo build(@NotNull PsiField psiField) {
    final PsiAnnotation accessorsFieldAnnotation = AnnotationUtil.findAnnotation(psiField, ACCESSORS_ANNOTATION_NAME);
    if (null != accessorsFieldAnnotation) {
      return buildFromAnnotation(accessorsFieldAnnotation);
    } else {
      PsiClass containingClass = psiField.getContainingClass();
      while (null != containingClass) {
        final PsiAnnotation accessorsClassAnnotation = AnnotationUtil.findAnnotation(containingClass, ACCESSORS_ANNOTATION_NAME);
        if (null != accessorsClassAnnotation) {
          return buildFromAnnotation(accessorsClassAnnotation);
        }
        containingClass = containingClass.getContainingClass();
      }
View Full Code Here

Examples of com.intellij.psi.PsiAnnotation

  @Override
  @NotNull
  public PsiAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) {
    final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
    final PsiAnnotation psiAnnotation = elementFactory.createAnnotationFromText('@' + qualifiedName, null);
    myAnnotations.put(qualifiedName, psiAnnotation);
    return psiAnnotation;
  }
View Full Code Here

Examples of com.intellij.psi.PsiAnnotation

  @Override
  @NotNull
  public PsiAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) {
    final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
    final PsiAnnotation psiAnnotation = elementFactory.createAnnotationFromText('@' + qualifiedName, null);
    myAnnotations.put(qualifiedName, psiAnnotation);
    return psiAnnotation;
  }
View Full Code Here

Examples of com.intellij.psi.PsiAnnotation

          }

          if (null != myNewValue) {
            //add new parameter
            final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(myAnnotation.getProject()).getElementFactory();
            PsiAnnotation newAnnotation = elementFactory.createAnnotationFromText("@" + myAnnotation.getQualifiedName() + "(" + myName + "=" + myNewValue + ")", myAnnotation.getContext());
            final PsiNameValuePair[] attributes = newAnnotation.getParameterList().getAttributes();

            myAnnotation.setDeclaredAttributeValue(attributes[0].getName(), attributes[0].getValue());
          }

          UndoUtil.markPsiFileForUndo(file);
View Full Code Here

Examples of com.intellij.psi.PsiAnnotation

* @author Plushnikov Michail
*/
public class PsiQuickFixFactory {
  public static LocalQuickFix createAddAnnotationQuickFix(@NotNull PsiClass psiClass, @NotNull String annotationFQN, @Nullable String annotationParam) {
    PsiElementFactory elementFactory = JavaPsiFacade.getInstance(psiClass.getProject()).getElementFactory();
    PsiAnnotation newAnnotation = elementFactory.createAnnotationFromText("@" + annotationFQN + "(" + StringUtil.notNullize(annotationParam) + ")", psiClass);
    final PsiNameValuePair[] attributes = newAnnotation.getParameterList().getAttributes();

    final BuildNumber buildNumber = ApplicationInfo.getInstance().getBuild();
    switch (IntelliJVersionRangeUtil.getIntelliJVersion(buildNumber)) {
      case INTELLIJ_8:
        throw new RuntimeException(String.format("This version (%s) of IntelliJ is not supported!", buildNumber.asString()));
View Full Code Here

Examples of com.intellij.psi.PsiAnnotation

    final PsiFile containingFile = myModifierListOwner.getContainingFile();
    if (!CodeInsightUtilBase.preparePsiElementForWrite(containingFile)) {
      return;
    }
    for (String fqn : getAnnotationsToRemove()) {
      PsiAnnotation annotation = AnnotationUtil.findAnnotation(myModifierListOwner, fqn);
      if (annotation != null) {
        annotation.delete();
      }
    }

    PsiAnnotation inserted = modifierList.addAnnotation(myAnnotation);
    for (PsiNameValuePair pair : myPairs) {
      inserted.setDeclaredAttributeValue(pair.getName(), pair.getValue());
    }
    JavaCodeStyleManager.getInstance(project).shortenClassReferences(inserted);
    if (containingFile != file) {
      UndoUtil.markPsiFileForUndo(file);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.