public abstract class IntroduceVariableBase extends IntroduceHandlerBase
Modifier and Type | Class and Description |
---|---|
static class |
IntroduceVariableBase.JavaReplaceChoice |
static interface |
IntroduceVariableBase.Validator |
Modifier and Type | Field and Description |
---|---|
static Key<java.lang.Boolean> |
NEED_PARENTHESIS |
Constructor and Description |
---|
IntroduceVariableBase() |
Modifier and Type | Method and Description |
---|---|
static boolean |
canBeExtractedWithoutExplicitType(PsiExpression expr) |
static boolean |
checkAnchorBeforeThisOrSuper(Project project,
Editor editor,
PsiElement tempAnchorElement,
java.lang.String refactoringName,
java.lang.String helpID) |
protected PsiElement |
checkAnchorStatement(Project project,
Editor editor,
PsiElement anchorStatement) |
static void |
checkInLoopCondition(PsiExpression occurence,
MultiMap<PsiElement,java.lang.String> conflicts) |
protected static PsiElement |
chooseAnchor(boolean allOccurrences,
boolean hasWriteAccess,
java.util.List<PsiExpression> nonWrite,
PsiElement anchorStatementIfAll,
PsiElement anchorStatement) |
static java.util.List<PsiExpression> |
collectExpressions(PsiFile file,
Document document,
int offset,
boolean acceptVoid) |
static java.util.List<PsiExpression> |
collectExpressions(PsiFile file,
Editor editor,
int offset) |
static java.util.List<PsiExpression> |
collectExpressions(PsiFile file,
Editor editor,
int offset,
boolean acceptVoid) |
static boolean |
createFinals(PsiFile file) |
static boolean |
createVarType() |
static PsiElement |
expandDiamondsAndReplaceExplicitTypeWithVar(PsiTypeElement typeElement,
PsiElement context)
Ensure that diamond inside initializer is expanded, then replace variable type with var
|
static PsiElement[] |
findStatementsAtOffset(Editor editor,
PsiFile file,
int offset) |
static java.lang.String |
getErrorMessage(PsiExpression expr) |
AbstractInplaceIntroducer |
getInplaceIntroducer() |
protected IntroduceVariableBase.JavaReplaceChoice |
getOccurrencesChoice() |
protected static java.lang.String |
getRefactoringName() |
static PsiExpression |
getSelectedExpression(Project project,
PsiFile file,
int startOffset,
int endOffset) |
IntroduceVariableSettings |
getSettings(Project project,
Editor editor,
PsiExpression expr,
PsiExpression[] occurrences,
TypeSelectorManagerImpl typeSelectorManager,
boolean declareFinalIfAll,
boolean anyAssignmentLHS,
InputValidator validator,
PsiElement anchor,
IntroduceVariableBase.JavaReplaceChoice replaceChoice) |
static SuggestedNameInfo |
getSuggestedName(PsiType type,
PsiExpression expression) |
static SuggestedNameInfo |
getSuggestedName(PsiType type,
PsiExpression expression,
PsiElement anchor) |
protected static void |
highlightReplacedOccurrences(Project project,
Editor editor,
PsiElement[] replacedOccurrences) |
void |
invoke(Project project,
Editor editor,
PsiFile file,
DataContext dataContext)
Invokes refactoring action from editor.
|
protected boolean |
invokeImpl(Project project,
PsiExpression expr,
Editor editor) |
protected boolean |
invokeImpl(Project project,
PsiLocalVariable localVariable,
Editor editor) |
static boolean |
isChooserNeeded(java.util.List<? extends PsiExpression> expressions) |
protected boolean |
isInplaceAvailableInTestMode() |
static boolean |
isPreferStatements() |
static int |
preferredSelection(PsiElement[] statementsInRange,
java.util.List<? extends PsiExpression> expressions) |
static PsiElement |
replace(PsiExpression expr1,
PsiExpression ref,
Project project) |
protected boolean |
reportConflicts(MultiMap<PsiElement,java.lang.String> conflicts,
Project project,
IntroduceVariableSettings settings) |
static boolean |
selectLineAtCaret(int offset,
PsiElement[] statementsInRange) |
protected abstract void |
showErrorMessage(Project project,
Editor editor,
java.lang.String message) |
static PsiExpression |
simplifyVariableInitializer(PsiExpression initializer,
PsiType expectedType) |
static PsiExpression |
simplifyVariableInitializer(PsiExpression initializer,
PsiType expectedType,
boolean inDeclaration) |
acceptLocalVariable, invoke, invoke, isAvailableForQuickList
public static final Key<java.lang.Boolean> NEED_PARENTHESIS
public static SuggestedNameInfo getSuggestedName(PsiType type, PsiExpression expression)
public static SuggestedNameInfo getSuggestedName(PsiType type, PsiExpression expression, PsiElement anchor)
public void invoke(Project project, Editor editor, PsiFile file, DataContext dataContext)
RefactoringActionHandler
project
- the project in which the refactoring is invoked.editor
- editor that refactoring is invoked infile
- file should correspond to editor
dataContext
- can be null
for some but not all of refactoring action handlers
(it is recommended to pass DataManager.getDataContext()
instead of null
)public static boolean isChooserNeeded(java.util.List<? extends PsiExpression> expressions)
public static boolean selectLineAtCaret(int offset, PsiElement[] statementsInRange)
public static int preferredSelection(PsiElement[] statementsInRange, java.util.List<? extends PsiExpression> expressions)
public static boolean isPreferStatements()
public static java.util.List<PsiExpression> collectExpressions(PsiFile file, Editor editor, int offset)
public static java.util.List<PsiExpression> collectExpressions(PsiFile file, Editor editor, int offset, boolean acceptVoid)
public static java.util.List<PsiExpression> collectExpressions(PsiFile file, Document document, int offset, boolean acceptVoid)
public static PsiElement[] findStatementsAtOffset(Editor editor, PsiFile file, int offset)
public static PsiExpression getSelectedExpression(Project project, PsiFile file, int startOffset, int endOffset)
getErrorMessage(PsiExpression)
public static java.lang.String getErrorMessage(PsiExpression expr)
protected boolean invokeImpl(Project project, PsiExpression expr, Editor editor)
invokeImpl
in class IntroduceHandlerBase
editor
- editor to highlight stuff in. Should accept null
public static boolean canBeExtractedWithoutExplicitType(PsiExpression expr)
protected PsiElement checkAnchorStatement(Project project, Editor editor, PsiElement anchorStatement)
protected IntroduceVariableBase.JavaReplaceChoice getOccurrencesChoice()
protected static PsiElement chooseAnchor(boolean allOccurrences, boolean hasWriteAccess, java.util.List<PsiExpression> nonWrite, PsiElement anchorStatementIfAll, PsiElement anchorStatement)
protected boolean isInplaceAvailableInTestMode()
public static PsiExpression simplifyVariableInitializer(PsiExpression initializer, PsiType expectedType)
public static PsiExpression simplifyVariableInitializer(PsiExpression initializer, PsiType expectedType, boolean inDeclaration)
public static PsiElement expandDiamondsAndReplaceExplicitTypeWithVar(PsiTypeElement typeElement, PsiElement context)
public static PsiElement replace(PsiExpression expr1, PsiExpression ref, Project project) throws IncorrectOperationException
IncorrectOperationException
protected boolean invokeImpl(Project project, PsiLocalVariable localVariable, Editor editor)
invokeImpl
in class IntroduceHandlerBase
editor
- editor to highlight stuff in. Should accept null
protected static void highlightReplacedOccurrences(Project project, Editor editor, PsiElement[] replacedOccurrences)
protected abstract void showErrorMessage(Project project, Editor editor, java.lang.String message)
protected boolean reportConflicts(MultiMap<PsiElement,java.lang.String> conflicts, Project project, IntroduceVariableSettings settings)
public IntroduceVariableSettings getSettings(Project project, Editor editor, PsiExpression expr, PsiExpression[] occurrences, TypeSelectorManagerImpl typeSelectorManager, boolean declareFinalIfAll, boolean anyAssignmentLHS, InputValidator validator, PsiElement anchor, IntroduceVariableBase.JavaReplaceChoice replaceChoice)
public static boolean createFinals(PsiFile file)
public static boolean createVarType()
public static boolean checkAnchorBeforeThisOrSuper(Project project, Editor editor, PsiElement tempAnchorElement, java.lang.String refactoringName, java.lang.String helpID)
public static void checkInLoopCondition(PsiExpression occurence, MultiMap<PsiElement,java.lang.String> conflicts)
public AbstractInplaceIntroducer getInplaceIntroducer()
getInplaceIntroducer
in class IntroduceHandlerBase
protected static java.lang.String getRefactoringName()