From f1314cfb180560d56f773bf4f1333239366ec911 Mon Sep 17 00:00:00 2001 From: qarlosalberto Date: Sun, 29 Sep 2024 13:32:02 +0200 Subject: [PATCH] feat: use path for base view --- auto_package/templates/info.nj | 2 +- package.json | 2 +- src/colibri/config/config_web.ts | 2 +- .../config/helpers/configs/schematic.yml | 2 +- src/colibri/config/web_config.html | 2 +- src/teroshdl/features/base_webview.ts | 6 +++--- src/teroshdl/features/documenter.ts | 17 ++++++++++------- src/teroshdl/features/schematic.ts | 18 ++++++++++-------- src/teroshdl/features/state_machine.ts | 16 ++++++++++------ .../features/tree_views/dependency/manager.ts | 2 +- 10 files changed, 39 insertions(+), 30 deletions(-) diff --git a/auto_package/templates/info.nj b/auto_package/templates/info.nj index 518f4184..695d5a48 100644 --- a/auto_package/templates/info.nj +++ b/auto_package/templates/info.nj @@ -2,7 +2,7 @@ "displayName": "TerosHDL", "publisher": "teros-technology", "description": "Powerful toolbox for ASIC/FPGA: state machine viewer, linter, documentation, snippets... and more! ", -"version": "6.0.8", +"version": "6.0.9", "engines": { "vscode": "^1.74.0" }, diff --git a/package.json b/package.json index 8b59cd03..a6247ddd 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "TerosHDL", "publisher": "teros-technology", "description": "Powerful toolbox for ASIC/FPGA: state machine viewer, linter, documentation, snippets... and more! ", - "version": "6.0.8", + "version": "6.0.9", "engines": { "vscode": "^1.74.0" }, diff --git a/src/colibri/config/config_web.ts b/src/colibri/config/config_web.ts index 1aeabf8b..c5e2c74c 100755 --- a/src/colibri/config/config_web.ts +++ b/src/colibri/config/config_web.ts @@ -1485,7 +1485,7 @@ export const WEB_CONFIG = `
diff --git a/src/colibri/config/helpers/configs/schematic.yml b/src/colibri/config/helpers/configs/schematic.yml index 613f68b2..13bc82f6 100644 --- a/src/colibri/config/helpers/configs/schematic.yml +++ b/src/colibri/config/helpers/configs/schematic.yml @@ -9,7 +9,7 @@ backend: value: "yowasp" extra: - description: "Extra options passed before to run yowasp-yosys. Eg: conda activate base & " + description: "Extra options passed before to run yowasp-yosys or yosys. Eg: 'conda activate base & ' or 'C:/OSS-CAD-SUITE/oss-cad-suite/start.bat & '" type: string value: "" diff --git a/src/colibri/config/web_config.html b/src/colibri/config/web_config.html index 64386696..9a679fdc 100644 --- a/src/colibri/config/web_config.html +++ b/src/colibri/config/web_config.html @@ -1464,7 +1464,7 @@
diff --git a/src/teroshdl/features/base_webview.ts b/src/teroshdl/features/base_webview.ts index 8d3ebe8c..b7438f25 100644 --- a/src/teroshdl/features/base_webview.ts +++ b/src/teroshdl/features/base_webview.ts @@ -46,8 +46,8 @@ export abstract class Base_webview { context.subscriptions.push( vscode.commands.registerCommand( activation_command, - async () => { - await this.create_webview(); + async (documentUri: vscode.Uri) => { + await this.create_webview(documentUri.fsPath); } ), vscode.workspace.onDidOpenTextDocument((e) => this.update_open_document(e)), @@ -59,7 +59,7 @@ export abstract class Base_webview { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Abstract //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - abstract create_webview(): void; + abstract create_webview(documentPath: string): void; abstract update(vscode_document : utils.t_vscode_document): void; abstract get_webview_content(webview: vscode.Webview): string; diff --git a/src/teroshdl/features/documenter.ts b/src/teroshdl/features/documenter.ts index 0c4a25e1..ea12e5f6 100644 --- a/src/teroshdl/features/documenter.ts +++ b/src/teroshdl/features/documenter.ts @@ -28,6 +28,8 @@ import { globalLogger } from '../logger'; import { Documenter } from 'colibri/documenter/documenter'; import { doc_output_type } from 'colibri/documenter/common'; import { t_documenter_options } from 'colibri/config/auxiliar_config'; +import { check_if_hdl_file } from 'colibri/utils/hdl_utils'; +import { get_language_from_filepath, read_file_sync } from 'colibri/utils/file_utils'; export class Documenter_manager extends Base_webview { @@ -69,13 +71,14 @@ export class Documenter_manager extends Base_webview { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Webview creator //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - async create_webview() { - // Get active editor file language. Return if no active editor - const document = utils.get_vscode_active_document(); - if (document === undefined) { - return; - } - + async create_webview(documentPath: string) { + const document: utils.t_vscode_document = { + filename: documentPath, + is_hdl: check_if_hdl_file(documentPath), + lang: get_language_from_filepath(documentPath), + code: read_file_sync(documentPath) + }; + if (this.panel === undefined) { this.panel = vscode.window.createWebviewPanel( 'catCoding', diff --git a/src/teroshdl/features/schematic.ts b/src/teroshdl/features/schematic.ts index a2a615cd..b3da939f 100644 --- a/src/teroshdl/features/schematic.ts +++ b/src/teroshdl/features/schematic.ts @@ -26,9 +26,9 @@ import * as os from 'os'; import * as fs from 'fs'; import * as nunjucks from 'nunjucks'; import { globalLogger } from '../logger'; -import { check_if_path_exist, get_default_version_for_filepath, get_language_from_filepath } from 'colibri/utils/file_utils'; +import { check_if_path_exist, get_default_version_for_filepath, get_language_from_filepath, read_file_sync } from 'colibri/utils/file_utils'; import { e_source_type, t_file } from 'colibri/project_manager/common'; -import { get_toplevel_from_path } from 'colibri/utils/hdl_utils'; +import { check_if_hdl_file, get_toplevel_from_path } from 'colibri/utils/hdl_utils'; import { e_schematic_result, getSchematic } from 'colibri/yosys/yosys'; import { e_schematic_general_backend } from 'colibri/config/config_declaration'; @@ -94,7 +94,7 @@ export class Schematic_manager extends Base_webview { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Webview creator //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - async create_webview(mode_project = false) { + async create_webview(documentPath: string) { // Create panel this.panel = vscode.window.createWebviewPanel( 'netlist_viewer', @@ -129,11 +129,13 @@ export class Schematic_manager extends Base_webview { this.panel.webview.html = this.get_webview_content(this.panel.webview); - if (mode_project === false) { - const document = utils.get_vscode_active_document(); - if (document === undefined) { - return; - } + if (documentPath != "") { + const document: utils.t_vscode_document = { + filename: documentPath, + is_hdl: check_if_hdl_file(documentPath), + lang: get_language_from_filepath(documentPath), + code: read_file_sync(documentPath) + }; await this.update(document); } else { diff --git a/src/teroshdl/features/state_machine.ts b/src/teroshdl/features/state_machine.ts index 4eface4e..558bb313 100644 --- a/src/teroshdl/features/state_machine.ts +++ b/src/teroshdl/features/state_machine.ts @@ -26,6 +26,8 @@ import { Base_webview } from './base_webview'; import { globalLogger } from '../logger'; import { Multi_project_manager } from 'colibri/project_manager/multi_project_manager'; import { t_documenter_options } from 'colibri/config/auxiliar_config'; +import { check_if_hdl_file } from 'colibri/utils/hdl_utils'; +import {get_language_from_filepath, read_file_sync} from 'colibri/utils/file_utils'; import { Documenter } from 'colibri/documenter/documenter'; export class State_machine_manager extends Base_webview { @@ -79,12 +81,14 @@ export class State_machine_manager extends Base_webview { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Webview creator //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - async create_webview() { - // Get active editor file language. Return if no active editor - const document = utils.get_vscode_active_document(); - if (document === undefined) { - return; - } + async create_webview(documentPath: string) { + + const document: utils.t_vscode_document = { + filename: documentPath, + is_hdl: check_if_hdl_file(documentPath), + lang: get_language_from_filepath(documentPath), + code: read_file_sync(documentPath) + }; this.panel = vscode.window.createWebviewPanel( 'state_machine_viewer', diff --git a/src/teroshdl/features/tree_views/dependency/manager.ts b/src/teroshdl/features/tree_views/dependency/manager.ts index fe522f88..fdd8320c 100644 --- a/src/teroshdl/features/tree_views/dependency/manager.ts +++ b/src/teroshdl/features/tree_views/dependency/manager.ts @@ -60,7 +60,7 @@ export class TreeDependencyManager extends BaseView{ } open_schematic_viewer(){ - this.schematic_manager.create_webview(true); + this.schematic_manager.create_webview(""); } open_dependencies_viewer(){