Make triple-slash comment classification more restrictive
It was overly permissive and ended up making a mess of C#-style comments: `/// <summary>Text</summary>` Now it checks the element name. Attribute names remain unchecked.
This commit is contained in:
parent
ec39d41287
commit
00d37268e8
|
@ -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] || !(commentPragmas as any)[match[3]]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let pos = start;
|
||||
|
||||
pushCommentRange(pos, match[1].length); // ///
|
||||
|
@ -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;
|
||||
|
||||
|
|
|
@ -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>"));
|
|
@ -4,5 +4,4 @@
|
|||
|
||||
var c = classification;
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/// "),
|
||||
c.punctuation("<"));
|
||||
c.comment("/// <")); // Don't classify until we recognize the element name
|
Loading…
Reference in a new issue