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

Unified Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 2526063002: Add parser support for using a URI in a part-of directive (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/src/generated/parser.dart
diff --git a/pkg/analyzer/lib/src/generated/parser.dart b/pkg/analyzer/lib/src/generated/parser.dart
index 85e186727c19f5868e0a357b2e952a070d28ad70..409960d38de0834a2641b739f6d149b0d51f8913 100644
--- a/pkg/analyzer/lib/src/generated/parser.dart
+++ b/pkg/analyzer/lib/src/generated/parser.dart
@@ -198,6 +198,12 @@ class Parser {
bool _enableNnbd = false;
/**
+ * A flag indicating whether the parser is to allow URI's in part-of
+ * directives.
+ */
+ bool _enableUriInPartOf = false;
+
+ /**
* A flag indicating whether parser is to parse function bodies.
*/
bool _parseFunctionBodies = true;
@@ -294,6 +300,19 @@ class Parser {
}
/**
+ * Return `true` if the parser is to allow URI's in part-of directives.
+ */
+ bool get enableUriInPartOf => _enableUriInPartOf;
+
+ /**
+ * Set whether the parser is to allow URI's in part-of directives to the given
+ * [enable] flag.
+ */
+ void set enableUriInPartOf(bool enable) {
+ _enableUriInPartOf = enable;
+ }
+
+ /**
* Return `true` if the current token is the first token of a return type that
* is followed by an identifier, possibly followed by a list of type
* parameters, followed by a left-parenthesis. This is used by
@@ -6891,6 +6910,18 @@ class Parser {
Directive _parsePartOfDirective(CommentAndMetadata commentAndMetadata) {
Token partKeyword = getAndAdvance();
Token ofKeyword = getAndAdvance();
+ if (enableUriInPartOf && _matches(TokenType.STRING)) {
+ StringLiteral libraryUri = _parseUri();
+ Token semicolon = _expect(TokenType.SEMICOLON);
+ return new PartOfDirective(
+ commentAndMetadata.comment,
+ commentAndMetadata.metadata,
+ partKeyword,
+ ofKeyword,
+ libraryUri,
+ null,
+ semicolon);
+ }
LibraryIdentifier libraryName = _parseLibraryName(
ParserErrorCode.MISSING_NAME_IN_PART_OF_DIRECTIVE, ofKeyword);
Token semicolon = _expect(TokenType.SEMICOLON);
@@ -6899,6 +6930,7 @@ class Parser {
commentAndMetadata.metadata,
partKeyword,
ofKeyword,
+ null,
libraryName,
semicolon);
}
« no previous file with comments | « pkg/analyzer/lib/src/generated/engine.dart ('k') | pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698