| 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);
|
|
|