修复结构树递归渲染的问题

This commit is contained in:
锦恢 2024-12-03 18:35:55 +08:00
parent 5c5136b316
commit fb157d07a9
17 changed files with 207 additions and 34 deletions

42
images/svg/dark/dide.svg Normal file
View File

@ -0,0 +1,42 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"
width="126px" height="126px" viewBox="-0.5 -0.5 126 126"
content="&lt;mxfile&gt;&lt;diagram id=&quot;E9SxX19eNgA6MUTyjjO6&quot; name=&quot;Icon-黑白&quot;&gt;7VnbktsoEP0aP0YlhG5+HF/GqVSS8pZrd2f3xcVIWGJXEiqEx3K+fsFCN8sXORnNuJL1g003TQN9DtDgEZzG+YKhNPxCfRyNDN3PR3A2MgzoOOJbKvaFwjDNQhEw4hcqUCtW5BtWSl1pt8THWcuQUxpxkraVHk0S7PGWDjFGd22zDY3avaYowB3FykNRV/sn8XmotMAe1xUfMQlC1bVrqAnHqDRWM8lC5NNdQwXnIzhllPKiFOdTHMnYlXHxJ7s5fqSf7OfpbvVp7cXpYv2hcPZ4S5NqCgwn/HVdw8L1C4q2Kl5qrnxfBnAXEo5XKfKkvBMcGcFJyONISEAUUZYWsG1IjkVXkw2JoimNKDs0h8YMGnAi9Bln9N8KA0ta0oQ3LDeHT2VZ1iQ0ET1PGN0mvuyg6JV5imrAFWLPAKlAvmDGcd6ghwrYAtMYc7YXJqrWtBX2JflLedegUsmPsMGiSokUfYPKdw2RKCiUbkDMfC/EYG/ERM104oLZwwXYLH1I2FyoOVYbuYaqAZ5jaFYXvVr76vDZ1+ETXsTmKDl/K5BtwIwutBUs5wELGPIJrmFWy2+4FeZobaSgVWmaq+wETGAokJx7B2koNCzrDtFw/0ejPn/eEo08X23Th+zzxPqbzBe7cGIbf/TZwAKx6adVXDrzrXI99Fy20G8J4fm9ZHzEXb17WlsnYgWHYu74eqxkdIjIVj+jZxwtaUY4oYmoeqac01jSrsw65YHpoyw8HKZSQBEJpKknYoZZm+el2wdlw2la+Eplv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TkeikaaakeG/kIVuj4dLrdVCpaNFBsJUFFTFVcq9TIDqyXPAKnYVtGOftMWEMLOocUQMJtEbYFG/t6QcQ+AOZ6NdlmheS6Y57Lm2MBi4t2xm6bODFXeLzLnUVfQvQ8x5JllZXw4YVpfsji+Mj1QbC88OvyTwVuUgP20c97A572D7Rwva1OvjuBqxP/plz5/acO+YfO3dvwPngdrmidT1sP2QOsc73IJ59Ag==&lt;/diagram&gt;&lt;/mxfile&gt;">
<defs />
<g>
<rect x="2" y="2" width="120" height="120" rx="21.6" ry="21.6" fill="#2d323b" stroke="none"
pointer-events="all" />
<rect x="25.75" y="25.75" width="72.5" height="72.5" rx="36.25" ry="36.25" fill="#2d323b"
stroke="#cb81da" stroke-width="3" pointer-events="all" />
<ellipse cx="17" cy="107" rx="7.500000000000001" ry="7.500000000000001" fill="#cb81da"
stroke="#cb81da" stroke-width="2" pointer-events="all" />
<ellipse cx="107" cy="107" rx="7.500000000000001" ry="7.500000000000001" fill="#cb81da"
stroke="#cb81da" stroke-width="2" pointer-events="all" />
<ellipse cx="107" cy="17" rx="7.500000000000001" ry="7.500000000000001" fill="#cb81da"
stroke="#cb81da" stroke-width="2" pointer-events="all" />
<path d="M 85.4 65.95 L 92 65.95 M 59 61.34 L 65.6 61.34 M 59 70.55 L 65.6 70.55"
fill="none" stroke="#cb81da" stroke-width="2" stroke-miterlimit="10"
pointer-events="none" />
<path
d="M 65.6 56.74 L 75.5 56.74 C 80.97 56.74 85.4 60.86 85.4 65.95 C 85.4 71.03 80.97 75.16 75.5 75.16 L 65.6 75.16 Z"
fill="#cb81da" stroke="#cb81da" stroke-width="2" stroke-miterlimit="10"
pointer-events="none" />
<rect x="37" y="42" width="11" height="11" fill="rgb(255, 255, 255)" stroke="rgb(0, 0, 0)"
pointer-events="none" />
<rect x="37" y="64.72" width="11" height="11" fill="rgb(255, 255, 255)"
stroke="rgb(0, 0, 0)" pointer-events="none" />
<path d="M 59 70.55 L 48.01 70.6" fill="none" stroke="#cb81da" stroke-width="2"
stroke-miterlimit="10" pointer-events="none" />
<rect x="37" y="64.72" width="11" height="11" fill="#000000" stroke="#000000"
pointer-events="none" />
<rect x="37" y="42" width="11" height="11" fill="#000000" stroke="#000000"
pointer-events="none" />
<rect x="37" y="42" width="11" height="11" fill="#cb81da" stroke="#cb81da"
pointer-events="none" />
<rect x="37" y="64.72" width="11" height="11" fill="#cb81da" stroke="#cb81da"
pointer-events="none" />
<path d="M 48 48.14 L 53.51 48.09 L 53.51 61.31 L 59 61.34" fill="none" stroke="#cb81da"
stroke-width="2" stroke-miterlimit="10" pointer-events="none" />
<ellipse cx="17" cy="17" rx="7.500000000000001" ry="7.500000000000001" fill="#cb81da"
stroke="#cb81da" stroke-width="2" pointer-events="none" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

