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

Side by Side Diff: pkg/analysis_server/lib/src/services/correction/util.dart

Issue 2538143003: Issue 27903. Use shared logic for computing new method location. (Closed)
Patch Set: Created 4 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
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.correction.util; 5 library services.src.correction.util;
6 6
7 import 'dart:math'; 7 import 'dart:math';
8 8
9 import 'package:analysis_server/plugin/protocol/protocol.dart' 9 import 'package:analysis_server/plugin/protocol/protocol.dart'
10 show SourceChange, SourceEdit; 10 show SourceChange, SourceEdit;
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 ClassMemberLocation prepareNewGetterLocation( 1310 ClassMemberLocation prepareNewGetterLocation(
1311 ClassDeclaration classDeclaration) { 1311 ClassDeclaration classDeclaration) {
1312 return prepareNewClassMemberLocation( 1312 return prepareNewClassMemberLocation(
1313 classDeclaration, 1313 classDeclaration,
1314 (member) => 1314 (member) =>
1315 member is FieldDeclaration || 1315 member is FieldDeclaration ||
1316 member is ConstructorDeclaration || 1316 member is ConstructorDeclaration ||
1317 member is MethodDeclaration && member.isGetter); 1317 member is MethodDeclaration && member.isGetter);
1318 } 1318 }
1319 1319
1320 ClassMemberLocation prepareNewMethodLocation(
1321 ClassDeclaration classDeclaration) {
1322 return prepareNewClassMemberLocation(
1323 classDeclaration,
1324 (member) =>
1325 member is FieldDeclaration ||
1326 member is ConstructorDeclaration ||
1327 member is MethodDeclaration);
1328 }
1329
1320 /** 1330 /**
1321 * Returns the source with indentation changed from [oldIndent] to 1331 * Returns the source with indentation changed from [oldIndent] to
1322 * [newIndent], keeping indentation of lines relative to each other. 1332 * [newIndent], keeping indentation of lines relative to each other.
1323 */ 1333 */
1324 String replaceSourceIndent( 1334 String replaceSourceIndent(
1325 String source, String oldIndent, String newIndent) { 1335 String source, String oldIndent, String newIndent) {
1326 // prepare STRING token ranges 1336 // prepare STRING token ranges
1327 List<SourceRange> lineRanges = []; 1337 List<SourceRange> lineRanges = [];
1328 { 1338 {
1329 List<Token> tokens = TokenUtils.getTokens(source); 1339 List<Token> tokens = TokenUtils.getTokens(source);
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 _InvertedCondition expr, int newOperatorPrecedence) { 1661 _InvertedCondition expr, int newOperatorPrecedence) {
1652 if (expr._precedence < newOperatorPrecedence) { 1662 if (expr._precedence < newOperatorPrecedence) {
1653 return "(${expr._source})"; 1663 return "(${expr._source})";
1654 } 1664 }
1655 return expr._source; 1665 return expr._source;
1656 } 1666 }
1657 1667
1658 static _InvertedCondition _simple(String source) => 1668 static _InvertedCondition _simple(String source) =>
1659 new _InvertedCondition(2147483647, source); 1669 new _InvertedCondition(2147483647, source);
1660 } 1670 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698