修复模块树中 vhdl 引用 vlog 模块渲染错误的问题

This commit is contained in:
锦恢 2024-12-01 19:36:55 +08:00
parent ab24f6c670
commit fa9e97be82
2 changed files with 11 additions and 6 deletions

View File

@ -154,6 +154,7 @@ class ModuleTreeProvider implements vscode.TreeDataProvider<ModuleDataItem> {
public getChildren(element?: ModuleDataItem | undefined): vscode.ProviderResult<ModuleDataItem[]> { public getChildren(element?: ModuleDataItem | undefined): vscode.ProviderResult<ModuleDataItem[]> {
if (element) { if (element) {
const name = element.name; const name = element.name;
if (name === 'sim' || name === 'src') { if (name === 'sim' || name === 'src') {
element.parent = undefined; element.parent = undefined;
return this.getTopModuleItemList(element); return this.getTopModuleItemList(element);
@ -242,9 +243,9 @@ class ModuleTreeProvider implements vscode.TreeDataProvider<ModuleDataItem> {
const moduleDataItemList: ModuleDataItem[] = []; const moduleDataItemList: ModuleDataItem[] = [];
const targetModule = hdlParam.getHdlModule(element.path, element.name); const targetModule = hdlParam.getHdlModule(element.path, element.name);
if (targetModule) { if (targetModule) {
const allInstances = targetModule.getAllInstances(); const allInstances = targetModule.getAllInstances();
// 根据出现次序进行排序 // 根据出现次序进行排序
allInstances.sort((a, b) => a.range.start.line - b.range.start.line); allInstances.sort((a, b) => a.range.start.line - b.range.start.line);
for (const instance of allInstances) { for (const instance of allInstances) {

View File

@ -808,7 +808,7 @@ class HdlModule {
const instModName = rawHdlInstance.type; const instModName = rawHdlInstance.type;
if (this.languageId === HdlLangID.Verilog || this.languageId === HdlLangID.SystemVerilog) { if (this.languageId === HdlLangID.Verilog || this.languageId === HdlLangID.SystemVerilog) {
const searchResult = this.searchInstModPath(instModName); const searchResult = this.searchInstModPath(instModName);
const hdlInstance = new HdlInstance(rawHdlInstance.name, const hdlInstance = new HdlInstance(rawHdlInstance.name,
rawHdlInstance.type, rawHdlInstance.type,
searchResult.path, searchResult.path,
@ -827,15 +827,19 @@ class HdlModule {
} }
return hdlInstance; return hdlInstance;
} else if (this.languageId === HdlLangID.Vhdl) { } else if (this.languageId === HdlLangID.Vhdl) {
const searchResult = this.searchInstModPath(instModName);
const hdlInstance = new HdlInstance(rawHdlInstance.name, const hdlInstance = new HdlInstance(rawHdlInstance.name,
rawHdlInstance.type, rawHdlInstance.type,
this.path, searchResult.path,
common.InstModPathStatus.Current, searchResult.status,
rawHdlInstance.instparams, rawHdlInstance.instparams,
rawHdlInstance.instports, rawHdlInstance.instports,
rawHdlInstance.range, rawHdlInstance.range,
this); this);
hdlInstance.module = this;
if (hdlInstance.module === undefined) {
hdlInstance.module = this;
}
if (this.nameToInstances) { if (this.nameToInstances) {
const key = this.makeInstanceKey(rawHdlInstance.name, rawHdlInstance.type); const key = this.makeInstanceKey(rawHdlInstance.name, rawHdlInstance.type);
this.nameToInstances.set(key, hdlInstance); this.nameToInstances.set(key, hdlInstance);