42
images/svg/light/dide.svg Normal file
View File

@ -0,0 +1,42 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"
width="126px" height="126px" viewBox="-0.5 -0.5 126 126"
content="&lt;mxfile&gt;&lt;diagram id=&quot;E9SxX19eNgA6MUTyjjO6&quot; name=&quot;Icon-黑白&quot;&gt;7VnbktsoEP0aP0YlhG5+HF/GqVSS8pZrd2f3xcVIWGJXEiqEx3K+fsFCN8sXORnNuJL1g003TQN9DtDgEZzG+YKhNPxCfRyNDN3PR3A2MgzoOOJbKvaFwjDNQhEw4hcqUCtW5BtWSl1pt8THWcuQUxpxkraVHk0S7PGWDjFGd22zDY3avaYowB3FykNRV/sn8XmotMAe1xUfMQlC1bVrqAnHqDRWM8lC5NNdQwXnIzhllPKiFOdTHMnYlXHxJ7s5fqSf7OfpbvVp7cXpYv2hcPZ4S5NqCgwn/HVdw8L1C4q2Kl5qrnxfBnAXEo5XKfKkvBMcGcFJyONISEAUUZYWsG1IjkVXkw2JoimNKDs0h8YMGnAi9Bln9N8KA0ta0oQ3LDeHT2VZ1iQ0ET1PGN0mvuyg6JV5imrAFWLP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quot;第 2 页&quot;&gt;5ZZdb4IwFEB/DY8m0DLQV5m6h7nEuGXPDVToVigpVXC/fkUuX+Lilui2RF+k515u29ObBgN7cbGQJI2WIqDcQGZQGPjeQAiZeKL/SrKviGU6qCKhZAGwFqzZB60TgW5ZQLNeohKCK5b2oS+ShPqqx4iUIu+nbQTvz5qSEGY0W7D2CaeDtFcWqKiiY+S2/IGyMKpnthzYcUzqZCicRSQQeQfhmYE9KYSqnuLCo7y0V3up3pt/EW0WJmmivvNCulw+b3YrwlZPycub9Tgd52oEVXaEb2HDsFi1rw1IsU0CWhaxDDzNI6boOiV+Gc31oWsWqZhDeMM49wQXUo8TkeikaaakeG/kIVuj4dLrdVCpaNFBsJUFFTFVcq9TIDqyXPAKnYVtGOftMWEMLOocUQMJtEbYFG/t6QcQ+AOZ6NdlmheS6Y57Lm2MBi4t2xm6bODFXeLzLnUVfQvQ8x5JllZXw4YVpfsji+Mj1QbC88OvyTwVuUgP20c97A572D7Rwva1OvjuBqxP/plz5/acO+YfO3dvwPngdrmidT1sP2QOsc73IJ59Ag==&lt;/diagram&gt;&lt;/mxfile&gt;">
<defs />
<g>
<rect x="2" y="2" width="120" height="120" rx="21.6" ry="21.6" fill="#2d323b" stroke="none"
pointer-events="all" />
<rect x="25.75" y="25.75" width="72.5" height="72.5" rx="36.25" ry="36.25" fill="#2d323b"
stroke="#cb81da" stroke-width="3" pointer-events="all" />
<ellipse cx="17" cy="107" rx="7.500000000000001" ry="7.500000000000001" fill="#cb81da"
stroke="#cb81da" stroke-width="2" pointer-events="all" />
<ellipse cx="107" cy="107" rx="7.500000000000001" ry="7.500000000000001" fill="#cb81da"
stroke="#cb81da" stroke-width="2" pointer-events="all" />
<ellipse cx="107" cy="17" rx="7.500000000000001" ry="7.500000000000001" fill="#cb81da"
stroke="#cb81da" stroke-width="2" pointer-events="all" />
<path d="M 85.4 65.95 L 92 65.95 M 59 61.34 L 65.6 61.34 M 59 70.55 L 65.6 70.55"
fill="none" stroke="#cb81da" stroke-width="2" stroke-miterlimit="10"
pointer-events="none" />
<path
d="M 65.6 56.74 L 75.5 56.74 C 80.97 56.74 85.4 60.86 85.4 65.95 C 85.4 71.03 80.97 75.16 75.5 75.16 L 65.6 75.16 Z"
fill="#cb81da" stroke="#cb81da" stroke-width="2" stroke-miterlimit="10"
pointer-events="none" />
<rect x="37" y="42" width="11" height="11" fill="rgb(255, 255, 255)" stroke="rgb(0, 0, 0)"
pointer-events="none" />
<rect x="37" y="64.72" width="11" height="11" fill="rgb(255, 255, 255)"
stroke="rgb(0, 0, 0)" pointer-events="none" />
<path d="M 59 70.55 L 48.01 70.6" fill="none" stroke="#cb81da" stroke-width="2"
stroke-miterlimit="10" pointer-events="none" />
<rect x="37" y="64.72" width="11" height="11" fill="#000000" stroke="#000000"
pointer-events="none" />
<rect x="37" y="42" width="11" height="11" fill="#000000" stroke="#000000"
pointer-events="none" />
<rect x="37" y="42" width="11" height="11" fill="#cb81da" stroke="#cb81da"
pointer-events="none" />
<rect x="37" y="64.72" width="11" height="11" fill="#cb81da" stroke="#cb81da"
pointer-events="none" />
<path d="M 48 48.14 L 53.51 48.09 L 53.51 61.31 L 59 61.34" fill="none" stroke="#cb81da"
stroke-width="2" stroke-miterlimit="10" pointer-events="none" />
<ellipse cx="17" cy="17" rx="7.500000000000001" ry="7.500000000000001" fill="#cb81da"
stroke="#cb81da" stroke-width="2" pointer-events="none" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@ -81,6 +81,5 @@
"error.simulation.error-happen-run-command": "Fehler bei der Icarus-Simulation:",
"info.command.structure.transform-xilinx-to-standard": "Konvertiere Xilinx-Projektstruktur in Digital IDE-Standardstruktur",
"error.command.structure.not-valid-xilinx-project": "Das aktuelle Projekt ist kein gültiges Xilinx-Projekt, die Konvertierung ist fehlgeschlagen!",
"info.command.structure.reload-vscode": "Projektstrukturkonvertierung abgeschlossen, bitte starten Sie vscode neu, um die Änderungen zu übernehmen.",
"info.common.confirm": "Bestätigen"
"info.common.codedoc": "Code-Dokumentation"
}

