| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library services.util; | 8 library services.util; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 } | 450 } |
| 451 } | 451 } |
| 452 // fill array of parents | 452 // fill array of parents |
| 453 List<AstNode> parents = new List<AstNode>(numParents); | 453 List<AstNode> parents = new List<AstNode>(numParents); |
| 454 AstNode current = node.parent; | 454 AstNode current = node.parent; |
| 455 int index = numParents; | 455 int index = numParents; |
| 456 while (current != null) { | 456 while (current != null) { |
| 457 parents[--index] = current; | 457 parents[--index] = current; |
| 458 current = current.parent; | 458 current = current.parent; |
| 459 } | 459 } |
| 460 return JavaArrays.asList(parents); | 460 return parents; |
| 461 } | 461 } |
| 462 | 462 |
| 463 /** | 463 /** |
| 464 * @return the precedence of the given [Expression] operator. May be | 464 * @return the precedence of the given [Expression] operator. May be |
| 465 * `Integer#MAX_VALUE` if not an operator. | 465 * `Integer#MAX_VALUE` if not an operator. |
| 466 */ | 466 */ |
| 467 static int getPrecedence(Expression expression) { | 467 static int getPrecedence(Expression expression) { |
| 468 if (expression is BinaryExpression) { | 468 if (expression is BinaryExpression) { |
| 469 BinaryExpression binaryExpression = expression; | 469 BinaryExpression binaryExpression = expression; |
| 470 return binaryExpression.operator.type.precedence; | 470 return binaryExpression.operator.type.precedence; |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 int lineOffset = 0; | 1003 int lineOffset = 0; |
| 1004 for (int i = 0; i < lines.length; i++) { | 1004 for (int i = 0; i < lines.length; i++) { |
| 1005 String line = lines[i]; | 1005 String line = lines[i]; |
| 1006 // last line, stop if empty | 1006 // last line, stop if empty |
| 1007 if (i == lines.length - 1 && StringUtils.isEmpty(line)) { | 1007 if (i == lines.length - 1 && StringUtils.isEmpty(line)) { |
| 1008 break; | 1008 break; |
| 1009 } | 1009 } |
| 1010 // check if "offset" is in one of the String ranges | 1010 // check if "offset" is in one of the String ranges |
| 1011 bool inString = false; | 1011 bool inString = false; |
| 1012 for (SourceRange lineRange in lineRanges) { | 1012 for (SourceRange lineRange in lineRanges) { |
| 1013 inString = javaBooleanOr(inString, lineOffset > lineRange.offset && line
Offset < lineRange.end); | 1013 if (lineOffset > lineRange.offset && lineOffset < lineRange.end) { |
| 1014 inString = true; |
| 1015 } |
| 1014 if (lineOffset > lineRange.end) { | 1016 if (lineOffset > lineRange.end) { |
| 1015 break; | 1017 break; |
| 1016 } | 1018 } |
| 1017 } | 1019 } |
| 1018 lineOffset += line.length + eol.length; | 1020 lineOffset += line.length + eol.length; |
| 1019 // update line indent | 1021 // update line indent |
| 1020 if (!inString) { | 1022 if (!inString) { |
| 1021 line = "${newIndent}${StringUtils.removeStart(line, oldIndent)}"; | 1023 line = "${newIndent}${StringUtils.removeStart(line, oldIndent)}"; |
| 1022 } | 1024 } |
| 1023 // append line | 1025 // append line |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1755 return []; | 1757 return []; |
| 1756 } | 1758 } |
| 1757 } | 1759 } |
| 1758 | 1760 |
| 1759 /** | 1761 /** |
| 1760 * @return <code>true</code> if given [Token]s contain only single [Token] wit
h given | 1762 * @return <code>true</code> if given [Token]s contain only single [Token] wit
h given |
| 1761 * [TokenType]. | 1763 * [TokenType]. |
| 1762 */ | 1764 */ |
| 1763 static bool hasOnly(List<Token> tokens, TokenType type) => tokens.length == 1
&& tokens[0].type == type; | 1765 static bool hasOnly(List<Token> tokens, TokenType type) => tokens.length == 1
&& tokens[0].type == type; |
| 1764 } | 1766 } |
| OLD | NEW |