Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 analyzer.src.generated.parser; | 5 library analyzer.src.generated.parser; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import "dart:math" as math; | 8 import "dart:math" as math; |
| 9 | 9 |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 5160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5171 * | 5171 * |
| 5172 * commentReference ::= | 5172 * commentReference ::= |
| 5173 * '[' 'new'? qualified ']' libraryReference? | 5173 * '[' 'new'? qualified ']' libraryReference? |
| 5174 * | 5174 * |
| 5175 * libraryReference ::= | 5175 * libraryReference ::= |
| 5176 * '(' stringLiteral ')' | 5176 * '(' stringLiteral ')' |
| 5177 */ | 5177 */ |
| 5178 List<CommentReference> _parseCommentReferences( | 5178 List<CommentReference> _parseCommentReferences( |
| 5179 List<DocumentationCommentToken> tokens) { | 5179 List<DocumentationCommentToken> tokens) { |
| 5180 List<CommentReference> references = <CommentReference>[]; | 5180 List<CommentReference> references = <CommentReference>[]; |
| 5181 bool isInGitHubCodeBlock = false; | |
| 5181 for (DocumentationCommentToken token in tokens) { | 5182 for (DocumentationCommentToken token in tokens) { |
| 5182 String comment = token.lexeme; | 5183 String comment = token.lexeme; |
| 5183 comment = _removeCodeBlocksGitHub(comment); | 5184 // Skip GitHub code blocks. |
| 5185 // https://help.github.com/articles/creating-and-highlighting-code-blocks/ | |
| 5186 if (tokens.length != 1) { | |
| 5187 if (comment.indexOf('```') != -1) { | |
|
Brian Wilkerson
2016/09/01 21:06:58
Do we care about the case where the tripled-quote
scheglov
2016/09/01 21:14:22
It seems even less used case for me.
So, no, not n
| |
| 5188 isInGitHubCodeBlock = !isInGitHubCodeBlock; | |
| 5189 } | |
| 5190 if (isInGitHubCodeBlock) { | |
| 5191 continue; | |
| 5192 } | |
| 5193 } | |
| 5194 // Remove GitHub include code. | |
| 5195 comment = _removeGitHubInlineCode(comment); | |
| 5196 // Find references. | |
| 5184 int length = comment.length; | 5197 int length = comment.length; |
| 5185 List<List<int>> codeBlockRanges = _getCodeBlockRanges(comment); | 5198 List<List<int>> codeBlockRanges = _getCodeBlockRanges(comment); |
| 5186 int leftIndex = comment.indexOf('['); | 5199 int leftIndex = comment.indexOf('['); |
| 5187 while (leftIndex >= 0 && leftIndex + 1 < length) { | 5200 while (leftIndex >= 0 && leftIndex + 1 < length) { |
| 5188 List<int> range = _findRange(codeBlockRanges, leftIndex); | 5201 List<int> range = _findRange(codeBlockRanges, leftIndex); |
| 5189 if (range == null) { | 5202 if (range == null) { |
| 5190 int nameOffset = token.offset + leftIndex + 1; | 5203 int nameOffset = token.offset + leftIndex + 1; |
| 5191 int rightIndex = JavaString.indexOf(comment, ']', leftIndex); | 5204 int rightIndex = JavaString.indexOf(comment, ']', leftIndex); |
| 5192 if (rightIndex >= 0) { | 5205 if (rightIndex >= 0) { |
| 5193 int firstChar = comment.codeUnitAt(leftIndex + 1); | 5206 int firstChar = comment.codeUnitAt(leftIndex + 1); |
| (...skipping 3682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8876 * is the current token, `1` is the next token, etc. | 8889 * is the current token, `1` is the next token, etc. |
| 8877 */ | 8890 */ |
| 8878 Token _peekAt(int distance) { | 8891 Token _peekAt(int distance) { |
| 8879 Token token = _currentToken; | 8892 Token token = _currentToken; |
| 8880 for (int i = 0; i < distance; i++) { | 8893 for (int i = 0; i < distance; i++) { |
| 8881 token = token.next; | 8894 token = token.next; |
| 8882 } | 8895 } |
| 8883 return token; | 8896 return token; |
| 8884 } | 8897 } |
| 8885 | 8898 |
| 8886 String _removeCodeBlocksGitHub(String comment) { | 8899 String _removeGitHubInlineCode(String comment) { |
| 8887 int index = 0; | 8900 int index = 0; |
| 8888 while (true) { | 8901 while (true) { |
| 8889 int beginIndex = comment.indexOf('`', index); | 8902 int beginIndex = comment.indexOf('`', index); |
| 8890 if (beginIndex == -1) { | 8903 if (beginIndex == -1) { |
| 8891 break; | 8904 break; |
| 8892 } | 8905 } |
| 8893 int endIndex = comment.indexOf('`', beginIndex + 1); | 8906 int endIndex = comment.indexOf('`', beginIndex + 1); |
| 8894 if (endIndex == -1) { | 8907 if (endIndex == -1) { |
| 8895 break; | 8908 break; |
| 8896 } | 8909 } |
| (...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10530 */ | 10543 */ |
| 10531 const ParserErrorCode(String name, String message, [String correction]) | 10544 const ParserErrorCode(String name, String message, [String correction]) |
| 10532 : super(name, message, correction); | 10545 : super(name, message, correction); |
| 10533 | 10546 |
| 10534 @override | 10547 @override |
| 10535 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR; | 10548 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR; |
| 10536 | 10549 |
| 10537 @override | 10550 @override |
| 10538 ErrorType get type => ErrorType.SYNTACTIC_ERROR; | 10551 ErrorType get type => ErrorType.SYNTACTIC_ERROR; |
| 10539 } | 10552 } |
| OLD | NEW |