上线新的后端

This commit is contained in:
锦恢 2024-09-22 21:40:02 +08:00
parent b16595bd81
commit 5cafbc67a6
5 changed files with 98 additions and 16 deletions

View File

@ -51,7 +51,7 @@ async function callParser(path, func) {
// console.log(res); // console.log(res);
debug.compute += Date.now() - s3; debug.compute += Date.now() - s3;
console.log(path, debug); // console.log(path, debug);
return JSON.parse(res); return JSON.parse(res);
} catch (error) { } catch (error) {
console.log(`errors happen when call wasm, path: ${path}, errors: ${error}, input params: (${path}, ${func})`); console.log(`errors happen when call wasm, path: ${path}, errors: ${error}, input params: (${path}, ${func})`);

View File

@ -12,8 +12,6 @@ import * as lspClient from './function/lsp-client';
async function registerCommand(context: vscode.ExtensionContext) { async function registerCommand(context: vscode.ExtensionContext) {
manager.registerManagerCommands(context);
func.registerFunctionCommands(context); func.registerFunctionCommands(context);
func.registerLsp(context); func.registerLsp(context);
func.registerToolCommands(context); func.registerToolCommands(context);
@ -28,15 +26,25 @@ async function registerCommand(context: vscode.ExtensionContext) {
async function launch(context: vscode.ExtensionContext) { async function launch(context: vscode.ExtensionContext) {
await vscode.window.withProgress({
location: vscode.ProgressLocation.Window,
title: 'Register Command (Digtial-IDE)'
}, async () => {
await registerCommand(context);
});
await vscode.window.withProgress({ await vscode.window.withProgress({
location: vscode.ProgressLocation.Window, location: vscode.ProgressLocation.Window,
title: 'Initialization (Digtial-IDE)' title: 'Initialization (Digtial-IDE)'
}, async () => { }, async () => {
await manager.prjManage.initialise(context); await manager.prjManage.initialise(context);
await registerCommand(context); manager.registerManagerCommands(context);
hdlMonitor.start(); hdlMonitor.start();
}); });
MainOutput.report('Digital-IDE has launched, Version: 0.3.3', ReportType.Launch); MainOutput.report('Digital-IDE has launched, Version: 0.3.3', ReportType.Launch);
MainOutput.report('OS: ' + opeParam.os, ReportType.Launch); MainOutput.report('OS: ' + opeParam.os, ReportType.Launch);

View File

@ -1,4 +1,6 @@
import * as vscode from 'vscode';
import { LanguageClient, RequestType, ProtocolConnection } from 'vscode-languageclient/node'; import { LanguageClient, RequestType, ProtocolConnection } from 'vscode-languageclient/node';
import { Fast } from '../../resources/hdlParser';
interface IDigitalIDELspClient { interface IDigitalIDELspClient {
@ -11,4 +13,29 @@ export const LspClient: IDigitalIDELspClient = {
VhdlClient: undefined VhdlClient: undefined
}; };
export const CustomRequestType = new RequestType<string[], void, void>('custom/request'); /**
* @description
* RequestType<P, R, E, RO>
* P: 请求的参数类型
* R: 请求的响应类型
* E: 请求的错误类型
* RO: 请求的可选参数类型
*/
export const CustomRequestType = new RequestType<void, number, void>('custom/request');
export const CustomParamRequestType = new RequestType<ICommonParam, number, void>('custom/paramRequest');
export const DoFastRequestType = new RequestType('api/fast');
export interface ITextDocumentItem {
uri: vscode.Uri,
languageId: string,
version: number,
text: string
}
export interface ICommonParam {
param: string
}
export interface IDoFastParam {
}

View File

@ -227,10 +227,9 @@ class HdlParam {
private async doHdlFast(path: AbsPath) { private async doHdlFast(path: AbsPath) {
try { try {
// TODO: make this quick const fast = await HdlSymbol.fast(path);
const fast = await HdlSymbol.fast(path);
if (fast) { if (fast) {
const languageId = this.alignLanguageId(fast.languageId); const languageId = hdlFile.getLanguageId(path);
new HdlFile(path, new HdlFile(path,
languageId, languageId,
fast.macro, fast.macro,
@ -248,13 +247,12 @@ class HdlParam {
} }
} }
public async initialize(hdlFiles: AbsPath[] | Generator<AbsPath>) { public async initialize(hdlFiles: AbsPath[] | Generator<AbsPath>) {
await this.initHdlFiles(hdlFiles);
// await this.initHdlFiles(hdlFiles); for (const hdlFile of this.getAllHdlFiles()) {
hdlFile.makeInstance();
// for (const hdlFile of this.getAllHdlFiles()) { }
// hdlFile.makeInstance();
// }
} }
public getTopModulesByType(type: string): HdlModule[] { public getTopModulesByType(type: string): HdlModule[] {

View File

@ -1,9 +1,53 @@
import { Fast, vlogAll, vlogFast, vhdlAll, svFast, svAll, vhdlFast, All } from '../../resources/hdlParser'; import * as vscode from 'vscode';
import { Fast, vlogAll, vhdlAll, svAll, vhdlFast, All } from '../../resources/hdlParser';
import { hdlFile } from '../hdlFs'; import { hdlFile } from '../hdlFs';
import { HdlLangID } from '../global/enum'; import { HdlLangID } from '../global/enum';
import { AbsPath } from '../global'; import { AbsPath, LspClient } from '../global';
import { DoFastRequestType, ITextDocumentItem, CustomParamRequestType } from '../global/lsp';
import { RawHdlModule } from './common';
async function doFastApi(path: string): Promise<Fast | undefined> {
try {
const client = LspClient.MainClient;
const langID = hdlFile.getLanguageId(path);
if (client) {
const response = await client.sendRequest(DoFastRequestType, { path }) as { fast: any };
if (response.fast instanceof Array) {
const rawModules = response.fast as RawHdlModule[];
return {
content: rawModules,
languageId: langID,
macro: {
errors: [],
defines: [],
includes: [],
invalid: []
}
};
}
}
} catch (error) {
console.error("error happen when run doFastApi, " + error);
return undefined;
}
}
async function vlogFast(path: string): Promise<Fast | undefined> {
const fast = await doFastApi(path);
return fast;
}
async function svFast(path: string): Promise<Fast | undefined> {
const fast = await doFastApi(path);
return fast;
}
namespace HdlSymbol { namespace HdlSymbol {
/**
* @description
* @param path
* @returns
*/
export function fast(path: AbsPath): Promise<Fast | undefined> { export function fast(path: AbsPath): Promise<Fast | undefined> {
const langID = hdlFile.getLanguageId(path); const langID = hdlFile.getLanguageId(path);
switch (langID) { switch (langID) {
@ -14,6 +58,11 @@ namespace HdlSymbol {
} }
} }
/**
* @description 0.4.0
* @param path
* @returns
*/
export function all(path: AbsPath): Promise<All | undefined> { export function all(path: AbsPath): Promise<All | undefined> {
const langID = hdlFile.getLanguageId(path); const langID = hdlFile.getLanguageId(path);
switch (langID) { switch (langID) {