Skip to content

Commit

Permalink
chore(language-server): use in-place parsed command line options
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Dec 20, 2023
1 parent 8371314 commit cb09244
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 101 deletions.
2 changes: 1 addition & 1 deletion extensions/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@
"devDependencies": {
"@types/semver": "^7.5.3",
"@types/vscode": "^1.82.0",
"@volar/vscode": "2.0.0-alpha.9",
"@volar/vscode": "2.0.0-alpha.10",
"@vue/language-core": "1.8.25",
"@vue/language-server": "1.8.25",
"esbuild": "latest",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"devDependencies": {
"@lerna-lite/cli": "latest",
"@lerna-lite/publish": "latest",
"@volar/language-service": "2.0.0-alpha.9",
"@volar/language-service": "2.0.0-alpha.10",
"typescript": "latest",
"vite": "latest",
"vitest": "latest"
Expand Down
2 changes: 1 addition & 1 deletion packages/component-meta/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"directory": "packages/component-meta"
},
"dependencies": {
"@volar/typescript": "2.0.0-alpha.9",
"@volar/typescript": "2.0.0-alpha.10",
"@vue/language-core": "1.8.25",
"path-browserify": "^1.0.1",
"vue-component-type-helpers": "1.8.25"
Expand Down
2 changes: 1 addition & 1 deletion packages/language-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"directory": "packages/language-core"
},
"dependencies": {
"@volar/language-core": "2.0.0-alpha.9",
"@volar/language-core": "2.0.0-alpha.10",
"@vue/compiler-dom": "^3.3.0",
"@vue/shared": "^3.3.0",
"computeds": "^0.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/language-plugin-pug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@vue/language-core": "1.8.25"
},
"dependencies": {
"@volar/source-map": "2.0.0-alpha.9",
"@volar/source-map": "2.0.0-alpha.10",
"volar-service-pug": "0.0.24"
}
}
6 changes: 3 additions & 3 deletions packages/language-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"directory": "packages/language-server"
},
"dependencies": {
"@volar/language-core": "2.0.0-alpha.9",
"@volar/language-server": "2.0.0-alpha.9",
"@volar/typescript": "2.0.0-alpha.9",
"@volar/language-core": "2.0.0-alpha.10",
"@volar/language-server": "2.0.0-alpha.10",
"@volar/typescript": "2.0.0-alpha.10",
"@vue/language-core": "1.8.25",
"@vue/language-service": "1.8.25",
"vscode-languageserver-protocol": "^3.17.5",
Expand Down
18 changes: 10 additions & 8 deletions packages/language-server/src/nodeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,19 @@ connection.onInitialize(params => {
},
async getProjectSetup(serviceEnv, projectContext) {
const ts = getTsLib();
const vueOptions = await getVueCompilerOptions();
const [commandLine, vueOptions] = await parseCommandLine();
envToVueOptions.set(serviceEnv, vue.resolveVueCompilerOptions(vueOptions));
const services = vue.resolveServices(ts, {}, vueOptions);
const languages = vue.resolveLanguages(ts, {}, projectContext.typescript?.parsedCommandLine.options ?? {}, vueOptions, options.codegenStack);
const languages = vue.resolveLanguages(ts, {}, commandLine?.options ?? {}, vueOptions, options.codegenStack);

return {
languagePlugins: Object.values(languages),
servicePlugins: Object.values(services),
};

async function getVueCompilerOptions() {
async function parseCommandLine() {

let commandLine: vue2.ParsedCommandLine | undefined;
let vueOptions: Partial<vue.VueCompilerOptions> = {};

if (projectContext.typescript) {
Expand All @@ -62,22 +64,22 @@ connection.onInitialize(params => {
while (sysVersion !== newSysVersion) {
sysVersion = newSysVersion;
if (projectContext.typescript.configFileName) {
vueOptions = vue2.createParsedCommandLine(ts, sys, projectContext.typescript.configFileName).vueOptions;
}
else {
vueOptions = vue2.createParsedCommandLineByJson(ts, sys, serviceEnv.uriToFileName(serviceEnv.workspaceFolder.uri.toString()), projectContext.typescript.parsedCommandLine.options).vueOptions;
commandLine = vue2.createParsedCommandLine(ts, sys, projectContext.typescript.configFileName);
}
newSysVersion = await sys.sync();
}
}

if (commandLine) {
vueOptions = commandLine.vueOptions;
}
vueOptions.extensions = [
...vueOptions.extensions ?? ['.vue'],
...vueFileExtensions.map(ext => '.' + ext),
];
vueOptions.extensions = [...new Set(vueOptions.extensions)];

return vueOptions;
return [commandLine, vueOptions] as const;
}
},
},
Expand Down
8 changes: 4 additions & 4 deletions packages/language-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"update-html-data": "node ./scripts/update-html-data.js"
},
"dependencies": {
"@volar/language-core": "2.0.0-alpha.9",
"@volar/language-service": "2.0.0-alpha.9",
"@volar/typescript": "2.0.0-alpha.9",
"@volar/language-core": "2.0.0-alpha.10",
"@volar/language-service": "2.0.0-alpha.10",
"@volar/typescript": "2.0.0-alpha.10",
"@vue/compiler-dom": "^3.3.0",
"@vue/language-core": "1.8.25",
"@vue/shared": "^3.3.0",
Expand All @@ -39,7 +39,7 @@
"devDependencies": {
"@types/node": "latest",
"@types/path-browserify": "latest",
"@volar/kit": "2.0.0-alpha.9",
"@volar/kit": "2.0.0-alpha.10",
"vscode-languageserver-protocol": "^3.17.5",
"vscode-uri": "^3.0.8"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/tsc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"vue-tsc": "./bin/vue-tsc.js"
},
"dependencies": {
"@volar/typescript": "2.0.0-alpha.9",
"@volar/typescript": "2.0.0-alpha.10",
"@vue/language-core": "1.8.25"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"directory": "packages/typescript-plugin"
},
"dependencies": {
"@volar/typescript": "2.0.0-alpha.9",
"@volar/typescript": "2.0.0-alpha.10",
"@vue/language-core": "1.8.25"
}
}
Loading

0 comments on commit cb09244

Please sign in to comment.