Skip to content

Commit

Permalink
Merge pull request #709 from Domiii/misc
Browse files Browse the repository at this point in the history
misc fixes for PR reviews #703, #704
  • Loading branch information
Domiii authored Mar 28, 2022
2 parents 2a747fe + 4118f04 commit 7238826
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 24 deletions.
15 changes: 15 additions & 0 deletions dbux-code/src/codeUtil/treeView/BaseTreeViewNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,19 @@ export default class BaseTreeViewNode extends TreeItem {
registerActiveEvents() {
return null;
}


/** ###########################################################################
* helper
* #########################################################################*/

/**
* Find a chlid node of given class from parent, or from roots if parent is `undefined`.
* @param {*} clazz A node class that extends `BaseTreeViewNode`
* @param {BaseTreeViewNode} parent
* @return {BaseTreeViewNode}
*/
getChildByClass(clazz) {
return this.children.find(node => node instanceof clazz);
}
}
20 changes: 5 additions & 15 deletions dbux-code/src/codeUtil/treeView/BaseTreeViewNodeProvider.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TreeItemCollapsibleState, EventEmitter, window, TreeView } from 'vscode';
import TriggerablePromise from '@dbux/common/src/util/TriggerablePromise';
import SyncPromise from '@dbux/common/src/util/SyncPromise';
import EmptyObject from '@dbux/common/src/util/EmptyObject';
import { newLogger } from '@dbux/common/src/log/logger';
import NestedError from '@dbux/common/src/NestedError';
Expand Down Expand Up @@ -51,7 +51,7 @@ export default class BaseTreeViewNodeProvider {
constructor(viewName, options = {}) {
this.treeViewName = viewName;
this.logger = newLogger(this.constructor.name);
this.refreshPromise = new TriggerablePromise(500);
this.refreshPromise = new SyncPromise(500);
const { showCollapseAll = false, createTreeView = true } = options;

// NOTE: view creation inside the data provider is not ideal,
Expand Down Expand Up @@ -389,7 +389,7 @@ export default class BaseTreeViewNodeProvider {
}

getChildren = async (node) => {
const children = await this._getChildren(node);
const children = await this._getChildren(node);
this.refreshPromise.resolve(children);
return children;
}
Expand Down Expand Up @@ -422,18 +422,8 @@ export default class BaseTreeViewNodeProvider {
}

/** ###########################################################################
* helper
* #########################################################################*/

/**
* Find a chlid node of given class from parent, or from roots if parent is `undefined`.
* @param {*} clazz A node class that extends `BaseTreeViewNode`
* @param {BaseTreeViewNode} parent
* @return {BaseTreeViewNode}
*/
getChildByClass(clazz, parent) {
return parent.children.find(node => node instanceof clazz);
}
* helper
* #########################################################################*/

/**
* Find root of given class.
Expand Down
16 changes: 10 additions & 6 deletions dbux-code/src/globalAnalysisView/GlobalAnalysisViewController.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@ export default class GlobalAnalysisViewController {
* #########################################################################*/

async focusOnSearchResult() {
const searchResultNode = this.treeDataProvider.getRootByClass(GlobalSearchNode);
/**
* NOTE: VSCode sometimes failed to reveal if `refresh` is executing simultaneously, which causes an error:
* `Error: TreeError [dbuxTraceDetailsView] Data tree node not found: [object Object]`.
* But currently VSCode API does not support thenable `refresh`.
*/
if (!this.treeView.visible) {
return;
}

try {
/**
* NOTE: VSCode sometimes failed to reveal if `refresh` is executing simultaneously, which causes an error:
* `Error: TreeError [dbuxTraceDetailsView] Data tree node not found: [object Object]`.
* But currently VSCode API does not support thenable `refresh`.
*/
const searchResultNode = this.treeDataProvider.getRootByClass(GlobalSearchNode);
await this.treeView.reveal(searchResultNode, { select: false, expand: 1 });
}
catch (err) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sleep from './sleep';

export default class TriggerablePromise {
export default class SyncPromise {
promise;

_resolve;
Expand Down
4 changes: 3 additions & 1 deletion dbux-graph-client/src/graph/asyncGraph/AsyncGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import GraphBase from '../GraphBase';

/** @typedef {import('../controllers/PopperManager').default} PopperManager */

const Verbose = false;

class AsyncGraph extends GraphBase {
/**
* @return {PopperManager}
Expand Down Expand Up @@ -533,7 +535,7 @@ class AsyncGraph extends GraphBase {
asyncNodeData.valueTraceId = valueTraceId;
}
else {
this.logger.warn(`[updateRootValueLabel] update before asyncNodeData is set.`);
Verbose && this.logger.warn(`[updateRootValueLabel] update before asyncNodeData is set.`);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion dbux-graph-host/src/graph/SyncGraphBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ class CallGraphNodes {
contexts = node.group.contexts;
}
else {
throw new Error(`Calling "_handleContextNodeDisposed" with non-ContextNode parameter`);
throw new Error(`Calling "_handleContextNodeDisposed" with non-ContextNode parameter: ${node}`);
}

for (const context of contexts) {
Expand Down

0 comments on commit 7238826

Please sign in to comment.