Skip to content

Commit

Permalink
[OneStorage] Improve insert (#1704)
Browse files Browse the repository at this point in the history
This commit improves insert function to manipulate cfgToCfgObjMap too.
This way, we can refresh only related nodes in some cases.

ONE-vscode-DCO-1.0-Signed-off-by: Dayoung Lee <[email protected]>
  • Loading branch information
dayo09 authored Oct 11, 2023
1 parent 23a5afc commit e597fb9
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/OneExplorer/OneStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ class CfgToCfgObjMap {
return this._map.get(path);
}

public set(path: string, cfgObj: ConfigObj) {
this.map.set(path, cfgObj);
}

// TODO Revisit here
public reset(type: NodeType, path: string) {
switch (type) {
case NodeType.config:
Expand Down Expand Up @@ -130,7 +135,7 @@ export class OneStorage {
/**
* @brief A map of ConfigObj (key: cfg path)
*/
private _cfgToCfgObjMap = new CfgToCfgObjMap();
private _cfgToCfgObjMap: CfgToCfgObjMap = new CfgToCfgObjMap();

/**
* Get the list of .cfg files within the workspace
Expand Down Expand Up @@ -232,10 +237,16 @@ export class OneStorage {
}

public static insert(node: Node) {
// NOTE
// Only _nodeMap is built by calling this function
// _baseModelToCfgsMap and _cfgToCfgObjMap are built at constructors
OneStorage.get()._nodeMap.set(node.path, node);
const inst = OneStorage.get();
inst._nodeMap.set(node.path, node);
if (node.type === NodeType.config) {
if (!inst._cfgToCfgObjMap.get(node.path)) {
const cfgObj = ConfigObj.createConfigObj(node.uri);
if (cfgObj) {
inst._cfgToCfgObjMap.set(node.path, cfgObj);
}
}
}
}

/**
Expand Down

0 comments on commit e597fb9

Please sign in to comment.