| 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 AstNode parent2 = label.parent; | 452 AstNode parent2 = label.parent; |
| 453 if (parent2 is NamedExpression) { | 453 if (parent2 is NamedExpression) { |
| 454 return identical(parent2.name, label); | 454 return identical(parent2.name, label); |
| 455 } | 455 } |
| 456 } | 456 } |
| 457 } | 457 } |
| 458 return false; | 458 return false; |
| 459 } | 459 } |
| 460 | 460 |
| 461 | 461 |
| 462 /** |
| 463 * If the given [expression] is the `expression` property of a [NamedExpression] |
| 464 * then returns this [NamedExpression]. Otherwise returns [expression]. |
| 465 */ |
| 466 Expression stepUpNamedExpression(Expression expression) { |
| 467 if (expression != null) { |
| 468 AstNode parent = expression.parent; |
| 469 if (parent is NamedExpression && parent.expression == expression) { |
| 470 return parent; |
| 471 } |
| 472 } |
| 473 return expression; |
| 474 } |
| 475 |
| 476 |
| 462 class CorrectionUtils { | 477 class CorrectionUtils { |
| 463 final CompilationUnit unit; | 478 final CompilationUnit unit; |
| 464 | 479 |
| 465 LibraryElement _library; | 480 LibraryElement _library; |
| 466 String _buffer; | 481 String _buffer; |
| 467 String _endOfLine; | 482 String _endOfLine; |
| 468 | 483 |
| 469 CorrectionUtils(this.unit) { | 484 CorrectionUtils(this.unit) { |
| 470 CompilationUnitElement unitElement = unit.element; | 485 CompilationUnitElement unitElement = unit.element; |
| 471 this._library = unitElement.library; | 486 this._library = unitElement.library; |
| (...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 | 1382 |
| 1368 @override | 1383 @override |
| 1369 Object visitExpression(Expression node) { | 1384 Object visitExpression(Expression node) { |
| 1370 if (node is BinaryExpression && node.operator.type == groupOperatorType) { | 1385 if (node is BinaryExpression && node.operator.type == groupOperatorType) { |
| 1371 return super.visitNode(node); | 1386 return super.visitNode(node); |
| 1372 } | 1387 } |
| 1373 operands.add(node); | 1388 operands.add(node); |
| 1374 return null; | 1389 return null; |
| 1375 } | 1390 } |
| 1376 } | 1391 } |
| OLD | NEW |