-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retrieve macro expansions for
PeekDocumentsRequest
through `GetRefe…
…renceDocumentRequest` instead of showing temporary files (#971)
- Loading branch information
Showing
4 changed files
with
75 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// 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 { GetReferenceDocumentParams, GetReferenceDocumentRequest } from "./lspExtensions"; | ||
|
||
export function activateGetReferenceDocument(client: langclient.LanguageClient): vscode.Disposable { | ||
const getReferenceDocument = vscode.workspace.registerTextDocumentContentProvider( | ||
"sourcekit-lsp", | ||
{ | ||
provideTextDocumentContent: async (uri, token) => { | ||
const params: GetReferenceDocumentParams = { | ||
uri: uri.toString(true), | ||
}; | ||
|
||
const result = await client.sendRequest(GetReferenceDocumentRequest, params, token); | ||
|
||
if (result) { | ||
return result.content; | ||
} else { | ||
return "Unable to retrieve reference document"; | ||
} | ||
}, | ||
} | ||
); | ||
|
||
return getReferenceDocument; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters