mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
disable introduce refactorings for expr with not inferred types
This commit is contained in:
+1
-1
@@ -103,7 +103,7 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase
|
||||
}
|
||||
|
||||
final PsiType tempType = getTypeByExpression(selectedExpr);
|
||||
if (tempType == null) {
|
||||
if (tempType == null || LambdaUtil.notInferredType(tempType)) {
|
||||
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("unknown.expression.type"));
|
||||
CommonRefactoringUtil.showErrorHint(project, editor, message, getRefactoringName(), getHelpID());
|
||||
return false;
|
||||
|
||||
+1
-1
@@ -151,7 +151,7 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase {
|
||||
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, method)) return false;
|
||||
|
||||
final PsiType typeByExpression = invokedOnDeclaration ? null : RefactoringUtil.getTypeByExpressionWithExpectedType(expr);
|
||||
if (!invokedOnDeclaration && typeByExpression == null) {
|
||||
if (!invokedOnDeclaration && (typeByExpression == null || LambdaUtil.notInferredType(typeByExpression))) {
|
||||
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("type.of.the.selected.expression.cannot.be.determined"));
|
||||
showErrorMessage(project, message, editor);
|
||||
return false;
|
||||
|
||||
+1
-1
@@ -501,7 +501,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
|
||||
|
||||
final PsiType originalType = RefactoringUtil.getTypeByExpressionWithExpectedType(expr);
|
||||
if (originalType == null) {
|
||||
if (originalType == null || LambdaUtil.notInferredType(originalType)) {
|
||||
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("unknown.expression.type"));
|
||||
showErrorMessage(project, editor, message);
|
||||
return false;
|
||||
|
||||
@@ -847,6 +847,10 @@ public class LambdaUtil {
|
||||
return psiSubstitutor;
|
||||
}
|
||||
|
||||
public static boolean notInferredType(PsiType typeByExpression) {
|
||||
return typeByExpression instanceof PsiMethodReferenceType || typeByExpression instanceof PsiLambdaExpressionType || typeByExpression instanceof PsiLambdaParameterType;
|
||||
}
|
||||
|
||||
private static class TypeParamsChecker extends PsiTypeVisitor<Boolean> {
|
||||
private PsiMethod myMethod;
|
||||
private final PsiClass myClass;
|
||||
|
||||
Reference in New Issue
Block a user