Skip to content

Commit d131215

Browse files
authored
Allow VS Code to recognise files with "sourcekit-lsp" scheme and pass it to SourceKitLSP inorder to provide Semantic Functionality (#990)
1 parent 0747917 commit d131215

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

Diff for: src/WorkspaceContext.ts

+4-1
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
}

Diff for: src/sourcekit-lsp/LanguageClientManager.ts

+1
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" },

Diff for: src/sourcekit-lsp/getReferenceDocument.ts

+1-1
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);

Diff for: src/sourcekit-lsp/peekDocuments.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ export function activatePeekDocuments(client: langclient.LanguageClient): vscode
2121
PeekDocumentsRequest.method,
2222
async (params: PeekDocumentsParams) => {
2323
const locations = params.locations.map(uri => {
24-
const url = new URL(uri);
2524
const location = new vscode.Location(
26-
vscode.Uri.parse(url.href, true),
25+
client.protocol2CodeConverter.asUri(uri),
2726
new vscode.Position(0, 0)
2827
);
2928

@@ -32,10 +31,7 @@ export function activatePeekDocuments(client: langclient.LanguageClient): vscode
3231

3332
await vscode.commands.executeCommand(
3433
"editor.action.peekLocations",
35-
vscode.Uri.from({
36-
scheme: "file",
37-
path: new URL(params.uri).pathname,
38-
}),
34+
client.protocol2CodeConverter.asUri(params.uri),
3935
new vscode.Position(params.position.line, params.position.character),
4036
locations,
4137
"peek"

0 commit comments

Comments
 (0)