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

Side by Side Diff: pkg/analyzer/lib/src/fasta/ast_builder.dart

Issue 2872453004: cleanup TokenType var names (Closed)
Patch Set: Created 3 years, 7 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 fasta.analyzer.ast_builder; 5 library fasta.analyzer.ast_builder;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory; 8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory;
9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard; 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard;
10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token; 10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token;
(...skipping 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after
1936 tokenToStartReplacing.previous = prev; 1936 tokenToStartReplacing.previous = prev;
1937 } 1937 }
1938 return tokenToStartReplacing; 1938 return tokenToStartReplacing;
1939 } 1939 }
1940 1940
1941 @override 1941 @override
1942 void discardTypeReplacedWithCommentTypeAssign() { 1942 void discardTypeReplacedWithCommentTypeAssign() {
1943 pop(); 1943 pop();
1944 } 1944 }
1945 1945
1946 /// Check if the given [token] has a comment token with the given [info], 1946 /// Check if the given [token] has a comment token with the given [type],
1947 /// which should be either [TokenType.GENERIC_METHOD_TYPE_ASSIGN] or 1947 /// which should be either [TokenType.GENERIC_METHOD_TYPE_ASSIGN] or
1948 /// [TokenType.GENERIC_METHOD_TYPE_LIST]. If found, parse the comment 1948 /// [TokenType.GENERIC_METHOD_TYPE_LIST]. If found, parse the comment
1949 /// into tokens and inject into the token stream before the [token]. 1949 /// into tokens and inject into the token stream before the [token].
1950 Token _injectGenericComment(Token token, TokenType info, int prefixLen) { 1950 Token _injectGenericComment(Token token, TokenType type, int prefixLen) {
1951 if (parseGenericMethodComments) { 1951 if (parseGenericMethodComments) {
1952 CommentToken t = token.precedingCommentTokens; 1952 CommentToken t = token.precedingCommentTokens;
1953 for (; t != null; t = t.next) { 1953 for (; t != null; t = t.next) {
1954 if (t.info == info) { 1954 if (t.type == type) {
1955 String code = t.lexeme.substring(prefixLen, t.lexeme.length - 2); 1955 String code = t.lexeme.substring(prefixLen, t.lexeme.length - 2);
1956 Token tokens = _scanGenericMethodComment(code, t.offset + prefixLen); 1956 Token tokens = _scanGenericMethodComment(code, t.offset + prefixLen);
1957 if (tokens != null) { 1957 if (tokens != null) {
1958 // Remove the token from the comment stream. 1958 // Remove the token from the comment stream.
1959 t.remove(); 1959 t.remove();
1960 // Insert the tokens into the stream. 1960 // Insert the tokens into the stream.
1961 _injectTokenList(token, tokens); 1961 _injectTokenList(token, tokens);
1962 return tokens; 1962 return tokens;
1963 } 1963 }
1964 } 1964 }
1965 } 1965 }
1966 } 1966 }
1967 return token; 1967 return token;
1968 } 1968 }
1969 1969
1970 void _injectTokenList(Token beforeToken, Token firstToken) { 1970 void _injectTokenList(Token beforeToken, Token firstToken) {
1971 // Scanner creates a cyclic EOF token. 1971 // Scanner creates a cyclic EOF token.
1972 Token lastToken = firstToken; 1972 Token lastToken = firstToken;
1973 while (lastToken.next.info != TokenType.EOF) { 1973 while (lastToken.next.type != TokenType.EOF) {
1974 lastToken = lastToken.next; 1974 lastToken = lastToken.next;
1975 } 1975 }
1976 // Inject these new tokens into the stream. 1976 // Inject these new tokens into the stream.
1977 Token previous = beforeToken.previous; 1977 Token previous = beforeToken.previous;
1978 lastToken.setNext(beforeToken); 1978 lastToken.setNext(beforeToken);
1979 previous.setNext(firstToken); 1979 previous.setNext(firstToken);
1980 beforeToken = firstToken; 1980 beforeToken = firstToken;
1981 } 1981 }
1982 1982
1983 /// Scans the given [code], and returns the tokens, otherwise returns `null`. 1983 /// Scans the given [code], and returns the tokens, otherwise returns `null`.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 } else if (identical('static', s)) { 2086 } else if (identical('static', s)) {
2087 staticKeyword = token; 2087 staticKeyword = token;
2088 } else if (identical('var', s)) { 2088 } else if (identical('var', s)) {
2089 finalConstOrVarKeyword = token; 2089 finalConstOrVarKeyword = token;
2090 } else { 2090 } else {
2091 internalError('Unhandled modifier: $s'); 2091 internalError('Unhandled modifier: $s');
2092 } 2092 }
2093 } 2093 }
2094 } 2094 }
2095 } 2095 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/scanner/scanner.dart ('k') | pkg/analyzer/lib/src/fasta/token_utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698