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

Side by Side Diff: pkg/analysis_server/lib/src/services/refactoring/inline_local.dart

Issue 1042033002: Issue 23018. Fix for inlining multiline strings with leading whitespaces. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 services.src.refactoring.inline_local; 5 library services.src.refactoring.inline_local;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol_server.dart' hide Element; 9 import 'package:analysis_server/src/protocol_server.dart' hide Element;
10 import 'package:analysis_server/src/services/correction/source_range.dart'; 10 import 'package:analysis_server/src/services/correction/source_range.dart';
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 StringInterpolation target = parent.parent; 138 StringInterpolation target = parent.parent;
139 if (initializer is SingleStringLiteral && 139 if (initializer is SingleStringLiteral &&
140 !initializer.isRaw && 140 !initializer.isRaw &&
141 initializer.isSingleQuoted == target.isSingleQuoted && 141 initializer.isSingleQuoted == target.isSingleQuoted &&
142 (!initializer.isMultiline || target.isMultiline)) { 142 (!initializer.isMultiline || target.isMultiline)) {
143 range = rangeNode(parent); 143 range = rangeNode(parent);
144 // unwrap the literal being inlined 144 // unwrap the literal being inlined
145 int initOffset = initializer.contentsOffset; 145 int initOffset = initializer.contentsOffset;
146 int initLength = initializer.contentsEnd - initOffset; 146 int initLength = initializer.contentsEnd - initOffset;
147 codeForReference = utils.getText(initOffset, initLength); 147 codeForReference = utils.getText(initOffset, initLength);
148 // drop leading multiline EOL
149 if (initializer.isMultiline) {
150 if (codeForReference.startsWith('\n')) {
151 codeForReference = codeForReference.substring(1);
152 } else if (codeForReference.startsWith('\r\n')) {
153 codeForReference = codeForReference.substring(2);
154 }
155 }
156 } else if (_shouldBeExpressionInterpolation(parent, initializer)) { 148 } else if (_shouldBeExpressionInterpolation(parent, initializer)) {
157 codeForReference = '{$initializerCode}'; 149 codeForReference = '{$initializerCode}';
158 } else { 150 } else {
159 codeForReference = initializerCode; 151 codeForReference = initializerCode;
160 } 152 }
161 } else if (_shouldUseParenthesis(initializer, node)) { 153 } else if (_shouldUseParenthesis(initializer, node)) {
162 codeForReference = '($initializerCode)'; 154 codeForReference = '($initializerCode)';
163 } else { 155 } else {
164 codeForReference = initializerCode; 156 codeForReference = initializerCode;
165 } 157 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 if (initializerOperator == TokenType.MINUS || 202 if (initializerOperator == TokenType.MINUS ||
211 initializerOperator == TokenType.MINUS_MINUS) { 203 initializerOperator == TokenType.MINUS_MINUS) {
212 return true; 204 return true;
213 } 205 }
214 } 206 }
215 } 207 }
216 // no () is needed 208 // no () is needed
217 return false; 209 return false;
218 } 210 }
219 } 211 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698