Skip to content

Commit

Permalink
Merge pull request microsoft#33056 from amcasey/TripleSlashRestrictions
Browse files Browse the repository at this point in the history
Make triple-slash comment classification more restrictive
  • Loading branch information
amcasey committed Aug 23, 2019
2 parents ec39d41 + e3690c3 commit 5b59cfb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/services/classifier.ts
Expand Up @@ -771,6 +771,14 @@ namespace ts {
return false;
}

// Limiting classification to exactly the elements and attributes
// defined in `ts.commentPragmas` would be excessive, but we can avoid
// some obvious false positives (e.g. in XML-like doc comments) by
// checking the element name.
if (!match[3] || !(match[3] in commentPragmas)) {
return false;
}

let pos = start;

pushCommentRange(pos, match[1].length); // ///
Expand All @@ -779,10 +787,6 @@ namespace ts {
pushClassification(pos, match[2].length, ClassificationType.punctuation); // <
pos += match[2].length;

if (!match[3]) {
return true;
}

pushClassification(pos, match[3].length, ClassificationType.jsxSelfClosingTagName); // element name
pos += match[3].length;

Expand Down
@@ -0,0 +1,7 @@
/// <reference path="fourslash.ts"/>

//// /// <summary>Text</summary>

var c = classification;
verify.syntacticClassificationsAre(
c.comment("/// <summary>Text</summary>"));
@@ -0,0 +1,7 @@
/// <reference path="fourslash.ts"/>

//// /// <reference>Text</reference>

var c = classification;
verify.syntacticClassificationsAre(
c.comment("/// <reference>Text</reference>"));
Expand Up @@ -4,5 +4,4 @@

var c = classification;
verify.syntacticClassificationsAre(
c.comment("/// "),
c.punctuation("<"));
c.comment("/// <")); // Don't classify until we recognize the element name

0 comments on commit 5b59cfb

Please sign in to comment.