✨ feat(lsp_server): implement missing providers and json coverage
Implement workspace configuration/folders and apply WorkspaceEdit.changes. Strengthen provider JSON coverage (all methods require params, no errors). Verified: Release test_provider
This commit is contained in:
+47
-2
@@ -3,7 +3,7 @@ import * as vscode from 'vscode'
|
||||
import * as fs from 'fs'
|
||||
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind } from 'vscode-languageclient/node'
|
||||
|
||||
let client: LanguageClient
|
||||
let client: LanguageClient | undefined
|
||||
|
||||
function findInSystemPath(binary: string): string | null {
|
||||
const pathDirs = process.env.PATH?.split(path.delimiter) || []
|
||||
@@ -37,6 +37,48 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
const config = vscode.workspace.getConfiguration('tsl')
|
||||
let serverArguments = config.get<string[]>('server.arguments') || []
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand('tsl.showReferences', async (data?: any) => {
|
||||
if (!data || typeof data !== 'object') {
|
||||
vscode.window.showErrorMessage('TSL: invalid reference payload')
|
||||
return
|
||||
}
|
||||
|
||||
const uriValue = (data as any).uri
|
||||
const positionValue = (data as any).position
|
||||
if (typeof uriValue !== 'string' || !positionValue || typeof positionValue !== 'object') {
|
||||
vscode.window.showErrorMessage('TSL: missing uri/position in reference payload')
|
||||
return
|
||||
}
|
||||
|
||||
const line = (positionValue as any).line
|
||||
const character = (positionValue as any).character
|
||||
if (typeof line !== 'number' || typeof character !== 'number') {
|
||||
vscode.window.showErrorMessage('TSL: invalid position in reference payload')
|
||||
return
|
||||
}
|
||||
|
||||
if (client && !client.isRunning()) {
|
||||
await client.start()
|
||||
}
|
||||
|
||||
const uri = vscode.Uri.parse(uriValue)
|
||||
const position = new vscode.Position(line, character)
|
||||
const locations = await vscode.commands.executeCommand<vscode.Location[]>(
|
||||
'vscode.executeReferenceProvider',
|
||||
uri,
|
||||
position
|
||||
)
|
||||
|
||||
if (!locations || locations.length === 0) {
|
||||
vscode.window.showInformationMessage('TSL: no references found')
|
||||
return
|
||||
}
|
||||
|
||||
await vscode.commands.executeCommand('editor.action.showReferences', uri, position, locations)
|
||||
})
|
||||
)
|
||||
|
||||
const serverBinary = process.platform === 'win32' ? 'tsl-server.exe' : 'tsl-server'
|
||||
let serverExe = findExecutable(
|
||||
context,
|
||||
@@ -86,7 +128,10 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
const clientOptions: LanguageClientOptions = {
|
||||
documentSelector: [{ scheme: 'file', language: 'tsl' }],
|
||||
synchronize: {
|
||||
fileEvents: vscode.workspace.createFileSystemWatcher('**/*.tsl')
|
||||
fileEvents: [
|
||||
vscode.workspace.createFileSystemWatcher('**/*.tsl'),
|
||||
vscode.workspace.createFileSystemWatcher('**/*.tsf')
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user