| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 formatter_impl; | 5 library formatter_impl; |
| 6 | 6 |
| 7 import 'dart:math'; | 7 import 'dart:math'; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart'; | 9 import 'package:analyzer/analyzer.dart'; |
| 10 import 'package:analyzer/src/generated/parser.dart'; | 10 import 'package:analyzer/src/generated/parser.dart'; |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 visitAssignmentExpression(AssignmentExpression node) { | 455 visitAssignmentExpression(AssignmentExpression node) { |
| 456 visit(node.leftHandSide); | 456 visit(node.leftHandSide); |
| 457 space(); | 457 space(); |
| 458 token(node.operator); | 458 token(node.operator); |
| 459 allowContinuedLines((){ | 459 allowContinuedLines((){ |
| 460 space(); | 460 space(); |
| 461 visit(node.rightHandSide); | 461 visit(node.rightHandSide); |
| 462 }); | 462 }); |
| 463 } | 463 } |
| 464 | 464 |
| 465 @override |
| 466 visitAwaitExpression(AwaitExpression node) { |
| 467 token(node.awaitKeyword); |
| 468 space(); |
| 469 visit(node.expression); |
| 470 // TODO(scheglov) a bug in the spec, there sould not be a ';' |
| 471 token(node.semicolon); |
| 472 } |
| 473 |
| 465 visitBinaryExpression(BinaryExpression node) { | 474 visitBinaryExpression(BinaryExpression node) { |
| 466 Token operator = node.operator; | 475 Token operator = node.operator; |
| 467 TokenType operatorType = operator.type; | 476 TokenType operatorType = operator.type; |
| 468 int addOperands(List<Expression> operands, Expression e, int i) { | 477 int addOperands(List<Expression> operands, Expression e, int i) { |
| 469 if (e is BinaryExpression && e.operator.type == operatorType) { | 478 if (e is BinaryExpression && e.operator.type == operatorType) { |
| 470 i = addOperands(operands, e.leftOperand, i); | 479 i = addOperands(operands, e.leftOperand, i); |
| 471 i = addOperands(operands, e.rightOperand, i); | 480 i = addOperands(operands, e.rightOperand, i); |
| 472 } else { | 481 } else { |
| 473 operands.insert(i++, e); | 482 operands.insert(i++, e); |
| 474 } | 483 } |
| (...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1423 } | 1432 } |
| 1424 visit(node.body); | 1433 visit(node.body); |
| 1425 } | 1434 } |
| 1426 | 1435 |
| 1427 visitWithClause(WithClause node) { | 1436 visitWithClause(WithClause node) { |
| 1428 token(node.withKeyword); | 1437 token(node.withKeyword); |
| 1429 space(); | 1438 space(); |
| 1430 visitCommaSeparatedNodes(node.mixinTypes); | 1439 visitCommaSeparatedNodes(node.mixinTypes); |
| 1431 } | 1440 } |
| 1432 | 1441 |
| 1442 @override |
| 1443 visitYieldStatement(YieldStatement node) { |
| 1444 token(node.yieldKeyword); |
| 1445 token(node.star); |
| 1446 space(); |
| 1447 visit(node.expression); |
| 1448 token(node.semicolon); |
| 1449 } |
| 1450 |
| 1433 /// Safely visit the given [node]. | 1451 /// Safely visit the given [node]. |
| 1434 visit(AstNode node) { | 1452 visit(AstNode node) { |
| 1435 if (node != null) { | 1453 if (node != null) { |
| 1436 node.accept(this); | 1454 node.accept(this); |
| 1437 } | 1455 } |
| 1438 } | 1456 } |
| 1439 | 1457 |
| 1440 /// Visit member metadata | 1458 /// Visit member metadata |
| 1441 visitMemberMetadata(NodeList<Annotation> metadata) { | 1459 visitMemberMetadata(NodeList<Annotation> metadata) { |
| 1442 visitNodes(metadata, | 1460 visitNodes(metadata, |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1823 /// Count the lines between two offsets. | 1841 /// Count the lines between two offsets. |
| 1824 int linesBetween(int lastOffset, int currentOffset) { | 1842 int linesBetween(int lastOffset, int currentOffset) { |
| 1825 var lastLine = | 1843 var lastLine = |
| 1826 lineInfo.getLocation(lastOffset).lineNumber; | 1844 lineInfo.getLocation(lastOffset).lineNumber; |
| 1827 var currentLine = | 1845 var currentLine = |
| 1828 lineInfo.getLocation(currentOffset).lineNumber; | 1846 lineInfo.getLocation(currentOffset).lineNumber; |
| 1829 return currentLine - lastLine; | 1847 return currentLine - lastLine; |
| 1830 } | 1848 } |
| 1831 | 1849 |
| 1832 String toString() => writer.toString(); | 1850 String toString() => writer.toString(); |
| 1833 | |
| 1834 } | 1851 } |
| OLD | NEW |