diff --git a/src/views/solution-outline/tree-structure/solution-outline-file-item.ts b/src/views/solution-outline/tree-structure/solution-outline-file-item.ts index ca8a12dd..e7030fab 100644 --- a/src/views/solution-outline/tree-structure/solution-outline-file-item.ts +++ b/src/views/solution-outline/tree-structure/solution-outline-file-item.ts @@ -22,8 +22,19 @@ import { getStatusTooltip, setContextMenuAttributes, setHeaderContext, setMergeD import { getCmsisPackRoot } from '../../../utils/path-utils'; import { matchesContext } from '../../../utils/context-utils'; import { SolutionOutlineItemBuilder } from './solution-outline-item-builder'; +import { CSolution } from '../../../solutions/csolution'; +import { SolutionRpcData } from '../../../solutions/solution-rpc-data'; export class FileItemBuilder extends SolutionOutlineItemBuilder { + constructor( + csolution?: CSolution, + rpcData?: SolutionRpcData, + context?: string, + public readonly topTag?: string, + ) { + super(csolution, rpcData, context); + } + public createFileNodes(cgroupItem: COutlineItem, files: ITreeItem[], docs?: ITreeItem[], isApi?: boolean, addContextMenu?: boolean) { for (const f of files) { const category = f.getValue('category'); @@ -65,7 +76,7 @@ export class FileItemBuilder extends SolutionOutlineItemBuilder { } if (addContextMenu) { - setContextMenuAttributes(cfileItem, fileValue, rootFileName); + setContextMenuAttributes(cfileItem, fileValue, rootFileName, this.topTag); } // add copy header button for header files diff --git a/src/views/solution-outline/tree-structure/solution-outline-project-items.ts b/src/views/solution-outline/tree-structure/solution-outline-project-items.ts index 6cb3b8df..8ac12d9b 100644 --- a/src/views/solution-outline/tree-structure/solution-outline-project-items.ts +++ b/src/views/solution-outline/tree-structure/solution-outline-project-items.ts @@ -70,16 +70,17 @@ export class ProjectItemsBuilder extends SolutionOutlineItemBuilder { } private createGroupNode(cprojectItem: COutlineItem, group: CTreeItem, parentGroupPath: string, mapFilePath?: string) { - const cgroupItem = this.createGroupTreeItem(cprojectItem, group, parentGroupPath, mapFilePath); + const topTag = group.getRoot()?.getChild()?.getTag() ?? ''; + + const cgroupItem = this.createGroupTreeItem(cprojectItem, group, parentGroupPath, topTag, mapFilePath); - this.createGroupChildren(cgroupItem, group); + this.createGroupChildren(cgroupItem, group, topTag); this.setExpandableAttribute(cgroupItem); } - private createGroupTreeItem(cprojectItem: COutlineItem, group: CTreeItem, parentGroupPath: string, mapFilePath?: string): COutlineItem { + private createGroupTreeItem(cprojectItem: COutlineItem, group: CTreeItem, parentGroupPath: string, topTag: string, mapFilePath?: string): COutlineItem { const tag = group.getTag() ?? ''; - const topTag = group.getRoot()?.getChild()?.getTag() ?? ''; const rootFileName = group.rootFileName; const mutable = topTag === 'project' || topTag === 'layer'; @@ -128,9 +129,9 @@ export class ProjectItemsBuilder extends SolutionOutlineItemBuilder { } } - private createGroupChildren(cgroupItem: COutlineItem, group: CTreeItem): void { + private createGroupChildren(cgroupItem: COutlineItem, group: CTreeItem, topTag: string): void { const isRegularGroup = !group.getTag() || group.getTag() === '-'; - const fileTreeItem = new FileItemBuilder(this.csolution, this.rpcData, this.context); + const fileTreeItem = new FileItemBuilder(this.csolution, this.rpcData, this.context, topTag); if (isRegularGroup) { this.createGroupTree(cgroupItem, group, cgroupItem.getAttribute('groupPath') ?? ''); diff --git a/src/views/solution-outline/tree-structure/solution-outline-utils.ts b/src/views/solution-outline/tree-structure/solution-outline-utils.ts index a913b6a0..a70dd52c 100644 --- a/src/views/solution-outline/tree-structure/solution-outline-utils.ts +++ b/src/views/solution-outline/tree-structure/solution-outline-utils.ts @@ -20,9 +20,12 @@ import * as fs from 'fs'; import { CTreeItem, ITreeItem } from '../../../generic/tree-item'; import path from 'path'; -export function setContextMenuAttributes(item: COutlineItem, resourcePath: string, rootFileName: string): void { +export function setContextMenuAttributes(item: COutlineItem, resourcePath: string, rootFileName: string, topTag?: string): void { item.setAttribute('fileUri', resourcePath); item.setAttribute('projectUri', rootFileName); + if (topTag === 'layer') { + item.setAttribute('layerUri', rootFileName); + } } export function setHeaderContext(node: COutlineItem): void { diff --git a/test-data/solutions/USBD/CmsisViewTreeOneProjRef.txt b/test-data/solutions/USBD/CmsisViewTreeOneProjRef.txt index ae04f89b..b51b3d1e 100644 --- a/test-data/solutions/USBD/CmsisViewTreeOneProjRef.txt +++ b/test-data/solutions/USBD/CmsisViewTreeOneProjRef.txt @@ -317,6 +317,7 @@ solution features=file fileUri=README.md projectUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml + layerUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml file label=retarget_stdio.c expandable=0 @@ -324,6 +325,7 @@ solution features=file fileUri=./retarget_stdio.c projectUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml + layerUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml components label=Components (9) expandable=1 diff --git a/test-data/solutions/USBD/CmsisViewTreeRef.txt b/test-data/solutions/USBD/CmsisViewTreeRef.txt index d2843996..47147234 100644 --- a/test-data/solutions/USBD/CmsisViewTreeRef.txt +++ b/test-data/solutions/USBD/CmsisViewTreeRef.txt @@ -360,6 +360,7 @@ solution features=file fileUri=README.md projectUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml + layerUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml file label=retarget_stdio.c expandable=0 @@ -367,6 +368,7 @@ solution features=file fileUri=./retarget_stdio.c projectUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml + layerUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml components label=Components (9) expandable=1 @@ -1094,6 +1096,7 @@ solution features=file fileUri=README.md projectUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml + layerUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml file label=retarget_stdio.c expandable=0 @@ -1101,6 +1104,7 @@ solution features=file fileUri=./retarget_stdio.c projectUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml + layerUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml components label=Components (9) expandable=1