public class InlineUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
InlineUtil.TailCallType |
Modifier and Type | Method and Description |
---|---|
static boolean |
allUsagesAreTailCalls(PsiMethod method) |
static boolean |
canInlineParameterOrThisVariable(PsiLocalVariable variable) |
static void |
checkChangedBeforeLastAccessConflicts(MultiMap<PsiElement,java.lang.String> conflicts,
PsiExpression initializer,
PsiVariable variable)
Extracts all references from initializer and checks whether
referenced variables are changed after variable initialization and before last usage of variable.
|
static void |
extractReturnValues(PsiMethod method,
boolean replaceWithContinue)
Extracts side effects from return statements, replacing them with simple
return; or continue;
while preserving semantics. |
static InlineUtil.TailCallType |
getTailCallType(PsiReference psiReference) |
static void |
inlineArrayCreationForVarargs(PsiNewExpression arrayCreation) |
static PsiExpression |
inlineInitializer(PsiVariable variable,
PsiExpression initializer,
PsiJavaCodeReferenceElement ref) |
static PsiExpression |
inlineVariable(PsiVariable variable,
PsiExpression initializer,
PsiJavaCodeReferenceElement ref) |
static PsiExpression |
inlineVariable(PsiVariable variable,
PsiExpression initializer,
PsiJavaCodeReferenceElement ref,
PsiExpression thisAccessExpr) |
static boolean |
isChainingConstructor(PsiMethod constructor) |
static void |
solveVariableNameConflicts(PsiElement scope,
PsiElement placeToInsert,
PsiElement renameScope) |
static void |
substituteTypeParams(PsiElement scope,
PsiSubstitutor substitutor,
PsiElementFactory factory) |
static void |
tryInlineGeneratedLocal(PsiLocalVariable variable,
boolean strictlyFinal)
Try to inline local variable which was generated during method inlining (e.g.
|
static void |
tryInlineResultVariable(PsiLocalVariable resultVar,
PsiReferenceExpression resultUsage)
Try to inline the result variable after method inlining
|
static void |
tryToInlineArrayCreationForVarargs(PsiExpression expr) |
public static PsiExpression inlineVariable(PsiVariable variable, PsiExpression initializer, PsiJavaCodeReferenceElement ref) throws IncorrectOperationException
IncorrectOperationException
public static PsiExpression inlineVariable(PsiVariable variable, PsiExpression initializer, PsiJavaCodeReferenceElement ref, PsiExpression thisAccessExpr) throws IncorrectOperationException
IncorrectOperationException
public static void tryToInlineArrayCreationForVarargs(PsiExpression expr)
public static void inlineArrayCreationForVarargs(PsiNewExpression arrayCreation)
public static boolean allUsagesAreTailCalls(PsiMethod method)
public static InlineUtil.TailCallType getTailCallType(PsiReference psiReference)
public static void substituteTypeParams(PsiElement scope, PsiSubstitutor substitutor, PsiElementFactory factory)
public static void solveVariableNameConflicts(PsiElement scope, PsiElement placeToInsert, PsiElement renameScope) throws IncorrectOperationException
IncorrectOperationException
public static boolean isChainingConstructor(PsiMethod constructor)
public static void checkChangedBeforeLastAccessConflicts(MultiMap<PsiElement,java.lang.String> conflicts, PsiExpression initializer, PsiVariable variable)
conflicts
- map for found conflictsinitializer
- variable initializerpublic static void extractReturnValues(PsiMethod method, boolean replaceWithContinue)
return;
or continue;
while preserving semantics.method
- method to processreplaceWithContinue
- if true, returns will be replaced with continue
.public static PsiExpression inlineInitializer(PsiVariable variable, PsiExpression initializer, PsiJavaCodeReferenceElement ref)
public static boolean canInlineParameterOrThisVariable(PsiLocalVariable variable)
public static void tryInlineGeneratedLocal(PsiLocalVariable variable, boolean strictlyFinal) throws IncorrectOperationException
variable
- variable to inlinestrictlyFinal
- whether the variable is referenced in the places where final variable is requiredIncorrectOperationException
public static void tryInlineResultVariable(PsiLocalVariable resultVar, PsiReferenceExpression resultUsage) throws IncorrectOperationException
resultVar
- variable to inlineresultUsage
- variable usageIncorrectOperationException