兼容 entity(archName) 的模块树渲染

This commit is contained in:
锦恢 2024-12-17 23:32:53 +08:00
parent 758a108096
commit 8900b2b920
3 changed files with 56 additions and 10 deletions

View File

@ -321,8 +321,6 @@ export async function refreshWorkspaceDiagonastics(
const configuration = vscode.workspace.getConfiguration();
const linterMode = configuration.get<LinterMode>('digital-ide.function.lsp.linter.linter-mode', LinterMode.Common);
console.log('进入诊断,当前诊断模式:', linterMode, lintPaths);
if (linterMode === LinterMode.Full) {
// full对工作区所有文件进行诊断
const consumer = async (path: string) => {

View File

@ -188,7 +188,7 @@ class ModuleTreeProvider implements vscode.TreeDataProvider<ModuleDataItem> {
icon: this.judgeTopModuleIconByDoFastType(module.file.doFastType),
type: moduleType,
doFastFileType: module.file.doFastType,
name: module.name,
name: module.archName === undefined ? module.name : `${module.name}(${module.archName})`,
range: module.range,
path: module.path,
parent: element,

View File

@ -656,7 +656,7 @@ class HdlInstance {
// 构造 fake hdlfile
if (opeParam.prjInfo.toolChain === 'xilinx') {
const fakeModule = new HdlModule(
XilinxPrimitivesHdlFile, instModName, defaultRange, [], [], []);
XilinxPrimitivesHdlFile, instModName, undefined, defaultRange, [], [], []);
this.module = fakeModule;
// 原语在任何情况下都不是顶层模块
hdlParam.deleteTopModule(fakeModule);
@ -749,6 +749,7 @@ class HdlInstance {
class HdlModule {
file: HdlFile;
name: string;
archName: string | undefined;
range: common.Range;
params: common.HdlModuleParam[];
ports: common.HdlModulePort[];
@ -761,6 +762,7 @@ class HdlModule {
constructor(file: HdlFile,
name: string,
archName: string | undefined,
range: common.Range,
params: common.HdlModuleParam[],
ports: common.HdlModulePort[],
@ -768,6 +770,7 @@ class HdlModule {
this.file = file;
this.name = name;
this.archName = archName;
this.range = range;
this.params = params ? params : [];
this.ports = ports ? ports : [];
@ -1149,28 +1152,73 @@ export class HdlFile {
// make nameToModule
this.nameToModule = new Map<string, HdlModule>();
if (path.endsWith('vhd')) {
console.log(path);
console.log(modules);
}
for (const rawHdlModule of modules) {
this.createHdlModule(rawHdlModule);
}
}
public createHdlModule(rawHdlModule: common.RawHdlModule): HdlModule {
const archName = rawHdlModule.archName.trim().length === 0 ? undefined: rawHdlModule.archName;
const module: HdlModule = new HdlModule(this,
rawHdlModule.name,
archName,
rawHdlModule.range,
rawHdlModule.params,
rawHdlModule.ports,
rawHdlModule.instances);
this.nameToModule.set(rawHdlModule.name, module);
const key = this.makeKey(rawHdlModule.name, archName);
this.nameToModule.set(key, module);
return module;
}
public makeKey(name: string, archName: string | undefined): string {
return archName === undefined ? name: `${name}(${archName})`;
}
/**
* @description name module
* name name item
* @param name
* @returns
*/
public hasHdlModule(name: string): boolean {
return this.nameToModule.has(name);
if (this.nameToModule.has(name)) {
return true;
}
for (const moduleName of this.nameToModule.keys()) {
if (moduleName.includes('(')) {
const entityName = moduleName.split('(')[0];
if (entityName === name) {
return true;
}
}
}
return false;
}
public getHdlModule(name: string): HdlModule | undefined {
return this.nameToModule.get(name);
const hdlModule = this.nameToModule.get(name);
if (hdlModule !== undefined) {
return hdlModule;
}
for (const [moduleName, hdlModule] of this.nameToModule.entries()) {
if (moduleName.includes('(')) {
const entityName = moduleName.split('(')[0];
if (entityName === name) {
return hdlModule;
}
}
}
return undefined;
}
public getAllModuleNames(): string[] {