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

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

Issue 2302003003: [linter] Issue 295. Skip comment tokens with GitHub code blocks (in ```). (Closed)
Patch Set: Created 4 years, 3 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 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 d3f747517b61ae2e1f002434f72d482c97e7f9f7..8e24b98c06697bbe362c40ffa2116bc2ebed9176 100644
--- a/pkg/analyzer/lib/src/generated/parser.dart
+++ b/pkg/analyzer/lib/src/generated/parser.dart
@@ -5178,9 +5178,22 @@ class Parser {
List<CommentReference> _parseCommentReferences(
List<DocumentationCommentToken> tokens) {
List<CommentReference> references = <CommentReference>[];
+ bool isInGitHubCodeBlock = false;
for (DocumentationCommentToken token in tokens) {
String comment = token.lexeme;
- comment = _removeCodeBlocksGitHub(comment);
+ // Skip GitHub code blocks.
+ // https://help.github.com/articles/creating-and-highlighting-code-blocks/
+ if (tokens.length != 1) {
+ 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
+ isInGitHubCodeBlock = !isInGitHubCodeBlock;
+ }
+ if (isInGitHubCodeBlock) {
+ continue;
+ }
+ }
+ // Remove GitHub include code.
+ comment = _removeGitHubInlineCode(comment);
+ // Find references.
int length = comment.length;
List<List<int>> codeBlockRanges = _getCodeBlockRanges(comment);
int leftIndex = comment.indexOf('[');
@@ -8883,7 +8896,7 @@ class Parser {
return token;
}
- String _removeCodeBlocksGitHub(String comment) {
+ String _removeGitHubInlineCode(String comment) {
int index = 0;
while (true) {
int beginIndex = comment.indexOf('`', index);
« 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