admin管理员组

文章数量:1125411

maybe I'm just doing something obvious wrong, as I don't have any LSP or really TS experience.

I am currently trying to implement an Language server using the vscode-languageserver/node package, but cannot get the activeParameter for the Signatures to work. (Taken from MS LSP Specifications)

This is my signatureHelp.ts:

import {
    Connection,
    SignatureHelp,
    SignatureHelpContext,
    SignatureHelpParams,
    SignatureInformation,
} from 'vscode-languageserver/node';

export function handleSignatureHelp(connection: Connection) {
    connection.onSignatureHelp((params: SignatureHelpParams): SignatureHelp | null => {
        console.log('Signature Help Params:', params);
        const signatures: SignatureInformation[] = [
            {
                label: 'set_bapi_val(bapi_string: string, kennung: string, wert: string)',
                documentation: {
                    kind: 'markdown',
                    value: 'Replaces or appends a specified entry in a BAPI string.'
                },
                parameters: [
                    { label: 'bapi_string', documentation: 'The BAPI string to modify.' },
                    { label: 'kennung', documentation: 'Identifier to replace or append.' },
                    { label: 'wert', documentation: 'Value to set.' }
                ],
            },
        ];

        const context: SignatureHelpContext | undefined = params.context;
        
        const activeSignatureIndex = context?.activeSignatureHelp?.activeSignature ?? 0;
        console.log(context?.activeSignatureHelp?.activeSignature);

        const activeParameterIndex = context?.activeSignatureHelp?.activeParameter ?? 0;
        console.log(context?.activeSignatureHelp?.activeParameter);

        return {
            signatures,
            activeSignature: activeSignatureIndex,
            activeParameter: activeParameterIndex,
        };
    });
}

But no matter what I do or try, the activeSignature and activeParameter just stay 0, no matter at what parameter I am actually at.

Image:

Am I just misinterpreting the spec or is there something else going on? My client has contextSupport and activeParameterSupport enabled.

Output:

Signature Help Params: {
  textDocument: { uri: 'file:///c%3A/Projects/awdawd.hsc' },
  position: { line: 102, character: 35 },
  context: {
    isRetrigger: true,
    triggerCharacter: ',',
    triggerKind: 2,
    activeSignatureHelp: { signatures: [Array], activeSignature: 0, activeParameter: 0 }
  }
}

According to my understanding and the specs, the highlighted parameter should dynamically change, depending on where I am on the client-side of the plugin. But for whatever reason the values just stay "undefined", always highlighting only the first entry.

Thanks

本文标签: typescriptLSP SignatureHelpactiveParameter not dynamically changingStack Overflow