Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor CMSIS View #193

Open
ReinhardKeil opened this issue Feb 4, 2025 · 2 comments
Open

Refactor CMSIS View #193

ReinhardKeil opened this issue Feb 4, 2025 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@ReinhardKeil
Copy link
Collaborator

Improve the structure of the CMSIS View

@edriouk
Copy link
Collaborator

edriouk commented Feb 4, 2025

The central idea of the refactoring is to replace SolutionNode type in SolutionOutlineTree with CTreeItem class.

Advantages:

  • CTreeItem represents a generic tree with label, attributes and child elements
  • new attributes can be introduced without modifying the type
  • can be written to a YAML string that can ease testing: compare result with golden reference

An estimated effort is ~2 weeks including adding tests for the existing Outline View content functionality

@edriouk
Copy link
Collaborator

edriouk commented Feb 5, 2025

Create a new class COutlineItem that extends CTreeItem (later we can decide to derive it directly from GenericTreeItem.
Some methods need to be overwritten to return COutlineItem, in particular createItem(), getChildItem(), getParentItem()

Please note that:

  • CTreeItem does not have defined properties, but uses methods to access them.
  • there is no need to define and add additional data structures like data in solutionNode

COutlineItem should use the following rules to store information:

  1. Use tag property as a tree item label (constructor, getTag(), setTag())
    const cprojectItem = new COutlineItem(projectName);

  2. Let parent nodes create their children:
    const groupItem=cprojectItem.createChild(groupName);

  3. Use setAttribute()/getAttribute() to insert additional information for instance:
    groupItem.setAttribute('icon', 'csolution-files');
    Item need to store only relevant attributes which are non-empty.
    For instance, if an item has an associated document, use: item.setAttribute('doc', url);
    of for an associated header file: item.setAttribute('header', headerName);
    Since attributes can only be string, use 'none', 'expanded, 'collapsed' strings, e.g.
    item.setAttribute('expandable', 'none'); or item.setAttribute('expandable', 'expanded');

  4. Item context should be obtained over a special method COutlineItem.getContext() string | undefined
    the returned string should a set of available contexts for the item separated by semicolon, e.g: 'hasDoc;hasHeader'
    Regular expressions in package.json then can match sub-stings or their combinations

  5. To test the tree: write it to a YAML string using CTreeItemYamlParser or corresponding toYamlString() global function
    then match the string against golden reference stored as a YAML file, matching needs to escape absolute paths

Later it could make sense to accommodate additional functionality in COutlineItem, in particular:

  • provide specific virtual methods
  • store reference to the original CTreeItem read from YAML file: this can ease editing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

3 participants