| OLD | NEW |
| 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/src/protocol.dart' show SourceEdit; | 9 import 'package:analysis_server/src/protocol.dart' show SourceEdit; |
| 10 import 'package:analysis_server/src/services/correction/source_range.dart'; | 10 import 'package:analysis_server/src/services/correction/source_range.dart'; |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 * [SourceRange] from [oldIndent] to [newIndent], keeping indentation of lines | 404 * [SourceRange] from [oldIndent] to [newIndent], keeping indentation of lines |
| 405 * relative to each other. | 405 * relative to each other. |
| 406 */ | 406 */ |
| 407 SourceEdit createIndentEdit(SourceRange range, String oldIndent, | 407 SourceEdit createIndentEdit(SourceRange range, String oldIndent, |
| 408 String newIndent) { | 408 String newIndent) { |
| 409 String newSource = replaceSourceRangeIndent(range, oldIndent, newIndent); | 409 String newSource = replaceSourceRangeIndent(range, oldIndent, newIndent); |
| 410 return new SourceEdit(range.offset, range.length, newSource); | 410 return new SourceEdit(range.offset, range.length, newSource); |
| 411 } | 411 } |
| 412 | 412 |
| 413 /** | 413 /** |
| 414 * Returns the [AstNode] that encloses the given offset. |
| 415 */ |
| 416 AstNode findNode(int offset) => new NodeLocator.con1(offset).searchWithin(unit
); |
| 417 |
| 418 /** |
| 414 * Returns the actual type source of the given [Expression], may be `null` | 419 * Returns the actual type source of the given [Expression], may be `null` |
| 415 * if can not be resolved, should be treated as the `dynamic` type. | 420 * if can not be resolved, should be treated as the `dynamic` type. |
| 416 */ | 421 */ |
| 417 String getExpressionTypeSource(Expression expression) { | 422 String getExpressionTypeSource(Expression expression) { |
| 418 if (expression == null) { | 423 if (expression == null) { |
| 419 return null; | 424 return null; |
| 420 } | 425 } |
| 421 DartType type = expression.bestType; | 426 DartType type = expression.bestType; |
| 422 if (type.isDynamic) { | 427 if (type.isDynamic) { |
| 423 return null; | 428 return null; |
| (...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 | 1278 |
| 1274 @override | 1279 @override |
| 1275 Object visitExpression(Expression node) { | 1280 Object visitExpression(Expression node) { |
| 1276 if (node is BinaryExpression && node.operator.type == groupOperatorType) { | 1281 if (node is BinaryExpression && node.operator.type == groupOperatorType) { |
| 1277 return super.visitNode(node); | 1282 return super.visitNode(node); |
| 1278 } | 1283 } |
| 1279 operands.add(node); | 1284 operands.add(node); |
| 1280 return null; | 1285 return null; |
| 1281 } | 1286 } |
| 1282 } | 1287 } |
| OLD | NEW |