Skip to content

Commit 0cad6d1

Browse files
authored
Fix file removal from clayer.yml
1 parent ebcffa4 commit 0cad6d1

5 files changed

Lines changed: 29 additions & 8 deletions

File tree

src/views/solution-outline/tree-structure/solution-outline-file-item.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,19 @@ import { getStatusTooltip, setContextMenuAttributes, setHeaderContext, setMergeD
2222
import { getCmsisPackRoot } from '../../../utils/path-utils';
2323
import { matchesContext } from '../../../utils/context-utils';
2424
import { SolutionOutlineItemBuilder } from './solution-outline-item-builder';
25+
import { CSolution } from '../../../solutions/csolution';
26+
import { SolutionRpcData } from '../../../solutions/solution-rpc-data';
2527

2628
export class FileItemBuilder extends SolutionOutlineItemBuilder {
29+
constructor(
30+
csolution?: CSolution,
31+
rpcData?: SolutionRpcData,
32+
context?: string,
33+
public readonly topTag?: string,
34+
) {
35+
super(csolution, rpcData, context);
36+
}
37+
2738
public createFileNodes(cgroupItem: COutlineItem, files: ITreeItem<CTreeItem>[], docs?: ITreeItem<CTreeItem>[], isApi?: boolean, addContextMenu?: boolean) {
2839
for (const f of files) {
2940
const category = f.getValue('category');
@@ -65,7 +76,7 @@ export class FileItemBuilder extends SolutionOutlineItemBuilder {
6576
}
6677

6778
if (addContextMenu) {
68-
setContextMenuAttributes(cfileItem, fileValue, rootFileName);
79+
setContextMenuAttributes(cfileItem, fileValue, rootFileName, this.topTag);
6980
}
7081

7182
// add copy header button for header files

src/views/solution-outline/tree-structure/solution-outline-project-items.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,17 @@ export class ProjectItemsBuilder extends SolutionOutlineItemBuilder {
7070
}
7171

7272
private createGroupNode(cprojectItem: COutlineItem, group: CTreeItem, parentGroupPath: string, mapFilePath?: string) {
73-
const cgroupItem = this.createGroupTreeItem(cprojectItem, group, parentGroupPath, mapFilePath);
73+
const topTag = group.getRoot()?.getChild()?.getTag() ?? '';
74+
75+
const cgroupItem = this.createGroupTreeItem(cprojectItem, group, parentGroupPath, topTag, mapFilePath);
7476

75-
this.createGroupChildren(cgroupItem, group);
77+
this.createGroupChildren(cgroupItem, group, topTag);
7678

7779
this.setExpandableAttribute(cgroupItem);
7880
}
7981

80-
private createGroupTreeItem(cprojectItem: COutlineItem, group: CTreeItem, parentGroupPath: string, mapFilePath?: string): COutlineItem {
82+
private createGroupTreeItem(cprojectItem: COutlineItem, group: CTreeItem, parentGroupPath: string, topTag: string, mapFilePath?: string): COutlineItem {
8183
const tag = group.getTag() ?? '';
82-
const topTag = group.getRoot()?.getChild()?.getTag() ?? '';
8384
const rootFileName = group.rootFileName;
8485
const mutable = topTag === 'project' || topTag === 'layer';
8586

@@ -128,9 +129,9 @@ export class ProjectItemsBuilder extends SolutionOutlineItemBuilder {
128129
}
129130
}
130131

131-
private createGroupChildren(cgroupItem: COutlineItem, group: CTreeItem): void {
132+
private createGroupChildren(cgroupItem: COutlineItem, group: CTreeItem, topTag: string): void {
132133
const isRegularGroup = !group.getTag() || group.getTag() === '-';
133-
const fileTreeItem = new FileItemBuilder(this.csolution, this.rpcData, this.context);
134+
const fileTreeItem = new FileItemBuilder(this.csolution, this.rpcData, this.context, topTag);
134135

135136
if (isRegularGroup) {
136137
this.createGroupTree(cgroupItem, group, cgroupItem.getAttribute('groupPath') ?? '');

src/views/solution-outline/tree-structure/solution-outline-utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ import * as fs from 'fs';
2020
import { CTreeItem, ITreeItem } from '../../../generic/tree-item';
2121
import path from 'path';
2222

23-
export function setContextMenuAttributes(item: COutlineItem, resourcePath: string, rootFileName: string): void {
23+
export function setContextMenuAttributes(item: COutlineItem, resourcePath: string, rootFileName: string, topTag?: string): void {
2424
item.setAttribute('fileUri', resourcePath);
2525
item.setAttribute('projectUri', rootFileName);
26+
if (topTag === 'layer') {
27+
item.setAttribute('layerUri', rootFileName);
28+
}
2629
}
2730

2831
export function setHeaderContext(node: COutlineItem): void {

test-data/solutions/USBD/CmsisViewTreeOneProjRef.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,13 +317,15 @@ solution
317317
features=file
318318
fileUri=README.md
319319
projectUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml
320+
layerUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml
320321
file
321322
label=retarget_stdio.c
322323
expandable=0
323324
resourcePath=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/retarget_stdio.c
324325
features=file
325326
fileUri=./retarget_stdio.c
326327
projectUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml
328+
layerUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml
327329
components
328330
label=Components (9)
329331
expandable=1

test-data/solutions/USBD/CmsisViewTreeRef.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,15 @@ solution
360360
features=file
361361
fileUri=README.md
362362
projectUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml
363+
layerUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml
363364
file
364365
label=retarget_stdio.c
365366
expandable=0
366367
resourcePath=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/retarget_stdio.c
367368
features=file
368369
fileUri=./retarget_stdio.c
369370
projectUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml
371+
layerUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml
370372
components
371373
label=Components (9)
372374
expandable=1
@@ -1094,13 +1096,15 @@ solution
10941096
features=file
10951097
fileUri=README.md
10961098
projectUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml
1099+
layerUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml
10971100
file
10981101
label=retarget_stdio.c
10991102
expandable=0
11001103
resourcePath=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/retarget_stdio.c
11011104
features=file
11021105
fileUri=./retarget_stdio.c
11031106
projectUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml
1107+
layerUri=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/Board.clayer.yml
11041108
components
11051109
label=Components (9)
11061110
expandable=1

0 commit comments

Comments
 (0)