IDEA-CR-62340: move common prefix out of the error message & test expected errors messages

GitOrigin-RevId: 218608616889b2021860dc1ec31d5a30b30ebfb6
This commit is contained in:
Alexandr Suhinin
2020-05-06 13:15:07 +00:00
committed by intellij-monorepo-bot
parent e71428cc30
commit 5347c755c7
4 changed files with 14 additions and 25 deletions
@@ -46,7 +46,6 @@ fun findExtractOptions(elements: List<PsiElement>): ExtractOptions {
return ExtractMethodHelper.areSemanticallySame(statements) && !haveReferenceToScope(statements, scope)
}
//TODO use correct error messages
val dataOutput = when {
expression != null -> ExpressionOutput(getExpressionType(expression), null, listOf(expression), CodeFragmentAnalyzer.inferNullability(listOf(expression)))
variableData is VariableOutput -> when {
@@ -3,6 +3,7 @@ package com.intellij.refactoring.extractMethod.newImpl
import com.intellij.codeInsight.highlighting.HighlightManager
import com.intellij.ide.util.PropertiesComponent
import com.intellij.java.refactoring.JavaRefactoringBundle
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.command.CommandProcessor
import com.intellij.openapi.diagnostic.Logger
@@ -56,7 +57,8 @@ class MethodExtractor {
}
}
catch (e: ExtractException) {
CommonRefactoringUtil.showErrorHint(project, editor, e.message!!, refactoringName, HelpID.EXTRACT_METHOD)
val message = JavaRefactoringBundle.message("extract.method.error.prefix") + " " + (e.message ?: "")
CommonRefactoringUtil.showErrorHint(project, editor, message, refactoringName, HelpID.EXTRACT_METHOD)
showError(editor, e.problems)
}
}
@@ -484,20 +484,11 @@ public class ExtractMethodNewTest extends LightJavaCodeInsightTestCase {
}
public void testLocalClass() throws Exception {
try {
doTest();
fail("Should fail if local class is defined out of the selected block");
} catch (PrepareFailedException ignore){
}
doPrepareErrorTest("Local class is defined out of the selected block.");
}
public void testLocalClassUsage() throws Exception {
try {
doTest();
fail("Should fail if local class is used out of the selected block");
} catch (PrepareFailedException ignore) {
}
doPrepareErrorTest("Local class is used out of the selected block.");
}
public void testStaticImport() throws Exception {
@@ -525,11 +516,7 @@ public class ExtractMethodNewTest extends LightJavaCodeInsightTestCase {
}
public void testLocalClassDefinedInMethodWhichIsUsedLater() throws Exception {
try {
doTest();
fail("Should fail if local class is used out of the selected block");
} catch (PrepareFailedException ignored) {
}
doPrepareErrorTest("Local class is used out of the selected block.");
}
public void testForceBraces() throws Exception {
@@ -193,13 +193,14 @@ extract.delegate.create.nested.checkbox=Create nested class
extract.delegate.generate.accessors.checkbox=Generate accessors
extract.delegate.unable.create.warning.message=Unable to create class with the given name
extract.method.control.flow.analysis.failed=Code contains syntax errors. Cannot perform necessary analysis.
extract.method.error.class.outside.used=Unable to extract method. Local class is used out of the selected block.
extract.method.error.class.outside.defined=Unable to extract method. Local class is defined out of the selected block.
extract.method.error.many.outputs = Unable to extract method. There are multiple variables to return.
extract.method.error.many.exits = Unable to extract method. There are multiple exit points.
extract.method.error.many.finals = Unable to extract method. There is an assignment to the final field.
extract.method.error.variable.in.expression=Unable to extract method. There is a variable to return inside of the selected expression.
extract.method.error.class.not.found=Unable to extract method. Selected block should be a part of java class.
extract.method.error.prefix=Unable to extract method.
extract.method.error.class.outside.used=Local class is used out of the selected block.
extract.method.error.class.outside.defined=Local class is defined out of the selected block.
extract.method.error.many.outputs=There are multiple variables to return.
extract.method.error.many.exits=There are multiple exit points.
extract.method.error.many.finals=There is an assignment to the final field.
extract.method.error.variable.in.expression=There is a variable to return inside of the selected expression.
extract.method.error.class.not.found=Selected block should be a part of java class.
extract.method.object.anonymous.make.varargs.option=Make &varargs
extract.method.object.class.name=&Class name:
extract.method.object.create.anonymous.class=Create &anonymous class