mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
@NotNull
This commit is contained in:
+5
-8
@@ -75,18 +75,15 @@ public class ConvertToBasicLatinAction extends PsiElementBaseIntentionAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException {
|
||||
PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
|
||||
if (element == null) return;
|
||||
|
||||
public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException {
|
||||
final Pair<PsiElement, Handler> pair = findHandler(element);
|
||||
if (pair == null) return;
|
||||
element = pair.first;
|
||||
final PsiElement workElement = pair.first;
|
||||
final Handler handler = pair.second;
|
||||
|
||||
final String newText = handler.processText(element);
|
||||
final PsiElement newElement = handler.createReplacement(element, newText);
|
||||
element.replace(newElement);
|
||||
final String newText = handler.processText(workElement);
|
||||
final PsiElement newElement = handler.createReplacement(workElement, newText);
|
||||
workElement.replace(newElement);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+11
-9
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,15 +32,14 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public abstract class PsiElementBaseIntentionAction extends BaseIntentionAction {
|
||||
/**
|
||||
* Invokes intention action for the element under cursor
|
||||
* Invokes intention action for the element under cursor.
|
||||
*
|
||||
* @param project the project in which the file is opened.
|
||||
* @param editor the editor for the file
|
||||
* @param element the element under cursor
|
||||
|
||||
* @throws com.intellij.util.IncorrectOperationException ...
|
||||
* @param editor the editor for the file.
|
||||
* @param element the element under cursor.
|
||||
* @throws com.intellij.util.IncorrectOperationException
|
||||
*/
|
||||
public void invoke(Project project, Editor editor, PsiElement element) throws IncorrectOperationException {
|
||||
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException();
|
||||
}
|
||||
|
||||
@@ -59,7 +58,10 @@ public abstract class PsiElementBaseIntentionAction extends BaseIntentionAction
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
invoke(project, editor, getElement(editor, file));
|
||||
final PsiElement element = getElement(editor, file);
|
||||
if (element != null) {
|
||||
invoke(project, editor, element);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +69,7 @@ public abstract class PsiElementBaseIntentionAction extends BaseIntentionAction
|
||||
* If this method returns true, a light bulb for this intention is shown.
|
||||
*
|
||||
* @param project the project in which the availability is checked.
|
||||
* @param editor the editor in which the intention will be invoked.
|
||||
* @param editor the editor in which the intention will be invoked.
|
||||
* @param element the element under caret.
|
||||
* @return true if the intention is available, false otherwise.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,10 +39,13 @@ public abstract class SuppressIntentionAction extends PsiElementBaseIntentionAct
|
||||
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException {
|
||||
final CaretModel caretModel = editor.getCaretModel();
|
||||
final int position = caretModel.getOffset();
|
||||
invoke(project, editor, file.findElementAt(position));
|
||||
final PsiElement element = file.findElementAt(position);
|
||||
if (element != null) {
|
||||
invoke(project, editor, element);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void invoke(Project project, Editor editor, PsiElement element) throws IncorrectOperationException;
|
||||
public abstract void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException;
|
||||
|
||||
public Icon getIcon(int flags) {
|
||||
return ICON;
|
||||
|
||||
@@ -46,7 +46,7 @@ public abstract class Intention extends PsiElementBaseIntentionAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(Project project, Editor editor, PsiElement element) throws IncorrectOperationException {
|
||||
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
|
||||
if (!isWritable(project, element)) {
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-3
@@ -60,9 +60,7 @@ abstract class SuppressInspectionAction extends SuppressIntentionAction {
|
||||
return getAnchor(element) != null;
|
||||
}
|
||||
|
||||
public void invoke(Project project, Editor editor, PsiElement element) throws IncorrectOperationException {
|
||||
if (element == null) return;
|
||||
|
||||
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
|
||||
final XmlTag anchor = getAnchor(element);
|
||||
if (anchor == null) return;
|
||||
|
||||
|
||||
@@ -119,13 +119,12 @@ public abstract class BaseInspection extends XmlSuppressableInspectionTool {
|
||||
return ContainerUtil.map(super.getSuppressActions(element), new Function<SuppressIntentionAction, SuppressIntentionAction>() {
|
||||
public SuppressIntentionAction fun(final SuppressIntentionAction action) {
|
||||
return new SuppressIntentionAction() {
|
||||
public void invoke(Project project, Editor editor, PsiElement element) throws IncorrectOperationException {
|
||||
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
|
||||
action.invoke(project, editor, element);
|
||||
}
|
||||
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
|
||||
return element != null && element.getContainingFile().getFileType() == StdFileTypes.XML &&
|
||||
action.isAvailable(project, editor, element);
|
||||
return element.getContainingFile().getFileType() == StdFileTypes.XML && action.isAvailable(project, editor, element);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user