Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: pkg/compiler/lib/src/parser/partial_elements.dart

Issue 1723443003: First step of support for parsing and ignoring generic methods. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fixes bug with nested type arguments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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, parsing.parserOptions);
431 try { 434 try {
432 Token token = parser.parseTopLevelDeclaration(beginToken); 435 Token token = parser.parseTopLevelDeclaration(beginToken);
433 assert(identical(token, endToken.next)); 436 assert(identical(token, endToken.next));
434 cachedNode = listener.popNode(); 437 cachedNode = listener.popNode();
435 assert( 438 assert(
436 invariant( 439 invariant(
437 beginToken, listener.nodes.isEmpty, 440 beginToken, listener.nodes.isEmpty,
438 message: "Non-empty listener stack: ${listener.nodes}")); 441 message: "Non-empty listener stack: ${listener.nodes}"));
439 } on ParserError { 442 } on ParserError {
440 // TODO(ahe): Often, a ParserError is thrown while parsing the class 443 // TODO(ahe): Often, a ParserError is thrown while parsing the class
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 return parsing.measure(() { 487 return parsing.measure(() {
485 return reporter.withCurrentElement(element, () { 488 return reporter.withCurrentElement(element, () {
486 CompilationUnitElement unit = element.compilationUnit; 489 CompilationUnitElement unit = element.compilationUnit;
487 NodeListener listener = new NodeListener( 490 NodeListener listener = new NodeListener(
488 parsing.getScannerOptionsFor(element), reporter, unit); 491 parsing.getScannerOptionsFor(element), reporter, unit);
489 listener.memberErrors = listener.memberErrors.prepend(false); 492 listener.memberErrors = listener.memberErrors.prepend(false);
490 try { 493 try {
491 if (partial.hasParseError) { 494 if (partial.hasParseError) {
492 listener.suppressParseErrors = true; 495 listener.suppressParseErrors = true;
493 } 496 }
494 doParse(new Parser(listener)); 497 ParserOptions options = parsing.parserOptions;
498 doParse(new Parser(listener,
499 enableConditionalDirectives: options.enableConditionalDirectives,
500 enableGenericMethods: options.enableGenericMethods));
495 } on ParserError catch (e) { 501 } on ParserError catch (e) {
496 partial.hasParseError = true; 502 partial.hasParseError = true;
497 return new ErrorNode(element.position, e.reason); 503 return new ErrorNode(element.position, e.reason);
498 } 504 }
499 Node node = listener.popNode(); 505 Node node = listener.popNode();
500 assert(listener.nodes.isEmpty); 506 assert(listener.nodes.isEmpty);
501 return node; 507 return node;
502 }); 508 });
503 }); 509 });
504 } 510 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/parser/parser_task.dart ('k') | pkg/compiler/lib/src/parser/partial_parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698