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

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/correction/QuickFixProcessorTest.java

Issue 10834222: Initial implementation of 'Create Method' quick fix (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use resolveUnit() in ASTProvider Created 8 years, 4 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/correction/QuickFixProcessorTest.java
diff --git a/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/correction/QuickFixProcessorTest.java b/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/correction/QuickFixProcessorTest.java
index 031fb6ba7e7ba01fa326054ddba6bc04a804a67f..29574b5237449f850b10bdabceee88e68760b0fd 100644
--- a/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/correction/QuickFixProcessorTest.java
+++ b/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/correction/QuickFixProcessorTest.java
@@ -14,6 +14,7 @@
package com.google.dart.tools.ui.correction;
import com.google.dart.compiler.ErrorCode;
+import com.google.dart.compiler.resolver.ResolverErrorCode;
import com.google.dart.compiler.resolver.TypeErrorCode;
import com.google.dart.compiler.util.apache.ArrayUtils;
import com.google.dart.tools.core.DartCore;
@@ -43,6 +44,111 @@ public final class QuickFixProcessorTest extends AbstractDartTest {
private int proposalsExpectedNumber = 1;
private int proposalsIndexToCheck = 0;
+ public void test_createFunction_hasParameters() throws Exception {
+ setTestUnitContent(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " foo(1, 2.0, '');",
+ "}",
+ "");
+ problemCode = ResolverErrorCode.CANNOT_RESOLVE_METHOD;
+ problemOffset = findOffset("foo(");
+ problemLength = "foo".length();
+ assertQuickFix(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " foo(1, 2.0, '');",
+ "}",
+ "",
+ "foo(int i, double d, String string) {",
+ "}",
+ "");
+ }
+
+ public void test_createFunction_hasParameters_Dynamic() throws Exception {
+ setTestUnitContent(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " foo(null);",
+ "}",
+ "");
+ problemCode = ResolverErrorCode.CANNOT_RESOLVE_METHOD;
+ problemOffset = findOffset("foo(");
+ problemLength = "foo".length();
+ assertQuickFix(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " foo(null);",
+ "}",
+ "",
+ "foo(arg0) {",
+ "}",
+ "");
+ }
+
+ public void test_createFunction_noParameters_hasReturnType_Dynamic() throws Exception {
+ setTestUnitContent(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " var v = foo();",
+ "}",
+ "");
+ problemCode = ResolverErrorCode.CANNOT_RESOLVE_METHOD;
+ problemOffset = findOffset("foo();");
+ problemLength = "foo".length();
+ assertQuickFix(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " var v = foo();",
+ "}",
+ "",
+ "foo() {",
+ "}",
+ "");
+ }
+
+ public void test_createFunction_noParameters_hasReturnType_fromVariable() throws Exception {
+ setTestUnitContent(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " int v = foo();",
+ "}",
+ "");
+ problemCode = ResolverErrorCode.CANNOT_RESOLVE_METHOD;
+ problemOffset = findOffset("foo();");
+ problemLength = "foo".length();
+ assertQuickFix(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " int v = foo();",
+ "}",
+ "",
+ "int foo() {",
+ "}",
+ "");
+ }
+
+ public void test_createFunction_noParameters_noReturnType() throws Exception {
+ setTestUnitContent(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " foo();",
+ "}",
+ "");
+ problemCode = ResolverErrorCode.CANNOT_RESOLVE_METHOD;
+ problemOffset = findOffset("foo();");
+ problemLength = "foo".length();
+ assertQuickFix(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " foo();",
+ "}",
+ "",
+ "foo() {",
+ "}",
+ "");
+ }
+
public void test_importLibrary_withType_fromSDK() throws Exception {
setTestUnitContent(
"// filler filler filler filler filler filler filler filler filler filler",

Powered by Google App Engine
This is Rietveld 408576698