View File

@ -81,6 +81,5 @@
"error.simulation.error-happen-run-command": "Error during Icarus simulation:",
"info.command.structure.transform-xilinx-to-standard": "Converting Xilinx project structure to Digital IDE standard structure",
"error.command.structure.not-valid-xilinx-project": "The current project is not a valid Xilinx project, the conversion failed!",
"info.command.structure.reload-vscode": "Project structure conversion completed, please restart vscode to apply the changes.",
"info.common.confirm": "Confirm"
"info.common.codedoc": "Code Documentation"
}

View File

@ -81,6 +81,5 @@
"error.simulation.error-happen-run-command": "Icarusシミュレーション中にエラーが発生しました",
"info.command.structure.transform-xilinx-to-standard": "Xilinx プロジェクト構造を Digital IDE 標準構造に変換しています",
"error.command.structure.not-valid-xilinx-project": "現在のプロジェクトは有効なXilinxプロジェクトではありません、変換に失敗しました",
"info.command.structure.reload-vscode": "プロジェクト構造の変換が完了しました。変更を適用するために vscode を再起動してください。",
"info.common.confirm": "確認"
"info.common.codedoc": "コードドキュメント"
}

View File

@ -81,6 +81,5 @@
"error.simulation.error-happen-run-command": "Icarus 仿真时,出现错误:",
"info.command.structure.transform-xilinx-to-standard": "正在将 Xilinx 项目结构转变为 Digital IDE 标准结构",
"error.command.structure.not-valid-xilinx-project": "当前项目不是一个有效的 Xilinx 项目,转换失败!",
"info.command.structure.reload-vscode": "项目结构转换完成,请重启 vscode 使应用生效",
"info.common.confirm": "确定"
"info.common.codedoc": "代码文档"
}

