vscode-languageclient#Code2ProtocolConverter TypeScript Examples

The following examples show how to use vscode-languageclient#Code2ProtocolConverter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: converters.ts    From vscode-lean4 with Apache License 2.0 6 votes vote down vote up
export function patchConverters(p2cConverter: Protocol2CodeConverter, c2pConverter: Code2ProtocolConverter) {
    // eslint-disable-next-line @typescript-eslint/unbound-method
    const oldAsDiagnostic = p2cConverter.asDiagnostic
    p2cConverter.asDiagnostic = function (protDiag: Lean4Diagnostic): code.Diagnostic {
        if (!protDiag.message) {
            // Fixes: Notification handler 'textDocument/publishDiagnostics' failed with message: message must be set
            protDiag.message = ' ';
        }
        const diag = oldAsDiagnostic.apply(this, [protDiag])
        diag.fullRange = p2cConverter.asRange(protDiag.fullRange)
        return diag
    }
    p2cConverter.asDiagnostics = async (diags) => diags.map(d => p2cConverter.asDiagnostic(d))


    // eslint-disable-next-line @typescript-eslint/unbound-method
    const c2pAsDiagnostic = c2pConverter.asDiagnostic
    c2pConverter.asDiagnostic = function (diag: code.Diagnostic & {fullRange: code.Range}): Lean4Diagnostic {
        const protDiag = c2pAsDiagnostic.apply(this, [diag])
        protDiag.fullRange = c2pConverter.asRange(diag.fullRange)
        return protDiag
    }
    c2pConverter.asDiagnostics = async (diags) => diags.map(d => c2pConverter.asDiagnostic(d))
}