| 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.partial_elements; | 5 library dart2js.parser.partial_elements; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/resolution.dart' show | 8 import '../common/resolution.dart' show |
| 9 Parsing, | 9 Parsing, |
| 10 Resolution; | 10 Resolution; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 StringToken, | 44 StringToken, |
| 45 Token, | 45 Token, |
| 46 UnmatchedToken, | 46 UnmatchedToken, |
| 47 UnterminatedToken; | 47 UnterminatedToken; |
| 48 import '../tokens/token_constants.dart' as Tokens show | 48 import '../tokens/token_constants.dart' as Tokens show |
| 49 EOF_TOKEN; | 49 EOF_TOKEN; |
| 50 import '../tree/tree.dart'; | 50 import '../tree/tree.dart'; |
| 51 | 51 |
| 52 import 'class_element_parser.dart' show | 52 import 'class_element_parser.dart' show |
| 53 ClassElementParser; | 53 ClassElementParser; |
| 54 import 'element_listener.dart' show |
| 55 ParserOptions; |
| 54 import 'parser.dart' show | 56 import 'parser.dart' show |
| 55 Parser; | 57 Parser; |
| 56 import 'listener.dart' show | 58 import 'listener.dart' show |
| 57 ParserError; | 59 ParserError; |
| 58 import 'member_listener.dart' show | 60 import 'member_listener.dart' show |
| 59 MemberListener; | 61 MemberListener; |
| 60 import 'node_listener.dart' show | 62 import 'node_listener.dart' show |
| 61 NodeListener; | 63 NodeListener; |
| 62 | 64 |
| 63 abstract class PartialElement implements DeclarationSite { | 65 abstract class PartialElement implements DeclarationSite { |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 return cachedNode; | 422 return cachedNode; |
| 421 } | 423 } |
| 422 | 424 |
| 423 ClassNode parseNode(Parsing parsing) { | 425 ClassNode parseNode(Parsing parsing) { |
| 424 if (cachedNode != null) return cachedNode; | 426 if (cachedNode != null) return cachedNode; |
| 425 DiagnosticReporter reporter = parsing.reporter; | 427 DiagnosticReporter reporter = parsing.reporter; |
| 426 reporter.withCurrentElement(this, () { | 428 reporter.withCurrentElement(this, () { |
| 427 parsing.measure(() { | 429 parsing.measure(() { |
| 428 MemberListener listener = new MemberListener( | 430 MemberListener listener = new MemberListener( |
| 429 parsing.getScannerOptionsFor(this), reporter, this); | 431 parsing.getScannerOptionsFor(this), reporter, this); |
| 430 Parser parser = new ClassElementParser(listener); | 432 ParserOptions options = parsing.parserOptions; |
| 433 Parser parser = new ClassElementParser(listener, |
| 434 enableConditionalDirectives: options.enableConditionalDirectives, |
| 435 enableGenericMethods: options.enableGenericMethods); |
| 431 try { | 436 try { |
| 432 Token token = parser.parseTopLevelDeclaration(beginToken); | 437 Token token = parser.parseTopLevelDeclaration(beginToken); |
| 433 assert(identical(token, endToken.next)); | 438 assert(identical(token, endToken.next)); |
| 434 cachedNode = listener.popNode(); | 439 cachedNode = listener.popNode(); |
| 435 assert( | 440 assert( |
| 436 invariant( | 441 invariant( |
| 437 beginToken, listener.nodes.isEmpty, | 442 beginToken, listener.nodes.isEmpty, |
| 438 message: "Non-empty listener stack: ${listener.nodes}")); | 443 message: "Non-empty listener stack: ${listener.nodes}")); |
| 439 } on ParserError { | 444 } on ParserError { |
| 440 // TODO(ahe): Often, a ParserError is thrown while parsing the class | 445 // TODO(ahe): Often, a ParserError is thrown while parsing the class |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 return parsing.measure(() { | 489 return parsing.measure(() { |
| 485 return reporter.withCurrentElement(element, () { | 490 return reporter.withCurrentElement(element, () { |
| 486 CompilationUnitElement unit = element.compilationUnit; | 491 CompilationUnitElement unit = element.compilationUnit; |
| 487 NodeListener listener = new NodeListener( | 492 NodeListener listener = new NodeListener( |
| 488 parsing.getScannerOptionsFor(element), reporter, unit); | 493 parsing.getScannerOptionsFor(element), reporter, unit); |
| 489 listener.memberErrors = listener.memberErrors.prepend(false); | 494 listener.memberErrors = listener.memberErrors.prepend(false); |
| 490 try { | 495 try { |
| 491 if (partial.hasParseError) { | 496 if (partial.hasParseError) { |
| 492 listener.suppressParseErrors = true; | 497 listener.suppressParseErrors = true; |
| 493 } | 498 } |
| 494 doParse(new Parser(listener)); | 499 ParserOptions options = parsing.parserOptions; |
| 500 doParse(new Parser(listener, |
| 501 enableConditionalDirectives: options.enableConditionalDirectives, |
| 502 enableGenericMethods: options.enableGenericMethods)); |
| 495 } on ParserError catch (e) { | 503 } on ParserError catch (e) { |
| 496 partial.hasParseError = true; | 504 partial.hasParseError = true; |
| 497 return new ErrorNode(element.position, e.reason); | 505 return new ErrorNode(element.position, e.reason); |
| 498 } | 506 } |
| 499 Node node = listener.popNode(); | 507 Node node = listener.popNode(); |
| 500 assert(listener.nodes.isEmpty); | 508 assert(listener.nodes.isEmpty); |
| 501 return node; | 509 return node; |
| 502 }); | 510 }); |
| 503 }); | 511 }); |
| 504 } | 512 } |
| OLD | NEW |