mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
InlineUtil#surroundWithCast: support variables w/o type element
Review: IDEA-CR-23062
This commit is contained in:
@@ -148,10 +148,15 @@ public class InlineUtil {
|
||||
}
|
||||
|
||||
private static PsiExpression surroundWithCast(PsiVariable variable, PsiExpression expr) {
|
||||
PsiTypeCastExpression cast = (PsiTypeCastExpression)JavaPsiFacade.getElementFactory(expr.getProject()).createExpressionFromText("(t)a", null);
|
||||
PsiElementFactory factory = JavaPsiFacade.getElementFactory(expr.getProject());
|
||||
PsiTypeCastExpression cast = (PsiTypeCastExpression)factory.createExpressionFromText("(t)a", null);
|
||||
PsiTypeElement castTypeElement = cast.getCastType();
|
||||
assert castTypeElement != null;
|
||||
castTypeElement.replace(variable.getTypeElement());
|
||||
PsiTypeElement typeElement = variable.getTypeElement();
|
||||
if (typeElement == null) {
|
||||
typeElement = factory.createTypeElement(variable.getType());
|
||||
}
|
||||
castTypeElement.replace(typeElement);
|
||||
final PsiExpression operand = cast.getOperand();
|
||||
assert operand != null;
|
||||
operand.replace(expr);
|
||||
|
||||
-2
@@ -213,7 +213,6 @@ public class TrivialFunctionalExpressionUsageInspection extends BaseJavaBatchLoc
|
||||
private static void replaceExpression(PsiMethodCallExpression callExpression, PsiLambdaExpression element) {
|
||||
PsiExpression expression;
|
||||
final CommentTracker ct = new CommentTracker();
|
||||
LambdaRefactoringUtil.specifyLambdaParameterTypes(element);
|
||||
inlineCallArguments(callExpression, element, ct);
|
||||
// body could be invalidated after inlining
|
||||
expression = LambdaUtil.extractSingleExpressionFromBody(element.getBody());
|
||||
@@ -228,7 +227,6 @@ public class TrivialFunctionalExpressionUsageInspection extends BaseJavaBatchLoc
|
||||
PsiMethodCallExpression callExpression = PsiTreeUtil.getParentOfType(element, PsiMethodCallExpression.class);
|
||||
if (callExpression == null) return;
|
||||
final CommentTracker ct = new CommentTracker();
|
||||
LambdaRefactoringUtil.specifyLambdaParameterTypes(element);
|
||||
inlineCallArguments(callExpression, element, ct);
|
||||
body = element.getBody();
|
||||
final PsiElement parent = callExpression.getParent();
|
||||
|
||||
Reference in New Issue
Block a user