@typespec/prettier-plugin-typespec 1.10.0-dev.1 → 1.10.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 +270 -165
- package/dist/index.js.map +3 -3
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -320,7 +320,8 @@ var diagnostics = {
|
|
|
320
320
|
severity: "warning",
|
|
321
321
|
messages: {
|
|
322
322
|
default: paramMessage`${"feature"} is an experimental feature. It may change in the future or be removed. Use with caution and consider providing feedback on this feature.`,
|
|
323
|
-
functionDeclarations: "Function declarations are an experimental feature that may change in the future. Use with caution and consider providing feedback to the TypeSpec team."
|
|
323
|
+
functionDeclarations: "Function declarations are an experimental feature that may change in the future. Use with caution and consider providing feedback to the TypeSpec team.",
|
|
324
|
+
internal: `Internal symbols are experimental and may be changed in a future release. Use with caution. Suppress this message ('#suppress "experimental-feature"') to silence this warning.`
|
|
324
325
|
}
|
|
325
326
|
},
|
|
326
327
|
"using-invalid-ref": {
|
|
@@ -397,7 +398,8 @@ var diagnostics = {
|
|
|
397
398
|
underNamespace: paramMessage`Namespace ${"namespace"} doesn't have member ${"id"}`,
|
|
398
399
|
member: paramMessage`${"kind"} doesn't have member ${"id"}`,
|
|
399
400
|
metaProperty: paramMessage`${"kind"} doesn't have meta property ${"id"}`,
|
|
400
|
-
node: paramMessage`Cannot resolve '${"id"}' in node ${"nodeName"} since it has no members. Did you mean to use "::" instead of "."
|
|
401
|
+
node: paramMessage`Cannot resolve '${"id"}' in node ${"nodeName"} since it has no members. Did you mean to use "::" instead of "."?`,
|
|
402
|
+
internal: paramMessage`Symbol '${"id"}' is internal and can only be accessed from within its declaring package.`
|
|
401
403
|
}
|
|
402
404
|
},
|
|
403
405
|
"duplicate-property": {
|
|
@@ -608,16 +610,12 @@ var diagnostics = {
|
|
|
608
610
|
default: "A rest parameter must be of an array type."
|
|
609
611
|
}
|
|
610
612
|
},
|
|
611
|
-
"
|
|
613
|
+
"invalid-modifier": {
|
|
612
614
|
severity: "error",
|
|
613
615
|
messages: {
|
|
614
|
-
default:
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
"function-extern": {
|
|
618
|
-
severity: "error",
|
|
619
|
-
messages: {
|
|
620
|
-
default: "A function declaration must be prefixed with the 'extern' modifier."
|
|
616
|
+
default: paramMessage`Modifier '${"modifier"}' is invalid.`,
|
|
617
|
+
"missing-required": paramMessage`Declaration of type '${"nodeKind"}' is missing required modifier '${"modifier"}'.`,
|
|
618
|
+
"not-allowed": paramMessage`Modifier '${"modifier"}' cannot be used on declarations of type '${"nodeKind"}'.`
|
|
621
619
|
}
|
|
622
620
|
},
|
|
623
621
|
"function-return": {
|
|
@@ -1286,7 +1284,8 @@ var SyntaxKind;
|
|
|
1286
1284
|
SyntaxKind2[SyntaxKind2["ConstStatement"] = 67] = "ConstStatement";
|
|
1287
1285
|
SyntaxKind2[SyntaxKind2["CallExpression"] = 68] = "CallExpression";
|
|
1288
1286
|
SyntaxKind2[SyntaxKind2["ScalarConstructor"] = 69] = "ScalarConstructor";
|
|
1289
|
-
SyntaxKind2[SyntaxKind2["
|
|
1287
|
+
SyntaxKind2[SyntaxKind2["InternalKeyword"] = 70] = "InternalKeyword";
|
|
1288
|
+
SyntaxKind2[SyntaxKind2["FunctionTypeExpression"] = 71] = "FunctionTypeExpression";
|
|
1290
1289
|
})(SyntaxKind || (SyntaxKind = {}));
|
|
1291
1290
|
var IdentifierKind;
|
|
1292
1291
|
(function(IdentifierKind2) {
|
|
@@ -2881,6 +2880,52 @@ function lookupInNonAsciiMap(codePoint, map) {
|
|
|
2881
2880
|
return false;
|
|
2882
2881
|
}
|
|
2883
2882
|
|
|
2883
|
+
// ../compiler/dist/src/core/modifiers.js
|
|
2884
|
+
var DEFAULT_COMPATIBILITY = {
|
|
2885
|
+
allowed: 4,
|
|
2886
|
+
required: 0
|
|
2887
|
+
};
|
|
2888
|
+
var NO_MODIFIERS = {
|
|
2889
|
+
allowed: 0,
|
|
2890
|
+
required: 0
|
|
2891
|
+
};
|
|
2892
|
+
var SYNTAX_MODIFIERS = {
|
|
2893
|
+
[SyntaxKind.NamespaceStatement]: NO_MODIFIERS,
|
|
2894
|
+
[SyntaxKind.OperationStatement]: DEFAULT_COMPATIBILITY,
|
|
2895
|
+
[SyntaxKind.ModelStatement]: DEFAULT_COMPATIBILITY,
|
|
2896
|
+
[SyntaxKind.ScalarStatement]: DEFAULT_COMPATIBILITY,
|
|
2897
|
+
[SyntaxKind.InterfaceStatement]: DEFAULT_COMPATIBILITY,
|
|
2898
|
+
[SyntaxKind.UnionStatement]: DEFAULT_COMPATIBILITY,
|
|
2899
|
+
[SyntaxKind.EnumStatement]: DEFAULT_COMPATIBILITY,
|
|
2900
|
+
[SyntaxKind.AliasStatement]: DEFAULT_COMPATIBILITY,
|
|
2901
|
+
[SyntaxKind.ConstStatement]: DEFAULT_COMPATIBILITY,
|
|
2902
|
+
[SyntaxKind.DecoratorDeclarationStatement]: {
|
|
2903
|
+
allowed: 6,
|
|
2904
|
+
required: 2
|
|
2905
|
+
},
|
|
2906
|
+
[SyntaxKind.FunctionDeclarationStatement]: {
|
|
2907
|
+
allowed: 6,
|
|
2908
|
+
required: 2
|
|
2909
|
+
}
|
|
2910
|
+
};
|
|
2911
|
+
function modifiersToFlags(modifiers) {
|
|
2912
|
+
let flags = 0;
|
|
2913
|
+
for (const modifier of modifiers) {
|
|
2914
|
+
flags |= modifierToFlag(modifier);
|
|
2915
|
+
}
|
|
2916
|
+
return flags;
|
|
2917
|
+
}
|
|
2918
|
+
function modifierToFlag(modifier) {
|
|
2919
|
+
switch (modifier.kind) {
|
|
2920
|
+
case SyntaxKind.ExternKeyword:
|
|
2921
|
+
return 2;
|
|
2922
|
+
case SyntaxKind.InternalKeyword:
|
|
2923
|
+
return 4;
|
|
2924
|
+
default:
|
|
2925
|
+
compilerAssert(false, `Unknown modifier kind: ${modifier.kind}`);
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
|
|
2884
2929
|
// ../compiler/dist/src/core/helpers/syntax-utils.js
|
|
2885
2930
|
function printIdentifier(sv, context = "disallow-reserved") {
|
|
2886
2931
|
if (needBacktick(sv, context)) {
|
|
@@ -2894,8 +2939,14 @@ function needBacktick(sv, context) {
|
|
|
2894
2939
|
if (sv.length === 0) {
|
|
2895
2940
|
return false;
|
|
2896
2941
|
}
|
|
2897
|
-
if (context === "allow-reserved"
|
|
2898
|
-
|
|
2942
|
+
if (context === "allow-reserved") {
|
|
2943
|
+
if (ReservedKeywords.has(sv)) {
|
|
2944
|
+
return false;
|
|
2945
|
+
}
|
|
2946
|
+
const kwToken = Keywords.get(sv);
|
|
2947
|
+
if (kwToken !== void 0 && isModifier(kwToken)) {
|
|
2948
|
+
return false;
|
|
2949
|
+
}
|
|
2899
2950
|
}
|
|
2900
2951
|
if (Keywords.has(sv)) {
|
|
2901
2952
|
return true;
|
|
@@ -3068,55 +3119,55 @@ var Token;
|
|
|
3068
3119
|
Token2[Token2["__EndStatementKeyword"] = 69] = "__EndStatementKeyword";
|
|
3069
3120
|
Token2[Token2["__StartModifierKeyword"] = 69] = "__StartModifierKeyword";
|
|
3070
3121
|
Token2[Token2["ExternKeyword"] = 69] = "ExternKeyword";
|
|
3071
|
-
Token2[Token2["
|
|
3072
|
-
Token2[Token2["
|
|
3073
|
-
Token2[Token2["
|
|
3074
|
-
Token2[Token2["
|
|
3075
|
-
Token2[Token2["
|
|
3076
|
-
Token2[Token2["
|
|
3077
|
-
Token2[Token2["
|
|
3078
|
-
Token2[Token2["
|
|
3079
|
-
Token2[Token2["
|
|
3080
|
-
Token2[Token2["
|
|
3081
|
-
Token2[Token2["
|
|
3082
|
-
Token2[Token2["
|
|
3083
|
-
Token2[Token2["
|
|
3084
|
-
Token2[Token2["
|
|
3085
|
-
Token2[Token2["
|
|
3086
|
-
Token2[Token2["
|
|
3087
|
-
Token2[Token2["
|
|
3088
|
-
Token2[Token2["
|
|
3089
|
-
Token2[Token2["
|
|
3090
|
-
Token2[Token2["
|
|
3091
|
-
Token2[Token2["
|
|
3092
|
-
Token2[Token2["
|
|
3093
|
-
Token2[Token2["
|
|
3094
|
-
Token2[Token2["
|
|
3095
|
-
Token2[Token2["
|
|
3096
|
-
Token2[Token2["
|
|
3097
|
-
Token2[Token2["
|
|
3098
|
-
Token2[Token2["
|
|
3099
|
-
Token2[Token2["
|
|
3100
|
-
Token2[Token2["
|
|
3101
|
-
Token2[Token2["
|
|
3102
|
-
Token2[Token2["
|
|
3103
|
-
Token2[Token2["
|
|
3104
|
-
Token2[Token2["
|
|
3105
|
-
Token2[Token2["
|
|
3106
|
-
Token2[Token2["
|
|
3107
|
-
Token2[Token2["
|
|
3108
|
-
Token2[Token2["
|
|
3109
|
-
Token2[Token2["
|
|
3110
|
-
Token2[Token2["
|
|
3111
|
-
Token2[Token2["
|
|
3112
|
-
Token2[Token2["
|
|
3113
|
-
Token2[Token2["
|
|
3114
|
-
Token2[Token2["
|
|
3115
|
-
Token2[Token2["
|
|
3116
|
-
Token2[Token2["
|
|
3117
|
-
Token2[Token2["
|
|
3118
|
-
Token2[Token2["
|
|
3119
|
-
Token2[Token2["
|
|
3122
|
+
Token2[Token2["InternalKeyword"] = 70] = "InternalKeyword";
|
|
3123
|
+
Token2[Token2["__EndModifierKeyword"] = 71] = "__EndModifierKeyword";
|
|
3124
|
+
Token2[Token2["ExtendsKeyword"] = 71] = "ExtendsKeyword";
|
|
3125
|
+
Token2[Token2["FnKeyword"] = 72] = "FnKeyword";
|
|
3126
|
+
Token2[Token2["TrueKeyword"] = 73] = "TrueKeyword";
|
|
3127
|
+
Token2[Token2["FalseKeyword"] = 74] = "FalseKeyword";
|
|
3128
|
+
Token2[Token2["ReturnKeyword"] = 75] = "ReturnKeyword";
|
|
3129
|
+
Token2[Token2["VoidKeyword"] = 76] = "VoidKeyword";
|
|
3130
|
+
Token2[Token2["NeverKeyword"] = 77] = "NeverKeyword";
|
|
3131
|
+
Token2[Token2["UnknownKeyword"] = 78] = "UnknownKeyword";
|
|
3132
|
+
Token2[Token2["ValueOfKeyword"] = 79] = "ValueOfKeyword";
|
|
3133
|
+
Token2[Token2["TypeOfKeyword"] = 80] = "TypeOfKeyword";
|
|
3134
|
+
Token2[Token2["__EndKeyword"] = 81] = "__EndKeyword";
|
|
3135
|
+
Token2[Token2["__StartReservedKeyword"] = 81] = "__StartReservedKeyword";
|
|
3136
|
+
Token2[Token2["StatemachineKeyword"] = 81] = "StatemachineKeyword";
|
|
3137
|
+
Token2[Token2["MacroKeyword"] = 82] = "MacroKeyword";
|
|
3138
|
+
Token2[Token2["PackageKeyword"] = 83] = "PackageKeyword";
|
|
3139
|
+
Token2[Token2["MetadataKeyword"] = 84] = "MetadataKeyword";
|
|
3140
|
+
Token2[Token2["EnvKeyword"] = 85] = "EnvKeyword";
|
|
3141
|
+
Token2[Token2["ArgKeyword"] = 86] = "ArgKeyword";
|
|
3142
|
+
Token2[Token2["DeclareKeyword"] = 87] = "DeclareKeyword";
|
|
3143
|
+
Token2[Token2["ArrayKeyword"] = 88] = "ArrayKeyword";
|
|
3144
|
+
Token2[Token2["StructKeyword"] = 89] = "StructKeyword";
|
|
3145
|
+
Token2[Token2["RecordKeyword"] = 90] = "RecordKeyword";
|
|
3146
|
+
Token2[Token2["ModuleKeyword"] = 91] = "ModuleKeyword";
|
|
3147
|
+
Token2[Token2["ModKeyword"] = 92] = "ModKeyword";
|
|
3148
|
+
Token2[Token2["SymKeyword"] = 93] = "SymKeyword";
|
|
3149
|
+
Token2[Token2["ContextKeyword"] = 94] = "ContextKeyword";
|
|
3150
|
+
Token2[Token2["PropKeyword"] = 95] = "PropKeyword";
|
|
3151
|
+
Token2[Token2["PropertyKeyword"] = 96] = "PropertyKeyword";
|
|
3152
|
+
Token2[Token2["ScenarioKeyword"] = 97] = "ScenarioKeyword";
|
|
3153
|
+
Token2[Token2["PubKeyword"] = 98] = "PubKeyword";
|
|
3154
|
+
Token2[Token2["SubKeyword"] = 99] = "SubKeyword";
|
|
3155
|
+
Token2[Token2["TypeRefKeyword"] = 100] = "TypeRefKeyword";
|
|
3156
|
+
Token2[Token2["TraitKeyword"] = 101] = "TraitKeyword";
|
|
3157
|
+
Token2[Token2["ThisKeyword"] = 102] = "ThisKeyword";
|
|
3158
|
+
Token2[Token2["SelfKeyword"] = 103] = "SelfKeyword";
|
|
3159
|
+
Token2[Token2["SuperKeyword"] = 104] = "SuperKeyword";
|
|
3160
|
+
Token2[Token2["KeyofKeyword"] = 105] = "KeyofKeyword";
|
|
3161
|
+
Token2[Token2["WithKeyword"] = 106] = "WithKeyword";
|
|
3162
|
+
Token2[Token2["ImplementsKeyword"] = 107] = "ImplementsKeyword";
|
|
3163
|
+
Token2[Token2["ImplKeyword"] = 108] = "ImplKeyword";
|
|
3164
|
+
Token2[Token2["SatisfiesKeyword"] = 109] = "SatisfiesKeyword";
|
|
3165
|
+
Token2[Token2["FlagKeyword"] = 110] = "FlagKeyword";
|
|
3166
|
+
Token2[Token2["AutoKeyword"] = 111] = "AutoKeyword";
|
|
3167
|
+
Token2[Token2["PartialKeyword"] = 112] = "PartialKeyword";
|
|
3168
|
+
Token2[Token2["PrivateKeyword"] = 113] = "PrivateKeyword";
|
|
3169
|
+
Token2[Token2["PublicKeyword"] = 114] = "PublicKeyword";
|
|
3170
|
+
Token2[Token2["ProtectedKeyword"] = 115] = "ProtectedKeyword";
|
|
3120
3171
|
Token2[Token2["SealedKeyword"] = 116] = "SealedKeyword";
|
|
3121
3172
|
Token2[Token2["LocalKeyword"] = 117] = "LocalKeyword";
|
|
3122
3173
|
Token2[Token2["AsyncKeyword"] = 118] = "AsyncKeyword";
|
|
@@ -3274,6 +3325,7 @@ var Keywords = /* @__PURE__ */ new Map([
|
|
|
3274
3325
|
["never", Token.NeverKeyword],
|
|
3275
3326
|
["unknown", Token.UnknownKeyword],
|
|
3276
3327
|
["extern", Token.ExternKeyword],
|
|
3328
|
+
["internal", Token.InternalKeyword],
|
|
3277
3329
|
// Reserved keywords
|
|
3278
3330
|
["statemachine", Token.StatemachineKeyword],
|
|
3279
3331
|
["macro", Token.MacroKeyword],
|
|
@@ -3310,7 +3362,6 @@ var Keywords = /* @__PURE__ */ new Map([
|
|
|
3310
3362
|
["private", Token.PrivateKeyword],
|
|
3311
3363
|
["public", Token.PublicKeyword],
|
|
3312
3364
|
["protected", Token.ProtectedKeyword],
|
|
3313
|
-
["internal", Token.InternalKeyword],
|
|
3314
3365
|
["sealed", Token.SealedKeyword],
|
|
3315
3366
|
["local", Token.LocalKeyword],
|
|
3316
3367
|
["async", Token.AsyncKeyword]
|
|
@@ -3349,7 +3400,6 @@ var ReservedKeywords = /* @__PURE__ */ new Map([
|
|
|
3349
3400
|
["private", Token.PrivateKeyword],
|
|
3350
3401
|
["public", Token.PublicKeyword],
|
|
3351
3402
|
["protected", Token.ProtectedKeyword],
|
|
3352
|
-
["internal", Token.InternalKeyword],
|
|
3353
3403
|
["sealed", Token.SealedKeyword],
|
|
3354
3404
|
["local", Token.LocalKeyword],
|
|
3355
3405
|
["async", Token.AsyncKeyword]
|
|
@@ -3379,6 +3429,9 @@ function isReservedKeyword(token) {
|
|
|
3379
3429
|
function isPunctuation(token) {
|
|
3380
3430
|
return token >= Token.__StartPunctuation && token < Token.__EndPunctuation;
|
|
3381
3431
|
}
|
|
3432
|
+
function isModifier(token) {
|
|
3433
|
+
return token >= Token.__StartModifierKeyword && token < Token.__EndModifierKeyword;
|
|
3434
|
+
}
|
|
3382
3435
|
function isStatementKeyword(token) {
|
|
3383
3436
|
return token >= Token.__StartStatementKeyword && token < Token.__EndStatementKeyword;
|
|
3384
3437
|
}
|
|
@@ -4078,14 +4131,13 @@ function createScanner(source, diagnosticHandler) {
|
|
|
4078
4131
|
}
|
|
4079
4132
|
function scanIdentifierOrKeyword() {
|
|
4080
4133
|
let count = 0;
|
|
4081
|
-
let ch = input.charCodeAt(position);
|
|
4082
4134
|
while (true) {
|
|
4083
4135
|
position++;
|
|
4084
4136
|
count++;
|
|
4085
4137
|
if (eof()) {
|
|
4086
4138
|
break;
|
|
4087
4139
|
}
|
|
4088
|
-
ch = input.charCodeAt(position);
|
|
4140
|
+
const ch = input.charCodeAt(position);
|
|
4089
4141
|
if (count < 12 && isLowercaseAsciiLetter(ch)) {
|
|
4090
4142
|
continue;
|
|
4091
4143
|
}
|
|
@@ -4431,35 +4483,6 @@ function createParser(code, options = {}) {
|
|
|
4431
4483
|
reportInvalidDecorators(decorators, "import statement");
|
|
4432
4484
|
item = parseImportStatement();
|
|
4433
4485
|
break;
|
|
4434
|
-
case Token.ModelKeyword:
|
|
4435
|
-
item = parseModelStatement(pos, decorators);
|
|
4436
|
-
break;
|
|
4437
|
-
case Token.ScalarKeyword:
|
|
4438
|
-
item = parseScalarStatement(pos, decorators);
|
|
4439
|
-
break;
|
|
4440
|
-
case Token.NamespaceKeyword:
|
|
4441
|
-
item = parseNamespaceStatement(pos, decorators, docs, directives);
|
|
4442
|
-
break;
|
|
4443
|
-
case Token.InterfaceKeyword:
|
|
4444
|
-
item = parseInterfaceStatement(pos, decorators);
|
|
4445
|
-
break;
|
|
4446
|
-
case Token.UnionKeyword:
|
|
4447
|
-
item = parseUnionStatement(pos, decorators);
|
|
4448
|
-
break;
|
|
4449
|
-
case Token.OpKeyword:
|
|
4450
|
-
item = parseOperationStatement(pos, decorators);
|
|
4451
|
-
break;
|
|
4452
|
-
case Token.EnumKeyword:
|
|
4453
|
-
item = parseEnumStatement(pos, decorators);
|
|
4454
|
-
break;
|
|
4455
|
-
case Token.AliasKeyword:
|
|
4456
|
-
reportInvalidDecorators(decorators, "alias statement");
|
|
4457
|
-
item = parseAliasStatement(pos);
|
|
4458
|
-
break;
|
|
4459
|
-
case Token.ConstKeyword:
|
|
4460
|
-
reportInvalidDecorators(decorators, "const statement");
|
|
4461
|
-
item = parseConstStatement(pos);
|
|
4462
|
-
break;
|
|
4463
4486
|
case Token.UsingKeyword:
|
|
4464
4487
|
reportInvalidDecorators(decorators, "using statement");
|
|
4465
4488
|
item = parseUsingStatement(pos);
|
|
@@ -4469,10 +4492,20 @@ function createParser(code, options = {}) {
|
|
|
4469
4492
|
item = parseEmptyStatement(pos);
|
|
4470
4493
|
break;
|
|
4471
4494
|
// Start of declaration with modifiers
|
|
4495
|
+
case Token.NamespaceKeyword:
|
|
4496
|
+
case Token.ModelKeyword:
|
|
4497
|
+
case Token.ScalarKeyword:
|
|
4498
|
+
case Token.InterfaceKeyword:
|
|
4499
|
+
case Token.UnionKeyword:
|
|
4500
|
+
case Token.OpKeyword:
|
|
4501
|
+
case Token.EnumKeyword:
|
|
4502
|
+
case Token.AliasKeyword:
|
|
4503
|
+
case Token.ConstKeyword:
|
|
4472
4504
|
case Token.ExternKeyword:
|
|
4505
|
+
case Token.InternalKeyword:
|
|
4473
4506
|
case Token.FnKeyword:
|
|
4474
4507
|
case Token.DecKeyword:
|
|
4475
|
-
item = parseDeclaration(pos);
|
|
4508
|
+
item = parseDeclaration(pos, decorators, docs, directives);
|
|
4476
4509
|
break;
|
|
4477
4510
|
default:
|
|
4478
4511
|
item = parseInvalidStatement(pos, decorators);
|
|
@@ -4519,47 +4552,24 @@ function createParser(code, options = {}) {
|
|
|
4519
4552
|
item = parseImportStatement();
|
|
4520
4553
|
error({ code: "import-first", messageId: "topLevel", target: item });
|
|
4521
4554
|
break;
|
|
4522
|
-
case Token.
|
|
4523
|
-
|
|
4555
|
+
case Token.UsingKeyword:
|
|
4556
|
+
reportInvalidDecorators(decorators, "using statement");
|
|
4557
|
+
item = parseUsingStatement(pos);
|
|
4524
4558
|
break;
|
|
4559
|
+
case Token.ModelKeyword:
|
|
4525
4560
|
case Token.ScalarKeyword:
|
|
4526
|
-
item = parseScalarStatement(pos, decorators);
|
|
4527
|
-
break;
|
|
4528
4561
|
case Token.NamespaceKeyword:
|
|
4529
|
-
const ns = parseNamespaceStatement(pos, decorators, docs, directives);
|
|
4530
|
-
if (isBlocklessNamespace(ns)) {
|
|
4531
|
-
error({ code: "blockless-namespace-first", messageId: "topLevel", target: ns });
|
|
4532
|
-
}
|
|
4533
|
-
item = ns;
|
|
4534
|
-
break;
|
|
4535
4562
|
case Token.InterfaceKeyword:
|
|
4536
|
-
item = parseInterfaceStatement(pos, decorators);
|
|
4537
|
-
break;
|
|
4538
4563
|
case Token.UnionKeyword:
|
|
4539
|
-
item = parseUnionStatement(pos, decorators);
|
|
4540
|
-
break;
|
|
4541
4564
|
case Token.OpKeyword:
|
|
4542
|
-
item = parseOperationStatement(pos, decorators);
|
|
4543
|
-
break;
|
|
4544
4565
|
case Token.EnumKeyword:
|
|
4545
|
-
item = parseEnumStatement(pos, decorators);
|
|
4546
|
-
break;
|
|
4547
4566
|
case Token.AliasKeyword:
|
|
4548
|
-
reportInvalidDecorators(decorators, "alias statement");
|
|
4549
|
-
item = parseAliasStatement(pos);
|
|
4550
|
-
break;
|
|
4551
4567
|
case Token.ConstKeyword:
|
|
4552
|
-
reportInvalidDecorators(decorators, "const statement");
|
|
4553
|
-
item = parseConstStatement(pos);
|
|
4554
|
-
break;
|
|
4555
|
-
case Token.UsingKeyword:
|
|
4556
|
-
reportInvalidDecorators(decorators, "using statement");
|
|
4557
|
-
item = parseUsingStatement(pos);
|
|
4558
|
-
break;
|
|
4559
4568
|
case Token.ExternKeyword:
|
|
4569
|
+
case Token.InternalKeyword:
|
|
4560
4570
|
case Token.FnKeyword:
|
|
4561
4571
|
case Token.DecKeyword:
|
|
4562
|
-
item = parseDeclaration(pos);
|
|
4572
|
+
item = parseDeclaration(pos, decorators, docs, directives);
|
|
4563
4573
|
break;
|
|
4564
4574
|
case Token.EndOfFile:
|
|
4565
4575
|
parseExpected(Token.CloseBrace);
|
|
@@ -4572,6 +4582,9 @@ function createParser(code, options = {}) {
|
|
|
4572
4582
|
item = parseInvalidStatement(pos, decorators);
|
|
4573
4583
|
break;
|
|
4574
4584
|
}
|
|
4585
|
+
if (isBlocklessNamespace(item)) {
|
|
4586
|
+
error({ code: "blockless-namespace-first", messageId: "topLevel", target: item });
|
|
4587
|
+
}
|
|
4575
4588
|
mutate(item).directives = directives;
|
|
4576
4589
|
if (tok !== Token.NamespaceKeyword) {
|
|
4577
4590
|
mutate(item).docs = docs;
|
|
@@ -4594,7 +4607,7 @@ function createParser(code, options = {}) {
|
|
|
4594
4607
|
}
|
|
4595
4608
|
return directives;
|
|
4596
4609
|
}
|
|
4597
|
-
function parseNamespaceStatement(pos, decorators, docs, directives) {
|
|
4610
|
+
function parseNamespaceStatement(pos, decorators, modifiers, docs, directives) {
|
|
4598
4611
|
parseExpected(Token.NamespaceKeyword);
|
|
4599
4612
|
let currentName = parseIdentifierOrMemberExpression();
|
|
4600
4613
|
const nsSegments = [];
|
|
@@ -4617,6 +4630,8 @@ function createParser(code, options = {}) {
|
|
|
4617
4630
|
locals: void 0,
|
|
4618
4631
|
statements,
|
|
4619
4632
|
directives,
|
|
4633
|
+
modifiers,
|
|
4634
|
+
modifierFlags: modifiersToFlags(modifiers),
|
|
4620
4635
|
...finishNode(pos)
|
|
4621
4636
|
};
|
|
4622
4637
|
for (let i = 1; i < nsSegments.length; i++) {
|
|
@@ -4627,12 +4642,14 @@ function createParser(code, options = {}) {
|
|
|
4627
4642
|
id: nsSegments[i],
|
|
4628
4643
|
statements: outerNs,
|
|
4629
4644
|
locals: void 0,
|
|
4645
|
+
modifiers: [],
|
|
4646
|
+
modifierFlags: 0,
|
|
4630
4647
|
...finishNode(pos)
|
|
4631
4648
|
};
|
|
4632
4649
|
}
|
|
4633
4650
|
return outerNs;
|
|
4634
4651
|
}
|
|
4635
|
-
function parseInterfaceStatement(pos, decorators) {
|
|
4652
|
+
function parseInterfaceStatement(pos, decorators, modifiers) {
|
|
4636
4653
|
parseExpected(Token.InterfaceKeyword);
|
|
4637
4654
|
const id = parseIdentifier();
|
|
4638
4655
|
const { items: templateParameters, range: templateParametersRange } = parseTemplateParameterList();
|
|
@@ -4644,7 +4661,13 @@ function createParser(code, options = {}) {
|
|
|
4644
4661
|
error({ code: "token-expected", format: { token: "'extends' or '{'" } });
|
|
4645
4662
|
nextToken();
|
|
4646
4663
|
}
|
|
4647
|
-
const { items: operations, range: bodyRange } = parseList(ListKind.InterfaceMembers, (pos2, decorators2) => parseOperationStatement(
|
|
4664
|
+
const { items: operations, range: bodyRange } = parseList(ListKind.InterfaceMembers, (pos2, decorators2) => parseOperationStatement(
|
|
4665
|
+
pos2,
|
|
4666
|
+
decorators2,
|
|
4667
|
+
/* modifiers */
|
|
4668
|
+
void 0,
|
|
4669
|
+
true
|
|
4670
|
+
));
|
|
4648
4671
|
return {
|
|
4649
4672
|
kind: SyntaxKind.InterfaceStatement,
|
|
4650
4673
|
id,
|
|
@@ -4654,6 +4677,8 @@ function createParser(code, options = {}) {
|
|
|
4654
4677
|
bodyRange,
|
|
4655
4678
|
extends: extendList.items,
|
|
4656
4679
|
decorators,
|
|
4680
|
+
modifiers,
|
|
4681
|
+
modifierFlags: modifiersToFlags(modifiers),
|
|
4657
4682
|
...finishNode(pos)
|
|
4658
4683
|
};
|
|
4659
4684
|
}
|
|
@@ -4671,7 +4696,7 @@ function createParser(code, options = {}) {
|
|
|
4671
4696
|
}
|
|
4672
4697
|
return detail;
|
|
4673
4698
|
}
|
|
4674
|
-
function parseUnionStatement(pos, decorators) {
|
|
4699
|
+
function parseUnionStatement(pos, decorators, modifiers) {
|
|
4675
4700
|
parseExpected(Token.UnionKeyword);
|
|
4676
4701
|
const id = parseIdentifier();
|
|
4677
4702
|
const { items: templateParameters, range: templateParametersRange } = parseTemplateParameterList();
|
|
@@ -4682,6 +4707,8 @@ function createParser(code, options = {}) {
|
|
|
4682
4707
|
templateParameters,
|
|
4683
4708
|
templateParametersRange,
|
|
4684
4709
|
decorators,
|
|
4710
|
+
modifiers,
|
|
4711
|
+
modifierFlags: modifiersToFlags(modifiers),
|
|
4685
4712
|
options: options2,
|
|
4686
4713
|
...finishNode(pos)
|
|
4687
4714
|
};
|
|
@@ -4689,10 +4716,14 @@ function createParser(code, options = {}) {
|
|
|
4689
4716
|
function parseIdOrValueForVariant() {
|
|
4690
4717
|
const nextToken2 = token();
|
|
4691
4718
|
let id;
|
|
4692
|
-
if (isReservedKeyword(nextToken2)) {
|
|
4719
|
+
if (isReservedKeyword(nextToken2) || isModifier(nextToken2)) {
|
|
4693
4720
|
id = parseIdentifier({ allowReservedIdentifier: true });
|
|
4694
4721
|
if (token() !== Token.Colon) {
|
|
4695
|
-
|
|
4722
|
+
if (isReservedKeyword(nextToken2)) {
|
|
4723
|
+
error({ code: "reserved-identifier", messageId: "future", format: { name: id.sv } });
|
|
4724
|
+
} else {
|
|
4725
|
+
error({ code: "reserved-identifier" });
|
|
4726
|
+
}
|
|
4696
4727
|
}
|
|
4697
4728
|
return {
|
|
4698
4729
|
kind: SyntaxKind.TypeReference,
|
|
@@ -4751,10 +4782,13 @@ function createParser(code, options = {}) {
|
|
|
4751
4782
|
...finishNode(pos)
|
|
4752
4783
|
};
|
|
4753
4784
|
}
|
|
4754
|
-
function parseOperationStatement(pos, decorators, inInterface) {
|
|
4785
|
+
function parseOperationStatement(pos, decorators, _modifiers, inInterface) {
|
|
4786
|
+
let modifiers;
|
|
4755
4787
|
if (inInterface) {
|
|
4788
|
+
modifiers = parseModifiers();
|
|
4756
4789
|
parseOptional(Token.OpKeyword);
|
|
4757
4790
|
} else {
|
|
4791
|
+
modifiers = _modifiers;
|
|
4758
4792
|
parseExpected(Token.OpKeyword);
|
|
4759
4793
|
}
|
|
4760
4794
|
const id = parseIdentifier();
|
|
@@ -4791,6 +4825,8 @@ function createParser(code, options = {}) {
|
|
|
4791
4825
|
templateParametersRange,
|
|
4792
4826
|
signature,
|
|
4793
4827
|
decorators,
|
|
4828
|
+
modifiers,
|
|
4829
|
+
modifierFlags: modifiersToFlags(modifiers),
|
|
4794
4830
|
...finishNode(pos)
|
|
4795
4831
|
};
|
|
4796
4832
|
}
|
|
@@ -4805,7 +4841,7 @@ function createParser(code, options = {}) {
|
|
|
4805
4841
|
};
|
|
4806
4842
|
return parameters;
|
|
4807
4843
|
}
|
|
4808
|
-
function parseModelStatement(pos, decorators) {
|
|
4844
|
+
function parseModelStatement(pos, decorators, modifiers) {
|
|
4809
4845
|
parseExpected(Token.ModelKeyword);
|
|
4810
4846
|
const id = parseIdentifier();
|
|
4811
4847
|
const { items: templateParameters, range: templateParametersRange } = parseTemplateParameterList();
|
|
@@ -4833,6 +4869,8 @@ function createParser(code, options = {}) {
|
|
|
4833
4869
|
decorators,
|
|
4834
4870
|
properties: propDetail.items,
|
|
4835
4871
|
bodyRange: propDetail.range,
|
|
4872
|
+
modifiers,
|
|
4873
|
+
modifierFlags: modifiersToFlags(modifiers),
|
|
4836
4874
|
...finishNode(pos)
|
|
4837
4875
|
};
|
|
4838
4876
|
}
|
|
@@ -4956,7 +4994,7 @@ function createParser(code, options = {}) {
|
|
|
4956
4994
|
...finishNode(pos)
|
|
4957
4995
|
};
|
|
4958
4996
|
}
|
|
4959
|
-
function parseScalarStatement(pos, decorators) {
|
|
4997
|
+
function parseScalarStatement(pos, decorators, modifiers) {
|
|
4960
4998
|
parseExpected(Token.ScalarKeyword);
|
|
4961
4999
|
const id = parseIdentifier();
|
|
4962
5000
|
const { items: templateParameters, range: templateParametersRange } = parseTemplateParameterList();
|
|
@@ -4971,6 +5009,8 @@ function createParser(code, options = {}) {
|
|
|
4971
5009
|
members,
|
|
4972
5010
|
bodyRange,
|
|
4973
5011
|
decorators,
|
|
5012
|
+
modifiers,
|
|
5013
|
+
modifierFlags: modifiersToFlags(modifiers),
|
|
4974
5014
|
...finishNode(pos)
|
|
4975
5015
|
};
|
|
4976
5016
|
}
|
|
@@ -5000,7 +5040,7 @@ function createParser(code, options = {}) {
|
|
|
5000
5040
|
...finishNode(pos)
|
|
5001
5041
|
};
|
|
5002
5042
|
}
|
|
5003
|
-
function parseEnumStatement(pos, decorators) {
|
|
5043
|
+
function parseEnumStatement(pos, decorators, modifiers) {
|
|
5004
5044
|
parseExpected(Token.EnumKeyword);
|
|
5005
5045
|
const id = parseIdentifier();
|
|
5006
5046
|
const { items: members } = parseList(ListKind.EnumMembers, parseEnumMemberOrSpread);
|
|
@@ -5008,6 +5048,8 @@ function createParser(code, options = {}) {
|
|
|
5008
5048
|
kind: SyntaxKind.EnumStatement,
|
|
5009
5049
|
id,
|
|
5010
5050
|
decorators,
|
|
5051
|
+
modifiers,
|
|
5052
|
+
modifierFlags: modifiersToFlags(modifiers),
|
|
5011
5053
|
members,
|
|
5012
5054
|
...finishNode(pos)
|
|
5013
5055
|
};
|
|
@@ -5050,7 +5092,7 @@ function createParser(code, options = {}) {
|
|
|
5050
5092
|
...finishNode(pos)
|
|
5051
5093
|
};
|
|
5052
5094
|
}
|
|
5053
|
-
function parseAliasStatement(pos) {
|
|
5095
|
+
function parseAliasStatement(pos, modifiers) {
|
|
5054
5096
|
parseExpected(Token.AliasKeyword);
|
|
5055
5097
|
const id = parseIdentifier();
|
|
5056
5098
|
const { items: templateParameters, range: templateParametersRange } = parseTemplateParameterList();
|
|
@@ -5063,10 +5105,12 @@ function createParser(code, options = {}) {
|
|
|
5063
5105
|
templateParameters,
|
|
5064
5106
|
templateParametersRange,
|
|
5065
5107
|
value,
|
|
5108
|
+
modifiers,
|
|
5109
|
+
modifierFlags: modifiersToFlags(modifiers),
|
|
5066
5110
|
...finishNode(pos)
|
|
5067
5111
|
};
|
|
5068
5112
|
}
|
|
5069
|
-
function parseConstStatement(pos) {
|
|
5113
|
+
function parseConstStatement(pos, modifiers) {
|
|
5070
5114
|
parseExpected(Token.ConstKeyword);
|
|
5071
5115
|
const id = parseIdentifier();
|
|
5072
5116
|
const type = parseOptionalTypeAnnotation();
|
|
@@ -5078,6 +5122,8 @@ function createParser(code, options = {}) {
|
|
|
5078
5122
|
id,
|
|
5079
5123
|
value,
|
|
5080
5124
|
type,
|
|
5125
|
+
modifiers,
|
|
5126
|
+
modifierFlags: modifiersToFlags(modifiers),
|
|
5081
5127
|
...finishNode(pos)
|
|
5082
5128
|
};
|
|
5083
5129
|
}
|
|
@@ -5488,6 +5534,14 @@ function createParser(code, options = {}) {
|
|
|
5488
5534
|
...finishNode(pos)
|
|
5489
5535
|
};
|
|
5490
5536
|
}
|
|
5537
|
+
function parseInternalKeyword() {
|
|
5538
|
+
const pos = tokenPos();
|
|
5539
|
+
parseExpected(Token.InternalKeyword);
|
|
5540
|
+
return {
|
|
5541
|
+
kind: SyntaxKind.InternalKeyword,
|
|
5542
|
+
...finishNode(pos)
|
|
5543
|
+
};
|
|
5544
|
+
}
|
|
5491
5545
|
function parseVoidKeyword() {
|
|
5492
5546
|
const pos = tokenPos();
|
|
5493
5547
|
parseExpected(Token.VoidKeyword);
|
|
@@ -5672,8 +5726,10 @@ function createParser(code, options = {}) {
|
|
|
5672
5726
|
}
|
|
5673
5727
|
function parseIdentifier(options2) {
|
|
5674
5728
|
if (isKeyword(token())) {
|
|
5675
|
-
|
|
5676
|
-
|
|
5729
|
+
if (!(isModifier(token()) && options2?.allowReservedIdentifier)) {
|
|
5730
|
+
error({ code: "reserved-identifier" });
|
|
5731
|
+
return createMissingIdentifier();
|
|
5732
|
+
}
|
|
5677
5733
|
} else if (isReservedKeyword(token())) {
|
|
5678
5734
|
if (!options2?.allowReservedIdentifier) {
|
|
5679
5735
|
error({ code: "reserved-identifier", messageId: "future", format: { name: tokenValue() } });
|
|
@@ -5691,9 +5747,29 @@ function createParser(code, options = {}) {
|
|
|
5691
5747
|
...finishNode(pos)
|
|
5692
5748
|
};
|
|
5693
5749
|
}
|
|
5694
|
-
function parseDeclaration(pos) {
|
|
5750
|
+
function parseDeclaration(pos, decorators, docs, directives) {
|
|
5695
5751
|
const modifiers = parseModifiers();
|
|
5696
5752
|
switch (token()) {
|
|
5753
|
+
case Token.ModelKeyword:
|
|
5754
|
+
return parseModelStatement(pos, decorators, modifiers);
|
|
5755
|
+
case Token.ScalarKeyword:
|
|
5756
|
+
return parseScalarStatement(pos, decorators, modifiers);
|
|
5757
|
+
case Token.NamespaceKeyword:
|
|
5758
|
+
return parseNamespaceStatement(pos, decorators, modifiers, docs, directives);
|
|
5759
|
+
case Token.InterfaceKeyword:
|
|
5760
|
+
return parseInterfaceStatement(pos, decorators, modifiers);
|
|
5761
|
+
case Token.UnionKeyword:
|
|
5762
|
+
return parseUnionStatement(pos, decorators, modifiers);
|
|
5763
|
+
case Token.OpKeyword:
|
|
5764
|
+
return parseOperationStatement(pos, decorators, modifiers);
|
|
5765
|
+
case Token.EnumKeyword:
|
|
5766
|
+
return parseEnumStatement(pos, decorators, modifiers);
|
|
5767
|
+
case Token.AliasKeyword:
|
|
5768
|
+
reportInvalidDecorators(decorators, "alias statement");
|
|
5769
|
+
return parseAliasStatement(pos, modifiers);
|
|
5770
|
+
case Token.ConstKeyword:
|
|
5771
|
+
reportInvalidDecorators(decorators, "const statement");
|
|
5772
|
+
return parseConstStatement(pos, modifiers);
|
|
5697
5773
|
case Token.DecKeyword:
|
|
5698
5774
|
return parseDecoratorDeclarationStatement(pos, modifiers);
|
|
5699
5775
|
case Token.FnKeyword:
|
|
@@ -5713,6 +5789,8 @@ function createParser(code, options = {}) {
|
|
|
5713
5789
|
switch (token()) {
|
|
5714
5790
|
case Token.ExternKeyword:
|
|
5715
5791
|
return parseExternKeyword();
|
|
5792
|
+
case Token.InternalKeyword:
|
|
5793
|
+
return parseInternalKeyword();
|
|
5716
5794
|
default:
|
|
5717
5795
|
return void 0;
|
|
5718
5796
|
}
|
|
@@ -5806,17 +5884,6 @@ function createParser(code, options = {}) {
|
|
|
5806
5884
|
...finishNode(pos)
|
|
5807
5885
|
};
|
|
5808
5886
|
}
|
|
5809
|
-
function modifiersToFlags(modifiers) {
|
|
5810
|
-
let flags = 0;
|
|
5811
|
-
for (const modifier of modifiers) {
|
|
5812
|
-
switch (modifier.kind) {
|
|
5813
|
-
case SyntaxKind.ExternKeyword:
|
|
5814
|
-
flags |= 2;
|
|
5815
|
-
break;
|
|
5816
|
-
}
|
|
5817
|
-
}
|
|
5818
|
-
return flags;
|
|
5819
|
-
}
|
|
5820
5887
|
function parseRange(mode, range, callback) {
|
|
5821
5888
|
const savedMode = currentMode;
|
|
5822
5889
|
const result = scanner.scanRange(range, () => {
|
|
@@ -6350,15 +6417,15 @@ function visitChildren(node, cb) {
|
|
|
6350
6417
|
case SyntaxKind.ImportStatement:
|
|
6351
6418
|
return visitNode(cb, node.path);
|
|
6352
6419
|
case SyntaxKind.OperationStatement:
|
|
6353
|
-
return visitEach(cb, node.decorators) || visitNode(cb, node.id) || visitEach(cb, node.templateParameters) || visitNode(cb, node.signature);
|
|
6420
|
+
return visitEach(cb, node.modifiers) || visitEach(cb, node.decorators) || visitNode(cb, node.id) || visitEach(cb, node.templateParameters) || visitNode(cb, node.signature);
|
|
6354
6421
|
case SyntaxKind.OperationSignatureDeclaration:
|
|
6355
6422
|
return visitNode(cb, node.parameters) || visitNode(cb, node.returnType);
|
|
6356
6423
|
case SyntaxKind.OperationSignatureReference:
|
|
6357
6424
|
return visitNode(cb, node.baseOperation);
|
|
6358
6425
|
case SyntaxKind.NamespaceStatement:
|
|
6359
|
-
return visitEach(cb, node.decorators) || visitNode(cb, node.id) || (isArray(node.statements) ? visitEach(cb, node.statements) : visitNode(cb, node.statements));
|
|
6426
|
+
return visitEach(cb, node.modifiers) || visitEach(cb, node.decorators) || visitNode(cb, node.id) || (isArray(node.statements) ? visitEach(cb, node.statements) : visitNode(cb, node.statements));
|
|
6360
6427
|
case SyntaxKind.InterfaceStatement:
|
|
6361
|
-
return visitEach(cb, node.decorators) || visitNode(cb, node.id) || visitEach(cb, node.templateParameters) || visitEach(cb, node.extends) || visitEach(cb, node.operations);
|
|
6428
|
+
return visitEach(cb, node.modifiers) || visitEach(cb, node.decorators) || visitNode(cb, node.id) || visitEach(cb, node.templateParameters) || visitEach(cb, node.extends) || visitEach(cb, node.operations);
|
|
6362
6429
|
case SyntaxKind.UsingStatement:
|
|
6363
6430
|
return visitNode(cb, node.name);
|
|
6364
6431
|
case SyntaxKind.IntersectionExpression:
|
|
@@ -6372,25 +6439,25 @@ function visitChildren(node, cb) {
|
|
|
6372
6439
|
case SyntaxKind.ModelSpreadProperty:
|
|
6373
6440
|
return visitNode(cb, node.target);
|
|
6374
6441
|
case SyntaxKind.ModelStatement:
|
|
6375
|
-
return visitEach(cb, node.decorators) || visitNode(cb, node.id) || visitEach(cb, node.templateParameters) || visitNode(cb, node.extends) || visitNode(cb, node.is) || visitEach(cb, node.properties);
|
|
6442
|
+
return visitEach(cb, node.modifiers) || visitEach(cb, node.decorators) || visitNode(cb, node.id) || visitEach(cb, node.templateParameters) || visitNode(cb, node.extends) || visitNode(cb, node.is) || visitEach(cb, node.properties);
|
|
6376
6443
|
case SyntaxKind.ScalarStatement:
|
|
6377
|
-
return visitEach(cb, node.decorators) || visitNode(cb, node.id) || visitEach(cb, node.templateParameters) || visitEach(cb, node.members) || visitNode(cb, node.extends);
|
|
6444
|
+
return visitEach(cb, node.modifiers) || visitEach(cb, node.decorators) || visitNode(cb, node.id) || visitEach(cb, node.templateParameters) || visitEach(cb, node.members) || visitNode(cb, node.extends);
|
|
6378
6445
|
case SyntaxKind.ScalarConstructor:
|
|
6379
6446
|
return visitNode(cb, node.id) || visitEach(cb, node.parameters);
|
|
6380
6447
|
case SyntaxKind.UnionStatement:
|
|
6381
|
-
return visitEach(cb, node.decorators) || visitNode(cb, node.id) || visitEach(cb, node.templateParameters) || visitEach(cb, node.options);
|
|
6448
|
+
return visitEach(cb, node.modifiers) || visitEach(cb, node.decorators) || visitNode(cb, node.id) || visitEach(cb, node.templateParameters) || visitEach(cb, node.options);
|
|
6382
6449
|
case SyntaxKind.UnionVariant:
|
|
6383
6450
|
return visitEach(cb, node.decorators) || visitNode(cb, node.id) || visitNode(cb, node.value);
|
|
6384
6451
|
case SyntaxKind.EnumStatement:
|
|
6385
|
-
return visitEach(cb, node.decorators) || visitNode(cb, node.id) || visitEach(cb, node.members);
|
|
6452
|
+
return visitEach(cb, node.modifiers) || visitEach(cb, node.decorators) || visitNode(cb, node.id) || visitEach(cb, node.members);
|
|
6386
6453
|
case SyntaxKind.EnumMember:
|
|
6387
6454
|
return visitEach(cb, node.decorators) || visitNode(cb, node.id) || visitNode(cb, node.value);
|
|
6388
6455
|
case SyntaxKind.EnumSpreadMember:
|
|
6389
6456
|
return visitNode(cb, node.target);
|
|
6390
6457
|
case SyntaxKind.AliasStatement:
|
|
6391
|
-
return visitNode(cb, node.id) || visitEach(cb, node.templateParameters) || visitNode(cb, node.value);
|
|
6458
|
+
return visitEach(cb, node.modifiers) || visitNode(cb, node.id) || visitEach(cb, node.templateParameters) || visitNode(cb, node.value);
|
|
6392
6459
|
case SyntaxKind.ConstStatement:
|
|
6393
|
-
return visitNode(cb, node.id) || visitNode(cb, node.value) || visitNode(cb, node.type);
|
|
6460
|
+
return visitEach(cb, node.modifiers) || visitNode(cb, node.id) || visitNode(cb, node.value) || visitNode(cb, node.type);
|
|
6394
6461
|
case SyntaxKind.DecoratorDeclarationStatement:
|
|
6395
6462
|
return visitEach(cb, node.modifiers) || visitNode(cb, node.id) || visitNode(cb, node.target) || visitEach(cb, node.parameters);
|
|
6396
6463
|
case SyntaxKind.FunctionDeclarationStatement:
|
|
@@ -6450,6 +6517,7 @@ function visitChildren(node, cb) {
|
|
|
6450
6517
|
case SyntaxKind.VoidKeyword:
|
|
6451
6518
|
case SyntaxKind.NeverKeyword:
|
|
6452
6519
|
case SyntaxKind.ExternKeyword:
|
|
6520
|
+
case SyntaxKind.InternalKeyword:
|
|
6453
6521
|
case SyntaxKind.UnknownKeyword:
|
|
6454
6522
|
case SyntaxKind.JsSourceFile:
|
|
6455
6523
|
case SyntaxKind.JsNamespaceDeclaration:
|
|
@@ -6737,6 +6805,8 @@ function printNode(path, options, print) {
|
|
|
6737
6805
|
return printFunctionParameterDeclaration(path, options, print);
|
|
6738
6806
|
case SyntaxKind.ExternKeyword:
|
|
6739
6807
|
return "extern";
|
|
6808
|
+
case SyntaxKind.InternalKeyword:
|
|
6809
|
+
return "internal";
|
|
6740
6810
|
case SyntaxKind.VoidKeyword:
|
|
6741
6811
|
return "void";
|
|
6742
6812
|
case SyntaxKind.NeverKeyword:
|
|
@@ -6796,13 +6866,29 @@ function printTypeSpecScript(path, options, print) {
|
|
|
6796
6866
|
function printAliasStatement(path, options, print) {
|
|
6797
6867
|
const id = path.call(print, "id");
|
|
6798
6868
|
const template = printTemplateParameters(path, options, print, "templateParameters");
|
|
6799
|
-
return [
|
|
6869
|
+
return [
|
|
6870
|
+
printModifiers(path, options, print),
|
|
6871
|
+
"alias ",
|
|
6872
|
+
id,
|
|
6873
|
+
template,
|
|
6874
|
+
" = ",
|
|
6875
|
+
path.call(print, "value"),
|
|
6876
|
+
";"
|
|
6877
|
+
];
|
|
6800
6878
|
}
|
|
6801
6879
|
function printConstStatement(path, options, print) {
|
|
6802
6880
|
const node = path.node;
|
|
6803
6881
|
const id = path.call(print, "id");
|
|
6804
6882
|
const type = node.type ? [": ", path.call(print, "type")] : "";
|
|
6805
|
-
return [
|
|
6883
|
+
return [
|
|
6884
|
+
printModifiers(path, options, print),
|
|
6885
|
+
"const ",
|
|
6886
|
+
id,
|
|
6887
|
+
type,
|
|
6888
|
+
" = ",
|
|
6889
|
+
path.call(print, "value"),
|
|
6890
|
+
";"
|
|
6891
|
+
];
|
|
6806
6892
|
}
|
|
6807
6893
|
function printCallExpression(path, options, print) {
|
|
6808
6894
|
const args = printCallLikeArgs(path, options, print);
|
|
@@ -6960,7 +7046,14 @@ function printDirectiveArgs(path, options, print) {
|
|
|
6960
7046
|
function printEnumStatement(path, options, print) {
|
|
6961
7047
|
const { decorators } = printDecorators(path, options, print, { tryInline: false });
|
|
6962
7048
|
const id = path.call(print, "id");
|
|
6963
|
-
return [
|
|
7049
|
+
return [
|
|
7050
|
+
decorators,
|
|
7051
|
+
printModifiers(path, options, print),
|
|
7052
|
+
"enum ",
|
|
7053
|
+
id,
|
|
7054
|
+
" ",
|
|
7055
|
+
printEnumBlock(path, options, print)
|
|
7056
|
+
];
|
|
6964
7057
|
}
|
|
6965
7058
|
function printEnumBlock(path, options, print) {
|
|
6966
7059
|
const node = path.node;
|
|
@@ -6986,7 +7079,15 @@ function printUnionStatement(path, options, print) {
|
|
|
6986
7079
|
const id = path.call(print, "id");
|
|
6987
7080
|
const { decorators } = printDecorators(path, options, print, { tryInline: false });
|
|
6988
7081
|
const generic = printTemplateParameters(path, options, print, "templateParameters");
|
|
6989
|
-
return [
|
|
7082
|
+
return [
|
|
7083
|
+
decorators,
|
|
7084
|
+
printModifiers(path, options, print),
|
|
7085
|
+
"union ",
|
|
7086
|
+
id,
|
|
7087
|
+
generic,
|
|
7088
|
+
" ",
|
|
7089
|
+
printUnionVariantsBlock(path, options, print)
|
|
7090
|
+
];
|
|
6990
7091
|
}
|
|
6991
7092
|
function printUnionVariantsBlock(path, options, print) {
|
|
6992
7093
|
const node = path.node;
|
|
@@ -7010,6 +7111,7 @@ function printInterfaceStatement(path, options, print) {
|
|
|
7010
7111
|
const extendList = printInterfaceExtends(path, options, print);
|
|
7011
7112
|
return [
|
|
7012
7113
|
decorators,
|
|
7114
|
+
printModifiers(path, options, print),
|
|
7013
7115
|
"interface ",
|
|
7014
7116
|
id,
|
|
7015
7117
|
generic,
|
|
@@ -7165,6 +7267,7 @@ function printModelStatement(path, options, print) {
|
|
|
7165
7267
|
const body = shouldPrintBody ? [" ", printModelPropertiesBlock(path, options, print)] : ";";
|
|
7166
7268
|
return [
|
|
7167
7269
|
printDecorators(path, options, print, { tryInline: false }).decorators,
|
|
7270
|
+
printModifiers(path, options, print),
|
|
7168
7271
|
"model ",
|
|
7169
7272
|
id,
|
|
7170
7273
|
generic,
|
|
@@ -7271,6 +7374,7 @@ function printScalarStatement(path, options, print) {
|
|
|
7271
7374
|
const members = shouldPrintBody ? [" ", printScalarBody(path, options, print)] : ";";
|
|
7272
7375
|
return [
|
|
7273
7376
|
printDecorators(path, options, print, { tryInline: false }).decorators,
|
|
7377
|
+
printModifiers(path, options, print),
|
|
7274
7378
|
"scalar ",
|
|
7275
7379
|
id,
|
|
7276
7380
|
template,
|
|
@@ -7327,6 +7431,7 @@ function printOperationStatement(path, options, print) {
|
|
|
7327
7431
|
});
|
|
7328
7432
|
return [
|
|
7329
7433
|
decorators,
|
|
7434
|
+
printModifiers(path, options, print),
|
|
7330
7435
|
inInterface ? "" : "op ",
|
|
7331
7436
|
path.call(print, "id"),
|
|
7332
7437
|
templateParams,
|
|
@@ -7469,7 +7574,7 @@ function printFunctionParameterDeclaration(path, options, print) {
|
|
|
7469
7574
|
}
|
|
7470
7575
|
function printModifiers(path, options, print) {
|
|
7471
7576
|
const node = path.node;
|
|
7472
|
-
if (node.modifiers.length === 0) {
|
|
7577
|
+
if (node.modifiers === void 0 || node.modifiers.length === 0) {
|
|
7473
7578
|
return "";
|
|
7474
7579
|
}
|
|
7475
7580
|
return path.map((x) => [print(x), " "], "modifiers");
|