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

Side by Side Diff: pkg/analysis_server/test/services/correction/fix_test.dart

Issue 895773004: Issue 22316. Don't propose to create invalid local variable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.services.correction.fix; 5 library test.services.correction.fix;
6 6
7 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; 7 import 'package:analysis_server/src/protocol.dart' hide AnalysisError;
8 import 'package:analysis_server/src/services/correction/fix.dart'; 8 import 'package:analysis_server/src/services/correction/fix.dart';
9 import 'package:analysis_server/src/services/index/index.dart'; 9 import 'package:analysis_server/src/services/index/index.dart';
10 import 'package:analysis_server/src/services/index/local_memory_index.dart'; 10 import 'package:analysis_server/src/services/index/local_memory_index.dart';
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 class A { 915 class A {
916 get test => null; 916 get test => null;
917 917
918 main() { 918 main() {
919 test; 919 test;
920 } 920 }
921 } 921 }
922 '''); 922 ''');
923 } 923 }
924 924
925 void test_createLocalVariable_functionType_named() {
926 _indexTestUnit('''
927 typedef MY_FUNCTION(int p);
928 foo(MY_FUNCTION f) {}
929 main() {
930 foo(bar);
931 }
932 ''');
933 assertHasFix(FixKind.CREATE_LOCAL_VARIABLE, '''
934 typedef MY_FUNCTION(int p);
935 foo(MY_FUNCTION f) {}
936 main() {
937 MY_FUNCTION bar;
938 foo(bar);
939 }
940 ''');
941 }
942
943 void test_createLocalVariable_functionType_synthetic() {
944 _indexTestUnit('''
945 foo(f(int p)) {}
946 main() {
947 foo(bar);
948 }
949 ''');
950 assertNoFix(FixKind.CREATE_LOCAL_VARIABLE);
951 }
952
925 void test_createLocalVariable_read_typeAssignment() { 953 void test_createLocalVariable_read_typeAssignment() {
926 _indexTestUnit(''' 954 _indexTestUnit('''
927 main() { 955 main() {
928 int a = test; 956 int a = test;
929 } 957 }
930 '''); 958 ''');
931 assertHasFix(FixKind.CREATE_LOCAL_VARIABLE, ''' 959 assertHasFix(FixKind.CREATE_LOCAL_VARIABLE, '''
932 main() { 960 main() {
933 int test; 961 int test;
934 int a = test; 962 int a = test;
(...skipping 1878 matching lines...) Expand 10 before | Expand all | Expand 10 after
2813 positions.add(new Position(testFile, offset)); 2841 positions.add(new Position(testFile, offset));
2814 } 2842 }
2815 return positions; 2843 return positions;
2816 } 2844 }
2817 2845
2818 void _indexTestUnit(String code) { 2846 void _indexTestUnit(String code) {
2819 resolveTestUnit(code); 2847 resolveTestUnit(code);
2820 index.indexUnit(context, testUnit); 2848 index.indexUnit(context, testUnit);
2821 } 2849 }
2822 } 2850 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698