feature: 实现点击 VCD 文件时 Surfer 显示波形
- VCDViewerEditorProvider 现在接收并持有 vcdFileServer 实例 - createFromWebviewPanel 方法传递 vcdFileServer 参数 - 确保自定义编辑器打开 VCD 文件时能够通过 HTTP 服务器加载波形数据
This commit is contained in:
@ -175,7 +175,7 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 注册 VCD 自定义编辑器
|
// 注册 VCD 自定义编辑器
|
||||||
const vcdEditorProvider = VCDViewerEditorProvider.register(context);
|
const vcdEditorProvider = VCDViewerEditorProvider.register(context, vcdFileServer);
|
||||||
|
|
||||||
// 添加到订阅
|
// 添加到订阅
|
||||||
context.subscriptions.push(
|
context.subscriptions.push(
|
||||||
|
|||||||
@ -7,8 +7,8 @@ import { VCDFileServer } from "../services/vcdFileServer";
|
|||||||
* VCD 波形查看器自定义编辑器提供者
|
* VCD 波形查看器自定义编辑器提供者
|
||||||
*/
|
*/
|
||||||
export class VCDViewerEditorProvider implements vscode.CustomReadonlyEditorProvider {
|
export class VCDViewerEditorProvider implements vscode.CustomReadonlyEditorProvider {
|
||||||
public static register(context: vscode.ExtensionContext): vscode.Disposable {
|
public static register(context: vscode.ExtensionContext, vcdFileServer: VCDFileServer): vscode.Disposable {
|
||||||
const provider = new VCDViewerEditorProvider(context);
|
const provider = new VCDViewerEditorProvider(context, vcdFileServer);
|
||||||
const providerRegistration = vscode.window.registerCustomEditorProvider(
|
const providerRegistration = vscode.window.registerCustomEditorProvider(
|
||||||
"ic-coder.vcdViewer",
|
"ic-coder.vcdViewer",
|
||||||
provider,
|
provider,
|
||||||
@ -21,7 +21,10 @@ export class VCDViewerEditorProvider implements vscode.CustomReadonlyEditorProvi
|
|||||||
return providerRegistration;
|
return providerRegistration;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private readonly context: vscode.ExtensionContext) {}
|
constructor(
|
||||||
|
private readonly context: vscode.ExtensionContext,
|
||||||
|
private readonly vcdFileServer: VCDFileServer
|
||||||
|
) {}
|
||||||
|
|
||||||
async openCustomDocument(
|
async openCustomDocument(
|
||||||
uri: vscode.Uri,
|
uri: vscode.Uri,
|
||||||
@ -48,7 +51,8 @@ export class VCDViewerEditorProvider implements vscode.CustomReadonlyEditorProvi
|
|||||||
VCDViewerPanel.createFromWebviewPanel(
|
VCDViewerPanel.createFromWebviewPanel(
|
||||||
webviewPanel,
|
webviewPanel,
|
||||||
this.context.extensionUri,
|
this.context.extensionUri,
|
||||||
document.uri.fsPath
|
document.uri.fsPath,
|
||||||
|
this.vcdFileServer
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,9 +144,10 @@ export class VCDViewerPanel {
|
|||||||
public static createFromWebviewPanel(
|
public static createFromWebviewPanel(
|
||||||
panel: vscode.WebviewPanel,
|
panel: vscode.WebviewPanel,
|
||||||
extensionUri: vscode.Uri,
|
extensionUri: vscode.Uri,
|
||||||
vcdFilePath: string
|
vcdFilePath: string,
|
||||||
|
vcdFileServer?: VCDFileServer
|
||||||
) {
|
) {
|
||||||
const viewer = new VCDViewerPanel(panel, extensionUri);
|
const viewer = new VCDViewerPanel(panel, extensionUri, vcdFileServer);
|
||||||
viewer.loadVCDFile(vcdFilePath);
|
viewer.loadVCDFile(vcdFilePath);
|
||||||
return viewer;
|
return viewer;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user