use of com.intellij.psi.PsiModifierListOwner in project android by JetBrains.
the class AndroidLintAnimatorKeepInspection method getQuickFixes.
@NotNull
@Override
public AndroidLintQuickFix[] getQuickFixes(@NotNull PsiElement startElement, @NotNull PsiElement endElement, @NotNull String message) {
return new AndroidLintQuickFix[] { new AndroidLintQuickFix() {
@Override
public void apply(@NotNull PsiElement startElement, @NotNull PsiElement endElement, @NotNull AndroidQuickfixContexts.Context context) {
if (!ObjectAnimatorDetector.isAddKeepErrorMessage(message, TextFormat.RAW)) {
return;
}
PsiModifierListOwner container = PsiTreeUtil.getParentOfType(startElement, PsiModifierListOwner.class);
if (container == null) {
return;
}
if (!FileModificationService.getInstance().preparePsiElementForWrite(container)) {
return;
}
final PsiModifierList modifierList = container.getModifierList();
if (modifierList != null) {
PsiAnnotation annotation = AnnotationUtil.findAnnotation(container, KEEP_ANNOTATION);
if (annotation == null) {
Project project = startElement.getProject();
new AddAnnotationFix(KEEP_ANNOTATION, container).invoke(project, null, container.getContainingFile());
}
}
}
@Override
public boolean isApplicable(@NotNull PsiElement startElement, @NotNull PsiElement endElement, @NotNull AndroidQuickfixContexts.ContextType contextType) {
return true;
}
@NotNull
@Override
public String getName() {
return "Annotate with @Keep";
}
} };
}
use of com.intellij.psi.PsiModifierListOwner in project intellij-community by JetBrains.
the class ChangeModifierFix method doFix.
@Override
public void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
final PsiElement element = descriptor.getPsiElement();
final PsiModifierListOwner modifierListOwner = PsiTreeUtil.getParentOfType(element, PsiModifierListOwner.class);
if (modifierListOwner == null) {
return;
}
final PsiModifierList modifiers = modifierListOwner.getModifierList();
if (modifiers == null) {
return;
}
modifiers.setModifierProperty(modifierText, true);
}
Aggregations