Chromium Code Reviews| 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..822ca16e6f65a11150b75730cfacfe99730a4d5a 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,25 @@ 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; |
| + var buffer = new StringBuffer(); |
| + while (docToken != null) { |
| + String lexeme = docToken.lexeme; |
| + if (lexeme.startsWith('///') || lexeme.startsWith('/**')) { |
|
Siggi Cherem (dart-lang)
2017/07/24 17:34:47
I understand that the reason for this loop is to e
scheglov
2017/07/24 19:13:38
Done.
|
| + if (buffer.isNotEmpty) { |
| + buffer.writeln(); |
| + } |
| + buffer.write(lexeme); |
| + } |
| + docToken = docToken.next; |
| + } |
| + return buffer.toString(); |
| + } |
| + |
| @override |
| void debugEvent(String name) { |
| // printEvent(name); |