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

Unified Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 1527393002: Don't produce [references] in GitHub-like code blocks in comments. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/parser.dart
diff --git a/pkg/analyzer/lib/src/generated/parser.dart b/pkg/analyzer/lib/src/generated/parser.dart
index b15a92ebe857e0be863faa56d532bcefec8053ee..a30590015e6d572203c8f1668268a30a0194ade0 100644
--- a/pkg/analyzer/lib/src/generated/parser.dart
+++ b/pkg/analyzer/lib/src/generated/parser.dart
@@ -4052,7 +4052,8 @@ class Parser {
/**
* Return `true` if the given [character] is a valid hexadecimal digit.
*/
- bool _isHexDigit(int character) => (0x30 <= character && character <= 0x39) ||
+ bool _isHexDigit(int character) =>
+ (0x30 <= character && character <= 0x39) ||
(0x41 <= character && character <= 0x46) ||
(0x61 <= character && character <= 0x66);
@@ -4326,7 +4327,7 @@ class Parser {
*/
bool _matchesString(String identifier) =>
_currentToken.type == TokenType.IDENTIFIER &&
- _currentToken.lexeme == identifier;
+ _currentToken.lexeme == identifier;
/**
* If the current token has the given [type], then advance to the next token
@@ -5042,6 +5043,7 @@ class Parser {
List<CommentReference> references = new List<CommentReference>();
for (DocumentationCommentToken token in tokens) {
String comment = token.lexeme;
+ comment = _removeGitHubCodeBlocks(comment);
int length = comment.length;
List<List<int>> codeBlockRanges = _getCodeBlockRanges(comment);
int leftIndex = comment.indexOf('[');
@@ -8008,7 +8010,8 @@ class Parser {
* was parsed.
*/
StringLiteral _parseUri() {
- bool iskeywordAfterUri(Token token) => token.lexeme == Keyword.AS.syntax ||
+ bool iskeywordAfterUri(Token token) =>
+ token.lexeme == Keyword.AS.syntax ||
token.lexeme == _HIDE ||
token.lexeme == _SHOW;
if (!_matches(TokenType.STRING) &&
@@ -8230,6 +8233,25 @@ class Parser {
return token;
}
+ String _removeGitHubCodeBlocks(String comment) {
+ int index = 0;
+ while (true) {
+ int beginIndex = comment.indexOf('`', index);
+ if (beginIndex == -1) {
+ break;
+ }
+ int endIndex = comment.indexOf('`', beginIndex + 1);
+ if (endIndex == -1) {
+ break;
+ }
+ comment = comment.substring(0, beginIndex + 1) +
+ ' ' * (endIndex - beginIndex - 1) +
+ comment.substring(endIndex);
+ index = endIndex + 1;
+ }
+ return comment;
+ }
+
/**
* Report the given [error].
*/
@@ -8741,21 +8763,21 @@ class Parser {
*/
bool _tokenMatchesIdentifier(Token token) =>
_tokenMatches(token, TokenType.IDENTIFIER) ||
- _tokenMatchesPseudoKeyword(token);
+ _tokenMatchesPseudoKeyword(token);
/**
* Return `true` if the given [token] matches the given [keyword].
*/
bool _tokenMatchesKeyword(Token token, Keyword keyword) =>
token.type == TokenType.KEYWORD &&
- (token as KeywordToken).keyword == keyword;
+ (token as KeywordToken).keyword == keyword;
/**
* Return `true` if the given [token] matches a pseudo keyword.
*/
bool _tokenMatchesPseudoKeyword(Token token) =>
_tokenMatches(token, TokenType.KEYWORD) &&
- (token as KeywordToken).keyword.isPseudoKeyword;
+ (token as KeywordToken).keyword.isPseudoKeyword;
/**
* Return `true` if the given [token] matches the given [identifier].
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698