| OLD | NEW |
| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 void handleOperatorName(Token operatorKeyword, Token token) { | 193 void handleOperatorName(Token operatorKeyword, Token token) { |
| 194 debugEvent("OperatorName"); | 194 debugEvent("OperatorName"); |
| 195 push(operatorFromString(token.stringValue)); | 195 push(operatorFromString(token.stringValue)); |
| 196 push(token.charOffset); | 196 push(token.charOffset); |
| 197 } | 197 } |
| 198 | 198 |
| 199 @override | 199 @override |
| 200 void handleIdentifier(Token token, IdentifierContext context) { | 200 void handleIdentifier(Token token, IdentifierContext context) { |
| 201 super.handleIdentifier(token, context); | 201 super.handleIdentifier(token, context); |
| 202 push(token.charOffset); | 202 push(token.charOffset); |
| 203 if (context == IdentifierContext.enumValueDeclaration) { |
| 204 String documentationComment = _getDocumentationComment(token); |
| 205 push(documentationComment ?? NullValue.DocumentationComment); |
| 206 } |
| 203 } | 207 } |
| 204 | 208 |
| 205 @override | 209 @override |
| 206 void handleNoName(Token token) { | 210 void handleNoName(Token token) { |
| 207 super.handleNoName(token); | 211 super.handleNoName(token); |
| 208 push(token.charOffset); | 212 push(token.charOffset); |
| 209 } | 213 } |
| 210 | 214 |
| 211 @override | 215 @override |
| 212 void endLiteralString(int interpolationCount, Token endToken) { | 216 void endLiteralString(int interpolationCount, Token endToken) { |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 } | 623 } |
| 620 | 624 |
| 621 @override | 625 @override |
| 622 void handleNoFormalParameters(Token token, MemberKind kind) { | 626 void handleNoFormalParameters(Token token, MemberKind kind) { |
| 623 push(token.charOffset); | 627 push(token.charOffset); |
| 624 super.handleNoFormalParameters(token, kind); | 628 super.handleNoFormalParameters(token, kind); |
| 625 } | 629 } |
| 626 | 630 |
| 627 @override | 631 @override |
| 628 void endEnum(Token enumKeyword, Token endBrace, int count) { | 632 void endEnum(Token enumKeyword, Token endBrace, int count) { |
| 629 List constantNamesAndOffsets = popList(count * 2); | 633 String documentationComment = _getDocumentationComment(enumKeyword); |
| 634 List constantNamesAndOffsets = popList(count * 3); |
| 630 int charOffset = pop(); | 635 int charOffset = pop(); |
| 631 String name = pop(); | 636 String name = pop(); |
| 632 List<MetadataBuilder> metadata = pop(); | 637 List<MetadataBuilder> metadata = pop(); |
| 633 library.addEnum(metadata, name, constantNamesAndOffsets, charOffset, | 638 library.addEnum(documentationComment, metadata, name, |
| 634 endBrace.charOffset); | 639 constantNamesAndOffsets, charOffset, endBrace.charOffset); |
| 635 checkEmpty(enumKeyword.charOffset); | 640 checkEmpty(enumKeyword.charOffset); |
| 636 } | 641 } |
| 637 | 642 |
| 638 @override | 643 @override |
| 639 void beginFunctionTypeAlias(Token token) { | 644 void beginFunctionTypeAlias(Token token) { |
| 640 library.beginNestedDeclaration("#typedef", hasMembers: false); | 645 library.beginNestedDeclaration("#typedef", hasMembers: false); |
| 641 silenceParserErrors = false; | 646 silenceParserErrors = false; |
| 642 } | 647 } |
| 643 | 648 |
| 644 @override | 649 @override |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 } | 921 } |
| 917 | 922 |
| 918 @override | 923 @override |
| 919 Link<Token> handleMemberName(Link<Token> identifiers) { | 924 Link<Token> handleMemberName(Link<Token> identifiers) { |
| 920 if (!enableNative || identifiers.isEmpty) return identifiers; | 925 if (!enableNative || identifiers.isEmpty) return identifiers; |
| 921 return removeNativeClause(identifiers, stringExpectedAfterNative); | 926 return removeNativeClause(identifiers, stringExpectedAfterNative); |
| 922 } | 927 } |
| 923 | 928 |
| 924 /// Return the documentation comment for the entity that starts at the | 929 /// Return the documentation comment for the entity that starts at the |
| 925 /// given [token], or `null` if there is no preceding documentation comment. | 930 /// given [token], or `null` if there is no preceding documentation comment. |
| 926 String _getDocumentationComment(Token token) { | 931 static String _getDocumentationComment(Token token) { |
| 927 Token docToken = token.precedingComments; | 932 Token docToken = token.precedingComments; |
| 928 if (docToken == null) return null; | 933 if (docToken == null) return null; |
| 929 bool inSlash = false; | 934 bool inSlash = false; |
| 930 var buffer = new StringBuffer(); | 935 var buffer = new StringBuffer(); |
| 931 while (docToken != null) { | 936 while (docToken != null) { |
| 932 String lexeme = docToken.lexeme; | 937 String lexeme = docToken.lexeme; |
| 933 if (lexeme.startsWith('/**')) { | 938 if (lexeme.startsWith('/**')) { |
| 934 inSlash = false; | 939 inSlash = false; |
| 935 buffer.clear(); | 940 buffer.clear(); |
| 936 buffer.write(lexeme); | 941 buffer.write(lexeme); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 947 docToken = docToken.next; | 952 docToken = docToken.next; |
| 948 } | 953 } |
| 949 return buffer.toString(); | 954 return buffer.toString(); |
| 950 } | 955 } |
| 951 | 956 |
| 952 @override | 957 @override |
| 953 void debugEvent(String name) { | 958 void debugEvent(String name) { |
| 954 // printEvent(name); | 959 // printEvent(name); |
| 955 } | 960 } |
| 956 } | 961 } |
| OLD | NEW |