mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
inline: do not delete call but warn when resulted expr is not a valid statement (IDEA-88886)
This commit is contained in:
@@ -190,6 +190,21 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
final PsiReturnStatement[] returnStatements = RefactoringUtil.findReturnStatements(myMethod);
|
||||
for (PsiReturnStatement statement : returnStatements) {
|
||||
PsiExpression value = statement.getReturnValue();
|
||||
if (value != null && !(value instanceof PsiCallExpression)) {
|
||||
for (UsageInfo info : usagesIn) {
|
||||
PsiReference reference = info.getReference();
|
||||
InlineUtil.TailCallType type = InlineUtil.getTailCallType(reference);
|
||||
if (type == InlineUtil.TailCallType.Simple) {
|
||||
conflicts.putValue(statement, "Inlined result won't be a valid statement");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addInaccessibleMemberConflicts(myMethod, usagesIn, new ReferencedElementsCollector(), conflicts);
|
||||
|
||||
addInaccessibleSuperCallsConflicts(usagesIn, conflicts);
|
||||
@@ -730,7 +745,7 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
if (returnValue == null) continue;
|
||||
PsiStatement statement;
|
||||
if (tailCallType == InlineUtil.TailCallType.Simple) {
|
||||
if (returnValue instanceof PsiCallExpression) {
|
||||
if (returnValue instanceof PsiExpression) {
|
||||
PsiExpressionStatement exprStatement = (PsiExpressionStatement) myFactory.createStatementFromText("a;", null);
|
||||
exprStatement.getExpression().replace(returnValue);
|
||||
returnStatement.getParent().addBefore(exprStatement, returnStatement);
|
||||
|
||||
Reference in New Issue
Block a user