| 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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 assert(invariant(this, cachedNode != null, | 414 assert(invariant(this, cachedNode != null, |
| 415 message: "Node has not been computed for $this.")); | 415 message: "Node has not been computed for $this.")); |
| 416 return cachedNode; | 416 return cachedNode; |
| 417 } | 417 } |
| 418 | 418 |
| 419 ClassNode parseNode(Parsing parsing) { | 419 ClassNode parseNode(Parsing parsing) { |
| 420 if (cachedNode != null) return cachedNode; | 420 if (cachedNode != null) return cachedNode; |
| 421 DiagnosticReporter reporter = parsing.reporter; | 421 DiagnosticReporter reporter = parsing.reporter; |
| 422 reporter.withCurrentElement(this, () { | 422 reporter.withCurrentElement(this, () { |
| 423 parsing.measure(() { | 423 parsing.measure(() { |
| 424 MemberListener listener = new MemberListener(reporter, this); | 424 MemberListener listener = new MemberListener( |
| 425 parsing.getScannerOptionsFor(this), reporter, this); |
| 425 Parser parser = new ClassElementParser(listener); | 426 Parser parser = new ClassElementParser(listener); |
| 426 try { | 427 try { |
| 427 Token token = parser.parseTopLevelDeclaration(beginToken); | 428 Token token = parser.parseTopLevelDeclaration(beginToken); |
| 428 assert(identical(token, endToken.next)); | 429 assert(identical(token, endToken.next)); |
| 429 cachedNode = listener.popNode(); | 430 cachedNode = listener.popNode(); |
| 430 assert( | 431 assert( |
| 431 invariant( | 432 invariant( |
| 432 beginToken, listener.nodes.isEmpty, | 433 beginToken, listener.nodes.isEmpty, |
| 433 message: "Non-empty listener stack: ${listener.nodes}")); | 434 message: "Non-empty listener stack: ${listener.nodes}")); |
| 434 } on ParserError { | 435 } on ParserError { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 | 473 |
| 473 Node parse( | 474 Node parse( |
| 474 Parsing parsing, | 475 Parsing parsing, |
| 475 ElementX element, | 476 ElementX element, |
| 476 PartialElement partial, | 477 PartialElement partial, |
| 477 doParse(Parser parser)) { | 478 doParse(Parser parser)) { |
| 478 DiagnosticReporter reporter = parsing.reporter; | 479 DiagnosticReporter reporter = parsing.reporter; |
| 479 return parsing.measure(() { | 480 return parsing.measure(() { |
| 480 return reporter.withCurrentElement(element, () { | 481 return reporter.withCurrentElement(element, () { |
| 481 CompilationUnitElement unit = element.compilationUnit; | 482 CompilationUnitElement unit = element.compilationUnit; |
| 482 NodeListener listener = new NodeListener(reporter, unit); | 483 NodeListener listener = new NodeListener( |
| 484 parsing.getScannerOptionsFor(element), reporter, unit); |
| 483 listener.memberErrors = listener.memberErrors.prepend(false); | 485 listener.memberErrors = listener.memberErrors.prepend(false); |
| 484 try { | 486 try { |
| 485 if (partial.hasParseError) { | 487 if (partial.hasParseError) { |
| 486 listener.suppressParseErrors = true; | 488 listener.suppressParseErrors = true; |
| 487 } | 489 } |
| 488 doParse(new Parser(listener)); | 490 doParse(new Parser(listener)); |
| 489 } on ParserError catch (e) { | 491 } on ParserError catch (e) { |
| 490 partial.hasParseError = true; | 492 partial.hasParseError = true; |
| 491 return new ErrorNode(element.position, e.reason); | 493 return new ErrorNode(element.position, e.reason); |
| 492 } | 494 } |
| 493 Node node = listener.popNode(); | 495 Node node = listener.popNode(); |
| 494 assert(listener.nodes.isEmpty); | 496 assert(listener.nodes.isEmpty); |
| 495 return node; | 497 return node; |
| 496 }); | 498 }); |
| 497 }); | 499 }); |
| 498 } | 500 } |
| OLD | NEW |