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


Java PsiAnnotation.delete方法代码示例

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


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

示例1: invoke

import com.intellij.psi.PsiAnnotation; //导入方法依赖的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

示例2: removeDefaultAnnotation

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
protected void removeDefaultAnnotation(@NotNull PsiModifierListOwner targetElement, @NotNull Class<? extends Annotation> annotationClass) {
  final PsiAnnotation psiAnnotation = PsiAnnotationSearchUtil.findAnnotation(targetElement, annotationClass);
  if (null != psiAnnotation) {
    boolean hasOnlyDefaultValues = true;

    final PsiAnnotationParameterList psiAnnotationParameterList = psiAnnotation.getParameterList();
    for (PsiNameValuePair nameValuePair : psiAnnotationParameterList.getAttributes()) {
      if (null != psiAnnotation.findDeclaredAttributeValue(nameValuePair.getName())) {
        hasOnlyDefaultValues = false;
        break;
      }
    }

    if (hasOnlyDefaultValues) {
      psiAnnotation.delete();
    }
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:19,代码来源:BaseLombokHandler.java

示例3: applyFix

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
/** Remove @Default and @Nullable from the method parameter if they exist. */
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
  PsiElement element = descriptor.getPsiElement();
  if (element == null) {
    return;
  }

  if (!(element instanceof PsiParameter)) {
    return;
  }

  PsiModifierList modifierList = ((PsiParameter) element).getModifierList();
  PsiAnnotation gaeNullableAnnotation =
      modifierList.findAnnotation(GctConstants.APP_ENGINE_ANNOTATION_NULLABLE);
  if (gaeNullableAnnotation != null) {
    gaeNullableAnnotation.delete();
  }

  PsiAnnotation javaxNullableAnnotation =
      modifierList.findAnnotation("javax.annotation.Nullable");
  if (javaxNullableAnnotation != null) {
    javaxNullableAnnotation.delete();
  }

  PsiAnnotation defaultValueAnnotation =
      modifierList.findAnnotation(GctConstants.APP_ENGINE_ANNOTATION_DEFAULT_VALUE);
  if (defaultValueAnnotation != null) {
    defaultValueAnnotation.delete();
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:32,代码来源:InvalidParameterAnnotationsInspection.java

示例4: performRefactoring

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
@Override
public void performRefactoring() throws IncorrectOperationException {
  PsiUtil.setModifierProperty(getMethod(), PsiModifier.PRIVATE, true);
  final PsiAnnotation annotation = AnnotationUtil.findAnnotation(getMethod(), true, JavaClassNames.JAVA_LANG_OVERRIDE);
  if (annotation != null) {
    annotation.delete();
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:9,代码来源:SafeDeletePrivatizeMethod.java

示例5: performRefactoring

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
public void performRefactoring() throws IncorrectOperationException {
  final PsiAnnotation annotation = AnnotationUtil.findAnnotation(getMethod(), true, Override.class.getName());
  if (annotation != null) {
    annotation.delete();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:SafeDeleteOverrideAnnotation.java

示例6: deleteAnnotations

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
private void deleteAnnotations(Collection<PsiAnnotation> psiAnnotations) {
  for (PsiAnnotation psiAnnotation : psiAnnotations) {
    psiAnnotation.delete();
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:6,代码来源:BaseDelombokHandler.java

示例7: checkForDataFieldInitializationProblems

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
public static void checkForDataFieldInitializationProblems(final ProblemsHolder holder,
                                                           final PsiAnnotation annotation) {
  final PsiElement ownerElement = Util.getImmediateOwnerElement(annotation);

  final boolean fieldIsInject = Util.fieldOrMethodIsAnnotated(ownerElement, Types.JAVAX_INJECT);
  final boolean fieldInitialized = Util.fieldElementIsInitialized(ownerElement);
  if (!fieldIsInject && !fieldInitialized) {
    holder.registerProblem(ownerElement, "Un-injected @DataField element is not initialized and may fail at runtime.");
  }
  else if (fieldIsInject && fieldInitialized) {
    final LocalQuickFix localQuickFix = new LocalQuickFix() {
      @NotNull
      @Override
      public String getName() {
        return "Remove @Inject annotation";
      }

      @NotNull
      @Override
      public String getFamilyName() {
        return GroupNames.BUGS_GROUP_NAME;
      }

      @Override
      public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
        final PsiElement psiElement = Util.getImmediateOwnerElement(annotation);
        final PsiField psiField = (PsiField) psiElement;
        final PsiModifierList modifierList = psiField.getModifierList();
        if (modifierList != null) {
          for (PsiAnnotation psiAnnotation : modifierList.getAnnotations()) {
            final String qualifiedName = psiAnnotation.getQualifiedName();
            if (qualifiedName != null && qualifiedName.equals(Types.JAVAX_INJECT)) {
              psiAnnotation.delete();
            }
          }
        }
      }
    };

    if (ownerElement != null) {
      holder.registerProblem(ownerElement, "Injected @DataField element has a default value which will be overwritten at runtime.",
          localQuickFix);
    }
  }
}
 
开发者ID:errai,项目名称:errai-intellij-idea-plugin,代码行数:46,代码来源:UIDataFieldInitProblemsInspection.java

示例8: ensureDataFieldIsValid

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
public static void ensureDataFieldIsValid(final ProblemsHolder holder,
                                          final PsiAnnotation annotation) {
  final PsiElement ownerElement = Util.getImmediateOwnerElement(annotation);

  final boolean fieldIsInject = Util.fieldOrMethodIsAnnotated(ownerElement, Types.JAVAX_INJECT);
  final boolean fieldInitialized = Util.fieldElementIsInitialized(ownerElement);
  if (!fieldIsInject && !fieldInitialized) {
    holder.registerProblem(ownerElement, "Un-injected @DataField element is not initialized and may fail at runtime.");
  }
  else if (fieldIsInject && fieldInitialized) {
    final LocalQuickFix localQuickFix = new LocalQuickFix() {
      @NotNull
      @Override
      public String getName() {
        return "Remove @Inject annotation";
      }

      @NotNull
      @Override
      public String getFamilyName() {
        return GroupNames.BUGS_GROUP_NAME;
      }

      @Override
      public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
        final PsiElement psiElement = Util.getImmediateOwnerElement(annotation);
        final PsiField psiField = (PsiField) psiElement;
        final PsiModifierList modifierList = psiField.getModifierList();
        if (modifierList != null) {
          for (PsiAnnotation psiAnnotation : modifierList.getAnnotations()) {
            final String qualifiedName = psiAnnotation.getQualifiedName();
            if (qualifiedName != null && qualifiedName.equals(Types.JAVAX_INJECT)) {
              psiAnnotation.delete();
            }
          }
        }
      }
    };

    if (ownerElement != null) {
      holder.registerProblem(ownerElement, "Injected @DataField element has a default value which will be overwritten at runtime.",
          localQuickFix);
    }
  }
}
 
开发者ID:errai,项目名称:errai-intellij-idea-plugin,代码行数:46,代码来源:UITemplateCodeSmellInspections.java

示例9: performRefactoring

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
public void performRefactoring() throws IncorrectOperationException {
  final PsiAnnotation annotation = AnnotationUtil.findAnnotation(getMethod(), true, JavaClassNames.JAVA_LANG_OVERRIDE);
  if (annotation != null) {
    annotation.delete();
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:7,代码来源:SafeDeleteOverrideAnnotation.java


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