本文整理汇总了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();
}
}
}
示例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();
}
}
}
示例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();
}
}
示例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();
}
}
示例6: deleteAnnotations
import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
private void deleteAnnotations(Collection<PsiAnnotation> psiAnnotations) {
for (PsiAnnotation psiAnnotation : psiAnnotations) {
psiAnnotation.delete();
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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();
}
}