From 467a2f5ff14b92800b149c6b655f9f4309e61f95 Mon Sep 17 00:00:00 2001 From: Michelle Matias <38734287+michelleangela@users.noreply.github.com> Date: Fri, 28 Jul 2023 17:25:22 -0700 Subject: [PATCH 1/2] relative path --- .../src/LanguageServer/Providers/callHierarchyProvider.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Extension/src/LanguageServer/Providers/callHierarchyProvider.ts b/Extension/src/LanguageServer/Providers/callHierarchyProvider.ts index 15dba0f623..4b298f5720 100644 --- a/Extension/src/LanguageServer/Providers/callHierarchyProvider.ts +++ b/Extension/src/LanguageServer/Providers/callHierarchyProvider.ts @@ -230,7 +230,9 @@ export class CallHierarchyProvider implements vscode.CallHierarchyProvider { private makeVscodeCallHierarchyItem(item: CallHierarchyItem): vscode.CallHierarchyItem { const containerDetail: string = (item.detail !== "") ? `${item.detail} - ` : ""; - const fileDetail: string = `${path.basename(item.uri)} (${path.dirname(item.uri)})`; + const dirPath: string = path.relative(this.client.RootPath, path.dirname(item.uri)); + const fileDetail: string = dirPath.length === 0 ? + `${path.basename(item.uri)}` : `${path.basename(item.uri)} (${dirPath})`; return new vscode.CallHierarchyItem( item.kind, item.name, containerDetail + fileDetail, vscode.Uri.file(item.uri), From 82006f5f21e5323bfdbca609230c00eda7814302 Mon Sep 17 00:00:00 2001 From: Michelle Matias <38734287+michelleangela@users.noreply.github.com> Date: Mon, 31 Jul 2023 14:49:34 -0700 Subject: [PATCH 2/2] check workspace --- .../Providers/callHierarchyProvider.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Extension/src/LanguageServer/Providers/callHierarchyProvider.ts b/Extension/src/LanguageServer/Providers/callHierarchyProvider.ts index 4b298f5720..f6c132b41b 100644 --- a/Extension/src/LanguageServer/Providers/callHierarchyProvider.ts +++ b/Extension/src/LanguageServer/Providers/callHierarchyProvider.ts @@ -230,12 +230,21 @@ export class CallHierarchyProvider implements vscode.CallHierarchyProvider { private makeVscodeCallHierarchyItem(item: CallHierarchyItem): vscode.CallHierarchyItem { const containerDetail: string = (item.detail !== "") ? `${item.detail} - ` : ""; - const dirPath: string = path.relative(this.client.RootPath, path.dirname(item.uri)); + const itemUri: vscode.Uri = vscode.Uri.file(item.uri); + + // Get file detail + const isInWorkspace: boolean = this.client.RootUri !== undefined && + itemUri.fsPath.startsWith(this.client.RootUri?.fsPath); + const dirPath: string = isInWorkspace ? + path.relative(this.client.RootPath, path.dirname(item.uri)) : path.dirname(item.uri); const fileDetail: string = dirPath.length === 0 ? `${path.basename(item.uri)}` : `${path.basename(item.uri)} (${dirPath})`; + return new vscode.CallHierarchyItem( - item.kind, item.name, containerDetail + fileDetail, - vscode.Uri.file(item.uri), + item.kind, + item.name, + containerDetail + fileDetail, + itemUri, makeVscodeRange(item.range), makeVscodeRange(item.selectionRange)); }