| 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 Token, TokenType; | 11 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType; |
| 12 import 'package:analyzer/dart/element/element.dart' show Element; | 12 import 'package:analyzer/dart/element/element.dart' show Element; |
| 13 import 'package:front_end/src/fasta/parser/parser.dart' | 13 import 'package:front_end/src/fasta/parser/parser.dart' |
| 14 show Assert, FormalParameterType, MemberKind, Parser; | 14 show Assert, FormalParameterType, MemberKind, Parser; |
| 15 import 'package:front_end/src/fasta/scanner/string_scanner.dart'; | 15 import 'package:front_end/src/fasta/scanner/string_scanner.dart'; |
| 16 import 'package:front_end/src/fasta/scanner/token.dart' show CommentToken; | 16 import 'package:front_end/src/fasta/scanner/token.dart' show CommentToken; |
| 17 import 'package:front_end/src/scanner/token.dart' as analyzer; | 17 import 'package:front_end/src/scanner/token.dart' as analyzer; |
| 18 | 18 |
| 19 import 'package:front_end/src/fasta/deprecated_problems.dart' | 19 import 'package:front_end/src/fasta/deprecated_problems.dart' |
| 20 show deprecated_internalProblem; | 20 show deprecated_internalProblem; |
| 21 import 'package:front_end/src/fasta/fasta_codes.dart' | 21 import 'package:front_end/src/fasta/messages.dart' |
| 22 show | 22 show Code, Message, codeExpectedExpression, codeExpectedFunctionBody; |
| 23 FastaCode, | |
| 24 FastaMessage, | |
| 25 codeExpectedExpression, | |
| 26 codeExpectedFunctionBody; | |
| 27 import 'package:front_end/src/fasta/kernel/kernel_builder.dart' | 23 import 'package:front_end/src/fasta/kernel/kernel_builder.dart' |
| 28 show Builder, KernelLibraryBuilder, ProcedureBuilder, Scope; | 24 show Builder, KernelLibraryBuilder, ProcedureBuilder, Scope; |
| 29 import 'package:front_end/src/fasta/parser/identifier_context.dart' | 25 import 'package:front_end/src/fasta/parser/identifier_context.dart' |
| 30 show IdentifierContext; | 26 show IdentifierContext; |
| 31 import 'package:front_end/src/fasta/quote.dart'; | 27 import 'package:front_end/src/fasta/quote.dart'; |
| 32 import 'package:front_end/src/fasta/source/scope_listener.dart' | 28 import 'package:front_end/src/fasta/source/scope_listener.dart' |
| 33 show JumpTargetKind, NullValue, ScopeListener; | 29 show JumpTargetKind, NullValue, ScopeListener; |
| 34 import 'analyzer.dart' show toKernel; | 30 import 'analyzer.dart' show toKernel; |
| 35 import 'element_store.dart' | 31 import 'element_store.dart' |
| 36 show | 32 show |
| (...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 void handleInvalidExpression(Token token) { | 1075 void handleInvalidExpression(Token token) { |
| 1080 debugEvent("InvalidExpression"); | 1076 debugEvent("InvalidExpression"); |
| 1081 } | 1077 } |
| 1082 | 1078 |
| 1083 @override | 1079 @override |
| 1084 void handleInvalidFunctionBody(Token token) { | 1080 void handleInvalidFunctionBody(Token token) { |
| 1085 debugEvent("InvalidFunctionBody"); | 1081 debugEvent("InvalidFunctionBody"); |
| 1086 } | 1082 } |
| 1087 | 1083 |
| 1088 @override | 1084 @override |
| 1089 Token handleUnrecoverableError(Token token, FastaMessage message) { | 1085 Token handleUnrecoverableError(Token token, Message message) { |
| 1090 if (message.code == codeExpectedFunctionBody) { | 1086 if (message.code == codeExpectedFunctionBody) { |
| 1091 if (identical('native', token.stringValue) && parser != null) { | 1087 if (identical('native', token.stringValue) && parser != null) { |
| 1092 Token nativeKeyword = token; | 1088 Token nativeKeyword = token; |
| 1093 Token semicolon = parser.parseLiteralString(token.next); | 1089 Token semicolon = parser.parseLiteralString(token.next); |
| 1094 token = parser.expectSemicolon(semicolon); | 1090 token = parser.expectSemicolon(semicolon); |
| 1095 StringLiteral name = pop(); | 1091 StringLiteral name = pop(); |
| 1096 pop(); // star | 1092 pop(); // star |
| 1097 pop(); // async | 1093 pop(); // async |
| 1098 push(ast.nativeFunctionBody(nativeKeyword, name, semicolon)); | 1094 push(ast.nativeFunctionBody(nativeKeyword, name, semicolon)); |
| 1099 return token; | 1095 return token; |
| (...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1908 Token _scanGenericMethodComment(String code, int offset) { | 1904 Token _scanGenericMethodComment(String code, int offset) { |
| 1909 var scanner = new SubStringScanner(offset, code); | 1905 var scanner = new SubStringScanner(offset, code); |
| 1910 Token firstToken = scanner.tokenize(); | 1906 Token firstToken = scanner.tokenize(); |
| 1911 if (scanner.hasErrors) { | 1907 if (scanner.hasErrors) { |
| 1912 return null; | 1908 return null; |
| 1913 } | 1909 } |
| 1914 return firstToken; | 1910 return firstToken; |
| 1915 } | 1911 } |
| 1916 | 1912 |
| 1917 @override | 1913 @override |
| 1918 void addCompileTimeErrorFromMessage(FastaMessage message) { | 1914 void addCompileTimeError(Message message, int charOffset) { |
| 1919 FastaCode code = message.code; | 1915 Code code = message.code; |
| 1920 switch (code.analyzerCode) { | 1916 switch (code.analyzerCode) { |
| 1921 case "EXPECTED_TYPE_NAME": | 1917 case "EXPECTED_TYPE_NAME": |
| 1922 errorReporter?.reportErrorForOffset( | 1918 errorReporter?.reportErrorForOffset( |
| 1923 ParserErrorCode.EXPECTED_TYPE_NAME, message.charOffset, 1); | 1919 ParserErrorCode.EXPECTED_TYPE_NAME, charOffset, 1); |
| 1924 return; | 1920 return; |
| 1925 default: | 1921 default: |
| 1926 // fall through | 1922 // fall through |
| 1927 } | 1923 } |
| 1928 library.deprecated_addCompileTimeError(message.charOffset, message.message, | 1924 library.deprecated_addCompileTimeError(charOffset, message.message, |
| 1929 fileUri: message.uri); | 1925 fileUri: uri); |
| 1930 } | 1926 } |
| 1931 } | 1927 } |
| 1932 | 1928 |
| 1933 /// Data structure placed on the stack to represent a class body. | 1929 /// Data structure placed on the stack to represent a class body. |
| 1934 /// | 1930 /// |
| 1935 /// This is needed because analyzer has no separate AST representation of a | 1931 /// This is needed because analyzer has no separate AST representation of a |
| 1936 /// class body; it simply stores all of the relevant data in the | 1932 /// class body; it simply stores all of the relevant data in the |
| 1937 /// [ClassDeclaration] object. | 1933 /// [ClassDeclaration] object. |
| 1938 class _ClassBody { | 1934 class _ClassBody { |
| 1939 final Token beginToken; | 1935 final Token beginToken; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2028 } else if (identical('var', s)) { | 2024 } else if (identical('var', s)) { |
| 2029 finalConstOrVarKeyword = token; | 2025 finalConstOrVarKeyword = token; |
| 2030 } else if (identical('covariant', s)) { | 2026 } else if (identical('covariant', s)) { |
| 2031 covariantKeyword = token; | 2027 covariantKeyword = token; |
| 2032 } else { | 2028 } else { |
| 2033 deprecated_internalProblem('Unhandled modifier: $s'); | 2029 deprecated_internalProblem('Unhandled modifier: $s'); |
| 2034 } | 2030 } |
| 2035 } | 2031 } |
| 2036 } | 2032 } |
| 2037 } | 2033 } |
| OLD | NEW |