mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Remove unused properties for "Extract Method" from PyBundle and add several new ones
Also I dropped common wordy prefix "cannot.perform.refactoring" from their names where possible.
This commit is contained in:
@@ -593,15 +593,18 @@ refactoring.push.down.error.cannot.perform.refactoring.not.inside.class=Cannot p
|
||||
refactoring.inline.local.multiassignment=Definition is in multi-assign
|
||||
|
||||
# extract method
|
||||
refactoring.extract.method.error.cannot.perform.refactoring.when.class.declaration.inside=Cannot perform refactoring with class declaration inside code block
|
||||
refactoring.extract.method.error.cannot.perform.refactoring.when.function.declaration.inside=Cannot perform refactoring with function declaration inside code block
|
||||
refactoring.extract.method.error.cannot.perform.refactoring.no.corresponding.loop.for.break=No corresponding loop for break statement inside code fragment
|
||||
refactoring.extract.method.error.cannot.perform.refactoring.no.corresponding.loop.for.continue=No corresponding loop for continue statement inside code fragment
|
||||
refactoring.extract.method.error.cannot.perform.refactoring.when.execution.flow.is.interrupted=Cannot perform refactoring when execution flow is interrupted
|
||||
refactoring.extract.method.error.cannot.perform.refactoring.when.from.import.inside=Cannot perform refactoring with from import statement inside code block
|
||||
refactoring.extract.method.error.cannot.perform.refactoring.using.selected.elements=Cannot perform extract method using selected element(s)
|
||||
refactoring.extract.method=Extract method
|
||||
refactoring.extract.method.error.interrupted.execution.flow=Cannot perform refactoring when execution flow is interrupted
|
||||
refactoring.extract.method.error.star.import=Cannot perform refactoring with star import statement inside code block
|
||||
refactoring.extract.method.error.bad.selection=Cannot perform extract method using selected element(s)
|
||||
refactoring.extract.method.error.name.clash=Method name clashes with already existing name
|
||||
refactoring.extract.method.error.cannot.perform.refactoring.with.local=Cannot perform refactoring from expression with local variables modifications and return instructions inside code fragment
|
||||
refactoring.extract.method.error.returns=Cannot extract method with return instructions inside code fragment
|
||||
refactoring.extract.method.error.local.variable.modifications=Cannot perform refactoring from expression with local variable modifications inside code fragment
|
||||
refactoring.extract.method.error.local.variable.modifications.and.returns=Cannot perform refactoring from expression with local variables modifications and return instructions inside code fragment
|
||||
refactoring.extract.method.error.empty.fragment=Cannot perform refactoring from empty code fragment
|
||||
refactoring.extract.method.error.undetermined.execution.flow=Cannot determine execution flow for the code fragment
|
||||
refactoring.extract.method.error.yield=Cannot perform refactoring with 'yield' statement inside code block
|
||||
|
||||
|
||||
# extract superclass
|
||||
refactoring.extract.super.target.path.outside.roots=Target directory is outside the project. Must be within content roots
|
||||
|
||||
@@ -56,7 +56,7 @@ public class PyCodeFragmentUtil {
|
||||
final int end = endInScope.getTextOffset() + endInScope.getTextLength();
|
||||
final ControlFlow flow = ControlFlowCache.getControlFlow(owner);
|
||||
if (flow == null) {
|
||||
throw new CannotCreateCodeFragmentException("Cannot determine execution flow for the code fragment");
|
||||
throw new CannotCreateCodeFragmentException(PyBundle.message("refactoring.extract.method.error.undetermined.execution.flow"));
|
||||
}
|
||||
final List<Instruction> graph = Arrays.asList(flow.getInstructions());
|
||||
final List<Instruction> subGraph = getFragmentSubGraph(graph, start, end);
|
||||
@@ -64,12 +64,10 @@ public class PyCodeFragmentUtil {
|
||||
if ((subGraphAnalysis.regularExits > 0 && subGraphAnalysis.returns > 0) ||
|
||||
subGraphAnalysis.targetInstructions > 1 ||
|
||||
subGraphAnalysis.outerLoopBreaks > 0) {
|
||||
throw new CannotCreateCodeFragmentException(
|
||||
PyBundle.message("refactoring.extract.method.error.cannot.perform.refactoring.when.execution.flow.is.interrupted"));
|
||||
throw new CannotCreateCodeFragmentException(PyBundle.message("refactoring.extract.method.error.interrupted.execution.flow"));
|
||||
}
|
||||
if (subGraphAnalysis.starImports > 0) {
|
||||
throw new CannotCreateCodeFragmentException(
|
||||
PyBundle.message("refactoring.extract.method.error.cannot.perform.refactoring.when.from.import.inside"));
|
||||
throw new CannotCreateCodeFragmentException(PyBundle.message("refactoring.extract.method.error.star.import"));
|
||||
}
|
||||
|
||||
final Set<String> globalWrites = getGlobalWrites(subGraph, owner);
|
||||
@@ -104,7 +102,7 @@ public class PyCodeFragmentUtil {
|
||||
|
||||
final boolean yieldsFound = subGraphAnalysis.yieldExpressions > 0;
|
||||
if (yieldsFound && LanguageLevel.forElement(owner).isOlderThan(LanguageLevel.PYTHON33)) {
|
||||
throw new CannotCreateCodeFragmentException("Cannot perform refactoring with 'yield' statement inside code block");
|
||||
throw new CannotCreateCodeFragmentException(PyBundle.message("refactoring.extract.method.error.yield"));
|
||||
}
|
||||
|
||||
return new PyCodeFragment(inputNames, outputNames, globalWrites, nonlocalWrites, subGraphAnalysis.returns > 0, yieldsFound);
|
||||
|
||||
+2
-2
@@ -78,7 +78,7 @@ public class PyExtractMethodHandler implements RefactoringActionHandler {
|
||||
element2 = PyPsiUtils.getSignificantToTheLeft(element2, false);
|
||||
if (element1 == null || element2 == null) {
|
||||
CommonRefactoringUtil.showErrorHint(project, editor,
|
||||
PyBundle.message("refactoring.extract.method.error.cannot.perform.refactoring.using.selected.elements"),
|
||||
PyBundle.message("refactoring.extract.method.error.bad.selection"),
|
||||
RefactoringBundle.message("extract.method.title"), "refactoring.extractMethod");
|
||||
return;
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public class PyExtractMethodHandler implements RefactoringActionHandler {
|
||||
}
|
||||
|
||||
CommonRefactoringUtil.showErrorHint(project, editor,
|
||||
PyBundle.message("refactoring.extract.method.error.cannot.perform.refactoring.using.selected.elements"),
|
||||
PyBundle.message("refactoring.extract.method.error.bad.selection"),
|
||||
RefactoringBundle.message("extract.method.title"), "refactoring.extractMethod");
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ public class PyExtractMethodUtil {
|
||||
@NotNull final PsiElement statement2) {
|
||||
if (!fragment.getOutputVariables().isEmpty() && fragment.isReturnInstructionInside()) {
|
||||
CommonRefactoringUtil.showErrorHint(project, editor,
|
||||
PyBundle.message("refactoring.extract.method.error.cannot.perform.refactoring.with.local"),
|
||||
PyBundle.message("refactoring.extract.method.error.local.variable.modifications.and.returns"),
|
||||
RefactoringBundle.message("error.title"), "refactoring.extractMethod");
|
||||
return;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public class PyExtractMethodUtil {
|
||||
final List<PsiElement> elementsRange = PyPsiUtils.collectElements(statement1, statement2);
|
||||
if (elementsRange.isEmpty()) {
|
||||
CommonRefactoringUtil.showErrorHint(project, editor,
|
||||
"Cannot perform refactoring from empty code fragment",
|
||||
PyBundle.message("refactoring.extract.method.error.empty.fragment"),
|
||||
RefactoringBundle.message("extract.method.title"), "refactoring.extractMethod");
|
||||
return;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ public class PyExtractMethodUtil {
|
||||
}
|
||||
});
|
||||
}
|
||||
}, "Extract method", null);
|
||||
}, PyBundle.message("refactoring.extract.method"), null);
|
||||
}
|
||||
|
||||
private static void processDuplicates(@NotNull final PsiElement callElement,
|
||||
@@ -273,14 +273,14 @@ public class PyExtractMethodUtil {
|
||||
@NotNull final PsiElement expression) {
|
||||
if (!fragment.getOutputVariables().isEmpty()) {
|
||||
CommonRefactoringUtil.showErrorHint(project, editor,
|
||||
"Cannot perform refactoring from expression with local variables modifications inside code fragment",
|
||||
PyBundle.message("refactoring.extract.method.error.local.variable.modifications"),
|
||||
RefactoringBundle.message("error.title"), "refactoring.extractMethod");
|
||||
return;
|
||||
}
|
||||
|
||||
if (fragment.isReturnInstructionInside()) {
|
||||
CommonRefactoringUtil.showErrorHint(project, editor,
|
||||
"Cannot extract method with return instructions inside code fragment",
|
||||
PyBundle.message("refactoring.extract.method.error.returns"),
|
||||
RefactoringBundle.message("error.title"), "refactoring.extractMethod");
|
||||
return;
|
||||
}
|
||||
@@ -350,7 +350,7 @@ public class PyExtractMethodUtil {
|
||||
}
|
||||
});
|
||||
}
|
||||
}, "Extract method", null);
|
||||
}, PyBundle.message("refactoring.extract.method"), null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ public class PyExtractMethodTest extends LightMarkedTestCase {
|
||||
}
|
||||
|
||||
public void testWrongSelectionFromImportStar() {
|
||||
doFail("bar", "Cannot perform refactoring with from import statement inside code block");
|
||||
doFail("bar", "Cannot perform refactoring with star import statement inside code block");
|
||||
}
|
||||
|
||||
public void testPy479() {
|
||||
|
||||
Reference in New Issue
Block a user