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

Unified Diff: pkg/analysis_services/test/correction/fix_test.dart

Issue 414273002: New 'use similar' fixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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: pkg/analysis_services/test/correction/fix_test.dart
diff --git a/pkg/analysis_services/test/correction/fix_test.dart b/pkg/analysis_services/test/correction/fix_test.dart
index f843cac243af3489dddac0976a9a624ca4dd5cbc..f006941c6f6df6813af7654e8b547f2af157de39 100644
--- a/pkg/analysis_services/test/correction/fix_test.dart
+++ b/pkg/analysis_services/test/correction/fix_test.dart
@@ -1189,6 +1189,34 @@ void myUndefinedFunction() {
''');
}
+ void test_undefinedFunction_useSimilar_fromImport() {
+ _indexTestUnit('''
+main() {
+ pritn(0);
+}
+''');
+ assertHasFix(FixKind.CHANGE_TO, '''
+main() {
+ print(0);
+}
+''');
+ }
+
+ void test_undefinedFunction_useSimilar_thisLibrary() {
+ _indexTestUnit('''
+myFunction() {}
+main() {
+ myFuntcion();
+}
+''');
+ assertHasFix(FixKind.CHANGE_TO, '''
+myFunction() {}
+main() {
+ myFunction();
+}
+''');
+ }
+
void test_undefinedMethod_createQualified_fromClass() {
_indexTestUnit('''
class A {
@@ -1387,6 +1415,106 @@ main() {
''');
}
+ void test_undefinedMethod_useSimilar_ignoreOperators() {
+ _indexTestUnit('''
+main(Object object) {
+ object.then();
+}
+''');
+ assertNoFix(FixKind.CHANGE_TO);
+ }
+
+ void test_undefinedMethod_useSimilar_qualified() {
+ _indexTestUnit('''
+class A {
+ myMethod() {}
+}
+main() {
+ A a = new A();
+ a.myMehtod();
+}
+''');
+ assertHasFix(FixKind.CHANGE_TO, '''
+class A {
+ myMethod() {}
+}
+main() {
+ A a = new A();
+ a.myMethod();
+}
+''');
+ }
+
+ void test_undefinedClass_useSimilar_fromThisLibrary() {
+ _indexTestUnit('''
+class MyClass {}
+main() {
+ MyCalss v = null;
+}
+''');
+ assertHasFix(FixKind.CHANGE_TO, '''
+class MyClass {}
+main() {
+ MyClass v = null;
+}
+''');
+ }
+
+ void test_undefinedClass_useSimilar_fromImport() {
+ _indexTestUnit('''
+main() {
+ Stirng s = 'abc';
+}
+''');
+ assertHasFix(FixKind.CHANGE_TO, '''
+main() {
+ String s = 'abc';
+}
+''');
+ }
+
+ void test_undefinedMethod_useSimilar_unqualified_superClass() {
+ _indexTestUnit('''
+class A {
+ myMethod() {}
+}
+class B extends A {
+ main() {
+ myMehtod();
+ }
+}
+''');
+ assertHasFix(FixKind.CHANGE_TO, '''
+class A {
+ myMethod() {}
+}
+class B extends A {
+ main() {
+ myMethod();
+ }
+}
+''');
+ }
+
+ void test_undefinedMethod_useSimilar_unqualified_thisClass() {
+ _indexTestUnit('''
+class A {
+ myMethod() {}
+ main() {
+ myMehtod();
+ }
+}
+''');
+ assertHasFix(FixKind.CHANGE_TO, '''
+class A {
+ myMethod() {}
+ main() {
+ myMethod();
+ }
+}
+''');
+ }
+
void test_useEffectiveIntegerDivision() {
_indexTestUnit('''
main() {

Powered by Google App Engine
This is Rietveld 408576698