Skip to content

Commit 0b0dc46

Browse files
committed
refactor(language-service): remove component coloring logic from vue-template plugin
1 parent 266b165 commit 0b0dc46

File tree

3 files changed

+3
-68
lines changed

3 files changed

+3
-68
lines changed

packages/language-service/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ function getCommonLanguageServicePlugins(
192192
createCssPlugin(),
193193
createPugFormatPlugin(),
194194
createJsonPlugin(),
195-
createVueTemplatePlugin('html', ts, getTsPluginClient),
196-
createVueTemplatePlugin('pug', ts, getTsPluginClient),
195+
createVueTemplatePlugin('html', getTsPluginClient),
196+
createVueTemplatePlugin('pug', getTsPluginClient),
197197
createVueMissingPropsHintsPlugin(getTsPluginClient),
198198
createVueSfcPlugin(),
199199
createVueTwoslashQueriesPlugin(getTsPluginClient),

packages/language-service/lib/plugins/vue-template.ts

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { Disposable, LanguageServiceContext } from '@volar/language-service';
22
import { VueVirtualCode, hyphenateAttr, hyphenateTag, tsCodegen } from '@vue/language-core';
33
import { camelize, capitalize } from '@vue/shared';
4-
import { getComponentSpans } from '@vue/typescript-plugin/lib/common';
54
import type { ComponentPropInfo } from '@vue/typescript-plugin/lib/requests/getComponentProps';
65
import { create as createHtmlService } from 'volar-service-html';
76
import { create as createPugService } from 'volar-service-pug';
@@ -38,7 +37,6 @@ let modelData: html.HTMLDataV1;
3837

3938
export function create(
4039
mode: 'html' | 'pug',
41-
ts: typeof import('typescript'),
4240
getTsPluginClient?: (context: LanguageServiceContext) => import('@vue/typescript-plugin/lib/requests').Requests | undefined
4341
): LanguageServicePlugin {
4442
let customData: html.IHTMLDataProvider[] = [];
@@ -91,12 +89,6 @@ export function create(
9189
interFileDependencies: false,
9290
workspaceDiagnostics: false,
9391
},
94-
semanticTokensProvider: {
95-
legend: {
96-
tokenTypes: ['class'],
97-
tokenModifiers: [],
98-
},
99-
}
10092
},
10193
create(context) {
10294
const tsPluginClient = getTsPluginClient?.(context);
@@ -269,63 +261,6 @@ export function create(
269261
...templateErrors,
270262
];
271263
},
272-
273-
provideDocumentSemanticTokens(document, range, legend) {
274-
275-
if (!isSupportedDocument(document)) {
276-
return;
277-
}
278-
279-
if (!context.project.vue) {
280-
return;
281-
}
282-
const vueCompilerOptions = context.project.vue.compilerOptions;
283-
284-
const languageService = context.inject<(import('volar-service-typescript').Provide), 'typescript/languageService'>('typescript/languageService');
285-
if (!languageService) {
286-
return;
287-
}
288-
289-
const uri = URI.parse(document.uri);
290-
const decoded = context.decodeEmbeddedDocumentUri(uri);
291-
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
292-
const root = sourceScript?.generated?.root;
293-
if (!(root instanceof VueVirtualCode)) {
294-
return;
295-
}
296-
297-
const { template } = root.sfc;
298-
if (!template) {
299-
return;
300-
}
301-
302-
const spans = getComponentSpans.call(
303-
{
304-
files: context.language.scripts,
305-
languageService,
306-
typescript: ts,
307-
vueOptions: vueCompilerOptions,
308-
},
309-
root,
310-
template,
311-
{
312-
start: document.offsetAt(range.start),
313-
length: document.offsetAt(range.end) - document.offsetAt(range.start),
314-
}
315-
);
316-
const classTokenIndex = legend.tokenTypes.indexOf('class');
317-
318-
return spans.map(span => {
319-
const start = document.positionAt(span.start);
320-
return [
321-
start.line,
322-
start.character,
323-
span.length,
324-
classTokenIndex,
325-
0,
326-
];
327-
});
328-
},
329264
};
330265

331266
async function provideHtmlData(sourceDocumentUri: URI, vueCode: VueVirtualCode) {

packages/typescript-plugin/lib/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ function getEncodedSemanticClassifications<T>(
335335
};
336336
}
337337

338-
export function getComponentSpans(
338+
function getComponentSpans(
339339
this: Pick<RequestContext, 'typescript' | 'languageService'>,
340340
vueCode: VueVirtualCode,
341341
template: NonNullable<VueVirtualCode['_sfc']['template']>,

0 commit comments

Comments
 (0)