@typespec/prettier-plugin-typespec 0.49.0-dev.2 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +77 -33
- package/dist/index.js.map +1 -1
- package/package.json +3 -4
package/dist/index.js
CHANGED
|
@@ -58,39 +58,40 @@ var SyntaxKind;
|
|
|
58
58
|
SyntaxKind[SyntaxKind["DocText"] = 48] = "DocText";
|
|
59
59
|
SyntaxKind[SyntaxKind["DocParamTag"] = 49] = "DocParamTag";
|
|
60
60
|
SyntaxKind[SyntaxKind["DocReturnsTag"] = 50] = "DocReturnsTag";
|
|
61
|
-
SyntaxKind[SyntaxKind["
|
|
62
|
-
SyntaxKind[SyntaxKind["
|
|
63
|
-
SyntaxKind[SyntaxKind["
|
|
64
|
-
SyntaxKind[SyntaxKind["
|
|
65
|
-
SyntaxKind[SyntaxKind["
|
|
66
|
-
SyntaxKind[SyntaxKind["
|
|
67
|
-
SyntaxKind[SyntaxKind["
|
|
68
|
-
SyntaxKind[SyntaxKind["
|
|
69
|
-
SyntaxKind[SyntaxKind["
|
|
70
|
-
SyntaxKind[SyntaxKind["
|
|
71
|
-
SyntaxKind[SyntaxKind["
|
|
72
|
-
SyntaxKind[SyntaxKind["
|
|
73
|
-
SyntaxKind[SyntaxKind["
|
|
74
|
-
SyntaxKind[SyntaxKind["
|
|
75
|
-
SyntaxKind[SyntaxKind["
|
|
76
|
-
SyntaxKind[SyntaxKind["
|
|
77
|
-
SyntaxKind[SyntaxKind["
|
|
78
|
-
SyntaxKind[SyntaxKind["
|
|
79
|
-
SyntaxKind[SyntaxKind["
|
|
80
|
-
SyntaxKind[SyntaxKind["
|
|
81
|
-
SyntaxKind[SyntaxKind["
|
|
82
|
-
SyntaxKind[SyntaxKind["
|
|
83
|
-
SyntaxKind[SyntaxKind["
|
|
84
|
-
SyntaxKind[SyntaxKind["
|
|
85
|
-
SyntaxKind[SyntaxKind["
|
|
86
|
-
SyntaxKind[SyntaxKind["
|
|
87
|
-
SyntaxKind[SyntaxKind["
|
|
88
|
-
SyntaxKind[SyntaxKind["
|
|
89
|
-
SyntaxKind[SyntaxKind["
|
|
90
|
-
SyntaxKind[SyntaxKind["
|
|
91
|
-
SyntaxKind[SyntaxKind["
|
|
92
|
-
SyntaxKind[SyntaxKind["
|
|
93
|
-
SyntaxKind[SyntaxKind["
|
|
61
|
+
SyntaxKind[SyntaxKind["DocErrorsTag"] = 51] = "DocErrorsTag";
|
|
62
|
+
SyntaxKind[SyntaxKind["DocTemplateTag"] = 52] = "DocTemplateTag";
|
|
63
|
+
SyntaxKind[SyntaxKind["DocUnknownTag"] = 53] = "DocUnknownTag";
|
|
64
|
+
SyntaxKind[SyntaxKind["Projection"] = 54] = "Projection";
|
|
65
|
+
SyntaxKind[SyntaxKind["ProjectionParameterDeclaration"] = 55] = "ProjectionParameterDeclaration";
|
|
66
|
+
SyntaxKind[SyntaxKind["ProjectionModelSelector"] = 56] = "ProjectionModelSelector";
|
|
67
|
+
SyntaxKind[SyntaxKind["ProjectionModelPropertySelector"] = 57] = "ProjectionModelPropertySelector";
|
|
68
|
+
SyntaxKind[SyntaxKind["ProjectionOperationSelector"] = 58] = "ProjectionOperationSelector";
|
|
69
|
+
SyntaxKind[SyntaxKind["ProjectionUnionSelector"] = 59] = "ProjectionUnionSelector";
|
|
70
|
+
SyntaxKind[SyntaxKind["ProjectionUnionVariantSelector"] = 60] = "ProjectionUnionVariantSelector";
|
|
71
|
+
SyntaxKind[SyntaxKind["ProjectionInterfaceSelector"] = 61] = "ProjectionInterfaceSelector";
|
|
72
|
+
SyntaxKind[SyntaxKind["ProjectionEnumSelector"] = 62] = "ProjectionEnumSelector";
|
|
73
|
+
SyntaxKind[SyntaxKind["ProjectionEnumMemberSelector"] = 63] = "ProjectionEnumMemberSelector";
|
|
74
|
+
SyntaxKind[SyntaxKind["ProjectionExpressionStatement"] = 64] = "ProjectionExpressionStatement";
|
|
75
|
+
SyntaxKind[SyntaxKind["ProjectionIfExpression"] = 65] = "ProjectionIfExpression";
|
|
76
|
+
SyntaxKind[SyntaxKind["ProjectionBlockExpression"] = 66] = "ProjectionBlockExpression";
|
|
77
|
+
SyntaxKind[SyntaxKind["ProjectionMemberExpression"] = 67] = "ProjectionMemberExpression";
|
|
78
|
+
SyntaxKind[SyntaxKind["ProjectionLogicalExpression"] = 68] = "ProjectionLogicalExpression";
|
|
79
|
+
SyntaxKind[SyntaxKind["ProjectionEqualityExpression"] = 69] = "ProjectionEqualityExpression";
|
|
80
|
+
SyntaxKind[SyntaxKind["ProjectionUnaryExpression"] = 70] = "ProjectionUnaryExpression";
|
|
81
|
+
SyntaxKind[SyntaxKind["ProjectionRelationalExpression"] = 71] = "ProjectionRelationalExpression";
|
|
82
|
+
SyntaxKind[SyntaxKind["ProjectionArithmeticExpression"] = 72] = "ProjectionArithmeticExpression";
|
|
83
|
+
SyntaxKind[SyntaxKind["ProjectionCallExpression"] = 73] = "ProjectionCallExpression";
|
|
84
|
+
SyntaxKind[SyntaxKind["ProjectionLambdaExpression"] = 74] = "ProjectionLambdaExpression";
|
|
85
|
+
SyntaxKind[SyntaxKind["ProjectionLambdaParameterDeclaration"] = 75] = "ProjectionLambdaParameterDeclaration";
|
|
86
|
+
SyntaxKind[SyntaxKind["ProjectionModelExpression"] = 76] = "ProjectionModelExpression";
|
|
87
|
+
SyntaxKind[SyntaxKind["ProjectionModelProperty"] = 77] = "ProjectionModelProperty";
|
|
88
|
+
SyntaxKind[SyntaxKind["ProjectionModelSpreadProperty"] = 78] = "ProjectionModelSpreadProperty";
|
|
89
|
+
SyntaxKind[SyntaxKind["ProjectionSpreadProperty"] = 79] = "ProjectionSpreadProperty";
|
|
90
|
+
SyntaxKind[SyntaxKind["ProjectionTupleExpression"] = 80] = "ProjectionTupleExpression";
|
|
91
|
+
SyntaxKind[SyntaxKind["ProjectionStatement"] = 81] = "ProjectionStatement";
|
|
92
|
+
SyntaxKind[SyntaxKind["ProjectionDecoratorReferenceExpression"] = 82] = "ProjectionDecoratorReferenceExpression";
|
|
93
|
+
SyntaxKind[SyntaxKind["Return"] = 83] = "Return";
|
|
94
|
+
SyntaxKind[SyntaxKind["JsNamespaceDeclaration"] = 84] = "JsNamespaceDeclaration";
|
|
94
95
|
})(SyntaxKind || (SyntaxKind = {}));
|
|
95
96
|
var IdentifierKind;
|
|
96
97
|
(function (IdentifierKind) {
|
|
@@ -972,6 +973,15 @@ const diagnostics = {
|
|
|
972
973
|
default: paramMessage `Rule "${"ruleName"}" has been enabled and disabled in the same ruleset.`,
|
|
973
974
|
},
|
|
974
975
|
},
|
|
976
|
+
/**
|
|
977
|
+
* Formatter
|
|
978
|
+
*/
|
|
979
|
+
"format-failed": {
|
|
980
|
+
severity: "error",
|
|
981
|
+
messages: {
|
|
982
|
+
default: paramMessage `File '${"file"}' failed to format. ${"details"}`,
|
|
983
|
+
},
|
|
984
|
+
},
|
|
975
985
|
/**
|
|
976
986
|
* Decorator
|
|
977
987
|
*/
|
|
@@ -3743,6 +3753,8 @@ function createScanner(source, diagnosticHandler) {
|
|
|
3743
3753
|
if (atConflictMarker())
|
|
3744
3754
|
return scanConflictMarker();
|
|
3745
3755
|
return next(Token.DocText);
|
|
3756
|
+
case 45 /* CharCode.Minus */:
|
|
3757
|
+
return next(Token.Hyphen);
|
|
3746
3758
|
}
|
|
3747
3759
|
if (isAsciiIdentifierStart(ch)) {
|
|
3748
3760
|
return scanIdentifier();
|
|
@@ -4625,6 +4637,7 @@ path, options, print) {
|
|
|
4625
4637
|
case SyntaxKind.DocParamTag:
|
|
4626
4638
|
case SyntaxKind.DocTemplateTag:
|
|
4627
4639
|
case SyntaxKind.DocReturnsTag:
|
|
4640
|
+
case SyntaxKind.DocErrorsTag:
|
|
4628
4641
|
case SyntaxKind.DocUnknownTag:
|
|
4629
4642
|
// https://github.com/microsoft/typespec/issues/1319 Tracks pretty-printing doc comments.
|
|
4630
4643
|
compilerAssert(false, "Currently, doc comments are only handled as regular comments and we do not opt in to parsing them so we shouldn't reach here.");
|
|
@@ -7457,6 +7470,11 @@ function createParser(code, options = {}) {
|
|
|
7457
7470
|
},
|
|
7458
7471
|
];
|
|
7459
7472
|
}
|
|
7473
|
+
/**
|
|
7474
|
+
* Parses a documentation tag.
|
|
7475
|
+
*
|
|
7476
|
+
* @see <a href="https://microsoft.github.io/typespec/language-basics/documentation#tsdoc-doc-comments">TypeSpec documentation docs</a>
|
|
7477
|
+
*/
|
|
7460
7478
|
function parseDocTag() {
|
|
7461
7479
|
const pos = tokenPos();
|
|
7462
7480
|
parseExpected(Token.At);
|
|
@@ -7469,12 +7487,19 @@ function createParser(code, options = {}) {
|
|
|
7469
7487
|
case "return":
|
|
7470
7488
|
case "returns":
|
|
7471
7489
|
return parseDocSimpleTag(pos, tagName, SyntaxKind.DocReturnsTag);
|
|
7490
|
+
case "errors":
|
|
7491
|
+
return parseDocSimpleTag(pos, tagName, SyntaxKind.DocErrorsTag);
|
|
7472
7492
|
default:
|
|
7473
7493
|
return parseDocSimpleTag(pos, tagName, SyntaxKind.DocUnknownTag);
|
|
7474
7494
|
}
|
|
7475
7495
|
}
|
|
7496
|
+
/**
|
|
7497
|
+
* Handles param-like documentation comment tags.
|
|
7498
|
+
* For example, `@param` and `@template`.
|
|
7499
|
+
*/
|
|
7476
7500
|
function parseDocParamLikeTag(pos, tagName, kind, messageId) {
|
|
7477
7501
|
const name = parseDocIdentifier(messageId);
|
|
7502
|
+
parseOptionalHyphenDocParamLikeTag();
|
|
7478
7503
|
const content = parseDocContent();
|
|
7479
7504
|
return {
|
|
7480
7505
|
kind,
|
|
@@ -7484,6 +7509,24 @@ function createParser(code, options = {}) {
|
|
|
7484
7509
|
...finishNode(pos),
|
|
7485
7510
|
};
|
|
7486
7511
|
}
|
|
7512
|
+
/**
|
|
7513
|
+
* Handles the optional hyphen in param-like documentation comment tags.
|
|
7514
|
+
*
|
|
7515
|
+
* TypeSpec recommends no hyphen, but supports a hyphen to match TSDoc.
|
|
7516
|
+
* (Original design discussion recorded in [2390].)
|
|
7517
|
+
*
|
|
7518
|
+
* [2390]: https://github.com/microsoft/typespec/issues/2390
|
|
7519
|
+
*/
|
|
7520
|
+
function parseOptionalHyphenDocParamLikeTag() {
|
|
7521
|
+
while (parseOptional(Token.Whitespace))
|
|
7522
|
+
; // Skip whitespace
|
|
7523
|
+
if (parseOptional(Token.Hyphen)) {
|
|
7524
|
+
// The doc content started with a hyphen, so skip subsequent whitespace
|
|
7525
|
+
// (The if statement already advanced past the hyphen itself.)
|
|
7526
|
+
while (parseOptional(Token.Whitespace))
|
|
7527
|
+
;
|
|
7528
|
+
}
|
|
7529
|
+
}
|
|
7487
7530
|
function parseDocSimpleTag(pos, tagName, kind) {
|
|
7488
7531
|
const content = parseDocContent();
|
|
7489
7532
|
return {
|
|
@@ -8049,6 +8092,7 @@ function visitChildren(node, cb) {
|
|
|
8049
8092
|
case SyntaxKind.DocTemplateTag:
|
|
8050
8093
|
return (visitNode(cb, node.tagName) || visitNode(cb, node.paramName) || visitEach(cb, node.content));
|
|
8051
8094
|
case SyntaxKind.DocReturnsTag:
|
|
8095
|
+
case SyntaxKind.DocErrorsTag:
|
|
8052
8096
|
case SyntaxKind.DocUnknownTag:
|
|
8053
8097
|
return visitNode(cb, node.tagName) || visitEach(cb, node.content);
|
|
8054
8098
|
// no children for the rest of these.
|