| OLD | NEW |
| 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; |
| 11 import 'package:analyzer/dart/ast/token.dart' show TokenType; |
| 11 import 'package:analyzer/dart/element/element.dart' show Element; | 12 import 'package:analyzer/dart/element/element.dart' show Element; |
| 12 import 'package:front_end/src/fasta/parser/parser.dart' | 13 import 'package:front_end/src/fasta/parser/parser.dart' |
| 13 show FormalParameterType, Parser; | 14 show FormalParameterType, Parser; |
| 14 import 'package:front_end/src/fasta/scanner/precedence.dart'; | 15 import 'package:front_end/src/fasta/scanner/precedence.dart'; |
| 15 import 'package:front_end/src/fasta/scanner/string_scanner.dart'; | 16 import 'package:front_end/src/fasta/scanner/string_scanner.dart'; |
| 16 import 'package:front_end/src/fasta/scanner/token.dart' | 17 import 'package:front_end/src/fasta/scanner/token.dart' |
| 17 show BeginGroupToken, CommentToken, Token; | 18 show BeginGroupToken, CommentToken, Token; |
| 18 | 19 |
| 19 import 'package:front_end/src/fasta/errors.dart' show internalError; | 20 import 'package:front_end/src/fasta/errors.dart' show internalError; |
| 20 import 'package:front_end/src/fasta/fasta_codes.dart' | 21 import 'package:front_end/src/fasta/fasta_codes.dart' |
| (...skipping 1913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1934 tokenToStartReplacing = injected; | 1935 tokenToStartReplacing = injected; |
| 1935 tokenToStartReplacing.previous = prev; | 1936 tokenToStartReplacing.previous = prev; |
| 1936 } | 1937 } |
| 1937 return tokenToStartReplacing; | 1938 return tokenToStartReplacing; |
| 1938 } | 1939 } |
| 1939 | 1940 |
| 1940 /// Check if the given [token] has a comment token with the given [info], | 1941 /// Check if the given [token] has a comment token with the given [info], |
| 1941 /// which should be either [GENERIC_METHOD_TYPE_ASSIGN] or | 1942 /// which should be either [GENERIC_METHOD_TYPE_ASSIGN] or |
| 1942 /// [GENERIC_METHOD_TYPE_LIST]. If found, parse the comment into tokens and | 1943 /// [GENERIC_METHOD_TYPE_LIST]. If found, parse the comment into tokens and |
| 1943 /// inject into the token stream before the [token]. | 1944 /// inject into the token stream before the [token]. |
| 1944 Token _injectGenericComment(Token token, PrecedenceInfo info, int prefixLen) { | 1945 Token _injectGenericComment(Token token, TokenType info, int prefixLen) { |
| 1945 if (parseGenericMethodComments) { | 1946 if (parseGenericMethodComments) { |
| 1946 CommentToken t = token.precedingCommentTokens; | 1947 CommentToken t = token.precedingCommentTokens; |
| 1947 for (; t != null; t = t.next) { | 1948 for (; t != null; t = t.next) { |
| 1948 if (t.info == info) { | 1949 if (t.info == info) { |
| 1949 String code = t.lexeme.substring(prefixLen, t.lexeme.length - 2); | 1950 String code = t.lexeme.substring(prefixLen, t.lexeme.length - 2); |
| 1950 Token tokens = _scanGenericMethodComment(code, t.offset + prefixLen); | 1951 Token tokens = _scanGenericMethodComment(code, t.offset + prefixLen); |
| 1951 if (tokens != null) { | 1952 if (tokens != null) { |
| 1952 // Remove the token from the comment stream. | 1953 // Remove the token from the comment stream. |
| 1953 t.remove(); | 1954 t.remove(); |
| 1954 // Insert the tokens into the stream. | 1955 // Insert the tokens into the stream. |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2080 } else if (identical('static', s)) { | 2081 } else if (identical('static', s)) { |
| 2081 staticKeyword = token; | 2082 staticKeyword = token; |
| 2082 } else if (identical('var', s)) { | 2083 } else if (identical('var', s)) { |
| 2083 finalConstOrVarKeyword = token; | 2084 finalConstOrVarKeyword = token; |
| 2084 } else { | 2085 } else { |
| 2085 internalError('Unhandled modifier: $s'); | 2086 internalError('Unhandled modifier: $s'); |
| 2086 } | 2087 } |
| 2087 } | 2088 } |
| 2088 } | 2089 } |
| 2089 } | 2090 } |
| OLD | NEW |