View File

@ -81,6 +81,5 @@
"error.simulation.error-happen-run-command": "Icarus 模擬時,出現錯誤:",
"info.command.structure.transform-xilinx-to-standard": "正在將 Xilinx 專案結構轉變為 Digital IDE 標準結構",
"error.command.structure.not-valid-xilinx-project": "當前專案不是一個有效的 Xilinx 專案,轉換失敗!",
"info.command.structure.reload-vscode": "專案結構轉換完成,請重新啟動 vscode 使應用生效。",
"info.common.confirm": "確定"
"info.common.codedoc": "程式碼文件"
}

View File

@ -651,6 +651,20 @@ img {
background-color: rgb(53,59,140);
}
#write .source-ip-tag {
font-size: 0.85rem;
padding: 3px 4px;
border-radius: .5em;
background-color: rgb(24, 91, 149);
}
#write .source-primitive-tag {
font-size: 0.85rem;
padding: 3px 4px;
border-radius: .5em;
background-color: rgb(108, 53, 140);
}
#write .source-unk-tag {
font-size: 0.85rem;
padding: 3px 4px;

BIN
resources/dide-doc/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -5,6 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Digital IDE Document</title>
<link rel="icon" href="icon.png">
<link rel="stylesheet" href="documentation.css">
<link rel="stylesheet" href="iconfont.css">
</head>

View File

