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

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

Issue 2990523002: Parse documentation for class aliases, fix for /// comments. (Closed)
Patch Set: Fix and test mix of comment styles. Created 3 years, 5 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 04486e5594ece7e6786f75cff6fb6434dd6924fb..9458cde75336c55b51ce4e4c030f24de47884895 100644
--- a/pkg/front_end/lib/src/fasta/source/outline_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/outline_builder.dart
@@ -285,13 +285,7 @@ class OutlineBuilder extends UnhandledListener {
Token implementsKeyword,
Token endToken) {
debugEvent("endClassDeclaration");
-
- String documentationComment = null;
- if (beginToken.precedingComments != null) {
- documentationComment = beginToken.precedingComments.lexeme;
- // TODO(scheglov): Add support for line comments.
- }
-
+ String documentationComment = _getDocumentationComment(beginToken);
List<TypeBuilder> interfaces = popList(interfacesCount);
TypeBuilder supertype = pop();
List<TypeVariableBuilder> typeVariables = pop();
@@ -464,6 +458,7 @@ class OutlineBuilder extends UnhandledListener {
void endNamedMixinApplication(Token beginToken, Token classKeyword,
Token equals, Token implementsKeyword, Token endToken) {
debugEvent("endNamedMixinApplication");
+ String documentationComment = _getDocumentationComment(beginToken);
List<TypeBuilder> interfaces = popIfNotNull(implementsKeyword);
TypeBuilder mixinApplication = pop();
List<TypeVariableBuilder> typeVariables = pop();
@@ -471,8 +466,8 @@ class OutlineBuilder extends UnhandledListener {
String name = pop();
int modifiers = Modifier.validate(pop());
List<MetadataBuilder> metadata = pop();
- library.addNamedMixinApplication(metadata, name, typeVariables, modifiers,
- mixinApplication, interfaces, charOffset);
+ library.addNamedMixinApplication(documentationComment, metadata, name,
+ typeVariables, modifiers, mixinApplication, interfaces, charOffset);
checkEmpty(beginToken.charOffset);
}
@@ -916,6 +911,34 @@ class OutlineBuilder extends UnhandledListener {
return removeNativeClause(identifiers, stringExpectedAfterNative);
}
+ /// 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) {
+ Token docToken = token.precedingComments;
+ if (docToken == null) return null;
+ bool inSlash = false;
+ var buffer = new StringBuffer();
+ while (docToken != null) {
+ String lexeme = docToken.lexeme;
+ if (lexeme.startsWith('/**')) {
+ inSlash = false;
+ buffer.clear();
+ buffer.write(lexeme);
+ } else if (lexeme.startsWith('///')) {
+ if (!inSlash) {
+ inSlash = true;
+ buffer.clear();
+ }
+ if (buffer.isNotEmpty) {
+ buffer.writeln();
+ }
+ buffer.write(lexeme);
+ }
+ docToken = docToken.next;
+ }
+ return buffer.toString();
+ }
+
@override
void debugEvent(String name) {
// printEvent(name);

Powered by Google App Engine
This is Rietveld 408576698