Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/refactoring/ExtractMethodRefactoringTest.java

Issue 10790117: Check for conflicts between new function/method and other elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/refactoring/ExtractMethodRefactoringTest.java
diff --git a/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/refactoring/ExtractMethodRefactoringTest.java b/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/refactoring/ExtractMethodRefactoringTest.java
index ad6bb01393ffa697e095e330e62faf612033db9e..b60b364bf3d2fe4e75dc15812a915b00a9f609a6 100644
--- a/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/refactoring/ExtractMethodRefactoringTest.java
+++ b/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/refactoring/ExtractMethodRefactoringTest.java
@@ -368,6 +368,106 @@ public final class ExtractMethodRefactoringTest extends RefactoringTest {
}
}
+ public void test_bad_conflict_method_willHideTopLevel() throws Exception {
+ setTestUnitContent(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "void res() {}",
+ "class B extends A {",
+ " foo() {",
+ "// start",
+ " print(0);",
+ "// end",
+ " }",
+ " foo() {",
+ " res();",
+ " }",
+ "}",
+ "");
+ TestProject.waitForAutoBuild();
+ setSelectionFromStartEndComments();
+ createRefactoring();
+ assertTrue(refactoringStatus.hasError());
+ {
+ String msg = refactoringStatus.getMessageMatchingSeverity(RefactoringStatus.ERROR);
+ assertEquals(
+ "Usage of function 'res' in file 'Test/Test.dart' in library 'Test' will be shadowed by created function",
+ msg);
+ }
+ }
+
+ public void test_bad_conflict_topLevel_alreadyDeclaresFunction() throws Exception {
+ setTestUnitContent(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "void res() {}",
+ "main() {",
+ "// start",
+ " print(0);",
+ "// end",
+ "}",
+ "");
+ TestProject.waitForAutoBuild();
+ setSelectionFromStartEndComments();
+ createRefactoring();
+ assertTrue(refactoringStatus.hasError());
+ {
+ String msg = refactoringStatus.getMessageMatchingSeverity(RefactoringStatus.ERROR);
+ assertEquals(
+ "File 'Test/Test.dart' in library 'Test' already declares top-level function 'res'",
+ msg);
+ }
+ }
+
+ public void test_bad_conflict_topLevel_alreadyDeclaresType() throws Exception {
+ setTestUnitContent(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class res {}",
+ "main() {",
+ "// start",
+ " print(0);",
+ "// end",
+ "}",
+ "");
+ TestProject.waitForAutoBuild();
+ setSelectionFromStartEndComments();
+ createRefactoring();
+ assertTrue(refactoringStatus.hasError());
+ {
+ String msg = refactoringStatus.getMessageMatchingSeverity(RefactoringStatus.ERROR);
+ assertEquals(
+ "File 'Test/Test.dart' in library 'Test' already declares top-level type 'res'",
+ msg);
+ }
+ }
+
+ public void test_bad_conflict_topLevel_willHideInheritedMemberUsage() throws Exception {
+ setTestUnitContent(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {",
+ " void res() {}",
+ "}",
+ "class B extends A {",
+ " foo() {",
+ " res();",
+ " }",
+ "}",
+ "main() {",
+ "// start",
+ " print(0);",
+ "// end",
+ "}",
+ "");
+ TestProject.waitForAutoBuild();
+ setSelectionFromStartEndComments();
+ createRefactoring();
+ assertTrue(refactoringStatus.hasError());
+ {
+ String msg = refactoringStatus.getMessageMatchingSeverity(RefactoringStatus.ERROR);
+ assertEquals(
+ "Usage of method 'A.res' declared in 'Test/Test.dart' will be shadowed by created function",
+ msg);
+ }
+ }
+
public void test_bad_constructor_initializer() throws Exception {
setTestUnitContent(
"// filler filler filler filler filler filler filler filler filler filler",

Powered by Google App Engine
This is Rietveld 408576698