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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 return cachedNode; | 420 return cachedNode; |
421 } | 421 } |
422 | 422 |
423 ClassNode parseNode(Parsing parsing) { | 423 ClassNode parseNode(Parsing parsing) { |
424 if (cachedNode != null) return cachedNode; | 424 if (cachedNode != null) return cachedNode; |
425 DiagnosticReporter reporter = parsing.reporter; | 425 DiagnosticReporter reporter = parsing.reporter; |
426 reporter.withCurrentElement(this, () { | 426 reporter.withCurrentElement(this, () { |
427 parsing.measure(() { | 427 parsing.measure(() { |
428 MemberListener listener = new MemberListener( | 428 MemberListener listener = new MemberListener( |
429 parsing.getScannerOptionsFor(this), reporter, this); | 429 parsing.getScannerOptionsFor(this), reporter, this); |
430 Parser parser = new ClassElementParser(listener); | 430 Parser parser = new ClassElementParser(listener, parsing.parserOptions); |
431 try { | 431 try { |
432 Token token = parser.parseTopLevelDeclaration(beginToken); | 432 Token token = parser.parseTopLevelDeclaration(beginToken); |
433 assert(identical(token, endToken.next)); | 433 assert(identical(token, endToken.next)); |
434 cachedNode = listener.popNode(); | 434 cachedNode = listener.popNode(); |
435 assert( | 435 assert( |
436 invariant( | 436 invariant( |
437 beginToken, listener.nodes.isEmpty, | 437 beginToken, listener.nodes.isEmpty, |
438 message: "Non-empty listener stack: ${listener.nodes}")); | 438 message: "Non-empty listener stack: ${listener.nodes}")); |
439 } on ParserError { | 439 } on ParserError { |
440 // TODO(ahe): Often, a ParserError is thrown while parsing the class | 440 // 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(() { | 484 return parsing.measure(() { |
485 return reporter.withCurrentElement(element, () { | 485 return reporter.withCurrentElement(element, () { |
486 CompilationUnitElement unit = element.compilationUnit; | 486 CompilationUnitElement unit = element.compilationUnit; |
487 NodeListener listener = new NodeListener( | 487 NodeListener listener = new NodeListener( |
488 parsing.getScannerOptionsFor(element), reporter, unit); | 488 parsing.getScannerOptionsFor(element), reporter, unit); |
489 listener.memberErrors = listener.memberErrors.prepend(false); | 489 listener.memberErrors = listener.memberErrors.prepend(false); |
490 try { | 490 try { |
491 if (partial.hasParseError) { | 491 if (partial.hasParseError) { |
492 listener.suppressParseErrors = true; | 492 listener.suppressParseErrors = true; |
493 } | 493 } |
494 doParse(new Parser(listener)); | 494 doParse(new Parser(listener, parsing.parserOptions)); |
495 } on ParserError catch (e) { | 495 } on ParserError catch (e) { |
496 partial.hasParseError = true; | 496 partial.hasParseError = true; |
497 return new ErrorNode(element.position, e.reason); | 497 return new ErrorNode(element.position, e.reason); |
498 } | 498 } |
499 Node node = listener.popNode(); | 499 Node node = listener.popNode(); |
500 assert(listener.nodes.isEmpty); | 500 assert(listener.nodes.isEmpty); |
501 return node; | 501 return node; |
502 }); | 502 }); |
503 }); | 503 }); |
504 } | 504 } |
OLD | NEW |