typespec-vscode 0.57.0-dev.2 → 0.57.0-dev.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/dist/src/extension.cjs +130 -5
- package/package.json +13 -2
- package/typespec-vscode-0.56.0.vsix +0 -0
package/dist/src/extension.cjs
CHANGED
|
@@ -21044,8 +21044,116 @@ var api = {};
|
|
|
21044
21044
|
|
|
21045
21045
|
var node = main$3;
|
|
21046
21046
|
|
|
21047
|
+
const TRACE_PREFIX = /^\[Trace.*?\] /iu;
|
|
21048
|
+
const DEBUG_PREFIX = /^\[Debug.*?\] /iu;
|
|
21049
|
+
const INFO_PREFIX = /^\[Info.*?\] /iu;
|
|
21050
|
+
const WARN_PREFIX = /^\[Warn.*?\] /iu;
|
|
21051
|
+
const ERROR_PREFIX = /^\[Error.*?\] /iu;
|
|
21052
|
+
class TypeSpecLogOutputChannel {
|
|
21053
|
+
delegate;
|
|
21054
|
+
constructor(name) {
|
|
21055
|
+
this.delegate = require$$0$1.window.createOutputChannel(name, { log: true });
|
|
21056
|
+
}
|
|
21057
|
+
get logLevel() {
|
|
21058
|
+
return this.delegate.logLevel;
|
|
21059
|
+
}
|
|
21060
|
+
get onDidChangeLogLevel() {
|
|
21061
|
+
return this.delegate.onDidChangeLogLevel;
|
|
21062
|
+
}
|
|
21063
|
+
trace(message, ...args) {
|
|
21064
|
+
this.delegate.trace(message, ...args);
|
|
21065
|
+
}
|
|
21066
|
+
debug(message, ...args) {
|
|
21067
|
+
this.delegate.debug(message, ...args);
|
|
21068
|
+
}
|
|
21069
|
+
info(message, ...args) {
|
|
21070
|
+
this.delegate.info(message, ...args);
|
|
21071
|
+
}
|
|
21072
|
+
warn(message, ...args) {
|
|
21073
|
+
this.delegate.warn(message, ...args);
|
|
21074
|
+
}
|
|
21075
|
+
error(error, ...args) {
|
|
21076
|
+
this.delegate.error(error, ...args);
|
|
21077
|
+
}
|
|
21078
|
+
get name() {
|
|
21079
|
+
return this.delegate.name;
|
|
21080
|
+
}
|
|
21081
|
+
replace(value) {
|
|
21082
|
+
this.delegate.replace(value);
|
|
21083
|
+
}
|
|
21084
|
+
clear() {
|
|
21085
|
+
this.delegate.clear();
|
|
21086
|
+
}
|
|
21087
|
+
show(column, preserveFocus) {
|
|
21088
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
21089
|
+
this.delegate.show(column, preserveFocus);
|
|
21090
|
+
}
|
|
21091
|
+
hide() {
|
|
21092
|
+
this.delegate.hide();
|
|
21093
|
+
}
|
|
21094
|
+
dispose() {
|
|
21095
|
+
this.delegate.dispose();
|
|
21096
|
+
}
|
|
21097
|
+
append(value) {
|
|
21098
|
+
this.logToDelegate(value);
|
|
21099
|
+
}
|
|
21100
|
+
appendLine(value) {
|
|
21101
|
+
this.logToDelegate(value);
|
|
21102
|
+
}
|
|
21103
|
+
preLevel = "";
|
|
21104
|
+
logToDelegate(value) {
|
|
21105
|
+
if (TRACE_PREFIX.test(value)) {
|
|
21106
|
+
this.preLevel = "trace";
|
|
21107
|
+
this.delegate.trace(value.replace(TRACE_PREFIX, ""));
|
|
21108
|
+
}
|
|
21109
|
+
else if (DEBUG_PREFIX.test(value)) {
|
|
21110
|
+
this.preLevel = "debug";
|
|
21111
|
+
this.delegate.debug(value.replace(DEBUG_PREFIX, ""));
|
|
21112
|
+
}
|
|
21113
|
+
else if (INFO_PREFIX.test(value)) {
|
|
21114
|
+
this.preLevel = "info";
|
|
21115
|
+
this.delegate.info(value.replace(INFO_PREFIX, ""));
|
|
21116
|
+
}
|
|
21117
|
+
else if (WARN_PREFIX.test(value)) {
|
|
21118
|
+
this.preLevel = "warning";
|
|
21119
|
+
this.delegate.warn(value.replace(WARN_PREFIX, ""));
|
|
21120
|
+
}
|
|
21121
|
+
else if (ERROR_PREFIX.test(value)) {
|
|
21122
|
+
this.preLevel = "error";
|
|
21123
|
+
this.delegate.error(value.replace(ERROR_PREFIX, ""));
|
|
21124
|
+
}
|
|
21125
|
+
else {
|
|
21126
|
+
// a msg sent without a level prefix should be because a message is sent by calling multiple appendLine()
|
|
21127
|
+
// so just log it with the previous level
|
|
21128
|
+
switch (this.preLevel) {
|
|
21129
|
+
case "trace":
|
|
21130
|
+
this.delegate.trace(value);
|
|
21131
|
+
break;
|
|
21132
|
+
case "debug":
|
|
21133
|
+
this.delegate.debug(value);
|
|
21134
|
+
break;
|
|
21135
|
+
case "info":
|
|
21136
|
+
this.delegate.info(value);
|
|
21137
|
+
break;
|
|
21138
|
+
case "warning":
|
|
21139
|
+
this.delegate.warn(value);
|
|
21140
|
+
break;
|
|
21141
|
+
case "error":
|
|
21142
|
+
this.delegate.error(value);
|
|
21143
|
+
break;
|
|
21144
|
+
default:
|
|
21145
|
+
this.delegate.debug(`Log Message with invalid log level (${this.preLevel}). Raw message: ${value}`);
|
|
21146
|
+
}
|
|
21147
|
+
}
|
|
21148
|
+
}
|
|
21149
|
+
}
|
|
21150
|
+
|
|
21047
21151
|
let client;
|
|
21048
|
-
|
|
21152
|
+
/**
|
|
21153
|
+
* Workaround: LogOutputChannel doesn't work well with LSP RemoteConsole, so having a customized LogOutputChannel to make them work together properly
|
|
21154
|
+
* More detail can be found at https://github.com/microsoft/vscode-discussions/discussions/1149
|
|
21155
|
+
*/
|
|
21156
|
+
const outputChannel = new TypeSpecLogOutputChannel("TypeSpec");
|
|
21049
21157
|
async function activate(context) {
|
|
21050
21158
|
context.subscriptions.push(require$$0$1.commands.registerCommand("typespec.showOutputChannel", () => {
|
|
21051
21159
|
outputChannel.show(true /*preserveFocus*/);
|
|
@@ -21060,10 +21168,12 @@ async function restartTypeSpecServer() {
|
|
|
21060
21168
|
if (client) {
|
|
21061
21169
|
await client.stop();
|
|
21062
21170
|
await client.start();
|
|
21171
|
+
outputChannel.debug("TypeSpec server restarted");
|
|
21063
21172
|
}
|
|
21064
21173
|
}
|
|
21065
21174
|
async function launchLanguageClient(context) {
|
|
21066
21175
|
const exe = await resolveTypeSpecServer(context);
|
|
21176
|
+
outputChannel.debug("TypeSpec server resolved as ", exe);
|
|
21067
21177
|
const options = {
|
|
21068
21178
|
synchronize: {
|
|
21069
21179
|
// Synchronize the setting section 'typespec' to the server
|
|
@@ -21083,20 +21193,22 @@ async function launchLanguageClient(context) {
|
|
|
21083
21193
|
outputChannel,
|
|
21084
21194
|
};
|
|
21085
21195
|
const name = "TypeSpec";
|
|
21086
|
-
const id = "
|
|
21196
|
+
const id = "typespec";
|
|
21087
21197
|
try {
|
|
21088
21198
|
client = new node.LanguageClient(id, name, { run: exe, debug: exe }, options);
|
|
21089
21199
|
await client.start();
|
|
21200
|
+
outputChannel.debug("TypeSpec server started");
|
|
21090
21201
|
}
|
|
21091
21202
|
catch (e) {
|
|
21092
21203
|
if (typeof e === "string" && e.startsWith("Launching server using command")) {
|
|
21093
21204
|
const workspaceFolder = require$$0$1.workspace.workspaceFolders?.[0]?.uri?.fsPath ?? "";
|
|
21094
|
-
|
|
21205
|
+
outputChannel.error([
|
|
21095
21206
|
`TypeSpec server executable was not found: '${exe.command}' is not found. Make sure either:`,
|
|
21096
21207
|
` - TypeSpec is installed locally at the root of this workspace ("${workspaceFolder}") or in a parent directory.`,
|
|
21097
21208
|
" - TypeSpec is installed globally with `npm install -g @typespec/compiler'.",
|
|
21098
21209
|
" - TypeSpec server path is configured with https://github.com/microsoft/typespec#installing-vs-code-extension.",
|
|
21099
|
-
].join("\n")
|
|
21210
|
+
].join("\n"));
|
|
21211
|
+
outputChannel.error("Error detail", e);
|
|
21100
21212
|
throw `TypeSpec server executable was not found: '${exe.command}' is not found.`;
|
|
21101
21213
|
}
|
|
21102
21214
|
else {
|
|
@@ -21113,6 +21225,7 @@ async function resolveTypeSpecServer(context) {
|
|
|
21113
21225
|
// we use CLI instead of NODE_OPTIONS environment variable in this case
|
|
21114
21226
|
// because --nolazy is not supported by NODE_OPTIONS.
|
|
21115
21227
|
const options = nodeOptions?.split(" ").filter((o) => o) ?? [];
|
|
21228
|
+
outputChannel.debug("TypeSpec server resolved in development mode");
|
|
21116
21229
|
return { command: "node", args: [...options, script, ...args] };
|
|
21117
21230
|
}
|
|
21118
21231
|
const options = {
|
|
@@ -21130,11 +21243,15 @@ async function resolveTypeSpecServer(context) {
|
|
|
21130
21243
|
const workspaceFolder = require$$0$1.workspace.workspaceFolders?.[0]?.uri?.fsPath ?? "";
|
|
21131
21244
|
// Default to tsp-server on PATH, which would come from `npm install -g
|
|
21132
21245
|
// @typespec/compiler` in a vanilla setup.
|
|
21133
|
-
if (
|
|
21246
|
+
if (serverPath) {
|
|
21247
|
+
outputChannel.debug(`Server path loaded from VS Code configuration: ${serverPath}`);
|
|
21248
|
+
}
|
|
21249
|
+
else {
|
|
21134
21250
|
serverPath = await resolveLocalCompiler(workspaceFolder);
|
|
21135
21251
|
}
|
|
21136
21252
|
if (!serverPath) {
|
|
21137
21253
|
const executable = process.platform === "win32" ? "tsp-server.cmd" : "tsp-server";
|
|
21254
|
+
outputChannel.debug(`Can't resolve server path, try to use default value ${executable}.`);
|
|
21138
21255
|
return { command: executable, args, options };
|
|
21139
21256
|
}
|
|
21140
21257
|
const variableResolver = new VSCodeVariableResolver({
|
|
@@ -21142,6 +21259,7 @@ async function resolveTypeSpecServer(context) {
|
|
|
21142
21259
|
workspaceRoot: workspaceFolder, // workspaceRoot is deprecated but we still support it for backwards compatibility.
|
|
21143
21260
|
});
|
|
21144
21261
|
serverPath = variableResolver.resolve(serverPath);
|
|
21262
|
+
outputChannel.debug(`Server path expanded to: ${serverPath}`);
|
|
21145
21263
|
if (!serverPath.endsWith(".js")) {
|
|
21146
21264
|
// Allow path to tsp-server.cmd to be passed.
|
|
21147
21265
|
if (await isFile$1(serverPath)) {
|
|
@@ -21167,15 +21285,22 @@ async function resolveLocalCompiler(baseDir) {
|
|
|
21167
21285
|
stat: promises.stat,
|
|
21168
21286
|
};
|
|
21169
21287
|
try {
|
|
21288
|
+
outputChannel.debug(`Try to resolve compiler from local, baseDir: ${baseDir}`);
|
|
21170
21289
|
const executable = await resolveModule(host, "@typespec/compiler", {
|
|
21171
21290
|
baseDir,
|
|
21172
21291
|
});
|
|
21173
21292
|
if (executable.type === "module") {
|
|
21293
|
+
outputChannel.debug(`Resolved compiler from local: ${executable.path}`);
|
|
21174
21294
|
return executable.path;
|
|
21175
21295
|
}
|
|
21296
|
+
else {
|
|
21297
|
+
outputChannel.debug(`Failed to resolve compiler from local. Unexpected executable type: ${executable.type}`);
|
|
21298
|
+
}
|
|
21176
21299
|
}
|
|
21177
21300
|
catch (e) {
|
|
21178
21301
|
// Couldn't find the module
|
|
21302
|
+
outputChannel.debug("Exception when resolving compiler from local", e);
|
|
21303
|
+
return undefined;
|
|
21179
21304
|
}
|
|
21180
21305
|
return undefined;
|
|
21181
21306
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typespec-vscode",
|
|
3
|
-
"version": "0.57.0-dev.
|
|
3
|
+
"version": "0.57.0-dev.3",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec language support for VS Code",
|
|
6
6
|
"homepage": "https://typespec.io",
|
|
@@ -59,13 +59,24 @@
|
|
|
59
59
|
],
|
|
60
60
|
"configuration": [
|
|
61
61
|
{
|
|
62
|
-
"title": "TypeSpec
|
|
62
|
+
"title": "TypeSpec",
|
|
63
63
|
"properties": {
|
|
64
64
|
"typespec.tsp-server.path": {
|
|
65
65
|
"type": "string",
|
|
66
66
|
"default": "",
|
|
67
67
|
"description": "Path to `tsp-server` command that runs the TypeSpec language server.\n\nIf not specified, then `tsp-server` found on PATH is used.\n\nExample (User): /usr/local/bin/tsp-server\nExample (Workspace): ${workspaceFolder}/node_modules/@typespec/compiler",
|
|
68
68
|
"scope": "machine-overridable"
|
|
69
|
+
},
|
|
70
|
+
"typespec.trace.server": {
|
|
71
|
+
"scope": "window",
|
|
72
|
+
"type": "string",
|
|
73
|
+
"enum": [
|
|
74
|
+
"off",
|
|
75
|
+
"messages",
|
|
76
|
+
"verbose"
|
|
77
|
+
],
|
|
78
|
+
"default": "off",
|
|
79
|
+
"description": "Define whether/how the TypeSpec language server should send traces to client. For the traces to show properly in vscode Output, make sure 'Log Level' is also set to 'Trace' so that they won't be filtered at client side, which can be set through 'Developer: Set Log Level...' command."
|
|
69
80
|
}
|
|
70
81
|
}
|
|
71
82
|
}
|
|
Binary file
|