diff --git a/core/config/types.ts b/core/config/types.ts index 406f40ddd..25ae3247a 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -745,6 +745,7 @@ declare global { // LSP gotoDefinition(location: Location): Promise; + getReferences(location: Location): Promise; // Callbacks onDidChangeActiveTextEditor(callback: (filepath: string) => void): void; diff --git a/core/index.d.ts b/core/index.d.ts index e211c824e..8c7b2c1a6 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -836,6 +836,7 @@ export interface IDE { // LSP gotoDefinition(location: Location): Promise; + getReferences(location: Location): Promise; // Callbacks onDidChangeActiveTextEditor(callback: (fileUri: string) => void): void; diff --git a/core/protocol/ide.ts b/core/protocol/ide.ts index ba4cf4f88..ed108ba9b 100644 --- a/core/protocol/ide.ts +++ b/core/protocol/ide.ts @@ -82,6 +82,7 @@ export type ToIdeFromWebviewOrCoreProtocol = { getFileStats: [{ files: string[] }, FileStatsMap]; gotoDefinition: [{ location: Location }, RangeInFile[]]; + getReferences: [{ location: Location }, RangeInFile[]]; getControlPlaneSessionInfo: [ { silent: boolean; useOnboarding: boolean }, diff --git a/core/protocol/messenger/messageIde.ts b/core/protocol/messenger/messageIde.ts index 30d9b8177..de1ed3ecc 100644 --- a/core/protocol/messenger/messageIde.ts +++ b/core/protocol/messenger/messageIde.ts @@ -45,6 +45,10 @@ export class MessageIde implements IDE { return this.request("gotoDefinition", { location }); } + async getReferences(location: Location): Promise { + return this.request("getReferences", { location }); + } + onDidChangeActiveTextEditor(callback: (fileUri: string) => void): void { this.on("didChangeActiveTextEditor", (data) => callback(data.filepath)); } diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index f415e5e86..254bbe28a 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -44,6 +44,10 @@ class FileSystemIde implements IDE { return Promise.resolve([]); } + getReferences(location: Location): Promise { + return Promise.resolve([]); + } + onDidChangeActiveTextEditor(callback: (fileUri: string) => void): void { return; } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt index 2dfc3e3e1..1ce14b3fd 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt @@ -592,6 +592,10 @@ class IntelliJIDE( throw NotImplementedError("gotoDefinition not implemented yet") } + override suspend fun getReferences(location: Location): List { + throw NotImplementedError("getReferences not implemented yet") + } + override fun onDidChangeActiveTextEditor(callback: (filepath: String) -> Unit) { throw NotImplementedError("onDidChangeActiveTextEditor not implemented yet") } @@ -622,4 +626,4 @@ class IntelliJIDE( return listOfNotNull(project.guessProjectDir()?.toUriOrNull()).toTypedArray() } -} \ No newline at end of file +} diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt index 5ff9e9454..4e6c6c771 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt @@ -191,6 +191,7 @@ interface IDE { // LSP suspend fun gotoDefinition(location: Location): List + suspend fun getReferences(location: Location): List // Callbacks fun onDidChangeActiveTextEditor(callback: (filepath: String) -> Unit) @@ -247,4 +248,4 @@ data class AcceptOrRejectDiffPayload( data class ShowFilePayload( val filepath: String -) \ No newline at end of file +) diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index 91fb6154b..97c48f174 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -86,6 +86,17 @@ class VsCodeIde implements IDE { return result; } + async getReferences(location: Location): Promise { + const result = await executeGotoProvider({ + uri: vscode.Uri.parse(location.filepath), + line: location.position.line, + character: location.position.character, + name: "vscode.executeReferenceProvider", + }); + + return result; + } + onDidChangeActiveTextEditor(callback: (uri: string) => void): void { vscode.window.onDidChangeActiveTextEditor((editor) => { if (editor) { diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 430c4fff1..7f9158da5 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -390,6 +390,10 @@ export class VsCodeMessenger { return await ide.gotoDefinition(msg.data.location); }); + this.onWebviewOrCore("getReferences", async (msg) => { + return await ide.getReferences(msg.data.location); + }); + this.onWebviewOrCore("getFileStats", async (msg) => { return await ide.getFileStats(msg.data.files); });