| Index: editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/refactoring/ExtractLocalRefactoringTest.java
|
| diff --git a/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/refactoring/ExtractLocalRefactoringTest.java b/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/refactoring/ExtractLocalRefactoringTest.java
|
| index 9fc660063b4cb8ac2d20ab56826328e66c43ed96..d7095eb4467df7a116a3ed2c990738f9bf2ec9a4 100644
|
| --- a/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/refactoring/ExtractLocalRefactoringTest.java
|
| +++ b/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/refactoring/ExtractLocalRefactoringTest.java
|
| @@ -39,6 +39,56 @@ public final class ExtractLocalRefactoringTest extends RefactoringTest {
|
| private ExtractLocalRefactoring refactoring;
|
| private RefactoringStatus refactoringStatus;
|
|
|
| + /**
|
| + * Asserts that {@link refactoringStatus} has fatal error caused by selection.
|
| + */
|
| + private void assert_fatalError_selection() {
|
| + assertTrue(refactoringStatus.hasFatalError());
|
| + assertEquals(
|
| + "An expression must be selected to activate this refactoring.",
|
| + refactoringStatus.getMessageMatchingSeverity(RefactoringStatus.FATAL));
|
| + }
|
| +
|
| + private void assert_warning_alreadyDefined() {
|
| + assertTrue(refactoringStatus.hasWarning());
|
| + assertEquals(
|
| + "A variable with name 'res' is already defined in the visible scope.",
|
| + refactoringStatus.getMessageMatchingSeverity(RefactoringStatus.WARNING));
|
| + }
|
| +
|
| + /**
|
| + * Creates refactoring and checks all conditions.
|
| + */
|
| + private void createRefactoring(String name) throws Exception {
|
| + int selectionLength = selectionEnd - selectionStart;
|
| + refactoring = new ExtractLocalRefactoring(testUnit, selectionStart, selectionLength);
|
| + refactoring.setLocalName(name);
|
| + refactoring.setReplaceAllOccurrences(replaceAllOccurences);
|
| + refactoringStatus = refactoring.checkAllConditions(pm);
|
| + }
|
| +
|
| + private void doSuccessfullRefactoring() throws Exception {
|
| + // create refactoring
|
| + createRefactoring("res");
|
| + // OK status
|
| + if (!refactoringStatus.isOK()) {
|
| + fail(refactoringStatus.toString());
|
| + }
|
| + // perform change
|
| + performRefactoringChange();
|
| + }
|
| +
|
| + private void performRefactoringChange() throws Exception {
|
| + ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
|
| + @Override
|
| + public void run(IProgressMonitor monitor) throws CoreException {
|
| + Change change = refactoring.createChange(pm);
|
| + change.initializeValidationData(pm);
|
| + new PerformChangeOperation(change).run(pm);
|
| + }
|
| + }, null);
|
| + }
|
| +
|
| public void test_access() throws Exception {
|
| setTestUnitContent();
|
| createRefactoring("res");
|
| @@ -416,7 +466,7 @@ public final class ExtractLocalRefactoringTest extends RefactoringTest {
|
| setTestUnitContent(
|
| "// filler filler filler filler filler filler filler filler filler filler",
|
| "class A {",
|
| - " int get foo() => 42;",
|
| + " int get foo => 42;",
|
| "}",
|
| "main() {",
|
| " A a = new A();",
|
| @@ -428,7 +478,7 @@ public final class ExtractLocalRefactoringTest extends RefactoringTest {
|
| assertTestUnitContent(
|
| "// filler filler filler filler filler filler filler filler filler filler",
|
| "class A {",
|
| - " int get foo() => 42;",
|
| + " int get foo => 42;",
|
| "}",
|
| "main() {",
|
| " A a = new A();",
|
| @@ -535,54 +585,4 @@ public final class ExtractLocalRefactoringTest extends RefactoringTest {
|
| " int a = res; // marker",
|
| "}");
|
| }
|
| -
|
| - /**
|
| - * Asserts that {@link refactoringStatus} has fatal error caused by selection.
|
| - */
|
| - private void assert_fatalError_selection() {
|
| - assertTrue(refactoringStatus.hasFatalError());
|
| - assertEquals(
|
| - "An expression must be selected to activate this refactoring.",
|
| - refactoringStatus.getMessageMatchingSeverity(RefactoringStatus.FATAL));
|
| - }
|
| -
|
| - private void assert_warning_alreadyDefined() {
|
| - assertTrue(refactoringStatus.hasWarning());
|
| - assertEquals(
|
| - "A variable with name 'res' is already defined in the visible scope.",
|
| - refactoringStatus.getMessageMatchingSeverity(RefactoringStatus.WARNING));
|
| - }
|
| -
|
| - /**
|
| - * Creates refactoring and checks all conditions.
|
| - */
|
| - private void createRefactoring(String name) throws Exception {
|
| - int selectionLength = selectionEnd - selectionStart;
|
| - refactoring = new ExtractLocalRefactoring(testUnit, selectionStart, selectionLength);
|
| - refactoring.setLocalName(name);
|
| - refactoring.setReplaceAllOccurrences(replaceAllOccurences);
|
| - refactoringStatus = refactoring.checkAllConditions(pm);
|
| - }
|
| -
|
| - private void doSuccessfullRefactoring() throws Exception {
|
| - // create refactoring
|
| - createRefactoring("res");
|
| - // OK status
|
| - if (!refactoringStatus.isOK()) {
|
| - fail(refactoringStatus.toString());
|
| - }
|
| - // perform change
|
| - performRefactoringChange();
|
| - }
|
| -
|
| - private void performRefactoringChange() throws Exception {
|
| - ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
|
| - @Override
|
| - public void run(IProgressMonitor monitor) throws CoreException {
|
| - Change change = refactoring.createChange(pm);
|
| - change.initializeValidationData(pm);
|
| - new PerformChangeOperation(change).run(pm);
|
| - }
|
| - }, null);
|
| - }
|
| }
|
|
|