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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library fasta.outline_builder; 5 library fasta.outline_builder;
6 6
7 import 'package:kernel/ast.dart' show ProcedureKind; 7 import 'package:kernel/ast.dart' show ProcedureKind;
8 8
9 import '../../scanner/token.dart' show Token; 9 import '../../scanner/token.dart' show Token;
10 10
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 278
279 @override 279 @override
280 void endClassDeclaration( 280 void endClassDeclaration(
281 int interfacesCount, 281 int interfacesCount,
282 Token beginToken, 282 Token beginToken,
283 Token classKeyword, 283 Token classKeyword,
284 Token extendsKeyword, 284 Token extendsKeyword,
285 Token implementsKeyword, 285 Token implementsKeyword,
286 Token endToken) { 286 Token endToken) {
287 debugEvent("endClassDeclaration"); 287 debugEvent("endClassDeclaration");
288 288 String documentationComment = _getDocumentationComment(beginToken);
289 String documentationComment = null;
290 if (beginToken.precedingComments != null) {
291 documentationComment = beginToken.precedingComments.lexeme;
292 // TODO(scheglov): Add support for line comments.
293 }
294
295 List<TypeBuilder> interfaces = popList(interfacesCount); 289 List<TypeBuilder> interfaces = popList(interfacesCount);
296 TypeBuilder supertype = pop(); 290 TypeBuilder supertype = pop();
297 List<TypeVariableBuilder> typeVariables = pop(); 291 List<TypeVariableBuilder> typeVariables = pop();
298 int charOffset = pop(); 292 int charOffset = pop();
299 String name = pop(); 293 String name = pop();
300 if (typeVariables != null && supertype is MixinApplicationBuilder) { 294 if (typeVariables != null && supertype is MixinApplicationBuilder) {
301 supertype.typeVariables = typeVariables; 295 supertype.typeVariables = typeVariables;
302 supertype.subclassName = name; 296 supertype.subclassName = name;
303 } 297 }
304 int modifiers = Modifier.validate(pop()); 298 int modifiers = Modifier.validate(pop());
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 List<TypeBuilder> mixins = pop(); 451 List<TypeBuilder> mixins = pop();
458 TypeBuilder supertype = pop(); 452 TypeBuilder supertype = pop();
459 push( 453 push(
460 library.addMixinApplication(supertype, mixins, withKeyword.charOffset)); 454 library.addMixinApplication(supertype, mixins, withKeyword.charOffset));
461 } 455 }
462 456
463 @override 457 @override
464 void endNamedMixinApplication(Token beginToken, Token classKeyword, 458 void endNamedMixinApplication(Token beginToken, Token classKeyword,
465 Token equals, Token implementsKeyword, Token endToken) { 459 Token equals, Token implementsKeyword, Token endToken) {
466 debugEvent("endNamedMixinApplication"); 460 debugEvent("endNamedMixinApplication");
461 String documentationComment = _getDocumentationComment(beginToken);
467 List<TypeBuilder> interfaces = popIfNotNull(implementsKeyword); 462 List<TypeBuilder> interfaces = popIfNotNull(implementsKeyword);
468 TypeBuilder mixinApplication = pop(); 463 TypeBuilder mixinApplication = pop();
469 List<TypeVariableBuilder> typeVariables = pop(); 464 List<TypeVariableBuilder> typeVariables = pop();
470 int charOffset = pop(); 465 int charOffset = pop();
471 String name = pop(); 466 String name = pop();
472 int modifiers = Modifier.validate(pop()); 467 int modifiers = Modifier.validate(pop());
473 List<MetadataBuilder> metadata = pop(); 468 List<MetadataBuilder> metadata = pop();
474 library.addNamedMixinApplication(metadata, name, typeVariables, modifiers, 469 library.addNamedMixinApplication(documentationComment, metadata, name,
475 mixinApplication, interfaces, charOffset); 470 typeVariables, modifiers, mixinApplication, interfaces, charOffset);
476 checkEmpty(beginToken.charOffset); 471 checkEmpty(beginToken.charOffset);
477 } 472 }
478 473
479 @override 474 @override
480 void endTypeArguments(int count, Token beginToken, Token endToken) { 475 void endTypeArguments(int count, Token beginToken, Token endToken) {
481 debugEvent("TypeArguments"); 476 debugEvent("TypeArguments");
482 push(popList(count) ?? NullValue.TypeArguments); 477 push(popList(count) ?? NullValue.TypeArguments);
483 } 478 }
484 479
485 @override 480 @override
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 void addCompileTimeError(Message message, int charOffset) { 904 void addCompileTimeError(Message message, int charOffset) {
910 library.addCompileTimeError(message, charOffset, uri); 905 library.addCompileTimeError(message, charOffset, uri);
911 } 906 }
912 907
913 @override 908 @override
914 Link<Token> handleMemberName(Link<Token> identifiers) { 909 Link<Token> handleMemberName(Link<Token> identifiers) {
915 if (!enableNative || identifiers.isEmpty) return identifiers; 910 if (!enableNative || identifiers.isEmpty) return identifiers;
916 return removeNativeClause(identifiers, stringExpectedAfterNative); 911 return removeNativeClause(identifiers, stringExpectedAfterNative);
917 } 912 }
918 913
914 /// Return the documentation comment for the entity that starts at the
915 /// given [token], or `null` if there is no preceding documentation comment.
916 String _getDocumentationComment(Token token) {
917 Token docToken = token.precedingComments;
918 if (docToken == null) return null;
919 bool inSlash = false;
920 var buffer = new StringBuffer();
921 while (docToken != null) {
922 String lexeme = docToken.lexeme;
923 if (lexeme.startsWith('/**')) {
924 inSlash = false;
925 buffer.clear();
926 buffer.write(lexeme);
927 } else if (lexeme.startsWith('///')) {
928 if (!inSlash) {
929 inSlash = true;
930 buffer.clear();
931 }
932 if (buffer.isNotEmpty) {
933 buffer.writeln();
934 }
935 buffer.write(lexeme);
936 }
937 docToken = docToken.next;
938 }
939 return buffer.toString();
940 }
941
919 @override 942 @override
920 void debugEvent(String name) { 943 void debugEvent(String name) {
921 // printEvent(name); 944 // printEvent(name);
922 } 945 }
923 } 946 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698