typescript-language-server 4.3.1 → 4.3.3
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/CHANGELOG.md +14 -0
- package/lib/cli.mjs +273 -166
- package/lib/cli.mjs.map +1 -1
- package/package.json +11 -11
package/lib/cli.mjs
CHANGED
|
@@ -55,15 +55,13 @@ function getDefaultExportFromCjs(x) {
|
|
|
55
55
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
var commander
|
|
59
|
-
exports: {}
|
|
60
|
-
};
|
|
58
|
+
var commander = {};
|
|
61
59
|
|
|
62
60
|
var argument = {};
|
|
63
61
|
|
|
64
62
|
var error$2 = {};
|
|
65
63
|
|
|
66
|
-
let CommanderError$
|
|
64
|
+
let CommanderError$3 = class CommanderError extends Error {
|
|
67
65
|
constructor(exitCode, code, message) {
|
|
68
66
|
super(message);
|
|
69
67
|
Error.captureStackTrace(this, this.constructor);
|
|
@@ -74,7 +72,7 @@ let CommanderError$2 = class CommanderError extends Error {
|
|
|
74
72
|
}
|
|
75
73
|
};
|
|
76
74
|
|
|
77
|
-
let InvalidArgumentError$
|
|
75
|
+
let InvalidArgumentError$4 = class InvalidArgumentError extends CommanderError$3 {
|
|
78
76
|
constructor(message) {
|
|
79
77
|
super(1, 'commander.invalidArgument', message);
|
|
80
78
|
Error.captureStackTrace(this, this.constructor);
|
|
@@ -82,13 +80,13 @@ let InvalidArgumentError$3 = class InvalidArgumentError extends CommanderError$2
|
|
|
82
80
|
}
|
|
83
81
|
};
|
|
84
82
|
|
|
85
|
-
error$2.CommanderError = CommanderError$
|
|
83
|
+
error$2.CommanderError = CommanderError$3;
|
|
86
84
|
|
|
87
|
-
error$2.InvalidArgumentError = InvalidArgumentError$
|
|
85
|
+
error$2.InvalidArgumentError = InvalidArgumentError$4;
|
|
88
86
|
|
|
89
|
-
const {InvalidArgumentError: InvalidArgumentError$
|
|
87
|
+
const {InvalidArgumentError: InvalidArgumentError$3} = error$2;
|
|
90
88
|
|
|
91
|
-
let Argument$
|
|
89
|
+
let Argument$3 = class Argument {
|
|
92
90
|
constructor(name, description) {
|
|
93
91
|
this.description = description || '';
|
|
94
92
|
this.variadic = false;
|
|
@@ -139,7 +137,7 @@ let Argument$2 = class Argument {
|
|
|
139
137
|
this.argChoices = values.slice();
|
|
140
138
|
this.parseArg = (arg, previous) => {
|
|
141
139
|
if (!this.argChoices.includes(arg)) {
|
|
142
|
-
throw new InvalidArgumentError$
|
|
140
|
+
throw new InvalidArgumentError$3(`Allowed choices are ${this.argChoices.join(', ')}.`);
|
|
143
141
|
}
|
|
144
142
|
if (this.variadic) {
|
|
145
143
|
return this._concatValue(arg, previous);
|
|
@@ -163,7 +161,7 @@ function humanReadableArgName$2(arg) {
|
|
|
163
161
|
return arg.required ? '<' + nameOutput + '>' : '[' + nameOutput + ']';
|
|
164
162
|
}
|
|
165
163
|
|
|
166
|
-
argument.Argument = Argument$
|
|
164
|
+
argument.Argument = Argument$3;
|
|
167
165
|
|
|
168
166
|
argument.humanReadableArgName = humanReadableArgName$2;
|
|
169
167
|
|
|
@@ -173,7 +171,7 @@ var help = {};
|
|
|
173
171
|
|
|
174
172
|
const {humanReadableArgName: humanReadableArgName$1} = argument;
|
|
175
173
|
|
|
176
|
-
let Help$
|
|
174
|
+
let Help$3 = class Help {
|
|
177
175
|
constructor() {
|
|
178
176
|
this.helpWidth = undefined;
|
|
179
177
|
this.sortSubcommands = false;
|
|
@@ -182,11 +180,8 @@ let Help$2 = class Help {
|
|
|
182
180
|
}
|
|
183
181
|
visibleCommands(cmd) {
|
|
184
182
|
const visibleCommands = cmd.commands.filter((cmd => !cmd._hidden));
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const helpCommand = cmd.createCommand(helpName).helpOption(false);
|
|
188
|
-
helpCommand.description(cmd._helpCommandDescription);
|
|
189
|
-
if (helpArgs) helpCommand.arguments(helpArgs);
|
|
183
|
+
const helpCommand = cmd._getHelpCommand();
|
|
184
|
+
if (helpCommand && !helpCommand._hidden) {
|
|
190
185
|
visibleCommands.push(helpCommand);
|
|
191
186
|
}
|
|
192
187
|
if (this.sortSubcommands) {
|
|
@@ -200,18 +195,17 @@ let Help$2 = class Help {
|
|
|
200
195
|
}
|
|
201
196
|
visibleOptions(cmd) {
|
|
202
197
|
const visibleOptions = cmd.options.filter((option => !option.hidden));
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if (!
|
|
208
|
-
|
|
209
|
-
} else if (!
|
|
210
|
-
|
|
211
|
-
} else {
|
|
212
|
-
|
|
198
|
+
const helpOption = cmd._getHelpOption();
|
|
199
|
+
if (helpOption && !helpOption.hidden) {
|
|
200
|
+
const removeShort = helpOption.short && cmd._findOption(helpOption.short);
|
|
201
|
+
const removeLong = helpOption.long && cmd._findOption(helpOption.long);
|
|
202
|
+
if (!removeShort && !removeLong) {
|
|
203
|
+
visibleOptions.push(helpOption);
|
|
204
|
+
} else if (helpOption.long && !removeLong) {
|
|
205
|
+
visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description));
|
|
206
|
+
} else if (helpOption.short && !removeShort) {
|
|
207
|
+
visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description));
|
|
213
208
|
}
|
|
214
|
-
visibleOptions.push(helpOption);
|
|
215
209
|
}
|
|
216
210
|
if (this.sortOptions) {
|
|
217
211
|
visibleOptions.sort(this.compareOptions);
|
|
@@ -382,13 +376,13 @@ let Help$2 = class Help {
|
|
|
382
376
|
}
|
|
383
377
|
};
|
|
384
378
|
|
|
385
|
-
help.Help = Help$
|
|
379
|
+
help.Help = Help$3;
|
|
386
380
|
|
|
387
381
|
var option = {};
|
|
388
382
|
|
|
389
|
-
const {InvalidArgumentError: InvalidArgumentError$
|
|
383
|
+
const {InvalidArgumentError: InvalidArgumentError$2} = error$2;
|
|
390
384
|
|
|
391
|
-
let Option$
|
|
385
|
+
let Option$3 = class Option {
|
|
392
386
|
constructor(flags, description) {
|
|
393
387
|
this.flags = flags;
|
|
394
388
|
this.description = description || '';
|
|
@@ -396,7 +390,7 @@ let Option$2 = class Option {
|
|
|
396
390
|
this.optional = flags.includes('[');
|
|
397
391
|
this.variadic = /\w\.\.\.[>\]]$/.test(flags);
|
|
398
392
|
this.mandatory = false;
|
|
399
|
-
const optionFlags = splitOptionFlags
|
|
393
|
+
const optionFlags = splitOptionFlags(flags);
|
|
400
394
|
this.short = optionFlags.shortFlag;
|
|
401
395
|
this.long = optionFlags.longFlag;
|
|
402
396
|
this.negate = false;
|
|
@@ -462,7 +456,7 @@ let Option$2 = class Option {
|
|
|
462
456
|
this.argChoices = values.slice();
|
|
463
457
|
this.parseArg = (arg, previous) => {
|
|
464
458
|
if (!this.argChoices.includes(arg)) {
|
|
465
|
-
throw new InvalidArgumentError$
|
|
459
|
+
throw new InvalidArgumentError$2(`Allowed choices are ${this.argChoices.join(', ')}.`);
|
|
466
460
|
}
|
|
467
461
|
if (this.variadic) {
|
|
468
462
|
return this._concatValue(arg, previous);
|
|
@@ -519,7 +513,7 @@ function camelcase(str) {
|
|
|
519
513
|
return str.split('-').reduce(((str, word) => str + word[0].toUpperCase() + word.slice(1)));
|
|
520
514
|
}
|
|
521
515
|
|
|
522
|
-
function splitOptionFlags
|
|
516
|
+
function splitOptionFlags(flags) {
|
|
523
517
|
let shortFlag;
|
|
524
518
|
let longFlag;
|
|
525
519
|
const flagParts = flags.split(/[ |,]+/);
|
|
@@ -535,9 +529,7 @@ function splitOptionFlags$1(flags) {
|
|
|
535
529
|
};
|
|
536
530
|
}
|
|
537
531
|
|
|
538
|
-
option.Option = Option$
|
|
539
|
-
|
|
540
|
-
option.splitOptionFlags = splitOptionFlags$1;
|
|
532
|
+
option.Option = Option$3;
|
|
541
533
|
|
|
542
534
|
option.DualOptions = DualOptions$1;
|
|
543
535
|
|
|
@@ -621,17 +613,17 @@ const fs$k = require$$0$1;
|
|
|
621
613
|
|
|
622
614
|
const process$1 = require$$4;
|
|
623
615
|
|
|
624
|
-
const {Argument: Argument$
|
|
616
|
+
const {Argument: Argument$2, humanReadableArgName: humanReadableArgName} = argument;
|
|
625
617
|
|
|
626
|
-
const {CommanderError: CommanderError$
|
|
618
|
+
const {CommanderError: CommanderError$2} = error$2;
|
|
627
619
|
|
|
628
|
-
const {Help: Help$
|
|
620
|
+
const {Help: Help$2} = help;
|
|
629
621
|
|
|
630
|
-
const {Option: Option$
|
|
622
|
+
const {Option: Option$2, DualOptions: DualOptions} = option;
|
|
631
623
|
|
|
632
624
|
const {suggestSimilar: suggestSimilar} = suggestSimilar$2;
|
|
633
625
|
|
|
634
|
-
let Command$
|
|
626
|
+
let Command$2 = class Command extends EventEmitter {
|
|
635
627
|
constructor(name) {
|
|
636
628
|
super();
|
|
637
629
|
this.commands = [];
|
|
@@ -673,27 +665,15 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
673
665
|
outputError: (str, write) => write(str)
|
|
674
666
|
};
|
|
675
667
|
this._hidden = false;
|
|
676
|
-
this.
|
|
677
|
-
this._helpFlags = '-h, --help';
|
|
678
|
-
this._helpDescription = 'display help for command';
|
|
679
|
-
this._helpShortFlag = '-h';
|
|
680
|
-
this._helpLongFlag = '--help';
|
|
668
|
+
this._helpOption = undefined;
|
|
681
669
|
this._addImplicitHelpCommand = undefined;
|
|
682
|
-
this.
|
|
683
|
-
this._helpCommandnameAndArgs = 'help [command]';
|
|
684
|
-
this._helpCommandDescription = 'display help for command';
|
|
670
|
+
this._helpCommand = undefined;
|
|
685
671
|
this._helpConfiguration = {};
|
|
686
672
|
}
|
|
687
673
|
copyInheritedSettings(sourceCommand) {
|
|
688
674
|
this._outputConfiguration = sourceCommand._outputConfiguration;
|
|
689
|
-
this.
|
|
690
|
-
this.
|
|
691
|
-
this._helpDescription = sourceCommand._helpDescription;
|
|
692
|
-
this._helpShortFlag = sourceCommand._helpShortFlag;
|
|
693
|
-
this._helpLongFlag = sourceCommand._helpLongFlag;
|
|
694
|
-
this._helpCommandName = sourceCommand._helpCommandName;
|
|
695
|
-
this._helpCommandnameAndArgs = sourceCommand._helpCommandnameAndArgs;
|
|
696
|
-
this._helpCommandDescription = sourceCommand._helpCommandDescription;
|
|
675
|
+
this._helpOption = sourceCommand._helpOption;
|
|
676
|
+
this._helpCommand = sourceCommand._helpCommand;
|
|
697
677
|
this._helpConfiguration = sourceCommand._helpConfiguration;
|
|
698
678
|
this._exitCallback = sourceCommand._exitCallback;
|
|
699
679
|
this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;
|
|
@@ -729,7 +709,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
729
709
|
cmd._hidden = !!(opts.noHelp || opts.hidden);
|
|
730
710
|
cmd._executableFile = opts.executableFile || null;
|
|
731
711
|
if (args) cmd.arguments(args);
|
|
732
|
-
this.
|
|
712
|
+
this._registerCommand(cmd);
|
|
733
713
|
cmd.parent = this;
|
|
734
714
|
cmd.copyInheritedSettings(this);
|
|
735
715
|
if (desc) return this;
|
|
@@ -739,7 +719,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
739
719
|
return new Command(name);
|
|
740
720
|
}
|
|
741
721
|
createHelp() {
|
|
742
|
-
return Object.assign(new Help$
|
|
722
|
+
return Object.assign(new Help$2, this.configureHelp());
|
|
743
723
|
}
|
|
744
724
|
configureHelp(configuration) {
|
|
745
725
|
if (configuration === undefined) return this._helpConfiguration;
|
|
@@ -767,12 +747,13 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
767
747
|
opts = opts || {};
|
|
768
748
|
if (opts.isDefault) this._defaultCommandName = cmd._name;
|
|
769
749
|
if (opts.noHelp || opts.hidden) cmd._hidden = true;
|
|
770
|
-
this.
|
|
750
|
+
this._registerCommand(cmd);
|
|
771
751
|
cmd.parent = this;
|
|
752
|
+
cmd._checkForBrokenPassThrough();
|
|
772
753
|
return this;
|
|
773
754
|
}
|
|
774
755
|
createArgument(name, description) {
|
|
775
|
-
return new Argument$
|
|
756
|
+
return new Argument$2(name, description);
|
|
776
757
|
}
|
|
777
758
|
argument(name, description, fn, defaultValue) {
|
|
778
759
|
const argument = this.createArgument(name, description);
|
|
@@ -801,24 +782,40 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
801
782
|
this.registeredArguments.push(argument);
|
|
802
783
|
return this;
|
|
803
784
|
}
|
|
804
|
-
|
|
805
|
-
if (enableOrNameAndArgs ===
|
|
806
|
-
this._addImplicitHelpCommand =
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
785
|
+
helpCommand(enableOrNameAndArgs, description) {
|
|
786
|
+
if (typeof enableOrNameAndArgs === 'boolean') {
|
|
787
|
+
this._addImplicitHelpCommand = enableOrNameAndArgs;
|
|
788
|
+
return this;
|
|
789
|
+
}
|
|
790
|
+
enableOrNameAndArgs = enableOrNameAndArgs ?? 'help [command]';
|
|
791
|
+
const [, helpName, helpArgs] = enableOrNameAndArgs.match(/([^ ]+) *(.*)/);
|
|
792
|
+
const helpDescription = description ?? 'display help for command';
|
|
793
|
+
const helpCommand = this.createCommand(helpName);
|
|
794
|
+
helpCommand.helpOption(false);
|
|
795
|
+
if (helpArgs) helpCommand.arguments(helpArgs);
|
|
796
|
+
if (helpDescription) helpCommand.description(helpDescription);
|
|
797
|
+
this._addImplicitHelpCommand = true;
|
|
798
|
+
this._helpCommand = helpCommand;
|
|
799
|
+
return this;
|
|
800
|
+
}
|
|
801
|
+
addHelpCommand(helpCommand, deprecatedDescription) {
|
|
802
|
+
if (typeof helpCommand !== 'object') {
|
|
803
|
+
this.helpCommand(helpCommand, deprecatedDescription);
|
|
804
|
+
return this;
|
|
814
805
|
}
|
|
806
|
+
this._addImplicitHelpCommand = true;
|
|
807
|
+
this._helpCommand = helpCommand;
|
|
815
808
|
return this;
|
|
816
809
|
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
810
|
+
_getHelpCommand() {
|
|
811
|
+
const hasImplicitHelpCommand = this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand('help'));
|
|
812
|
+
if (hasImplicitHelpCommand) {
|
|
813
|
+
if (this._helpCommand === undefined) {
|
|
814
|
+
this.helpCommand(undefined, undefined);
|
|
815
|
+
}
|
|
816
|
+
return this._helpCommand;
|
|
820
817
|
}
|
|
821
|
-
return
|
|
818
|
+
return null;
|
|
822
819
|
}
|
|
823
820
|
hook(event, listener) {
|
|
824
821
|
const allowedValues = [ 'preSubcommand', 'preAction', 'postAction' ];
|
|
@@ -846,7 +843,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
846
843
|
}
|
|
847
844
|
_exit(exitCode, code, message) {
|
|
848
845
|
if (this._exitCallback) {
|
|
849
|
-
this._exitCallback(new CommanderError$
|
|
846
|
+
this._exitCallback(new CommanderError$2(exitCode, code, message));
|
|
850
847
|
}
|
|
851
848
|
process$1.exit(exitCode);
|
|
852
849
|
}
|
|
@@ -866,7 +863,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
866
863
|
return this;
|
|
867
864
|
}
|
|
868
865
|
createOption(flags, description) {
|
|
869
|
-
return new Option$
|
|
866
|
+
return new Option$2(flags, description);
|
|
870
867
|
}
|
|
871
868
|
_callParseArg(target, value, previous, invalidArgumentMessage) {
|
|
872
869
|
try {
|
|
@@ -882,7 +879,26 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
882
879
|
throw err;
|
|
883
880
|
}
|
|
884
881
|
}
|
|
882
|
+
_registerOption(option) {
|
|
883
|
+
const matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long);
|
|
884
|
+
if (matchingOption) {
|
|
885
|
+
const matchingFlag = option.long && this._findOption(option.long) ? option.long : option.short;
|
|
886
|
+
throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'\n- already used by option '${matchingOption.flags}'`);
|
|
887
|
+
}
|
|
888
|
+
this.options.push(option);
|
|
889
|
+
}
|
|
890
|
+
_registerCommand(command) {
|
|
891
|
+
const knownBy = cmd => [ cmd.name() ].concat(cmd.aliases());
|
|
892
|
+
const alreadyUsed = knownBy(command).find((name => this._findCommand(name)));
|
|
893
|
+
if (alreadyUsed) {
|
|
894
|
+
const existingCmd = knownBy(this._findCommand(alreadyUsed)).join('|');
|
|
895
|
+
const newCmd = knownBy(command).join('|');
|
|
896
|
+
throw new Error(`cannot add command '${newCmd}' as already have command '${existingCmd}'`);
|
|
897
|
+
}
|
|
898
|
+
this.commands.push(command);
|
|
899
|
+
}
|
|
885
900
|
addOption(option) {
|
|
901
|
+
this._registerOption(option);
|
|
886
902
|
const oname = option.name();
|
|
887
903
|
const name = option.attributeName();
|
|
888
904
|
if (option.negate) {
|
|
@@ -893,7 +909,6 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
893
909
|
} else if (option.defaultValue !== undefined) {
|
|
894
910
|
this.setOptionValueWithSource(name, option.defaultValue, 'default');
|
|
895
911
|
}
|
|
896
|
-
this.options.push(option);
|
|
897
912
|
const handleOptionValue = (val, invalidValueMessage, valueSource) => {
|
|
898
913
|
if (val == null && option.presetArg !== undefined) {
|
|
899
914
|
val = option.presetArg;
|
|
@@ -928,7 +943,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
928
943
|
return this;
|
|
929
944
|
}
|
|
930
945
|
_optionEx(config, flags, description, fn, defaultValue) {
|
|
931
|
-
if (typeof flags === 'object' && flags instanceof Option$
|
|
946
|
+
if (typeof flags === 'object' && flags instanceof Option$2) {
|
|
932
947
|
throw new Error('To add an Option object use addOption() instead of option() or requiredOption()');
|
|
933
948
|
}
|
|
934
949
|
const option = this.createOption(flags, description);
|
|
@@ -973,15 +988,21 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
973
988
|
}
|
|
974
989
|
passThroughOptions(passThrough = true) {
|
|
975
990
|
this._passThroughOptions = !!passThrough;
|
|
976
|
-
|
|
977
|
-
throw new Error('passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)');
|
|
978
|
-
}
|
|
991
|
+
this._checkForBrokenPassThrough();
|
|
979
992
|
return this;
|
|
980
993
|
}
|
|
994
|
+
_checkForBrokenPassThrough() {
|
|
995
|
+
if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) {
|
|
996
|
+
throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
981
999
|
storeOptionsAsProperties(storeAsProperties = true) {
|
|
982
1000
|
if (this.options.length) {
|
|
983
1001
|
throw new Error('call .storeOptionsAsProperties() before adding options');
|
|
984
1002
|
}
|
|
1003
|
+
if (Object.keys(this._optionValues).length) {
|
|
1004
|
+
throw new Error('call .storeOptionsAsProperties() before setting option values');
|
|
1005
|
+
}
|
|
985
1006
|
this._storeOptionsAsProperties = !!storeAsProperties;
|
|
986
1007
|
return this;
|
|
987
1008
|
}
|
|
@@ -1132,13 +1153,14 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1132
1153
|
}));
|
|
1133
1154
|
}
|
|
1134
1155
|
const exitCallback = this._exitCallback;
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1156
|
+
proc.on('close', ((code, _signal) => {
|
|
1157
|
+
code = code ?? 1;
|
|
1158
|
+
if (!exitCallback) {
|
|
1159
|
+
process$1.exit(code);
|
|
1160
|
+
} else {
|
|
1161
|
+
exitCallback(new CommanderError$2(code, 'commander.executeSubCommandAsync', '(close)'));
|
|
1162
|
+
}
|
|
1163
|
+
}));
|
|
1142
1164
|
proc.on('error', (err => {
|
|
1143
1165
|
if (err.code === 'ENOENT') {
|
|
1144
1166
|
const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : 'no directory for search for local subcommand, use .executableDir() to supply a custom directory';
|
|
@@ -1150,7 +1172,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1150
1172
|
if (!exitCallback) {
|
|
1151
1173
|
process$1.exit(1);
|
|
1152
1174
|
} else {
|
|
1153
|
-
const wrappedError = new CommanderError$
|
|
1175
|
+
const wrappedError = new CommanderError$2(1, 'commander.executeSubCommandAsync', '(error)');
|
|
1154
1176
|
wrappedError.nestedError = err;
|
|
1155
1177
|
exitCallback(wrappedError);
|
|
1156
1178
|
}
|
|
@@ -1181,7 +1203,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1181
1203
|
if (subCommand && !subCommand._executableHandler) {
|
|
1182
1204
|
subCommand.help();
|
|
1183
1205
|
}
|
|
1184
|
-
return this._dispatchSubcommand(subcommandName, [], [ this.
|
|
1206
|
+
return this._dispatchSubcommand(subcommandName, [], [ this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? '--help' ]);
|
|
1185
1207
|
}
|
|
1186
1208
|
_checkNumberOfArguments() {
|
|
1187
1209
|
this.registeredArguments.forEach(((arg, i) => {
|
|
@@ -1272,11 +1294,11 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1272
1294
|
if (operands && this._findCommand(operands[0])) {
|
|
1273
1295
|
return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
|
|
1274
1296
|
}
|
|
1275
|
-
if (this.
|
|
1297
|
+
if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) {
|
|
1276
1298
|
return this._dispatchHelpCommand(operands[1]);
|
|
1277
1299
|
}
|
|
1278
1300
|
if (this._defaultCommandName) {
|
|
1279
|
-
|
|
1301
|
+
this._outputHelpIfRequested(unknown);
|
|
1280
1302
|
return this._dispatchSubcommand(this._defaultCommandName, operands, unknown);
|
|
1281
1303
|
}
|
|
1282
1304
|
if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
|
|
@@ -1284,7 +1306,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1284
1306
|
error: true
|
|
1285
1307
|
});
|
|
1286
1308
|
}
|
|
1287
|
-
|
|
1309
|
+
this._outputHelpIfRequested(parsed.unknown);
|
|
1288
1310
|
this._checkForMissingMandatoryOptions();
|
|
1289
1311
|
this._checkForConflictingOptions();
|
|
1290
1312
|
const checkForUnknownOptions = () => {
|
|
@@ -1439,7 +1461,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1439
1461
|
operands.push(arg);
|
|
1440
1462
|
if (args.length > 0) unknown.push(...args);
|
|
1441
1463
|
break;
|
|
1442
|
-
} else if (
|
|
1464
|
+
} else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
|
|
1443
1465
|
operands.push(arg);
|
|
1444
1466
|
if (args.length > 0) operands.push(...args);
|
|
1445
1467
|
break;
|
|
@@ -1608,7 +1630,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1608
1630
|
description = description || 'output the version number';
|
|
1609
1631
|
const versionOption = this.createOption(flags, description);
|
|
1610
1632
|
this._versionOptionName = versionOption.attributeName();
|
|
1611
|
-
this.
|
|
1633
|
+
this._registerOption(versionOption);
|
|
1612
1634
|
this.on('option:' + versionOption.name(), (() => {
|
|
1613
1635
|
this._outputConfiguration.writeOut(`${str}\n`);
|
|
1614
1636
|
this._exit(0, 'commander.version', str);
|
|
@@ -1635,6 +1657,11 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1635
1657
|
command = this.commands[this.commands.length - 1];
|
|
1636
1658
|
}
|
|
1637
1659
|
if (alias === command._name) throw new Error('Command alias can\'t be the same as its name');
|
|
1660
|
+
const matchingCommand = this.parent?._findCommand(alias);
|
|
1661
|
+
if (matchingCommand) {
|
|
1662
|
+
const existingCmd = [ matchingCommand.name() ].concat(matchingCommand.aliases()).join('|');
|
|
1663
|
+
throw new Error(`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`);
|
|
1664
|
+
}
|
|
1638
1665
|
command._aliases.push(alias);
|
|
1639
1666
|
return this;
|
|
1640
1667
|
}
|
|
@@ -1647,7 +1674,7 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1647
1674
|
if (str === undefined) {
|
|
1648
1675
|
if (this._usage) return this._usage;
|
|
1649
1676
|
const args = this.registeredArguments.map((arg => humanReadableArgName(arg)));
|
|
1650
|
-
return [].concat(this.options.length || this.
|
|
1677
|
+
return [].concat(this.options.length || this._helpOption !== null ? '[options]' : [], this.commands.length ? '[command]' : [], this.registeredArguments.length ? args : []).join(' ');
|
|
1651
1678
|
}
|
|
1652
1679
|
this._usage = str;
|
|
1653
1680
|
return this;
|
|
@@ -1705,22 +1732,34 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1705
1732
|
}
|
|
1706
1733
|
}
|
|
1707
1734
|
context.write(helpInformation);
|
|
1708
|
-
if (this.
|
|
1709
|
-
this.emit(this.
|
|
1735
|
+
if (this._getHelpOption()?.long) {
|
|
1736
|
+
this.emit(this._getHelpOption().long);
|
|
1710
1737
|
}
|
|
1711
1738
|
this.emit('afterHelp', context);
|
|
1712
1739
|
this._getCommandAndAncestors().forEach((command => command.emit('afterAllHelp', context)));
|
|
1713
1740
|
}
|
|
1714
1741
|
helpOption(flags, description) {
|
|
1715
1742
|
if (typeof flags === 'boolean') {
|
|
1716
|
-
|
|
1743
|
+
if (flags) {
|
|
1744
|
+
this._helpOption = this._helpOption ?? undefined;
|
|
1745
|
+
} else {
|
|
1746
|
+
this._helpOption = null;
|
|
1747
|
+
}
|
|
1717
1748
|
return this;
|
|
1718
1749
|
}
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
this
|
|
1723
|
-
|
|
1750
|
+
flags = flags ?? '-h, --help';
|
|
1751
|
+
description = description ?? 'display help for command';
|
|
1752
|
+
this._helpOption = this.createOption(flags, description);
|
|
1753
|
+
return this;
|
|
1754
|
+
}
|
|
1755
|
+
_getHelpOption() {
|
|
1756
|
+
if (this._helpOption === undefined) {
|
|
1757
|
+
this.helpOption(undefined, undefined);
|
|
1758
|
+
}
|
|
1759
|
+
return this._helpOption;
|
|
1760
|
+
}
|
|
1761
|
+
addHelpOption(option) {
|
|
1762
|
+
this._helpOption = option;
|
|
1724
1763
|
return this;
|
|
1725
1764
|
}
|
|
1726
1765
|
help(contextOptions) {
|
|
@@ -1753,15 +1792,15 @@ let Command$1 = class Command extends EventEmitter {
|
|
|
1753
1792
|
}));
|
|
1754
1793
|
return this;
|
|
1755
1794
|
}
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1795
|
+
_outputHelpIfRequested(args) {
|
|
1796
|
+
const helpOption = this._getHelpOption();
|
|
1797
|
+
const helpRequested = helpOption && args.find((arg => helpOption.is(arg)));
|
|
1798
|
+
if (helpRequested) {
|
|
1799
|
+
this.outputHelp();
|
|
1800
|
+
this._exit(0, 'commander.helpDisplayed', '(outputHelp)');
|
|
1801
|
+
}
|
|
1763
1802
|
}
|
|
1764
|
-
}
|
|
1803
|
+
};
|
|
1765
1804
|
|
|
1766
1805
|
function incrementNodeInspectorPort(args) {
|
|
1767
1806
|
return args.map((arg => {
|
|
@@ -1793,28 +1832,39 @@ function incrementNodeInspectorPort(args) {
|
|
|
1793
1832
|
}));
|
|
1794
1833
|
}
|
|
1795
1834
|
|
|
1796
|
-
command.Command = Command$
|
|
1835
|
+
command.Command = Command$2;
|
|
1797
1836
|
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1837
|
+
const {Argument: Argument$1} = argument;
|
|
1838
|
+
|
|
1839
|
+
const {Command: Command$1} = command;
|
|
1840
|
+
|
|
1841
|
+
const {CommanderError: CommanderError$1, InvalidArgumentError: InvalidArgumentError$1} = error$2;
|
|
1842
|
+
|
|
1843
|
+
const {Help: Help$1} = help;
|
|
1844
|
+
|
|
1845
|
+
const {Option: Option$1} = option;
|
|
1846
|
+
|
|
1847
|
+
commander.program = new Command$1;
|
|
1848
|
+
|
|
1849
|
+
commander.createCommand = name => new Command$1(name);
|
|
1850
|
+
|
|
1851
|
+
commander.createOption = (flags, description) => new Option$1(flags, description);
|
|
1852
|
+
|
|
1853
|
+
commander.createArgument = (name, description) => new Argument$1(name, description);
|
|
1854
|
+
|
|
1855
|
+
commander.Command = Command$1;
|
|
1856
|
+
|
|
1857
|
+
commander.Option = Option$1;
|
|
1858
|
+
|
|
1859
|
+
commander.Argument = Argument$1;
|
|
1860
|
+
|
|
1861
|
+
commander.Help = Help$1;
|
|
1862
|
+
|
|
1863
|
+
commander.CommanderError = CommanderError$1;
|
|
1864
|
+
|
|
1865
|
+
commander.InvalidArgumentError = InvalidArgumentError$1;
|
|
1866
|
+
|
|
1867
|
+
commander.InvalidOptionArgumentError = InvalidArgumentError$1;
|
|
1818
1868
|
|
|
1819
1869
|
const {program: program$1, createCommand: createCommand, createArgument: createArgument, createOption: createOption, CommanderError: CommanderError, InvalidArgumentError: InvalidArgumentError, InvalidOptionArgumentError: InvalidOptionArgumentError, Command: Command, Argument: Argument, Option: Option, Help: Help} = commander;
|
|
1820
1870
|
|
|
@@ -14697,8 +14747,11 @@ var debug_1 = debug$1;
|
|
|
14697
14747
|
createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?` + `)?)?`);
|
|
14698
14748
|
createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
14699
14749
|
createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
14700
|
-
createToken('
|
|
14750
|
+
createToken('COERCEPLAIN', `${'(^|[^\\d])' + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
14751
|
+
createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
14752
|
+
createToken('COERCEFULL', src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?` + `(?:${src[t.BUILD]})?` + `(?:$|[^\\d])`);
|
|
14701
14753
|
createToken('COERCERTL', src[t.COERCE], true);
|
|
14754
|
+
createToken('COERCERTLFULL', src[t.COERCEFULL], true);
|
|
14702
14755
|
createToken('LONETILDE', '(?:~>?)');
|
|
14703
14756
|
createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
14704
14757
|
exports.tildeTrimReplace = '$1~';
|
|
@@ -15282,21 +15335,27 @@ const coerce$1 = (version, options) => {
|
|
|
15282
15335
|
options = options || {};
|
|
15283
15336
|
let match = null;
|
|
15284
15337
|
if (!options.rtl) {
|
|
15285
|
-
match = version.match(re[t.COERCE]);
|
|
15338
|
+
match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
|
|
15286
15339
|
} else {
|
|
15340
|
+
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
|
|
15287
15341
|
let next;
|
|
15288
|
-
while ((next =
|
|
15342
|
+
while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
|
|
15289
15343
|
if (!match || next.index + next[0].length !== match.index + match[0].length) {
|
|
15290
15344
|
match = next;
|
|
15291
15345
|
}
|
|
15292
|
-
|
|
15346
|
+
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
|
|
15293
15347
|
}
|
|
15294
|
-
|
|
15348
|
+
coerceRtlRegex.lastIndex = -1;
|
|
15295
15349
|
}
|
|
15296
15350
|
if (match === null) {
|
|
15297
15351
|
return null;
|
|
15298
15352
|
}
|
|
15299
|
-
|
|
15353
|
+
const major = match[2];
|
|
15354
|
+
const minor = match[3] || '0';
|
|
15355
|
+
const patch = match[4] || '0';
|
|
15356
|
+
const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : '';
|
|
15357
|
+
const build = options.includePrerelease && match[6] ? `+${match[6]}` : '';
|
|
15358
|
+
return parse$1(`${major}.${minor}.${patch}${prerelease}${build}`, options);
|
|
15300
15359
|
};
|
|
15301
15360
|
|
|
15302
15361
|
var coerce_1 = coerce$1;
|
|
@@ -17645,14 +17704,24 @@ class LspDocuments {
|
|
|
17645
17704
|
|
|
17646
17705
|
const file = 'file';
|
|
17647
17706
|
|
|
17707
|
+
const untitled = 'untitled';
|
|
17708
|
+
|
|
17648
17709
|
const git = 'git';
|
|
17649
17710
|
|
|
17650
17711
|
const github = 'github';
|
|
17651
17712
|
|
|
17652
17713
|
const azurerepos = 'azurerepos';
|
|
17653
17714
|
|
|
17715
|
+
const buffer = 'buffer';
|
|
17716
|
+
|
|
17717
|
+
const zipfile = 'zipfile';
|
|
17718
|
+
|
|
17654
17719
|
const vsls = 'vsls';
|
|
17655
17720
|
|
|
17721
|
+
function getSemanticSupportedSchemes() {
|
|
17722
|
+
return [ file, untitled, buffer, zipfile ];
|
|
17723
|
+
}
|
|
17724
|
+
|
|
17656
17725
|
const disabledSchemes = new Set([ git, vsls, github, azurerepos ]);
|
|
17657
17726
|
|
|
17658
17727
|
var TypeScriptServerPlugin;
|
|
@@ -18866,6 +18935,20 @@ class Tracer {
|
|
|
18866
18935
|
}
|
|
18867
18936
|
}
|
|
18868
18937
|
|
|
18938
|
+
class ZipfileURI extends URI {
|
|
18939
|
+
constructor(uri, components) {
|
|
18940
|
+
super(components);
|
|
18941
|
+
this._originalUri = uri;
|
|
18942
|
+
}
|
|
18943
|
+
toString(_skipEncoding = false) {
|
|
18944
|
+
return this._originalUri;
|
|
18945
|
+
}
|
|
18946
|
+
static parse(value, _strict = false) {
|
|
18947
|
+
const uri = URI.parse(value, _strict);
|
|
18948
|
+
return new ZipfileURI(value, uri);
|
|
18949
|
+
}
|
|
18950
|
+
}
|
|
18951
|
+
|
|
18869
18952
|
var ServerState;
|
|
18870
18953
|
|
|
18871
18954
|
(function(ServerState) {
|
|
@@ -18937,11 +19020,18 @@ class ServerInitializingIndicator {
|
|
|
18937
19020
|
}
|
|
18938
19021
|
}
|
|
18939
19022
|
|
|
19023
|
+
const emptyAuthority = 'ts-nul-authority';
|
|
19024
|
+
|
|
19025
|
+
const inMemoryResourcePrefix = '^';
|
|
19026
|
+
|
|
19027
|
+
const RE_IN_MEMORY_FILEPATH = /^\^\/([^/]+)\/([^/]*)\/(.+)$/;
|
|
19028
|
+
|
|
18940
19029
|
class TsClient {
|
|
18941
19030
|
constructor(onCaseInsensitiveFileSystem, logger, lspClient) {
|
|
18942
19031
|
this.apiVersion = API.defaultVersion;
|
|
18943
19032
|
this.typescriptVersionSource = 'bundled';
|
|
18944
19033
|
this.serverState = ServerState.None;
|
|
19034
|
+
this.isNeovimHost = false;
|
|
18945
19035
|
this.workspaceFolders = [];
|
|
18946
19036
|
this.useSyntaxServer = 2;
|
|
18947
19037
|
this.pluginManager = new PluginManager;
|
|
@@ -18967,7 +19057,7 @@ class TsClient {
|
|
|
18967
19057
|
return this.documents.files[0] || this.workspaceFolders[0]?.uri.fsPath;
|
|
18968
19058
|
}
|
|
18969
19059
|
toTsFilePath(stringUri) {
|
|
18970
|
-
if (stringUri.startsWith('zipfile:')) {
|
|
19060
|
+
if (this.isNeovimHost && stringUri.startsWith('zipfile:')) {
|
|
18971
19061
|
return stringUri;
|
|
18972
19062
|
}
|
|
18973
19063
|
const resource = URI.parse(stringUri);
|
|
@@ -18977,7 +19067,7 @@ class TsClient {
|
|
|
18977
19067
|
if (resource.scheme === file) {
|
|
18978
19068
|
return resource.fsPath;
|
|
18979
19069
|
}
|
|
18980
|
-
return
|
|
19070
|
+
return inMemoryResourcePrefix + '/' + resource.scheme + '/' + (resource.authority || emptyAuthority) + (resource.path.startsWith('/') ? resource.path : '/' + resource.path) + (resource.fragment ? '#' + resource.fragment : '');
|
|
18981
19071
|
}
|
|
18982
19072
|
toOpenDocument(textDocumentUri, options = {}) {
|
|
18983
19073
|
const filepath = this.toTsFilePath(textDocumentUri);
|
|
@@ -18998,13 +19088,25 @@ class TsClient {
|
|
|
18998
19088
|
return this.documents.hasPendingDiagnostics(resource);
|
|
18999
19089
|
}
|
|
19000
19090
|
toResource(filepath) {
|
|
19001
|
-
if (filepath.startsWith('zipfile:')) {
|
|
19002
|
-
return
|
|
19091
|
+
if (this.isNeovimHost && filepath.startsWith('zipfile:')) {
|
|
19092
|
+
return ZipfileURI.parse(filepath);
|
|
19093
|
+
}
|
|
19094
|
+
if (filepath.startsWith(inMemoryResourcePrefix)) {
|
|
19095
|
+
const parts = filepath.match(RE_IN_MEMORY_FILEPATH);
|
|
19096
|
+
if (parts) {
|
|
19097
|
+
const resource = URI.parse(parts[1] + '://' + (parts[2] === emptyAuthority ? '' : parts[2]) + '/' + parts[3]);
|
|
19098
|
+
const tsFilepath = this.toTsFilePath(resource.toString());
|
|
19099
|
+
const document = tsFilepath && this.documents.get(tsFilepath);
|
|
19100
|
+
return document ? document.uri : resource;
|
|
19101
|
+
}
|
|
19003
19102
|
}
|
|
19004
19103
|
const fileUri = URI.file(filepath);
|
|
19005
19104
|
const document = this.documents.get(fileUri.fsPath);
|
|
19006
19105
|
return document ? document.uri : fileUri;
|
|
19007
19106
|
}
|
|
19107
|
+
toResourceUri(filepath) {
|
|
19108
|
+
return this.toResource(filepath).toString();
|
|
19109
|
+
}
|
|
19008
19110
|
getWorkspaceRootForResource(resource) {
|
|
19009
19111
|
for (const root of this.workspaceFolders.sort(((a, b) => a.uri.fsPath.length - b.uri.fsPath.length))) {
|
|
19010
19112
|
if (root.uri.scheme === resource.scheme && root.uri.authority === resource.authority) {
|
|
@@ -19031,7 +19133,7 @@ class TsClient {
|
|
|
19031
19133
|
switch (capability) {
|
|
19032
19134
|
case ClientCapability.Semantic:
|
|
19033
19135
|
{
|
|
19034
|
-
return
|
|
19136
|
+
return getSemanticSupportedSchemes().includes(resource.scheme);
|
|
19035
19137
|
}
|
|
19036
19138
|
|
|
19037
19139
|
case ClientCapability.Syntax:
|
|
@@ -19052,6 +19154,7 @@ class TsClient {
|
|
|
19052
19154
|
start(workspaceRoot, options) {
|
|
19053
19155
|
this.apiVersion = options.typescriptVersion.version || API.defaultVersion;
|
|
19054
19156
|
this.typescriptVersionSource = options.typescriptVersion.source;
|
|
19157
|
+
this.isNeovimHost = options.hostInfo === 'neovim';
|
|
19055
19158
|
this.tracer = new Tracer(this.tsserverLogger, options.trace);
|
|
19056
19159
|
this.workspaceFolders = workspaceRoot ? [ {
|
|
19057
19160
|
uri: URI.file(workspaceRoot)
|
|
@@ -19391,9 +19494,9 @@ var Location;
|
|
|
19391
19494
|
})(Location || (Location = {}));
|
|
19392
19495
|
|
|
19393
19496
|
function toLocation(fileSpan, client) {
|
|
19394
|
-
const uri = client.
|
|
19497
|
+
const uri = client.toResourceUri(fileSpan.file);
|
|
19395
19498
|
return {
|
|
19396
|
-
uri: uri
|
|
19499
|
+
uri: uri,
|
|
19397
19500
|
range: {
|
|
19398
19501
|
start: Position.fromLocation(fileSpan.start),
|
|
19399
19502
|
end: Position.fromLocation(fileSpan.end)
|
|
@@ -19505,11 +19608,11 @@ function toTextEdit(edit) {
|
|
|
19505
19608
|
}
|
|
19506
19609
|
|
|
19507
19610
|
function toTextDocumentEdit(change, client) {
|
|
19508
|
-
const uri = client.
|
|
19509
|
-
const document = client.toOpenDocument(uri
|
|
19611
|
+
const uri = client.toResourceUri(change.fileName);
|
|
19612
|
+
const document = client.toOpenDocument(uri);
|
|
19510
19613
|
return {
|
|
19511
19614
|
textDocument: {
|
|
19512
|
-
uri: uri
|
|
19615
|
+
uri: uri,
|
|
19513
19616
|
version: document?.version ?? null
|
|
19514
19617
|
},
|
|
19515
19618
|
edits: change.textChanges.map((c => toTextEdit(c)))
|
|
@@ -19551,6 +19654,9 @@ class FileDiagnostics {
|
|
|
19551
19654
|
this.firePublishDiagnostics = pDebounce((() => this.publishDiagnostics()), 50);
|
|
19552
19655
|
}
|
|
19553
19656
|
update(kind, diagnostics) {
|
|
19657
|
+
if (this.diagnosticsPerKind.get(kind)?.length === 0 && diagnostics.length === 0) {
|
|
19658
|
+
return;
|
|
19659
|
+
}
|
|
19554
19660
|
this.diagnosticsPerKind.set(kind, diagnostics);
|
|
19555
19661
|
this.firePublishDiagnostics();
|
|
19556
19662
|
}
|
|
@@ -19607,7 +19713,7 @@ class DiagnosticEventQueue {
|
|
|
19607
19713
|
if (this.ignoredDiagnosticCodes.size) {
|
|
19608
19714
|
diagnostics = diagnostics.filter((diagnostic => !this.isDiagnosticIgnored(diagnostic)));
|
|
19609
19715
|
}
|
|
19610
|
-
const uri = this.client.
|
|
19716
|
+
const uri = this.client.toResourceUri(file);
|
|
19611
19717
|
const diagnosticsForFile = this.diagnostics.get(uri) || new FileDiagnostics(uri, this.publishDiagnostics, this.client, this.features);
|
|
19612
19718
|
diagnosticsForFile.update(kind, diagnostics);
|
|
19613
19719
|
this.diagnostics.set(uri, diagnosticsForFile);
|
|
@@ -19616,17 +19722,17 @@ class DiagnosticEventQueue {
|
|
|
19616
19722
|
this.ignoredDiagnosticCodes = new Set(ignoredCodes);
|
|
19617
19723
|
}
|
|
19618
19724
|
getDiagnosticsForFile(file) {
|
|
19619
|
-
const uri = this.client.
|
|
19725
|
+
const uri = this.client.toResourceUri(file);
|
|
19620
19726
|
return this.diagnostics.get(uri)?.getDiagnostics() || [];
|
|
19621
19727
|
}
|
|
19622
19728
|
onDidCloseFile(file) {
|
|
19623
|
-
const uri = this.client.
|
|
19729
|
+
const uri = this.client.toResourceUri(file);
|
|
19624
19730
|
const diagnosticsForFile = this.diagnostics.get(uri);
|
|
19625
19731
|
diagnosticsForFile?.onDidClose();
|
|
19626
19732
|
this.diagnostics.delete(uri);
|
|
19627
19733
|
}
|
|
19628
19734
|
async waitForDiagnosticsForTesting(file) {
|
|
19629
|
-
const uri = this.client.
|
|
19735
|
+
const uri = this.client.toResourceUri(file);
|
|
19630
19736
|
let diagnosticsForFile = this.diagnostics.get(uri);
|
|
19631
19737
|
if (diagnosticsForFile) {
|
|
19632
19738
|
diagnosticsForFile.onDidClose();
|
|
@@ -19656,7 +19762,7 @@ class SourceDefinitionCommand {
|
|
|
19656
19762
|
lspClient.showErrorMessage('Go to Source Definition failed. No resource provided.');
|
|
19657
19763
|
return;
|
|
19658
19764
|
}
|
|
19659
|
-
const document = client.toOpenDocument(client.
|
|
19765
|
+
const document = client.toOpenDocument(client.toResourceUri(file));
|
|
19660
19766
|
if (!document) {
|
|
19661
19767
|
lspClient.showErrorMessage('Go to Source Definition failed. File not opened in the editor.');
|
|
19662
19768
|
return;
|
|
@@ -20741,7 +20847,7 @@ function fromProtocolCallHierarchyItem(item, client, workspaceRoot) {
|
|
|
20741
20847
|
kind: fromProtocolScriptElementKind(item.kind),
|
|
20742
20848
|
name: name,
|
|
20743
20849
|
detail: detail,
|
|
20744
|
-
uri: client.
|
|
20850
|
+
uri: client.toResourceUri(item.file),
|
|
20745
20851
|
range: Range.fromTextSpan(item.span),
|
|
20746
20852
|
selectionRange: Range.fromTextSpan(item.selectionSpan)
|
|
20747
20853
|
};
|
|
@@ -21510,7 +21616,7 @@ class TypeScriptImplementationsCodeLensProvider extends TypeScriptBaseCodeLensPr
|
|
|
21510
21616
|
codeLens.command = response.type === 'cancelled' ? TypeScriptBaseCodeLensProvider.cancelledCommand : TypeScriptBaseCodeLensProvider.errorCommand;
|
|
21511
21617
|
return codeLens;
|
|
21512
21618
|
}
|
|
21513
|
-
const locations = response.body.map((reference => main$2.Location.create(this.client.
|
|
21619
|
+
const locations = response.body.map((reference => main$2.Location.create(this.client.toResourceUri(reference.file), reference.start.line === reference.end.line ? Range.fromTextSpan(reference) : main$2.Range.create(Position.fromLocation(reference.start), main$2.Position.create(reference.start.line, 0))))).filter((location => !(location.uri.toString() === codeLens.data.uri && location.range.start.line === codeLens.range.start.line && location.range.start.character === codeLens.range.start.character)));
|
|
21514
21620
|
codeLens.command = this.getCommand(locations, codeLens);
|
|
21515
21621
|
return codeLens;
|
|
21516
21622
|
}
|
|
@@ -21565,7 +21671,7 @@ class TypeScriptReferencesCodeLensProvider extends TypeScriptBaseCodeLensProvide
|
|
|
21565
21671
|
codeLens.command = response.type === 'cancelled' ? TypeScriptBaseCodeLensProvider.cancelledCommand : TypeScriptBaseCodeLensProvider.errorCommand;
|
|
21566
21672
|
return codeLens;
|
|
21567
21673
|
}
|
|
21568
|
-
const locations = response.body.refs.filter((reference => !reference.isDefinition)).map((reference => Location.fromTextSpan(this.client.
|
|
21674
|
+
const locations = response.body.refs.filter((reference => !reference.isDefinition)).map((reference => Location.fromTextSpan(this.client.toResourceUri(reference.file), reference)));
|
|
21569
21675
|
codeLens.command = {
|
|
21570
21676
|
title: this.getCodeLensLabel(locations),
|
|
21571
21677
|
command: locations.length ? 'editor.action.showReferences' : '',
|
|
@@ -22387,6 +22493,7 @@ class LspServer {
|
|
|
22387
22493
|
disableAutomaticTypingAcquisition: disableAutomaticTypingAcquisition,
|
|
22388
22494
|
maxTsServerMemory: maxTsServerMemory,
|
|
22389
22495
|
npmLocation: npmLocation,
|
|
22496
|
+
hostInfo: hostInfo,
|
|
22390
22497
|
locale: locale,
|
|
22391
22498
|
plugins: plugins || [],
|
|
22392
22499
|
onEvent: this.onTsEvent.bind(this),
|
|
@@ -22708,7 +22815,7 @@ class LspServer {
|
|
|
22708
22815
|
}
|
|
22709
22816
|
async completionResolve(item, token) {
|
|
22710
22817
|
item.data = item.data?.cacheId !== undefined ? this.completionDataCache.get(item.data.cacheId) : item.data;
|
|
22711
|
-
const uri = this.tsClient.
|
|
22818
|
+
const uri = this.tsClient.toResourceUri(item.data.file);
|
|
22712
22819
|
const document = item.data?.file ? this.tsClient.toOpenDocument(uri) : undefined;
|
|
22713
22820
|
if (!document) {
|
|
22714
22821
|
return item;
|
|
@@ -22781,7 +22888,7 @@ class LspServer {
|
|
|
22781
22888
|
}
|
|
22782
22889
|
const changes = {};
|
|
22783
22890
|
result.locs.forEach((spanGroup => {
|
|
22784
|
-
const uri = this.tsClient.
|
|
22891
|
+
const uri = this.tsClient.toResourceUri(spanGroup.file);
|
|
22785
22892
|
const textEdits = changes[uri] || (changes[uri] = []);
|
|
22786
22893
|
spanGroup.locs.forEach((textSpan => {
|
|
22787
22894
|
textEdits.push({
|
|
@@ -22977,7 +23084,7 @@ class LspServer {
|
|
|
22977
23084
|
if (renameLocation) {
|
|
22978
23085
|
await this.options.lspClient.rename({
|
|
22979
23086
|
textDocument: {
|
|
22980
|
-
uri: this.tsClient.
|
|
23087
|
+
uri: this.tsClient.toResourceUri(args.file)
|
|
22981
23088
|
},
|
|
22982
23089
|
position: Position.fromLocation(renameLocation)
|
|
22983
23090
|
});
|
|
@@ -22987,7 +23094,7 @@ class LspServer {
|
|
|
22987
23094
|
this.tsClient.configurePlugin(pluginName, configuration);
|
|
22988
23095
|
} else if (params.command === Commands.ORGANIZE_IMPORTS && params.arguments) {
|
|
22989
23096
|
const file = params.arguments[0];
|
|
22990
|
-
const uri = this.tsClient.
|
|
23097
|
+
const uri = this.tsClient.toResourceUri(file);
|
|
22991
23098
|
const document = this.tsClient.toOpenDocument(uri);
|
|
22992
23099
|
if (!document) {
|
|
22993
23100
|
return;
|
|
@@ -23044,7 +23151,7 @@ class LspServer {
|
|
|
23044
23151
|
}
|
|
23045
23152
|
const changes = {};
|
|
23046
23153
|
for (const edit of edits) {
|
|
23047
|
-
changes[this.tsClient.
|
|
23154
|
+
changes[this.tsClient.toResourceUri(edit.fileName)] = edit.textChanges.map(toTextEdit);
|
|
23048
23155
|
}
|
|
23049
23156
|
const {applied: applied} = await this.options.lspClient.applyWorkspaceEdit({
|
|
23050
23157
|
edit: {
|
|
@@ -23058,7 +23165,7 @@ class LspServer {
|
|
|
23058
23165
|
for (const rename of params.files) {
|
|
23059
23166
|
const codeEdits = await this.getEditsForFileRename(rename.oldUri, rename.newUri, token);
|
|
23060
23167
|
for (const codeEdit of codeEdits) {
|
|
23061
|
-
const uri = this.tsClient.
|
|
23168
|
+
const uri = this.tsClient.toResourceUri(codeEdit.fileName);
|
|
23062
23169
|
const textEdits = changes[uri] || (changes[uri] = []);
|
|
23063
23170
|
textEdits.push(...codeEdit.textChanges.map(toTextEdit));
|
|
23064
23171
|
}
|
|
@@ -23134,7 +23241,7 @@ class LspServer {
|
|
|
23134
23241
|
}
|
|
23135
23242
|
return response.body.map((item => ({
|
|
23136
23243
|
location: {
|
|
23137
|
-
uri: this.tsClient.
|
|
23244
|
+
uri: this.tsClient.toResourceUri(item.file),
|
|
23138
23245
|
range: {
|
|
23139
23246
|
start: Position.fromLocation(item.start),
|
|
23140
23247
|
end: Position.fromLocation(item.end)
|