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 ParsingContext, Resolution; | 8 import '../common/resolution.dart' show ParsingContext, Resolution; |
9 import '../dart_types.dart' show DynamicType; | 9 import '../dart_types.dart' show DynamicType; |
10 import '../elements/elements.dart' | 10 import '../elements/elements.dart' |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 return cachedNode; | 367 return cachedNode; |
368 } | 368 } |
369 | 369 |
370 ClassNode parseNode(ParsingContext parsing) { | 370 ClassNode parseNode(ParsingContext parsing) { |
371 if (cachedNode != null) return cachedNode; | 371 if (cachedNode != null) return cachedNode; |
372 DiagnosticReporter reporter = parsing.reporter; | 372 DiagnosticReporter reporter = parsing.reporter; |
373 reporter.withCurrentElement(this, () { | 373 reporter.withCurrentElement(this, () { |
374 parsing.measure(() { | 374 parsing.measure(() { |
375 MemberListener listener = new MemberListener( | 375 MemberListener listener = new MemberListener( |
376 parsing.getScannerOptionsFor(this), reporter, this); | 376 parsing.getScannerOptionsFor(this), reporter, this); |
377 Parser parser = new ClassElementParser(listener, parsing.parserOptions); | 377 Parser parser = new ClassElementParser(listener); |
378 try { | 378 try { |
379 Token token = parser.parseTopLevelDeclaration(beginToken); | 379 Token token = parser.parseTopLevelDeclaration(beginToken); |
380 assert(identical(token, endToken.next)); | 380 assert(identical(token, endToken.next)); |
381 cachedNode = listener.popNode(); | 381 cachedNode = listener.popNode(); |
382 assert(invariant(beginToken, listener.nodes.isEmpty, | 382 assert(invariant(beginToken, listener.nodes.isEmpty, |
383 message: "Non-empty listener stack: ${listener.nodes}")); | 383 message: "Non-empty listener stack: ${listener.nodes}")); |
384 } on ParserError { | 384 } on ParserError { |
385 // TODO(ahe): Often, a ParserError is thrown while parsing the class | 385 // TODO(ahe): Often, a ParserError is thrown while parsing the class |
386 // body. This means that the stack actually contains most of the | 386 // body. This means that the stack actually contains most of the |
387 // information synthesized below. Consider rewriting the parser so | 387 // information synthesized below. Consider rewriting the parser so |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 return parsing.measure(() { | 433 return parsing.measure(() { |
434 return reporter.withCurrentElement(element, () { | 434 return reporter.withCurrentElement(element, () { |
435 CompilationUnitElement unit = element.compilationUnit; | 435 CompilationUnitElement unit = element.compilationUnit; |
436 NodeListener listener = new NodeListener( | 436 NodeListener listener = new NodeListener( |
437 parsing.getScannerOptionsFor(element), reporter, unit); | 437 parsing.getScannerOptionsFor(element), reporter, unit); |
438 listener.memberErrors = listener.memberErrors.prepend(false); | 438 listener.memberErrors = listener.memberErrors.prepend(false); |
439 try { | 439 try { |
440 if (partial.hasParseError) { | 440 if (partial.hasParseError) { |
441 listener.suppressParseErrors = true; | 441 listener.suppressParseErrors = true; |
442 } | 442 } |
443 doParse(new Parser(listener, parsing.parserOptions)); | 443 doParse(new Parser(listener)); |
444 } on ParserError catch (e) { | 444 } on ParserError catch (e) { |
445 partial.hasParseError = true; | 445 partial.hasParseError = true; |
446 return new ErrorNode(element.position, e.reason); | 446 return new ErrorNode(element.position, e.reason); |
447 } | 447 } |
448 Node node = listener.popNode(); | 448 Node node = listener.popNode(); |
449 assert(listener.nodes.isEmpty); | 449 assert(listener.nodes.isEmpty); |
450 return node; | 450 return node; |
451 }); | 451 }); |
452 }); | 452 }); |
453 } | 453 } |
OLD | NEW |