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

Side by Side Diff: pkg/analysis_server/test/services/refactoring/inline_local_test.dart

Issue 780653005: Issue 21740. Allow inlining local variables declared in SwitchCase. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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/refactoring/inline_local.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.refactoring.inline_local; 5 library test.services.refactoring.inline_local;
6 6
7 import 'package:analysis_server/src/protocol.dart' hide Element; 7 import 'package:analysis_server/src/protocol.dart' hide Element;
8 import 'package:analysis_server/src/services/correction/status.dart'; 8 import 'package:analysis_server/src/services/correction/status.dart';
9 import 'package:analysis_server/src/services/refactoring/inline_local.dart'; 9 import 'package:analysis_server/src/services/refactoring/inline_local.dart';
10 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; 10 import 'package:analysis_server/src/services/refactoring/refactoring.dart';
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 class A { 161 class A {
162 foo() {} 162 foo() {}
163 bar() {} 163 bar() {}
164 } 164 }
165 main() { 165 main() {
166 (new A()..foo()).bar(); 166 (new A()..foo()).bar();
167 } 167 }
168 '''); 168 ''');
169 } 169 }
170 170
171 test_OK_inSwitchCase() {
172 indexTestUnit('''
173 main(int p) {
174 switch (p) {
175 case 0:
176 int test = 42;
177 print(test);
178 break;
179 }
180 }
181 ''');
182 _createRefactoring('test =');
183 // validate change
184 return assertSuccessfulRefactoring('''
185 main(int p) {
186 switch (p) {
187 case 0:
188 print(42);
189 break;
190 }
191 }
192 ''');
193 }
194
171 test_OK_intoStringInterpolation_binaryExpression() { 195 test_OK_intoStringInterpolation_binaryExpression() {
172 indexTestUnit(r''' 196 indexTestUnit(r'''
173 main() { 197 main() {
174 int test = 1 + 2; 198 int test = 1 + 2;
175 print('test = $test'); 199 print('test = $test');
176 print('test = ${test}'); 200 print('test = ${test}');
177 print('test = ${process(test)}'); 201 print('test = ${process(test)}');
178 } 202 }
179 process(x) {} 203 process(x) {}
180 '''); 204 ''');
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 RefactoringProblemSeverity.FATAL, 584 RefactoringProblemSeverity.FATAL,
561 expectedMessage: 'Local variable declaration or reference must be ' 585 expectedMessage: 'Local variable declaration or reference must be '
562 'selected to activate this refactoring.'); 586 'selected to activate this refactoring.');
563 } 587 }
564 588
565 void _createRefactoring(String search) { 589 void _createRefactoring(String search) {
566 int offset = findOffset(search); 590 int offset = findOffset(search);
567 refactoring = new InlineLocalRefactoring(searchEngine, testUnit, offset); 591 refactoring = new InlineLocalRefactoring(searchEngine, testUnit, offset);
568 } 592 }
569 } 593 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/inline_local.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698