-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathgetReferenceDocument.ts
49 lines (44 loc) · 1.55 KB
/
getReferenceDocument.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//===----------------------------------------------------------------------===//
//
// This source file is part of the VS Code Swift open source project
//
// Copyright (c) 2024 the VS Code Swift project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of VS Code Swift project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import * as vscode from "vscode";
import * as langclient from "vscode-languageclient/node";
import {
LegacyGetReferenceDocumentParams,
LegacyGetReferenceDocumentRequest,
} from "./lspExtensions";
export function activateLegacyGetReferenceDocument(
client: langclient.LanguageClient
): vscode.Disposable {
const getReferenceDocument = vscode.workspace.registerTextDocumentContentProvider(
"sourcekit-lsp",
{
provideTextDocumentContent: async (uri, token) => {
const params: LegacyGetReferenceDocumentParams = {
uri: client.code2ProtocolConverter.asUri(uri),
};
const result = await client.sendRequest(
LegacyGetReferenceDocumentRequest,
params,
token
);
if (result) {
return result.content;
} else {
return "Unable to retrieve reference document";
}
},
}
);
return getReferenceDocument;
}