public abstract class ImportClassFixBase<T extends PsiElement,R extends PsiReference> extends java.lang.Object implements HintAction, HighPriorityAction
Modifier and Type | Class and Description |
---|---|
static class |
ImportClassFixBase.Result |
PriorityAction.Priority
EMPTY_ARRAY
Modifier | Constructor and Description |
---|---|
protected |
ImportClassFixBase(T elem,
R ref) |
Modifier and Type | Method and Description |
---|---|
protected void |
bindReference(PsiReference reference,
PsiClass targetClass) |
protected boolean |
canReferenceClass(R ref) |
protected AddImportAction |
createAddImportAction(PsiClass [] classes,
Project project,
Editor editor) |
ImportClassFixBase.Result |
doFix(Editor editor,
boolean allowPopup,
boolean allowCaretNearRef) |
protected static java.util.List<PsiClass> |
filterAssignableFrom(PsiType type,
java.util.List<PsiClass> candidates) |
protected java.util.List<PsiClass> |
filterByContext(java.util.List<PsiClass> candidates,
T ref) |
protected static java.util.List<PsiClass> |
filterBySuperMethods(PsiParameter parameter,
java.util.List<PsiClass> candidates) |
boolean |
fixSilently(Editor editor)
Perform this action if it doesn't require any user interaction, doesn't show any popups.
|
java.util.List<PsiClass> |
getClassesToImport() |
java.util.List<PsiClass> |
getClassesToImport(boolean acceptWrongNumberOfTypeParams) |
protected int |
getEndOffset(T element,
R ref) |
java.lang.String |
getFamilyName()
Returns the name of the family of intentions.
|
protected abstract java.lang.String |
getQualifiedName(T reference) |
protected abstract java.lang.String |
getReferenceName(R reference) |
protected abstract PsiElement |
getReferenceNameElement(R reference) |
protected java.lang.String |
getRequiredMemberName(T reference) |
protected int |
getStartOffset(T element,
R ref) |
java.lang.String |
getText()
Returns text to be shown in the list of available actions, if this action
is available.
|
protected abstract boolean |
hasTypeParameters(R reference) |
protected abstract boolean |
hasUnresolvedImportWhichCanImport(PsiFile psiFile,
java.lang.String name) |
void |
invoke(Project project,
Editor editor,
PsiFile file)
Called when user invokes intention.
|
protected abstract boolean |
isAccessible(PsiMember member,
T reference) |
static boolean |
isAddUnambiguousImportsOnTheFlyEnabled(PsiFile psiFile) |
boolean |
isAvailable(Project project,
Editor editor,
PsiFile file)
Checks whether this intention is available at a caret offset in the file.
|
protected abstract boolean |
isQualified(R reference) |
boolean |
showHint(Editor editor)
Show a popup or perform an automatic action in the given editor.
|
boolean |
startInWriteAction()
Indicate whether this action should be invoked inside write action.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getElementToMakeWritable
getPriority
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.protected abstract java.lang.String getReferenceName(R reference)
protected abstract PsiElement getReferenceNameElement(R reference)
protected abstract boolean hasTypeParameters(R reference)
public java.util.List<PsiClass> getClassesToImport()
public java.util.List<PsiClass> getClassesToImport(boolean acceptWrongNumberOfTypeParams)
protected boolean canReferenceClass(R ref)
protected java.lang.String getRequiredMemberName(T reference)
protected java.util.List<PsiClass> filterByContext(java.util.List<PsiClass> candidates, T ref)
protected abstract java.lang.String getQualifiedName(T reference)
protected static java.util.List<PsiClass> filterAssignableFrom(PsiType type, java.util.List<PsiClass> candidates)
protected static java.util.List<PsiClass> filterBySuperMethods(PsiParameter parameter, java.util.List<PsiClass> candidates)
public boolean fixSilently(Editor editor)
HintAction
IntentionAction.isAvailable(Project, Editor, PsiFile)
is checked to be true
.fixSilently
in interface HintAction
public ImportClassFixBase.Result doFix(Editor editor, boolean allowPopup, boolean allowCaretNearRef)
public static boolean isAddUnambiguousImportsOnTheFlyEnabled(PsiFile psiFile)
protected abstract boolean isQualified(R reference)
public boolean showHint(Editor editor)
HintAction
IntentionAction.isAvailable(Project, Editor, PsiFile)
is checked to be true
.showHint
in interface HintAction
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 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.protected abstract boolean hasUnresolvedImportWhichCanImport(PsiFile psiFile, java.lang.String name)
public void invoke(Project project, Editor editor, PsiFile file)
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.protected void bindReference(PsiReference reference, PsiClass targetClass)
protected AddImportAction createAddImportAction(PsiClass [] classes, Project project, Editor editor)