Skip to content

Commit

Permalink
Restart Typespec Language Server when it's not started before or sett…
Browse files Browse the repository at this point in the history
…ings changed (#4912)

1. TypeSpec Language Server would be restarted with new settings when
setting "typespec.tsp-server.path" is changed
2. Typespec Language Server can be restarted properly when the server
wasn't running before
3. Code refactor in vscode extension.

related issues:
#2996, #4765

---------

Co-authored-by: Timothee Guerin <[email protected]>
  • Loading branch information
RodgeFu and timotheeguerin authored Oct 31, 2024
1 parent fe8f3f1 commit 81c83dd
Show file tree
Hide file tree
Showing 22 changed files with 690 additions and 453 deletions.
7 changes: 7 additions & 0 deletions .chronus/changes/vscode-restart-lsp-2024-9-30-20-29-32.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- typespec-vscode
---

Fix the issue when Typespec Language Server can't be restarted when the server wasn't running before
7 changes: 7 additions & 0 deletions .chronus/changes/vscode-restart-lsp-2024-9-31-11-4-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- typespec-vscode
---

TypeSpec Language Server would be restarted with new settings when setting "typespec.tsp-server.path" is changed
2 changes: 1 addition & 1 deletion packages/typespec-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
"deploy": "vsce publish",
"open-in-browser": "vscode-test-web --extensionDevelopmentPath=. .",
"test:e2e": "pnpm test:web",
"test:web": "vscode-test-web --extensionDevelopmentPath=. --headless --extensionTestsPath=dist/test/suite.js ./test/data"
"test:web": "vscode-test-web --extensionDevelopmentPath=. --headless --extensionTestsPath=dist/test/web/suite.js ./test/web/data"
},
"devDependencies": {
"@rollup/plugin-commonjs": "~28.0.0",
Expand Down
18 changes: 14 additions & 4 deletions packages/typespec-vscode/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import { dirname } from "path";

import { defineConfig } from "rollup";
import { fileURLToPath } from "url";
const projDir = dirname(fileURLToPath(import.meta.url));

const plugins = [(resolve as any)({ preferBuiltins: true }), (commonjs as any)()];
const baseConfig = defineConfig({
Expand Down Expand Up @@ -53,17 +56,24 @@ export default defineConfig([
},
{
...baseConfig,
input: "test/suite.ts",
input: "test/web/suite.ts",
output: {
file: "dist/test/suite.js", // VSCode web will add extra .js if you use .cjs
file: "dist/test/web/suite.js", // VSCode web will add extra .js if you use .cjs
format: "commonjs",
sourcemap: true,
inlineDynamicImports: true,
},
plugins: [...plugins, ts("dist/test")],
plugins: [...plugins, ts("dist/test/web")],
},
]);

function ts(outDir: string) {
return (typescript as any)({ tsconfig: "./tsconfig.build.json", outDir });
return (typescript as any)({
compilerOptions: {
// set sourceRoot to absolute path, otherwise the path in the map file generated is incorrect when outDir is given
sourceRoot: projDir,
},
tsconfig: "./tsconfig.build.json",
outDir,
});
}
3 changes: 3 additions & 0 deletions packages/typespec-vscode/src/const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const enum SettingName {
TspServerPath = "typespec.tsp-server.path",
}
88 changes: 0 additions & 88 deletions packages/typespec-vscode/src/extension-logger.ts

This file was deleted.

Loading

0 comments on commit 81c83dd

Please sign in to comment.