OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dart2js.parser.element_listener; | 5 library dart2js.parser.element_listener; |
6 | 6 |
7 import 'package:front_end/src/fasta/fasta_codes.dart' show FastaMessage; | 7 import 'package:front_end/src/fasta/fasta_codes.dart' show FastaMessage; |
8 | 8 |
9 import 'package:front_end/src/fasta/fasta_codes.dart' as codes; | 9 import 'package:front_end/src/fasta/fasta_codes.dart' as codes; |
10 | 10 |
11 import '../common.dart'; | 11 import '../common.dart'; |
12 import '../diagnostics/messages.dart' show MessageTemplate; | 12 import '../diagnostics/messages.dart' show MessageTemplate; |
13 import '../elements/elements.dart' | 13 import '../elements/elements.dart' |
14 show Element, LibraryElement, MetadataAnnotation; | 14 show Element, LibraryElement, MetadataAnnotation; |
15 import '../elements/modelx.dart' | 15 import '../elements/modelx.dart' |
16 show | 16 show |
17 CompilationUnitElementX, | 17 CompilationUnitElementX, |
18 DeclarationSite, | 18 DeclarationSite, |
19 ElementX, | 19 ElementX, |
20 EnumClassElementX, | 20 EnumClassElementX, |
21 FieldElementX, | 21 FieldElementX, |
22 LibraryElementX, | 22 LibraryElementX, |
23 MetadataAnnotationX, | 23 MetadataAnnotationX, |
24 NamedMixinApplicationElementX, | 24 NamedMixinApplicationElementX, |
25 VariableList; | 25 VariableList; |
26 import '../id_generator.dart'; | 26 import '../id_generator.dart'; |
27 import '../native/native.dart' as native; | 27 import '../native/native.dart' as native; |
28 import '../string_validator.dart' show StringValidator; | 28 import '../string_validator.dart' show StringValidator; |
29 import 'package:front_end/src/fasta/scanner.dart' | 29 import 'package:front_end/src/fasta/scanner.dart' |
30 show Keyword, BeginGroupToken, ErrorToken, KeywordToken, StringToken, Token; | 30 show BeginGroupToken, ErrorToken, StringToken, Token; |
31 import 'package:front_end/src/fasta/scanner.dart' as Tokens show EOF_TOKEN; | 31 import 'package:front_end/src/fasta/scanner.dart' as Tokens show EOF_TOKEN; |
32 import '../tree/tree.dart'; | 32 import '../tree/tree.dart'; |
33 import '../util/util.dart' show Link, LinkBuilder; | 33 import '../util/util.dart' show Link, LinkBuilder; |
34 import 'package:front_end/src/fasta/parser.dart' | 34 import 'package:front_end/src/fasta/parser.dart' |
35 show Listener, ParserError, optional; | 35 show Listener, ParserError, optional; |
36 import 'package:front_end/src/fasta/parser/identifier_context.dart' | 36 import 'package:front_end/src/fasta/parser/identifier_context.dart' |
37 show IdentifierContext; | 37 show IdentifierContext; |
38 import 'package:front_end/src/scanner/token.dart' show TokenType; | 38 import 'package:front_end/src/scanner/token.dart' show KeywordToken, TokenType; |
39 import 'partial_elements.dart' | 39 import 'partial_elements.dart' |
40 show | 40 show |
41 PartialClassElement, | 41 PartialClassElement, |
42 PartialElement, | 42 PartialElement, |
43 PartialFieldList, | 43 PartialFieldList, |
44 PartialFunctionElement, | 44 PartialFunctionElement, |
45 PartialMetadataAnnotation, | 45 PartialMetadataAnnotation, |
46 PartialTypedefElement; | 46 PartialTypedefElement; |
47 | 47 |
48 const bool VERBOSE = false; | 48 const bool VERBOSE = false; |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 Identifier name = popNode(); | 292 Identifier name = popNode(); |
293 int id = idGenerator.getNextFreeId(); | 293 int id = idGenerator.getNextFreeId(); |
294 PartialClassElement element = new PartialClassElement( | 294 PartialClassElement element = new PartialClassElement( |
295 name.source, beginToken, endToken, compilationUnitElement, id); | 295 name.source, beginToken, endToken, compilationUnitElement, id); |
296 pushElement(element); | 296 pushElement(element); |
297 rejectBuiltInIdentifier(name); | 297 rejectBuiltInIdentifier(name); |
298 } | 298 } |
299 | 299 |
300 void rejectBuiltInIdentifier(Identifier name) { | 300 void rejectBuiltInIdentifier(Identifier name) { |
301 if (name.token is KeywordToken) { | 301 if (name.token is KeywordToken) { |
302 Keyword keyword = (name.token as KeywordToken).keyword; | 302 TokenType type = name.token.type; |
303 if (!keyword.isPseudo) { | 303 if (!type.isPseudo) { |
304 recoverableError(name, "Illegal name '${keyword.lexeme}'."); | 304 recoverableError(name, "Illegal name '${type.lexeme}'."); |
305 } | 305 } |
306 } | 306 } |
307 } | 307 } |
308 | 308 |
309 @override | 309 @override |
310 void endFunctionTypeAlias( | 310 void endFunctionTypeAlias( |
311 Token typedefKeyword, Token equals, Token endToken) { | 311 Token typedefKeyword, Token equals, Token endToken) { |
312 Identifier name; | 312 Identifier name; |
313 if (equals == null) { | 313 if (equals == null) { |
314 popNode(); // TODO(karlklose): do not throw away typeVariables. | 314 popNode(); // TODO(karlklose): do not throw away typeVariables. |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 memberErrors = memberErrors.tail.prepend(true); | 935 memberErrors = memberErrors.tail.prepend(true); |
936 } | 936 } |
937 reporter.reportErrorMessage(spannable, errorCode, arguments); | 937 reporter.reportErrorMessage(spannable, errorCode, arguments); |
938 } | 938 } |
939 | 939 |
940 void reportErrorFromToken(Token token, MessageKind errorCode, | 940 void reportErrorFromToken(Token token, MessageKind errorCode, |
941 [Map arguments = const {}]) { | 941 [Map arguments = const {}]) { |
942 reportError(reporter.spanFromToken(token), errorCode, arguments); | 942 reportError(reporter.spanFromToken(token), errorCode, arguments); |
943 } | 943 } |
944 } | 944 } |
OLD | NEW |