@ -9,6 +9,7 @@ import { Count, MarkdownString, ThemeColorConfig, WavedromString } from './commo
import { getRenderList, getCurrentRenderList } from './markdown';
import { hdlPath, hdlIcon, hdlFile } from '../../hdlFs';
import { ThemeType } from '../../global/enum';
import { t } from '../../i18n';
const _cache = {
css : ''
@ -227,7 +228,8 @@ export async function makeDocWebview(uri: vscode.Uri, context: vscode.ExtensionC
}
);
panel.iconPath = hdlIcon.getIconConfig('documentation');
panel.iconPath = hdlIcon.getIconConfig('dide');
panel.title = t('info.common.codedoc') + ': ' + fspath.basename(uri.fsPath);
const html = getWebviewContent(context, panel);
if (html === undefined) {

View File

@ -43,17 +43,36 @@ function selectFieldValue(obj: any, subName: string, ws: string, name: string, i
if (fs.existsSync(value)) {
// 判断 类型
const hdlFile = hdlParam.getHdlFile(value);
if (hdlFile && hdlFile.projectType === HdlFileProjectType.RemoteLib) {
if (hdlFile) {
switch (hdlFile.projectType) {
case HdlFileProjectType.RemoteLib:
// 如果是 库 文件,做出更加自定义的字面量
const libRelPath = value.replace(`${opeParam.extensionPath}/library/`, '');
value = `<span class="source-lib-tag">library</span> [${libRelPath}](file://${value})`;
break;
case HdlFileProjectType.IP:
// 如果是 IP定向到 xci 上
const ipname = fspath.basename(value);
const xciPath = hdlPath.join(value, ipname + '.xci');
value = `<span class="source-ip-tag">ip core</span> [${relativePath}](file://${xciPath})`;
break;
default:
value = `<span class="source-prj-tag">project</span> [${relativePath}](file://${value})`;
break;
}
} else {
value = `<span class="source-prj-tag">project</span> [${relativePath}](file://${value})`;
}
} else {
// 如果不存在,可能是原语
const inst = obj as HdlInstance;
if (inst.getDoFastFileType === 'primitives') {
value = `<span class="source-primitive-tag">${opeParam.prjInfo.toolChain} primitive</span>`;
} else {
value = '<span class="source-unk-tag">unknown</span> ' + t('info.dide-doc.source.cannot-find');
}
}
}
if (value && value.trim().length === 0) {
return '——';
@ -171,14 +190,7 @@ async function getDocsFromModule(module: HdlModule): Promise<MarkdownString> {
await portPP;
// 判断是否为单文件
let isSingleFile = false;
if (!opeParam.workspacePath || !fs.existsSync(opeParam.workspacePath)) {
isSingleFile = true;
} else {
const workspacePath = opeParam.workspacePath;
const modulePath = module.path;
isSingleFile = !modulePath.startsWith(workspacePath);
}
const isSingleFile = opeParam.openMode === 'file';
// param section
const paramTitleIcon = '<span class="iconfont icon-parameter"></span> ';
@ -227,10 +239,10 @@ async function getDocsFromModule(module: HdlModule): Promise<MarkdownString> {
const depTitleIcon = '<span class="iconfont icon-tree"></span> ';
md.addTitle(depTitleIcon + t('info.dide-doc.dependency'), 2);
let insts = module.getAllInstances();
let insts: HdlInstance[] = [];
// 对于单文件模式而言,未进行 instance 搜索所以insts必然是空的
if (isSingleFile && insts.length === 0 && module.rawInstances) {
insts = module.rawInstances.map(rawInstance => new HdlInstance(
insts = module.rawInstances.map<HdlInstance>(rawInstance => new HdlInstance(
rawInstance.name,
rawInstance.type,
undefined,
@ -240,6 +252,9 @@ async function getDocsFromModule(module: HdlModule): Promise<MarkdownString> {
rawInstance.range,
module
));
} else {
// 对于多文件,找出所有依赖项
insts = [...module.getAllDependenceInstance()];
}
// 根据 start 进行排序

View File

@ -210,8 +210,10 @@ export async function activate(context: vscode.ExtensionContext, packageJson: an
);
LspClient.DigitalIDE = client;
// 启动 lsp
await client.start();
// 检测配置文件变动
registerConfigurationUpdater(client, packageJson);
}

View File

@ -204,6 +204,7 @@ class ModuleTreeProvider implements vscode.TreeDataProvider<ModuleDataItem> {
let firstTop: { path: string, name: string } | undefined = undefined;
let maxDepSize = 0;
for (const hdlModule of topModules) {
// 此处断言是因为当前的 name 和 path 是从 topModules 中提取的
// 它们对应的 hdlModule 一定存在

View File

@ -172,6 +172,7 @@ interface RawHdlInstance {
interface RawHdlModule {
name: string
archName: string
params: HdlModuleParam[]
ports: HdlModulePort[]
instances: RawHdlInstance[]

View File

@ -205,6 +205,8 @@ class HdlParam {
} else if (status === common.InstModPathStatus.Others && inst.instModPath) {
dependencies.others.push(inst.instModPath);
}
// 防止无限递归
if (inst.module && inst.module !== module) {
const instDependencies = this.getAllDependences(inst.module.path, inst.module.name);
if (instDependencies) {
dependencies.current.push(...instDependencies.current);
@ -212,6 +214,7 @@ class HdlParam {
dependencies.others.push(...instDependencies.others);
}
}
}
return dependencies;
}
@ -819,6 +822,59 @@ class HdlModule {
return this.nameToInstances.size;
}
/**
* @description
* @returns
*/
public getAllDependences(): common.HdlDependence {
const dependencies : common.HdlDependence = {
current: [],
include: [],
others: []
};
for (const inst of this.getAllInstances()) {
if (!inst.module) {
continue;
}
const status = inst.instModPathStatus;
if (status === common.InstModPathStatus.Current && inst.instModPath) {
dependencies.current.push(inst.instModPath);
} else if (status === common.InstModPathStatus.Include && inst.instModPath) {
dependencies.include.push(inst.instModPath);
} else if (status === common.InstModPathStatus.Others && inst.instModPath) {
dependencies.others.push(inst.instModPath);
}
if (inst.module) {
const instDependencies = inst.module.getAllDependences();
dependencies.current.push(...instDependencies.current);
dependencies.include.push(...instDependencies.include);
dependencies.others.push(...instDependencies.others);
}
}
return dependencies;
}
/**
* @description
*/
public getAllDependenceInstance(): Set<HdlInstance> {
const instances = new Set<HdlInstance>();
// 获取自身的
for (const inst of this.nameToInstances.values()) {
console.log(inst);
instances.add(inst);
// 递归获取 inst 的
if (inst.module) {
for (const subInst of inst.module.getAllDependenceInstance()) {
instances.add(subInst);
}
}
}
return instances;
}
public createHdlInstance(rawHdlInstance: common.RawHdlInstance): HdlInstance {
const instModName = rawHdlInstance.type;
@ -1092,6 +1148,8 @@ export class HdlFile {
// add to global hdlParam
hdlParam.setHdlFile(this);
console.log(modules);
// make nameToModule
this.nameToModule = new Map<string, HdlModule>();
for (const rawHdlModule of modules) {