兼容 entity(archName) 的模块树渲染
This commit is contained in:
parent
758a108096
commit
8900b2b920
@ -320,9 +320,7 @@ export async function refreshWorkspaceDiagonastics(
|
|||||||
const parallelChunk = Math.min(os.cpus().length, 32);
|
const parallelChunk = Math.min(os.cpus().length, 32);
|
||||||
const configuration = vscode.workspace.getConfiguration();
|
const configuration = vscode.workspace.getConfiguration();
|
||||||
const linterMode = configuration.get<LinterMode>('digital-ide.function.lsp.linter.linter-mode', LinterMode.Common);
|
const linterMode = configuration.get<LinterMode>('digital-ide.function.lsp.linter.linter-mode', LinterMode.Common);
|
||||||
|
|
||||||
console.log('进入诊断,当前诊断模式:', linterMode, lintPaths);
|
|
||||||
|
|
||||||
if (linterMode === LinterMode.Full) {
|
if (linterMode === LinterMode.Full) {
|
||||||
// full,对工作区所有文件进行诊断
|
// full,对工作区所有文件进行诊断
|
||||||
const consumer = async (path: string) => {
|
const consumer = async (path: string) => {
|
||||||
|
@ -181,14 +181,14 @@ class ModuleTreeProvider implements vscode.TreeDataProvider<ModuleDataItem> {
|
|||||||
const moduleType = element.name as keyof (SrcPath & SimPath);
|
const moduleType = element.name as keyof (SrcPath & SimPath);
|
||||||
|
|
||||||
// 获取所有对应类型(src | sim)下的顶层模块数量
|
// 获取所有对应类型(src | sim)下的顶层模块数量
|
||||||
const topModules = hdlParam.getTopModulesByType(moduleType);
|
const topModules = hdlParam.getTopModulesByType(moduleType);
|
||||||
|
|
||||||
// 将所有顶层模块转换成 ModuleDataItem 自定义 treeview item 数据结构
|
// 将所有顶层模块转换成 ModuleDataItem 自定义 treeview item 数据结构
|
||||||
let topModuleItemList = topModules.map<ModuleDataItem>(module => ({
|
let topModuleItemList = topModules.map<ModuleDataItem>(module => ({
|
||||||
icon: this.judgeTopModuleIconByDoFastType(module.file.doFastType),
|
icon: this.judgeTopModuleIconByDoFastType(module.file.doFastType),
|
||||||
type: moduleType,
|
type: moduleType,
|
||||||
doFastFileType: module.file.doFastType,
|
doFastFileType: module.file.doFastType,
|
||||||
name: module.name,
|
name: module.archName === undefined ? module.name : `${module.name}(${module.archName})`,
|
||||||
range: module.range,
|
range: module.range,
|
||||||
path: module.path,
|
path: module.path,
|
||||||
parent: element,
|
parent: element,
|
||||||
|
@ -656,7 +656,7 @@ class HdlInstance {
|
|||||||
// 构造 fake hdlfile
|
// 构造 fake hdlfile
|
||||||
if (opeParam.prjInfo.toolChain === 'xilinx') {
|
if (opeParam.prjInfo.toolChain === 'xilinx') {
|
||||||
const fakeModule = new HdlModule(
|
const fakeModule = new HdlModule(
|
||||||
XilinxPrimitivesHdlFile, instModName, defaultRange, [], [], []);
|
XilinxPrimitivesHdlFile, instModName, undefined, defaultRange, [], [], []);
|
||||||
this.module = fakeModule;
|
this.module = fakeModule;
|
||||||
// 原语在任何情况下都不是顶层模块
|
// 原语在任何情况下都不是顶层模块
|
||||||
hdlParam.deleteTopModule(fakeModule);
|
hdlParam.deleteTopModule(fakeModule);
|
||||||
@ -749,6 +749,7 @@ class HdlInstance {
|
|||||||
class HdlModule {
|
class HdlModule {
|
||||||
file: HdlFile;
|
file: HdlFile;
|
||||||
name: string;
|
name: string;
|
||||||
|
archName: string | undefined;
|
||||||
range: common.Range;
|
range: common.Range;
|
||||||
params: common.HdlModuleParam[];
|
params: common.HdlModuleParam[];
|
||||||
ports: common.HdlModulePort[];
|
ports: common.HdlModulePort[];
|
||||||
@ -761,6 +762,7 @@ class HdlModule {
|
|||||||
|
|
||||||
constructor(file: HdlFile,
|
constructor(file: HdlFile,
|
||||||
name: string,
|
name: string,
|
||||||
|
archName: string | undefined,
|
||||||
range: common.Range,
|
range: common.Range,
|
||||||
params: common.HdlModuleParam[],
|
params: common.HdlModuleParam[],
|
||||||
ports: common.HdlModulePort[],
|
ports: common.HdlModulePort[],
|
||||||
@ -768,6 +770,7 @@ class HdlModule {
|
|||||||
|
|
||||||
this.file = file;
|
this.file = file;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.archName = archName;
|
||||||
this.range = range;
|
this.range = range;
|
||||||
this.params = params ? params : [];
|
this.params = params ? params : [];
|
||||||
this.ports = ports ? ports : [];
|
this.ports = ports ? ports : [];
|
||||||
@ -1149,28 +1152,73 @@ export class HdlFile {
|
|||||||
|
|
||||||
// make nameToModule
|
// make nameToModule
|
||||||
this.nameToModule = new Map<string, HdlModule>();
|
this.nameToModule = new Map<string, HdlModule>();
|
||||||
for (const rawHdlModule of modules) {
|
|
||||||
|
if (path.endsWith('vhd')) {
|
||||||
|
console.log(path);
|
||||||
|
console.log(modules);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const rawHdlModule of modules) {
|
||||||
this.createHdlModule(rawHdlModule);
|
this.createHdlModule(rawHdlModule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public createHdlModule(rawHdlModule: common.RawHdlModule): HdlModule {
|
public createHdlModule(rawHdlModule: common.RawHdlModule): HdlModule {
|
||||||
|
const archName = rawHdlModule.archName.trim().length === 0 ? undefined: rawHdlModule.archName;
|
||||||
const module: HdlModule = new HdlModule(this,
|
const module: HdlModule = new HdlModule(this,
|
||||||
rawHdlModule.name,
|
rawHdlModule.name,
|
||||||
|
archName,
|
||||||
rawHdlModule.range,
|
rawHdlModule.range,
|
||||||
rawHdlModule.params,
|
rawHdlModule.params,
|
||||||
rawHdlModule.ports,
|
rawHdlModule.ports,
|
||||||
rawHdlModule.instances);
|
rawHdlModule.instances);
|
||||||
this.nameToModule.set(rawHdlModule.name, module);
|
const key = this.makeKey(rawHdlModule.name, archName);
|
||||||
|
this.nameToModule.set(key, module);
|
||||||
return 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 {
|
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 {
|
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[] {
|
public getAllModuleNames(): string[] {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user