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

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

Issue 633823002: Issue 21233. Improve inlining strings into string interpolations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 return assertSuccessfulRefactoring(r''' 87 return assertSuccessfulRefactoring(r'''
88 main() { 88 main() {
89 print('test = ${1 + 2}'); 89 print('test = ${1 + 2}');
90 print('test = ${1 + 2}'); 90 print('test = ${1 + 2}');
91 print('test = ${process(1 + 2)}'); 91 print('test = ${process(1 + 2)}');
92 } 92 }
93 process(x) {} 93 process(x) {}
94 '''); 94 ''');
95 } 95 }
96 96
97 test_OK_intoStringInterpolation_raw() {
98 indexTestUnit(r'''
99 main() {
100 String a = r'an $ignored interpolation';
101 String b = '$a bbb';
102 }
103 ''');
104 _createRefactoring('a =');
105 // we don't unwrap raw strings
106 return assertSuccessfulRefactoring(r'''
107 main() {
108 String b = '${r'an $ignored interpolation'} bbb';
109 }
110 ''');
111 }
112
113 test_OK_intoStringInterpolation_string() {
114 indexTestUnit(r'''
115 main() {
116 String a = 'aaa';
117 String b = '$a bbb';
118 }
119 ''');
120 _createRefactoring('a =');
121 // validate change
122 return assertSuccessfulRefactoring(r'''
123 main() {
124 String b = 'aaa bbb';
125 }
126 ''');
127 }
128
129 test_OK_intoStringInterpolation_stringInterpolation() {
130 indexTestUnit(r'''
131 main() {
132 String a = 'aaa';
133 String b = '$a bbb';
134 String c = '$b ccc';
135 }
136 ''');
137 _createRefactoring('b =');
138 // validate change
139 return assertSuccessfulRefactoring(r'''
140 main() {
141 String a = 'aaa';
142 String c = '$a bbb ccc';
143 }
144 ''');
145 }
146
97 /** 147 /**
98 * <p> 148 * <p>
99 * https://code.google.com/p/dart/issues/detail?id=18587 149 * https://code.google.com/p/dart/issues/detail?id=18587
100 */ 150 */
101 test_OK_keepNextCommentedLine() { 151 test_OK_keepNextCommentedLine() {
102 indexTestUnit(''' 152 indexTestUnit('''
103 main() { 153 main() {
104 int test = 1 + 2; 154 int test = 1 + 2;
105 // foo 155 // foo
106 print(test); 156 print(test);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 RefactoringProblemSeverity.FATAL, 370 RefactoringProblemSeverity.FATAL,
321 expectedMessage: 'Local variable declaration or reference must be ' 371 expectedMessage: 'Local variable declaration or reference must be '
322 'selected to activate this refactoring.'); 372 'selected to activate this refactoring.');
323 } 373 }
324 374
325 void _createRefactoring(String search) { 375 void _createRefactoring(String search) {
326 int offset = findOffset(search); 376 int offset = findOffset(search);
327 refactoring = new InlineLocalRefactoring(searchEngine, testUnit, offset); 377 refactoring = new InlineLocalRefactoring(searchEngine, testUnit, offset);
328 } 378 }
329 } 379 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698