| 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 */ | 282 */ |
| 283 static int getExpressionParentPrecedence(AstNode node) { | 283 static int getExpressionParentPrecedence(AstNode node) { |
| 284 AstNode parent = node.parent; | 284 AstNode parent = node.parent; |
| 285 if (parent is ParenthesizedExpression) { | 285 if (parent is ParenthesizedExpression) { |
| 286 return 0; | 286 return 0; |
| 287 } | 287 } |
| 288 return getExpressionPrecedence(parent); | 288 return getExpressionPrecedence(parent); |
| 289 } | 289 } |
| 290 | 290 |
| 291 /** | 291 /** |
| 292 * @return the precedence of the given node - result of [Expression#getPrecede
nce] if an | 292 * Return the precedence of the given [node]: the result of invoking |
| 293 * [Expression], negative otherwise. | 293 * [Expression.precedence] if the node is an [Expression], or a negative value |
| 294 * otherwise. |
| 294 */ | 295 */ |
| 295 static int getExpressionPrecedence(AstNode node) { | 296 static int getExpressionPrecedence(AstNode node) { |
| 296 if (node is Expression) { | 297 if (node is Expression) { |
| 297 return node.precedence; | 298 return node.precedence; |
| 298 } | 299 } |
| 299 return -1000; | 300 return -1000; |
| 300 } | 301 } |
| 301 | 302 |
| 302 /** | 303 /** |
| 303 * TODO(scheglov) may be replace with some API for this | 304 * TODO(scheglov) may be replace with some API for this |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 */ | 419 */ |
| 419 static ParameterElement getParameterElement(SimpleIdentifier node) { | 420 static ParameterElement getParameterElement(SimpleIdentifier node) { |
| 420 Element element = node.staticElement; | 421 Element element = node.staticElement; |
| 421 if (element is ParameterElement) { | 422 if (element is ParameterElement) { |
| 422 return element; | 423 return element; |
| 423 } | 424 } |
| 424 return null; | 425 return null; |
| 425 } | 426 } |
| 426 | 427 |
| 427 /** | 428 /** |
| 428 * @return the precedence of the given [Expression] parent. May be `-1` no ope
rator. | 429 * Return the precedence of the given [expression]'s parent. May be `-1` no |
| 429 * @see #getPrecedence(Expression) | 430 * operator. |
| 431 * |
| 432 * See [getPrecedence]. |
| 430 */ | 433 */ |
| 431 static int getParentPrecedence(Expression expression) { | 434 static int getParentPrecedence(Expression expression) { |
| 432 AstNode parent = expression.parent; | 435 AstNode parent = expression.parent; |
| 433 if (parent is Expression) { | 436 if (parent is Expression) { |
| 434 return getPrecedence(parent); | 437 return getPrecedence(parent); |
| 435 } | 438 } |
| 436 return -1; | 439 return -1; |
| 437 } | 440 } |
| 438 | 441 |
| 439 /** | 442 /** |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 } else { | 661 } else { |
| 659 _addAll(excluded, res, _getVariableNameSuggestions(typeName)); | 662 _addAll(excluded, res, _getVariableNameSuggestions(typeName)); |
| 660 } | 663 } |
| 661 res.remove(typeName); | 664 res.remove(typeName); |
| 662 } | 665 } |
| 663 // done | 666 // done |
| 664 return new List.from(res); | 667 return new List.from(res); |
| 665 } | 668 } |
| 666 | 669 |
| 667 /** | 670 /** |
| 668 * @return `true` if the given [Element#getDisplayName] equals to the given na
me. | 671 * Return `true` if the given [element]'s display name ([Element.displayName]) |
| 672 * is equal to the given [name]. |
| 669 */ | 673 */ |
| 670 static bool hasDisplayName(Element element, String name) { | 674 static bool hasDisplayName(Element element, String name) { |
| 671 if (element == null) { | 675 if (element == null) { |
| 672 return false; | 676 return false; |
| 673 } | 677 } |
| 674 String elementDisplayName = element.displayName; | 678 String elementDisplayName = element.displayName; |
| 675 return StringUtils.equals(elementDisplayName, name); | 679 return StringUtils.equals(elementDisplayName, name); |
| 676 } | 680 } |
| 677 | 681 |
| 678 /** | 682 /** |
| 679 * @return `true` if the given [Element#getName] equals to the given name. | 683 * Return `true` if the given [element]'s name ([Element.name]) is equal to |
| 684 * the given [name]. |
| 680 */ | 685 */ |
| 681 static bool hasName(Element element, String name) { | 686 static bool hasName(Element element, String name) { |
| 682 if (element == null) { | 687 if (element == null) { |
| 683 return false; | 688 return false; |
| 684 } | 689 } |
| 685 String elementName = element.name; | 690 String elementName = element.name; |
| 686 return StringUtils.equals(elementName, name); | 691 return StringUtils.equals(elementName, name); |
| 687 } | 692 } |
| 688 | 693 |
| 689 /** | 694 /** |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 this._library = element.library; | 907 this._library = element.library; |
| 903 this._buffer = getSourceContent(element.context, element.source); | 908 this._buffer = getSourceContent(element.context, element.source); |
| 904 } | 909 } |
| 905 | 910 |
| 906 /** | 911 /** |
| 907 * @return the [AstNode] that encloses the given offset. | 912 * @return the [AstNode] that encloses the given offset. |
| 908 */ | 913 */ |
| 909 AstNode findNode(int offset) => new NodeLocator.con1(offset).searchWithin(unit
); | 914 AstNode findNode(int offset) => new NodeLocator.con1(offset).searchWithin(unit
); |
| 910 | 915 |
| 911 /** | 916 /** |
| 912 * TODO(scheglov) replace with nodes once there will be [CompilationUnit#getCo
mments]. | 917 * TODO(scheglov) replace with nodes once there will be [CompilationUnit.comme
nts]. |
| 913 * | 918 * |
| 914 * @return the [SourceRange]s of all comments in [CompilationUnit]. | 919 * @return the [SourceRange]s of all comments in [CompilationUnit]. |
| 915 */ | 920 */ |
| 916 List<SourceRange> get commentRanges { | 921 List<SourceRange> get commentRanges { |
| 917 List<SourceRange> ranges = []; | 922 List<SourceRange> ranges = []; |
| 918 Token token = unit.beginToken; | 923 Token token = unit.beginToken; |
| 919 while (token != null && token.type != TokenType.EOF) { | 924 while (token != null && token.type != TokenType.EOF) { |
| 920 Token commentToken = token.precedingComments; | 925 Token commentToken = token.precedingComments; |
| 921 while (commentToken != null) { | 926 while (commentToken != null) { |
| 922 ranges.add(SourceRangeFactory.rangeToken(commentToken)); | 927 ranges.add(SourceRangeFactory.rangeToken(commentToken)); |
| (...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1757 return []; | 1762 return []; |
| 1758 } | 1763 } |
| 1759 } | 1764 } |
| 1760 | 1765 |
| 1761 /** | 1766 /** |
| 1762 * @return <code>true</code> if given [Token]s contain only single [Token] wit
h given | 1767 * @return <code>true</code> if given [Token]s contain only single [Token] wit
h given |
| 1763 * [TokenType]. | 1768 * [TokenType]. |
| 1764 */ | 1769 */ |
| 1765 static bool hasOnly(List<Token> tokens, TokenType type) => tokens.length == 1
&& tokens[0].type == type; | 1770 static bool hasOnly(List<Token> tokens, TokenType type) => tokens.length == 1
&& tokens[0].type == type; |
| 1766 } | 1771 } |
| OLD | NEW |