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 21, 2023
1 parent 1790014 commit ea1fdf5
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 95 deletions.
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/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.26"
},
"dependencies": {
"@volar/source-map": "2.0.0-alpha.9",
"@volar/source-map": "2.0.0-alpha.10",
"volar-service-pug": "0.0.24"
}
}
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.26",
"@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/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"
}
}

0 comments on commit ea1fdf5

Please sign in to comment.