Skip to content

Commit

Permalink
chore: update Volar to 2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Jun 17, 2024
1 parent 0feaf66 commit 04b1187
Show file tree
Hide file tree
Showing 18 changed files with 194 additions and 160 deletions.
2 changes: 1 addition & 1 deletion extensions/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@
"devDependencies": {
"@types/semver": "^7.5.3",
"@types/vscode": "^1.82.0",
"@volar/vscode": "~2.3.0-alpha.15",
"@volar/vscode": "~2.3.0",
"@vue/language-core": "2.0.21",
"@vue/language-server": "2.0.21",
"@vue/typescript-plugin": "2.0.21",
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@
"@lerna-lite/publish": "latest",
"@tsslint/cli": "latest",
"@tsslint/config": "latest",
"@volar/language-service": "~2.3.0-alpha.15",
"@volar/language-service": "~2.3.0",
"typescript": "latest",
"vite": "latest",
"vitest": "latest"
},
"pnpm": {
"overrides": {
"vscode-html-languageservice": "npm:@johnsoncodehk/vscode-html-languageservice"
}
}
}
2 changes: 1 addition & 1 deletion packages/component-meta/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"directory": "packages/component-meta"
},
"dependencies": {
"@volar/typescript": "~2.3.0-alpha.15",
"@volar/typescript": "~2.3.0",
"@vue/language-core": "2.0.21",
"path-browserify": "^1.0.1",
"vue-component-type-helpers": "2.0.21"
Expand Down
4 changes: 3 additions & 1 deletion packages/language-core/lib/plugins/file-md.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { buildMappings, Segment, SourceMap, toString } from '@volar/language-core';
import { SourceMap, toString } from '@volar/language-core';
import type { SFCBlock } from '@vue/compiler-sfc';
import type { Segment } from 'muggle-string';
import type { VueLanguagePlugin } from '../types';
import { buildMappings } from '../utils/buildMappings';
import { parse } from '../utils/parseSfc';

const codeblockReg = /(`{3,})[\s\S]+?\1/g;
Expand Down
22 changes: 22 additions & 0 deletions packages/language-core/lib/utils/buildMappings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { Segment } from 'muggle-string';
import type { Mapping } from '@volar/language-core';

export function buildMappings<T>(chunks: Segment<T>[]) {
let length = 0;
const mappings: Mapping<T>[] = [];
for (const segment of chunks) {
if (typeof segment === 'string') {
length += segment.length;
}
else {
mappings.push({
sourceOffsets: [segment[2]],
generatedOffsets: [length],
lengths: [segment[0].length],
data: segment[3]!,
});
length += segment[0].length;
}
}
return mappings;
}
4 changes: 3 additions & 1 deletion packages/language-core/lib/virtualFile/computedFiles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { VirtualCode, buildMappings, toString } from '@volar/language-core';
import type { VirtualCode } from '@volar/language-core';
import { computed } from 'computeds';
import { toString } from 'muggle-string';
import type * as ts from 'typescript';
import type { Code, Sfc, SfcBlock, VueLanguagePlugin } from '../types';
import { buildMappings } from '../utils/buildMappings';
import { VueEmbeddedCode } from './embeddedFile';

export function computedFiles(
Expand Down
3 changes: 2 additions & 1 deletion packages/language-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
"directory": "packages/language-core"
},
"dependencies": {
"@volar/language-core": "~2.3.0-alpha.15",
"@volar/language-core": "~2.3.0",
"@vue/compiler-dom": "^3.4.0",
"@vue/shared": "^3.4.0",
"computeds": "^0.0.1",
"minimatch": "^9.0.3",
"muggle-string": "^0.4.1",
"path-browserify": "^1.0.1",
"vue-template-compiler": "^2.7.14"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/language-plugin-pug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@vue/language-core": "2.0.21"
},
"dependencies": {
"@volar/source-map": "~2.3.0-alpha.15",
"volar-service-pug": "0.0.50"
"@volar/source-map": "~2.3.0",
"volar-service-pug": "0.0.51"
}
}
10 changes: 3 additions & 7 deletions packages/language-server/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,23 @@ connection.onRequest(ParseSFCRequest.type, params => {

connection.onRequest(DetectNameCasingRequest.type, async params => {
const uri = URI.parse(params.textDocument.uri);
const languageService = await getService(uri);
const languageService = await server.project.getLanguageService(uri);
if (languageService) {
return await detect(languageService.context, uri);
}
});

connection.onRequest(GetConvertTagCasingEditsRequest.type, async params => {
const uri = URI.parse(params.textDocument.uri);
const languageService = await getService(uri);
const languageService = await server.project.getLanguageService(uri);
if (languageService) {
return await convertTagName(languageService.context, uri, params.casing, getTsPluginClient(languageService.context));
}
});

connection.onRequest(GetConvertAttrCasingEditsRequest.type, async params => {
const uri = URI.parse(params.textDocument.uri);
const languageService = await getService(uri);
const languageService = await server.project.getLanguageService(uri);
if (languageService) {
return await convertAttrName(languageService.context, uri, params.casing, getTsPluginClient(languageService.context));
}
Expand All @@ -159,7 +159,3 @@ connection.onRequest(GetConnectedNamedPipeServerRequest.type, async fileName =>
return server;
}
});

async function getService(uri: URI) {
return (await server.project.getLanguageService(uri));
}
4 changes: 2 additions & 2 deletions packages/language-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"directory": "packages/language-server"
},
"dependencies": {
"@volar/language-core": "~2.3.0-alpha.15",
"@volar/language-server": "~2.3.0-alpha.15",
"@volar/language-core": "~2.3.0",
"@volar/language-server": "~2.3.0",
"@vue/language-core": "2.0.21",
"@vue/language-service": "2.0.21",
"@vue/typescript-plugin": "2.0.21",
Expand Down
4 changes: 2 additions & 2 deletions packages/language-service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export function getVueLanguageServicePlugins(
if (plugin.name === 'typescript-semantic') {
plugins[i] = {
...plugin,
create(context, api) {
const created = plugin.create(context, api);
create(context) {
const created = plugin.create(context);
if (!context.language.typescript) {
return created;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/language-service/lib/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export function create(): LanguageServicePlugin {
const base = baseCreate({ scssDocumentSelector: ['scss', 'postcss'] });
return {
...base,
create(context, api): LanguageServicePluginInstance {
const baseInstance = base.create(context, api);
create(context): LanguageServicePluginInstance {
const baseInstance = base.create(context);
return {
...baseInstance,
async provideDiagnostics(document, token) {
Expand Down
4 changes: 2 additions & 2 deletions packages/language-service/lib/plugins/vue-sfc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export function create(): LanguageServicePlugin {
return {
...htmlPlugin,
name: 'vue-sfc',
create(context, api): LanguageServicePluginInstance<Provide> {
const htmlPluginInstance = htmlPlugin.create(context, api);
create(context): LanguageServicePluginInstance<Provide> {
const htmlPluginInstance = htmlPlugin.create(context);

return {

Expand Down
6 changes: 3 additions & 3 deletions packages/language-service/lib/plugins/vue-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@ export function create(
},
inlayHintProvider: {},
hoverProvider: true,
diagnosticProvider: true,
diagnosticProvider: {},
semanticTokensProvider: {
legend: {
tokenTypes: ['class'],
tokenModifiers: [],
},
}
},
create(context, api): LanguageServicePluginInstance {
create(context): LanguageServicePluginInstance {
const tsPluginClient = getTsPluginClient?.(context);
const baseServiceInstance = baseService.create(context, api);
const baseServiceInstance = baseService.create(context);
const vueCompilerOptions = getVueOptions(context.env);

builtInData ??= loadTemplateData(context.env.locale ?? 'en');
Expand Down
26 changes: 13 additions & 13 deletions packages/language-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@
"update-html-data": "node ./scripts/update-html-data.js"
},
"dependencies": {
"@volar/language-core": "~2.3.0-alpha.15",
"@volar/language-service": "~2.3.0-alpha.15",
"@volar/typescript": "~2.3.0-alpha.15",
"@volar/language-core": "~2.3.0",
"@volar/language-service": "~2.3.0",
"@volar/typescript": "~2.3.0",
"@vue/compiler-dom": "^3.4.0",
"@vue/language-core": "2.0.21",
"@vue/shared": "^3.4.0",
"@vue/typescript-plugin": "2.0.21",
"computeds": "^0.0.1",
"path-browserify": "^1.0.1",
"volar-service-css": "0.0.50",
"volar-service-emmet": "0.0.50",
"volar-service-html": "0.0.50",
"volar-service-json": "0.0.50",
"volar-service-pug": "0.0.50",
"volar-service-pug-beautify": "0.0.50",
"volar-service-typescript": "0.0.50",
"volar-service-typescript-twoslash-queries": "0.0.50",
"vscode-html-languageservice": "npm:@johnsoncodehk/vscode-html-languageservice@5.2.0-34a5462",
"volar-service-css": "0.0.51",
"volar-service-emmet": "0.0.51",
"volar-service-html": "0.0.51",
"volar-service-json": "0.0.51",
"volar-service-pug": "0.0.51",
"volar-service-pug-beautify": "0.0.51",
"volar-service-typescript": "0.0.51",
"volar-service-typescript-twoslash-queries": "0.0.51",
"vscode-html-languageservice": "^5.2.0",
"vscode-languageserver-textdocument": "^1.0.11",
"vscode-uri": "^3.0.8"
},
"devDependencies": {
"@types/node": "latest",
"@types/path-browserify": "latest",
"@volar/kit": "~2.3.0-alpha.15",
"@volar/kit": "~2.3.0",
"vscode-languageserver-protocol": "^3.17.5"
}
}
2 changes: 1 addition & 1 deletion packages/tsc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"vue-tsc": "./bin/vue-tsc.js"
},
"dependencies": {
"@volar/typescript": "~2.3.0-alpha.15",
"@volar/typescript": "~2.3.0",
"@vue/language-core": "2.0.21",
"semver": "^7.5.4"
},
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 @@ -12,7 +12,7 @@
"directory": "packages/typescript-plugin"
},
"dependencies": {
"@volar/typescript": "~2.3.0-alpha.15",
"@volar/typescript": "~2.3.0",
"@vue/language-core": "2.0.21",
"@vue/shared": "^3.4.0"
},
Expand Down
Loading

0 comments on commit 04b1187

Please sign in to comment.