Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: pkg/analyzer/lib/src/generated/scanner.dart

Issue 1660873003: Clone and link all tokens in AstCloner. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 analyzer.src.generated.scanner; 5 library analyzer.src.generated.scanner;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/generated/error.dart'; 9 import 'package:analyzer/src/generated/error.dart';
10 import 'package:analyzer/src/generated/java_engine.dart'; 10 import 'package:analyzer/src/generated/java_engine.dart';
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 final List<Token> references = <Token>[]; 258 final List<Token> references = <Token>[];
259 259
260 /** 260 /**
261 * Initialize a newly created token to represent a token of the given [type] 261 * Initialize a newly created token to represent a token of the given [type]
262 * with the given [value] at the given [offset]. 262 * with the given [value] at the given [offset].
263 */ 263 */
264 DocumentationCommentToken(TokenType type, String value, int offset) 264 DocumentationCommentToken(TokenType type, String value, int offset)
265 : super(type, value, offset); 265 : super(type, value, offset);
266 266
267 @override 267 @override
268 CommentToken copy() => new DocumentationCommentToken(type, _value, offset); 268 CommentToken copy() {
269 DocumentationCommentToken copy =
270 new DocumentationCommentToken(type, _value, offset);
271 references.forEach((ref) => copy.references.add(ref.copy()));
272 return copy;
273 }
269 } 274 }
270 275
271 /** 276 /**
272 * The keywords in the Dart programming language. 277 * The keywords in the Dart programming language.
273 */ 278 */
274 class Keyword { 279 class Keyword {
275 static const Keyword ASSERT = const Keyword('ASSERT', "assert"); 280 static const Keyword ASSERT = const Keyword('ASSERT', "assert");
276 281
277 static const Keyword BREAK = const Keyword('BREAK', "break"); 282 static const Keyword BREAK = const Keyword('BREAK', "break");
278 283
(...skipping 2294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2573 * associative operator is an operator for which the following equality is 2578 * associative operator is an operator for which the following equality is
2574 * true: `(a * b) * c == a * (b * c)`. In other words, if the result of 2579 * true: `(a * b) * c == a * (b * c)`. In other words, if the result of
2575 * applying the operator to multiple operands does not depend on the order in 2580 * applying the operator to multiple operands does not depend on the order in
2576 * which those applications occur. 2581 * which those applications occur.
2577 * 2582 *
2578 * Note: This method considers the logical-and and logical-or operators to be 2583 * Note: This method considers the logical-and and logical-or operators to be
2579 * associative, even though the order in which the application of those 2584 * associative, even though the order in which the application of those
2580 * operators can have an effect because evaluation of the right-hand operand 2585 * operators can have an effect because evaluation of the right-hand operand
2581 * is conditional. 2586 * is conditional.
2582 */ 2587 */
2583 bool get isAssociativeOperator => this == AMPERSAND || 2588 bool get isAssociativeOperator =>
2589 this == AMPERSAND ||
2584 this == AMPERSAND_AMPERSAND || 2590 this == AMPERSAND_AMPERSAND ||
2585 this == BAR || 2591 this == BAR ||
2586 this == BAR_BAR || 2592 this == BAR_BAR ||
2587 this == CARET || 2593 this == CARET ||
2588 this == PLUS || 2594 this == PLUS ||
2589 this == STAR; 2595 this == STAR;
2590 2596
2591 /** 2597 /**
2592 * Return `true` if this type of token represents an equality operator. 2598 * Return `true` if this type of token represents an equality operator.
2593 */ 2599 */
2594 bool get isEqualityOperator => _tokenClass == TokenClass.EQUALITY_OPERATOR; 2600 bool get isEqualityOperator => _tokenClass == TokenClass.EQUALITY_OPERATOR;
2595 2601
2596 /** 2602 /**
2597 * Return `true` if this type of token represents an increment operator. 2603 * Return `true` if this type of token represents an increment operator.
2598 */ 2604 */
2599 bool get isIncrementOperator => 2605 bool get isIncrementOperator =>
2600 identical(lexeme, "++") || identical(lexeme, "--"); 2606 identical(lexeme, "++") || identical(lexeme, "--");
2601 2607
2602 /** 2608 /**
2603 * Return `true` if this type of token represents a multiplicative operator. 2609 * Return `true` if this type of token represents a multiplicative operator.
2604 */ 2610 */
2605 bool get isMultiplicativeOperator => 2611 bool get isMultiplicativeOperator =>
2606 _tokenClass == TokenClass.MULTIPLICATIVE_OPERATOR; 2612 _tokenClass == TokenClass.MULTIPLICATIVE_OPERATOR;
2607 2613
2608 /** 2614 /**
2609 * Return `true` if this token type represents an operator. 2615 * Return `true` if this token type represents an operator.
2610 */ 2616 */
2611 bool get isOperator => _tokenClass != TokenClass.NO_CLASS && 2617 bool get isOperator =>
2618 _tokenClass != TokenClass.NO_CLASS &&
2612 this != OPEN_PAREN && 2619 this != OPEN_PAREN &&
2613 this != OPEN_SQUARE_BRACKET && 2620 this != OPEN_SQUARE_BRACKET &&
2614 this != PERIOD; 2621 this != PERIOD;
2615 2622
2616 /** 2623 /**
2617 * Return `true` if this type of token represents a relational operator. 2624 * Return `true` if this type of token represents a relational operator.
2618 */ 2625 */
2619 bool get isRelationalOperator => 2626 bool get isRelationalOperator =>
2620 _tokenClass == TokenClass.RELATIONAL_OPERATOR; 2627 _tokenClass == TokenClass.RELATIONAL_OPERATOR;
2621 2628
(...skipping 11 matching lines...) Expand all
2633 /** 2640 /**
2634 * Return `true` if this type of token represents a unary prefix operator. 2641 * Return `true` if this type of token represents a unary prefix operator.
2635 */ 2642 */
2636 bool get isUnaryPrefixOperator => 2643 bool get isUnaryPrefixOperator =>
2637 _tokenClass == TokenClass.UNARY_PREFIX_OPERATOR; 2644 _tokenClass == TokenClass.UNARY_PREFIX_OPERATOR;
2638 2645
2639 /** 2646 /**
2640 * Return `true` if this token type represents an operator that can be defined 2647 * Return `true` if this token type represents an operator that can be defined
2641 * by users. 2648 * by users.
2642 */ 2649 */
2643 bool get isUserDefinableOperator => identical(lexeme, "==") || 2650 bool get isUserDefinableOperator =>
2651 identical(lexeme, "==") ||
2644 identical(lexeme, "~") || 2652 identical(lexeme, "~") ||
2645 identical(lexeme, "[]") || 2653 identical(lexeme, "[]") ||
2646 identical(lexeme, "[]=") || 2654 identical(lexeme, "[]=") ||
2647 identical(lexeme, "*") || 2655 identical(lexeme, "*") ||
2648 identical(lexeme, "/") || 2656 identical(lexeme, "/") ||
2649 identical(lexeme, "%") || 2657 identical(lexeme, "%") ||
2650 identical(lexeme, "~/") || 2658 identical(lexeme, "~/") ||
2651 identical(lexeme, "+") || 2659 identical(lexeme, "+") ||
2652 identical(lexeme, "-") || 2660 identical(lexeme, "-") ||
2653 identical(lexeme, "<<") || 2661 identical(lexeme, "<<") ||
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2699 CommentToken get precedingComments => _precedingComment; 2707 CommentToken get precedingComments => _precedingComment;
2700 2708
2701 void set precedingComments(CommentToken comment) { 2709 void set precedingComments(CommentToken comment) {
2702 _precedingComment = comment; 2710 _precedingComment = comment;
2703 _setCommentParent(_precedingComment); 2711 _setCommentParent(_precedingComment);
2704 } 2712 }
2705 2713
2706 @override 2714 @override
2707 Token copy() => new TokenWithComment(type, offset, precedingComments); 2715 Token copy() => new TokenWithComment(type, offset, precedingComments);
2708 } 2716 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/ast/utilities.dart ('k') | pkg/analyzer/test/generated/incremental_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698