| 1397 | } |
| 1398 | |
| 1399 | class SignatureHelpFeature extends TextDocumentFeature<SignatureHelpRegistrationOptions> { |
| 1400 | |
| 1401 | constructor(client: BaseLanguageClient) { |
| 1402 | super(client, SignatureHelpRequest.type); |
| 1403 | } |
| 1404 | |
| 1405 | public fillClientCapabilities(capabilites: ClientCapabilities): void { |
| 1406 | let config = ensure(ensure(capabilites, 'textDocument')!, 'signatureHelp')!; |
| 1407 | config.dynamicRegistration = true; |
| 1408 | config.signatureInformation = { documentationFormat: [MarkupKind.Markdown, MarkupKind.PlainText] }; |
| 1409 | } |
| 1410 | |
| 1411 | public initialize(capabilities: ServerCapabilities, documentSelector: DocumentSelector): void { |
| 1412 | if (!capabilities.signatureHelpProvider || !documentSelector) { |
| 1413 | return; |
| 1414 | } |
| 1415 | this.register(this.messages, { |
| 1416 | id: UUID.generateUuid(), |
| 1417 | registerOptions: Object.assign({}, { documentSelector: documentSelector }, capabilities.signatureHelpProvider) |
| 1418 | }); |
| 1419 | } |
| 1420 | |
| 1421 | protected registerLanguageProvider(options: SignatureHelpRegistrationOptions): Disposable { |
| 1422 | let client = this._client; |
| 1423 | let providerSignatureHelp: ProvideSignatureHelpSignature = (document, position, token) => { |
| 1424 | return client.sendRequest(SignatureHelpRequest.type, client.code2ProtocolConverter.asTextDocumentPositionParams(document, position), token).then( |
| 1425 | client.protocol2CodeConverter.asSignatureHelp, |
| 1426 | (error) => { |
| 1427 | client.logFailedRequest(SignatureHelpRequest.type, error); |
| 1428 | return Promise.resolve(null); |
| 1429 | } |
| 1430 | ); |
| 1431 | }; |
| 1432 | let middleware = client.clientOptions.middleware!; |
| 1433 | let triggerCharacters = options.triggerCharacters || []; |
| 1434 | return Languages.registerSignatureHelpProvider(options.documentSelector!, { |
| 1435 | provideSignatureHelp: (document: TextDocument, position: VPosition, token: CancellationToken): ProviderResult<VSignatureHelp> => { |
| 1436 | return middleware.provideSignatureHelp |
| 1437 | ? middleware.provideSignatureHelp(document, position, token, providerSignatureHelp) |
| 1438 | : providerSignatureHelp(document, position, token); |
| 1439 | } |
| 1440 | }, ...triggerCharacters); |
| 1441 | } |
| 1442 | } |
| 1443 | |
| 1444 | class DefinitionFeature extends TextDocumentFeature<TextDocumentRegistrationOptions> { |
| 1445 |
nothing calls this directly
no outgoing calls
no test coverage detected