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

Side by Side Diff: pkg/analyzer/lib/src/dart/ast/utilities.dart

Issue 1710163002: Always set the previous token 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
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/utilities_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.dart.ast.utilities; 5 library analyzer.src.dart.ast.utilities;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 24 matching lines...) Expand all
35 final Map<Token, Token> _clonedTokens = new Map<Token, Token>.identity(); 35 final Map<Token, Token> _clonedTokens = new Map<Token, Token>.identity();
36 36
37 /** 37 /**
38 * The next original token to clone. 38 * The next original token to clone.
39 */ 39 */
40 Token _nextToClone; 40 Token _nextToClone;
41 41
42 /** 42 /**
43 * The last cloned token. 43 * The last cloned token.
44 */ 44 */
45 Token _lastCloned; 45 Token _lastCloned = new Token(TokenType.EOF, -1);
Brian Wilkerson 2016/02/18 21:00:34 The EOF token should be it's own 'previous' token.
46 46
47 /** 47 /**
48 * The offset of the last cloned token. 48 * The offset of the last cloned token.
49 */ 49 */
50 int _lastClonedOffset = -1; 50 int _lastClonedOffset = -1;
51 51
52 /** 52 /**
53 * Initialize a newly created AST cloner to optionally clone tokens while 53 * Initialize a newly created AST cloner to optionally clone tokens while
54 * cloning AST nodes if [cloneTokens] is `true`. 54 * cloning AST nodes if [cloneTokens] is `true`.
55 * 55 *
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 c2 is DocumentationCommentToken) { 945 c2 is DocumentationCommentToken) {
946 for (int i = 0; i < c1.references.length; i++) { 946 for (int i = 0; i < c1.references.length; i++) {
947 _clonedTokens[c1.references[i]] = c2.references[i]; 947 _clonedTokens[c1.references[i]] = c2.references[i];
948 } 948 }
949 } 949 }
950 c1 = c1.next; 950 c1 = c1.next;
951 c2 = c2.next; 951 c2 = c2.next;
952 } 952 }
953 } 953 }
954 _clonedTokens[token] = clone; 954 _clonedTokens[token] = clone;
955 _lastCloned?.setNext(clone); 955 _lastCloned.setNext(clone);
956 _lastCloned = clone; 956 _lastCloned = clone;
957 if (token.type == TokenType.EOF) { 957 if (token.type == TokenType.EOF) {
958 break; 958 break;
959 } 959 }
960 if (token.offset > stopAfter) { 960 if (token.offset > stopAfter) {
961 _nextToClone = token.next; 961 _nextToClone = token.next;
962 _lastClonedOffset = token.offset; 962 _lastClonedOffset = token.offset;
963 break; 963 break;
964 } 964 }
965 token = token.next; 965 token = token.next;
(...skipping 5377 matching lines...) Expand 10 before | Expand all | Expand 10 after
6343 * Safely visit the given [token], printing the [suffix] after the token if it 6343 * Safely visit the given [token], printing the [suffix] after the token if it
6344 * is non-`null`. 6344 * is non-`null`.
6345 */ 6345 */
6346 void _visitTokenWithSuffix(Token token, String suffix) { 6346 void _visitTokenWithSuffix(Token token, String suffix) {
6347 if (token != null) { 6347 if (token != null) {
6348 _writer.print(token.lexeme); 6348 _writer.print(token.lexeme);
6349 _writer.print(suffix); 6349 _writer.print(suffix);
6350 } 6350 }
6351 } 6351 }
6352 } 6352 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/utilities_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698