feat: add getReferences
This commit is contained in:
parent
a6202c4b0b
commit
ec910c7047
9 changed files with 33 additions and 2 deletions
|
|
@ -745,6 +745,7 @@ declare global {
|
|||
|
||||
// LSP
|
||||
gotoDefinition(location: Location): Promise<RangeInFile[]>;
|
||||
getReferences(location: Location): Promise<RangeInFile[]>;
|
||||
|
||||
// Callbacks
|
||||
onDidChangeActiveTextEditor(callback: (filepath: string) => void): void;
|
||||
|
|
|
|||
1
core/index.d.ts
vendored
1
core/index.d.ts
vendored
|
|
@ -836,6 +836,7 @@ export interface IDE {
|
|||
|
||||
// LSP
|
||||
gotoDefinition(location: Location): Promise<RangeInFile[]>;
|
||||
getReferences(location: Location): Promise<RangeInFile[]>;
|
||||
|
||||
// Callbacks
|
||||
onDidChangeActiveTextEditor(callback: (fileUri: string) => void): void;
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ export type ToIdeFromWebviewOrCoreProtocol = {
|
|||
getFileStats: [{ files: string[] }, FileStatsMap];
|
||||
|
||||
gotoDefinition: [{ location: Location }, RangeInFile[]];
|
||||
getReferences: [{ location: Location }, RangeInFile[]];
|
||||
|
||||
getControlPlaneSessionInfo: [
|
||||
{ silent: boolean; useOnboarding: boolean },
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@ export class MessageIde implements IDE {
|
|||
return this.request("gotoDefinition", { location });
|
||||
}
|
||||
|
||||
async getReferences(location: Location): Promise<RangeInFile[]> {
|
||||
return this.request("getReferences", { location });
|
||||
}
|
||||
|
||||
onDidChangeActiveTextEditor(callback: (fileUri: string) => void): void {
|
||||
this.on("didChangeActiveTextEditor", (data) => callback(data.filepath));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,10 @@ class FileSystemIde implements IDE {
|
|||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
getReferences(location: Location): Promise<RangeInFile[]> {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
onDidChangeActiveTextEditor(callback: (fileUri: string) => void): void {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -592,6 +592,10 @@ class IntelliJIDE(
|
|||
throw NotImplementedError("gotoDefinition not implemented yet")
|
||||
}
|
||||
|
||||
override suspend fun getReferences(location: Location): List<RangeInFile> {
|
||||
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()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,6 +191,7 @@ interface IDE {
|
|||
|
||||
// LSP
|
||||
suspend fun gotoDefinition(location: Location): List<RangeInFile>
|
||||
suspend fun getReferences(location: Location): List<RangeInFile>
|
||||
|
||||
// Callbacks
|
||||
fun onDidChangeActiveTextEditor(callback: (filepath: String) -> Unit)
|
||||
|
|
@ -247,4 +248,4 @@ data class AcceptOrRejectDiffPayload(
|
|||
|
||||
data class ShowFilePayload(
|
||||
val filepath: String
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -86,6 +86,17 @@ class VsCodeIde implements IDE {
|
|||
return result;
|
||||
}
|
||||
|
||||
async getReferences(location: Location): Promise<RangeInFile[]> {
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue