Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<CTreeItem>[], docs?: ITreeItem<CTreeItem>[], isApi?: boolean, addContextMenu?: boolean) {
for (const f of files) {
const category = f.getValue('category');
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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') ?? '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Comment thread
edriouk marked this conversation as resolved.
}

export function setHeaderContext(node: COutlineItem): void {
Expand Down
2 changes: 2 additions & 0 deletions test-data/solutions/USBD/CmsisViewTreeOneProjRef.txt
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,15 @@ 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
resourcePath=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/retarget_stdio.c
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
Expand Down
4 changes: 4 additions & 0 deletions test-data/solutions/USBD/CmsisViewTreeRef.txt
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,15 @@ 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
resourcePath=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/retarget_stdio.c
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
Expand Down Expand Up @@ -1094,13 +1096,15 @@ 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
resourcePath=TEST_DIR/solutions/USBD/Board/B-U585I-IOT02A/retarget_stdio.c
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
Expand Down
Loading