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

Unified Diff: pkg/front_end/lib/src/fasta/source/outline_builder.dart

Issue 2997473002: Add documentation comments for enum and enum values. Resynthesize in analyzer. (Closed)
Patch Set: Created 3 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/source/outline_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/source/outline_builder.dart b/pkg/front_end/lib/src/fasta/source/outline_builder.dart
index 065020df65c346d373c200f00f13d83b74cbe884..b8db980cb6b161d5bb3b93e7377c041a2d8023fb 100644
--- a/pkg/front_end/lib/src/fasta/source/outline_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/outline_builder.dart
@@ -200,6 +200,10 @@ class OutlineBuilder extends UnhandledListener {
void handleIdentifier(Token token, IdentifierContext context) {
super.handleIdentifier(token, context);
push(token.charOffset);
+ if (context == IdentifierContext.enumValueDeclaration) {
+ String documentationComment = _getDocumentationComment(token);
+ push(documentationComment ?? NullValue.DocumentationComment);
+ }
}
@override
@@ -626,12 +630,13 @@ class OutlineBuilder extends UnhandledListener {
@override
void endEnum(Token enumKeyword, Token endBrace, int count) {
- List constantNamesAndOffsets = popList(count * 2);
+ String documentationComment = _getDocumentationComment(enumKeyword);
+ List constantNamesAndOffsets = popList(count * 3);
int charOffset = pop();
String name = pop();
List<MetadataBuilder> metadata = pop();
- library.addEnum(metadata, name, constantNamesAndOffsets, charOffset,
- endBrace.charOffset);
+ library.addEnum(documentationComment, metadata, name,
+ constantNamesAndOffsets, charOffset, endBrace.charOffset);
checkEmpty(enumKeyword.charOffset);
}
@@ -923,7 +928,7 @@ class OutlineBuilder extends UnhandledListener {
/// Return the documentation comment for the entity that starts at the
/// given [token], or `null` if there is no preceding documentation comment.
- String _getDocumentationComment(Token token) {
+ static String _getDocumentationComment(Token token) {
Token docToken = token.precedingComments;
if (docToken == null) return null;
bool inSlash = false;

Powered by Google App Engine
This is Rietveld 408576698