Skip to content

Commit

Permalink
fix: deactivate LS
Browse files Browse the repository at this point in the history
  • Loading branch information
qarlosalberto committed Oct 14, 2024
1 parent b54d1b9 commit 588edfa
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 132 deletions.
2 changes: 1 addition & 1 deletion auto_package/templates/info.nj
Original file line number Diff line number Diff line change
Expand Up @@ -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.11",
"version": "6.0.12",
"engines": {
"vscode": "^1.74.0"
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.11",
"version": "6.0.12",
"engines": {
"vscode": "^1.74.0"
},
Expand Down
27 changes: 17 additions & 10 deletions src/teroshdl/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@
import 'module-alias/register';

import * as vscode from 'vscode';
import * as release_notes_webview from "./features/utils/webview/release_notes";
import { ExtensionManager } from "./features/utils/webview/utils";
import * as release_notes_webview from './features/utils/webview/release_notes';
import { ExtensionManager } from './features/utils/webview/utils';
import { Teroshdl } from './teroshdl';
import { globalLogger, toolLogger, debugLogger } from './logger';
import {Logger} from "colibri/logger/logger";
import { Logger } from 'colibri/logger/logger';

export async function activate(context: vscode.ExtensionContext) {
console.log("hola")
let teroshdl: Teroshdl | undefined = undefined;

export async function activate(context: vscode.ExtensionContext) {
debugLogger.info('Congratulations, your extension "TerosHDL" is now active!');

const extension_manager = new ExtensionManager();

globalLogger.clear();
toolLogger.clear();
debugLogger.clear();

Logger.setLogger(debugLogger);

try {
Expand All @@ -46,11 +46,18 @@ export async function activate(context: vscode.ExtensionContext) {
if (installationType.firstInstall || installationType.update) {
await releaseNotesView.show();
}
}
catch (e) {
} catch (e) {
console.log(e);
}

const teroshdl = new Teroshdl(context);
teroshdl = new Teroshdl(context);
await teroshdl.init_teroshdl();
}

export async function deactivate() {
if (teroshdl === undefined) {
return;
}
await teroshdl.deactivate();
debugLogger.info('TerosHDL deactivated');
}
121 changes: 75 additions & 46 deletions src/teroshdl/features/language_provider/language_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,37 @@
// You should have received a copy of the GNU General Public License
// along with Teros Technology. If not, see <https://www.gnu.org/licenses/>.

import VerilogDocumentSymbolProvider from "./ctags/providers/DocumentSymbolProvider";
import VerilogHoverProvider from "./ctags/providers/HoverProvider";
import VerilogDefinitionProvider from "./ctags/providers/DefinitionProvider";
import VerilogCompletionItemProvider from "./ctags/providers/CompletionItemProvider";
import { CtagsManager } from "./ctags/ctags";
import { Logger } from "./ctags/Logger";
import VerilogDocumentSymbolProvider from './ctags/providers/DocumentSymbolProvider';
import VerilogHoverProvider from './ctags/providers/HoverProvider';
import VerilogDefinitionProvider from './ctags/providers/DefinitionProvider';
import VerilogCompletionItemProvider from './ctags/providers/CompletionItemProvider';
import { CtagsManager } from './ctags/ctags';
import { Logger } from './ctags/Logger';

import * as vscode from 'vscode';
import { Multi_project_manager } from 'colibri/project_manager/multi_project_manager';
import * as rusthdl_lib from './lsp/rust_hdl';
import * as utils from '../utils/utils';

export type e_provider = {
'completion': any,
'doc': any,
'hover': any,
'def': any
completion: any;
doc: any;
hover: any;
def: any;
};
export class LanguageProviderManager {
private manager: Multi_project_manager;
private ctagsManager: CtagsManager | undefined;

private provider_list: e_provider;
private context : vscode.ExtensionContext;
private context: vscode.ExtensionContext;

private rusthdl: rusthdl_lib.Rusthdl_lsp | undefined;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor(context: vscode.ExtensionContext, manager: Multi_project_manager) {

this.context = context;
this.manager = manager;

Expand All @@ -61,16 +62,16 @@ export class LanguageProviderManager {
const hover_provider = new VerilogHoverProvider(logger);
const def_provider = new VerilogDefinitionProvider(logger);

const provider_list : e_provider = {
'completion': comp_item_provider,
'doc': doc_provider,
'hover': hover_provider,
'def': def_provider
const provider_list: e_provider = {
completion: comp_item_provider,
doc: doc_provider,
hover: hover_provider,
def: def_provider
};
this.provider_list = provider_list;
}

public async configure(){
public async configure() {
// VHDL
this.configure_vhdl();

Expand All @@ -80,76 +81,104 @@ export class LanguageProviderManager {
// TCL
this.configure_tcl();

this.context.subscriptions.push(vscode.workspace.onDidSaveTextDocument((doc) => { this.provider_list.doc.onSave(doc); }));
this.context.subscriptions.push(
vscode.workspace.onDidSaveTextDocument((doc) => {
this.provider_list.doc.onSave(doc);
})
);
}

/////////////////////////////////////////////////////////////////////////////////////////
// TCL
/////////////////////////////////////////////////////////////////////////////////////////
private configure_tcl(){
private configure_tcl() {
const tcl_selector: vscode.DocumentSelector = { scheme: 'file', language: 'tcl' };
this.context.subscriptions.push(vscode.languages.registerCompletionItemProvider(tcl_selector, this.provider_list.completion, ".", "(", "="));
this.context.subscriptions.push(vscode.languages.registerDocumentSymbolProvider(tcl_selector, this.provider_list.doc));
this.context.subscriptions.push(
vscode.languages.registerCompletionItemProvider(tcl_selector, this.provider_list.completion, '.', '(', '=')
);
this.context.subscriptions.push(
vscode.languages.registerDocumentSymbolProvider(tcl_selector, this.provider_list.doc)
);
this.context.subscriptions.push(vscode.languages.registerHoverProvider(tcl_selector, this.provider_list.doc));
this.context.subscriptions.push(vscode.languages.registerDefinitionProvider(tcl_selector, this.provider_list.doc));
this.context.subscriptions.push(
vscode.languages.registerDefinitionProvider(tcl_selector, this.provider_list.doc)
);
}

/////////////////////////////////////////////////////////////////////////////////////////
// VHDL
/////////////////////////////////////////////////////////////////////////////////////////
private async configure_vhdl(){
private async configure_vhdl() {
const vhdlSelector: vscode.DocumentSelector = { scheme: 'file', language: 'vhdl' };
this.context.subscriptions.push(vscode.languages.registerCompletionItemProvider(vhdlSelector, this.provider_list.completion, ".", "(", "="));
this.context.subscriptions.push(
vscode.languages.registerCompletionItemProvider(vhdlSelector, this.provider_list.completion, '.', '(', '=')
);
// Symbol provider
this.context.subscriptions.push(vscode.languages.registerDocumentSymbolProvider(vhdlSelector, this.provider_list.doc));
this.context.subscriptions.push(
vscode.languages.registerDocumentSymbolProvider(vhdlSelector, this.provider_list.doc)
);

// Language server
let is_alive = false;
let rusthdl;

const config = utils.getConfig(this.manager);

const enable_vhdl_provider = config.general.general.go_to_definition_vhdl;
if (enable_vhdl_provider === true) {
rusthdl = new rusthdl_lib.Rusthdl_lsp(this.context, this.manager);
is_alive = await rusthdl.run_rusthdl();
}
else {
this.context.subscriptions.push(
vscode.commands.registerCommand('teroshdl.vhdlls.restart', async () => {
})
);
this.rusthdl = new rusthdl_lib.Rusthdl_lsp(this.context, this.manager);
is_alive = await this.rusthdl.run_rusthdl();
} else {
this.context.subscriptions.push(vscode.commands.registerCommand('teroshdl.vhdlls.restart', async () => {}));
}

if (is_alive === false && enable_vhdl_provider === true) {
this.context.subscriptions.push(vscode.languages.registerHoverProvider(vhdlSelector, this.provider_list.hover));
this.context.subscriptions.push(vscode.languages.registerDefinitionProvider(vhdlSelector, this.provider_list.def));
this.context.subscriptions.push(
vscode.languages.registerHoverProvider(vhdlSelector, this.provider_list.hover)
);
this.context.subscriptions.push(
vscode.languages.registerDefinitionProvider(vhdlSelector, this.provider_list.def)
);
}
}

/////////////////////////////////////////////////////////////////////////////////////////
// Verilog
/////////////////////////////////////////////////////////////////////////////////////////
private configure_verilog(){
private configure_verilog() {
let verilogSelector: vscode.DocumentSelector = [
{ scheme: 'file', language: 'verilog' },
{ scheme: 'file', language: 'systemverilog' }
];
// Completion
this.context.subscriptions.push(vscode.languages.registerCompletionItemProvider(verilogSelector,
this.provider_list.completion, ".", "(", "="));
this.context.subscriptions.push(
vscode.languages.registerCompletionItemProvider(
verilogSelector,
this.provider_list.completion,
'.',
'(',
'='
)
);
// Symbol
this.context.subscriptions.push(vscode.languages.registerDocumentSymbolProvider(verilogSelector,
this.provider_list.doc));
this.context.subscriptions.push(
vscode.languages.registerDocumentSymbolProvider(verilogSelector, this.provider_list.doc)
);

const config = utils.getConfig(this.manager);
const enable_verilog_provider = config.general.general.go_to_definition_verilog;
if (enable_verilog_provider === true) {
this.context.subscriptions.push(vscode.languages.registerHoverProvider(verilogSelector,
this.provider_list.hover));
this.context.subscriptions.push(vscode.languages.registerDefinitionProvider(verilogSelector,
this.provider_list.def));
this.context.subscriptions.push(
vscode.languages.registerHoverProvider(verilogSelector, this.provider_list.hover)
);
this.context.subscriptions.push(
vscode.languages.registerDefinitionProvider(verilogSelector, this.provider_list.def)
);
}
}

public async deactivate() {
if (this.rusthdl !== undefined) {
await this.rusthdl.deactivate();
}
}
}
Loading

0 comments on commit 588edfa

Please sign in to comment.