public class ExtractMethodIntentionAction extends java.lang.Object implements IntentionAction, Iconable
Iconable.IconFlags, Iconable.LastComputedIcon
EMPTY_ARRAY
ICON_FLAG_IGNORE_MASK, ICON_FLAG_OPEN, ICON_FLAG_READ_STATUS, ICON_FLAG_VISIBILITY
Constructor and Description |
---|
ExtractMethodIntentionAction() |
Modifier and Type | Method and Description |
---|---|
PsiElement |
getElementToMakeWritable(PsiFile currentFile)
Controls whether this intention/fix is going to modify the current file.
|
java.lang.String |
getFamilyName()
Returns the name of the family of intentions.
|
javax.swing.Icon |
getIcon(int flags) |
java.lang.String |
getText()
Returns text to be shown in the list of available actions, if this action
is available.
|
void |
invoke(Project project,
Editor editor,
PsiFile file)
Called when user invokes intention.
|
boolean |
isAvailable(Project project,
Editor editor,
PsiFile file)
Checks whether this intention is available at a caret offset in the file.
|
boolean |
startInWriteAction()
Indicate whether this action should be invoked inside write action.
|
public java.lang.String getText()
IntentionAction
getText
in interface IntentionAction
IntentionAction.isAvailable(Project, Editor, PsiFile)
public java.lang.String getFamilyName()
IntentionAction
getFamilyName
in interface IntentionAction
IntentionManager.registerIntentionAndMetaData(IntentionAction, String...)
public boolean isAvailable(Project project, Editor editor, PsiFile file)
IntentionAction
isAvailable
in interface IntentionAction
project
- the project in which the availability is checked.editor
- the editor in which the intention will be invoked.file
- the file open in the editor.true
if the intention is available, false
otherwise.public void invoke(Project project, Editor editor, PsiFile file) throws IncorrectOperationException
IntentionAction
IntentionAction.startInWriteAction()
returns true
, this method is also called
inside write action.invoke
in interface IntentionAction
project
- the project in which the intention is invoked.editor
- the editor in which the intention is invoked.file
- the file open in the editor.IncorrectOperationException
public boolean startInWriteAction()
IntentionAction
false
if, e.g., a modal dialog is shown inside the action.
If false is returned the action itself is responsible for starting write action
when needed, by calling Application.runWriteAction(Runnable)
.startInWriteAction
in interface IntentionAction
startInWriteAction
in interface WriteActionAware
true
if the intention requires a write action, false
otherwise.public PsiElement getElementToMakeWritable(PsiFile currentFile)
FileModifier
@NotNull
, and the current file is read-only,
it will be made writable (honoring version control integration) before the intention/fix is invoked.
By default, as a heuristic, returns the same as WriteActionAware.startInWriteAction()
.
If the action is going to modify multiple files, or the set of the files is unknown in advance, please
don't bother overriding this method, return false
from WriteActionAware.startInWriteAction()
, and call FileModificationService
methods in the implementation, and take write actions yourself as needed.getElementToMakeWritable
in interface FileModifier
currentFile
- the same file where intention would be invoked (for LocalQuickFix
it would be the containing file of ProblemDescriptor.getPsiElement()
)