Skip to content

Conversation

@johnsoncodehk
Copy link
Member

CSS classes, template slots references codeLens no longer works since 2.0, in order to support it again we need to add a find references request for the TS plugin's name piped server, I currently have trouble finding the time to implement it, so we have temporarily removed references codeLens.

When re-implementing in the future, the following language service plugin will be needed.

import type { LanguageServicePlugin, LanguageServicePluginInstance } from '@volar/language-service'; import { VueVirtualCode } from '@vue/language-core'; import type * as vscode from 'vscode-languageserver-protocol'; export function create(): LanguageServicePlugin { return { name: 'vue-codelens-references', create(context): LanguageServicePluginInstance { return { provideReferencesCodeLensRanges(document) { const decoded = context.decodeEmbeddedDocumentUri(document.uri); const sourceScript = decoded && context.language.scripts.get(decoded[0]); const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]); if (sourceScript?.generated?.root instanceof VueVirtualCode && virtualCode?.id.startsWith('style_')) { const result: vscode.Range[] = []; const styleIndex = parseInt(virtualCode.id.split('_')[1]); const style = sourceScript.generated.root.sfc.styles[styleIndex]; for (const className of style.classNames) { const start = document.positionAt(className.offset); const end = document.positionAt(className.offset + className.text.length); result.push({	start,	end, }); } return result; } }, }; }, }; }
@johnsoncodehk johnsoncodehk changed the title feat(language-service): temporarily remove references codeLens refactor(language-service): temporarily remove references codeLens May 10, 2024
@johnsoncodehk johnsoncodehk merged commit 999ff01 into master May 10, 2024
@johnsoncodehk johnsoncodehk deleted the remove-references-code-lens branch May 10, 2024 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants