Skip to content

Commit 866d41d

Browse files
committed
Allow VS Code to recognise files with "sourcekit-lsp" scheme and pass it to SourceKitLSP inorder to provide Semantic Functionality
1 parent 6acaab7 commit 866d41d

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

src/WorkspaceContext.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,10 @@ export class WorkspaceContext implements vscode.Disposable {
518518
async focusUri(uri?: vscode.Uri) {
519519
this.currentDocument = uri ?? null;
520520
this.updateContextKeysForFile();
521-
if (this.currentDocument?.scheme === "file") {
521+
if (
522+
this.currentDocument?.scheme === "file" ||
523+
this.currentDocument?.scheme === "sourcekit-lsp"
524+
) {
522525
await this.focusPackageUri(this.currentDocument);
523526
}
524527
}

src/sourcekit-lsp/LanguageClientManager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export class LanguageClientManager {
4444

4545
// document selector used by language client
4646
static appleLangDocumentSelector = [
47+
{ scheme: "sourcekit-lsp", language: "swift" },
4748
{ scheme: "file", language: "swift" },
4849
{ scheme: "untitled", language: "swift" },
4950
{ scheme: "file", language: "objective-c" },

src/sourcekit-lsp/getReferenceDocument.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function activateGetReferenceDocument(client: langclient.LanguageClient):
2222
{
2323
provideTextDocumentContent: async (uri, token) => {
2424
const params: GetReferenceDocumentParams = {
25-
uri: uri.toString(true),
25+
uri: client.code2ProtocolConverter.asUri(uri),
2626
};
2727

2828
const result = await client.sendRequest(GetReferenceDocumentRequest, params, token);

src/sourcekit-lsp/peekDocuments.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ export function activatePeekDocuments(client: langclient.LanguageClient): vscode
3232

3333
await vscode.commands.executeCommand(
3434
"editor.action.peekLocations",
35-
vscode.Uri.from({
36-
scheme: "file",
37-
path: new URL(params.uri).pathname,
38-
}),
35+
client.protocol2CodeConverter.asUri(params.uri),
3936
new vscode.Position(params.position.line, params.position.character),
4037
locations,
4138
"peek"

0 commit comments

Comments
 (0)