Skip to content

more fixes to issue#561 #596

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

Merged
merged 7 commits into from
Nov 9, 2021
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
30 changes: 24 additions & 6 deletions dbux-code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,21 +238,29 @@
}
},
{
"command": "dbuxTraceDetailsView.context.showError",
"command": "dbuxTraceDetailsView.node.showError",
"title": "Show all errors",
"icon": {
"light": "resources/light/fire.svg",
"dark": "resources/dark/fire.svg"
}
},
{
"command": "dbuxTraceDetailsView.context.showError.disabled",
"command": "dbuxTraceDetailsView.node.showError.disabled",
"title": "No error occurred",
"icon": {
"light": "resources/light/fire_disabled.svg",
"dark": "resources/dark/fire_disabled.svg"
}
},
{
"command": "dbuxTraceDetailsView.node.editedWarning",
"title": "Document changed -> code decorations might be inaccurate",
"icon": {
"light": "resources/light/warning.svg",
"dark": "resources/dark/warning.svg"
}
},
{
"command": "dbuxCallGraphView.setFilter",
"title": "Filter",
Expand Down Expand Up @@ -875,15 +883,20 @@
"group": "navigation"
},
{
"command": "dbuxTraceDetailsView.context.showError",
"command": "dbuxTraceDetailsView.node.showError",
"when": "view == dbuxTraceDetailsView && dbux.context.hasError",
"group": "navigation"
},
{
"command": "dbuxTraceDetailsView.context.showError.disabled",
"command": "dbuxTraceDetailsView.node.showError.disabled",
"when": "view == dbuxTraceDetailsView && !dbux.context.hasError",
"group": "navigation"
},
{
"command": "dbuxTraceDetailsView.node.editedWarning",
"when": "view == dbuxTraceDetailsView && dbuxTraceDetailsView.context.editedWarning",
"group": "navigation"
},
{
"command": "dbuxTraceDetailsView.selectTraceAtCursor",
"when": "view == dbuxTraceDetailsView && dbuxTraceDetailsView.context.hasTracesAtCursor",
Expand Down Expand Up @@ -1183,11 +1196,16 @@
"when": "false"
},
{
"command": "dbuxTraceDetailsView.context.showError",
"command": "dbuxTraceDetailsView.node.showError",
"when": "false"
},
{
"command": "dbuxTraceDetailsView.node.showError.disabled",
"when": "false"
},

{
"command": "dbuxTraceDetailsView.context.showError.disabled",
"command": "dbuxTraceDetailsView.node.editedWarning",
"when": "false"
},
{
Expand Down
7 changes: 7 additions & 0 deletions dbux-code/resources/dark/warning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions dbux-code/resources/light/warning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion dbux-code/src/codeDeco/editedWarning.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { showWarningMessage } from '../codeUtil/codeModals';
// eslint-disable-next-line no-unused-vars
const { log, debug, warn, error: logError } = newLogger('EditedWarning');

function getRelatedAppIds(fpath) {
export function getRelatedAppIds(fpath) {
return allApplications.selection.data.mapApplicationsOfFilePath(fpath, (app) => app.applicationId);
}

Expand Down
23 changes: 19 additions & 4 deletions dbux-code/src/codeUtil/BaseTreeViewNodeProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class BaseTreeViewNodeProvider {
* @param {boolean} [options.createTreeView]
*/
constructor(viewName, options = {}) {
this.viewName = viewName;
this.treeViewName = viewName;
const { showCollapseAll = false, createTreeView = true } = options;

// NOTE: view creation inside the data provider is not ideal,
Expand All @@ -51,6 +51,7 @@ export default class BaseTreeViewNodeProvider {
showCollapseAll: showCollapseAll,
treeDataProvider: this
});
this.defaultTitle = this.treeView.title;

this.treeView.onDidCollapseElement(this.handleCollapsibleStateChanged);
this.treeView.onDidExpandElement(this.handleCollapsibleStateChanged);
Expand All @@ -59,11 +60,25 @@ export default class BaseTreeViewNodeProvider {

initDefaultClickCommand(context) {
registerCommand(context,
this.clickCommandName = `${this.viewName}.click`,
this.clickCommandName = `${this.treeViewName}.click`,
(node) => this.handleClick(node)
);
}

/** ###########################################################################
* treeview controll
* #########################################################################*/

resetTitle() {
this.setTitle(this.defaultTitle);
}

setTitle(title) {
if (this.treeView) {
this.treeView.title = title;
}
}

// ###########################################################################
// basic event handling
// ###########################################################################
Expand Down Expand Up @@ -152,7 +167,7 @@ export default class BaseTreeViewNodeProvider {
* @virtual
*/
handleClick = async (node) => {
const treeViewName = this.viewName;
const { treeViewName } = this;
const action = ''; // not a button click
const nodeId = node.id;
const args = {
Expand All @@ -174,7 +189,7 @@ export default class BaseTreeViewNodeProvider {
}

handleNodeCollapsibleStateChanged = (node) => {
const treeViewName = this.viewName;
const { treeViewName } = this;
const action = ''; // not a button click
const nodeId = node.id;
const args = {
Expand Down
9 changes: 7 additions & 2 deletions dbux-code/src/commands/traceDetailsViewCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,17 @@ export function initTraceDetailsViewCommands(context, traceDetailsViewController
);

registerCommand(context,
'dbuxTraceDetailsView.context.showError',
'dbuxTraceDetailsView.node.showError',
() => traceDetailsViewController.showError()
);

registerCommand(context,
'dbuxTraceDetailsView.context.showError.disabled',
'dbuxTraceDetailsView.node.showError.disabled',
() => showInformationMessage('No error occurred.')
);

registerCommand(context,
'dbuxTraceDetailsView.node.editedWarning',
async () => traceDetailsViewController.showEditedWarning()
);
}
6 changes: 4 additions & 2 deletions dbux-code/src/traceDetailsView/TraceDetailsNodeProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ export default class TraceDetailsDataProvider extends BaseTreeViewNodeProvider {
.filter(node => !!node);
}

maybeBuildTraceDetailNode(NodeClass, entry, parent, props) {
maybeBuildTraceDetailNode(NodeClass, trace, parent, props) {
let entry = trace;
if (NodeClass.makeEntry) {
entry = NodeClass.makeEntry(entry, parent, props);
// Some NodeClasses might depend on non-trace entry
entry = NodeClass.makeEntry(trace, parent, props);
if (!entry) {
return null;
}
Expand Down
36 changes: 20 additions & 16 deletions dbux-code/src/traceDetailsView/nodes/ValueTDRefNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ import ValueTDSimpleNode from './ValueTDSimpleNode';

/** @typedef {import('@dbux/common/src/types/Trace').default} Trace */

/**
* Node represents an complex value, use `ValueNode.entry.refId` + `ValueNode.rootDataNode.nodeId`(as terminalNodeId) to render.
*/
export default class ValueTDRefNode extends ValueNode {
/**
* For root node only.
* @param {Trace} trace
*/
static makeEntry(trace, parent, props) {
const { traceId, applicationId } = trace;
const dp = allApplications.getById(applicationId).dataProvider;
const dataTrace = dp.util.getValueTrace(traceId);
const { nodeId } = dataTrace;
const dataNode = dp.collections.dataNodes.getById(nodeId);
const dataNode = dp.util.getDataNodeOfTrace(traceId);
if (dataNode && dataNode.refId && dp.collections.values.getById(dataNode.refId)) {
return dataNode;
}
Expand All @@ -23,58 +25,60 @@ export default class ValueTDRefNode extends ValueNode {
}

/**
* Make initial props
* For root node only.
*/
static makeProperties({ refId }/*, parent, props*/) {
static makeProperties(dataNode/*, parent, props*/) {
return {
refId,
key: ValueLabel
key: ValueLabel,
rootDataNode: dataNode,
};
}

static makeLabel(dataNode, parent, { key }) {
return `${key}:`;
}

get rootDataNode() {
get dataNode() {
return this.entry;
}

get valueRef() {
const { refId, dp } = this;
return dp.collections.values.getById(refId);
return this.dp.collections.values.getById(this.dataNode.refId);
}

init() {
super.init();

const { rootDataNode } = this;
const { typeName } = this.valueRef;
const { nodeId } = this.rootDataNode;
this.description = `${this.dp.util.getDataNodeValueStringShort(nodeId)}${typeName && ` (${typeName})`}`;
const { nodeId } = this.dataNode;
this.description = `${this.dp.util.getDataNodeValueStringShort(nodeId, rootDataNode.nodeId)}${typeName && ` (${typeName})`}`;
}

buildChildren() {
const { rootDataNode, dp, refId } = this;
const { rootDataNode, dp } = this;
const { refId, nodeId } = this.dataNode;
const valueObj = dp.util.constructValueObjectShallow(refId, rootDataNode.nodeId);
const entries = valueObj && Object.entries(valueObj);

if (entries?.length) {
return entries.map(([key, [childNodeId, childRefId, childValue]]) => {
const childDataNode = dp.collections.dataNodes.getById(childNodeId);
if (childRefId) {
return this.treeNodeProvider.buildNode(
ValueTDRefNode, rootDataNode, this, { key, refId: childRefId, nodeId: childNodeId }
ValueTDRefNode, childDataNode, this, { key, refId: childRefId, rootDataNode }
);
}
else {
return this.treeNodeProvider.buildNode(
ValueTDSimpleNode, rootDataNode, this, { key, value: childValue, nodeId: childNodeId }
ValueTDSimpleNode, childDataNode, this, { key, value: childValue, rootDataNode }
);
}
});
}
else {
// node was omitted, or in trouble for other reasons
const simpleValue = this.dp.collections.values.getById(refId)?.value;
const simpleValue = dp.collections.values.getById(refId)?.value;
if (simpleValue !== undefined) {
return [];
}
Expand Down
21 changes: 13 additions & 8 deletions dbux-code/src/traceDetailsView/nodes/ValueTDSimpleNode.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
import EmptyObject from '@dbux/common/src/util/EmptyObject';
import allApplications from '@dbux/data/src/applications/allApplications';
import ValueNode, { ValueLabel } from './ValueNode';

/** @typedef {import('@dbux/common/src/types/Trace').default} Trace */

/**
* Node contains pure value, no entry(dataNode) available
* Node contains pure value, use `V`alueNode.value` to render
*/
export default class ValueTDSimpleNode extends ValueNode {
/**
* For root node only.
* @param {Trace} trace
*/
static makeEntry(trace, parent, props) {
const { traceId, applicationId } = trace;
const dp = allApplications.getById(applicationId).dataProvider;
const dataTrace = dp.util.getValueTrace(traceId);
const { nodeId } = dataTrace;
const dataNode = dp.collections.dataNodes.getById(nodeId);
const dataNode = dp.util.getDataNodeOfTrace(traceId);
if (dataNode && !dataNode.refId) {
return dataNode;
}
if (!dataNode) {
// render empty value
return {};
return EmptyObject;
}
return null;
}

/**
* Make initial props
* For root node only.
*/
static makeProperties({ value }/*, parent, props*/) {
static makeProperties(dataNode/*, parent, props*/) {
const { value } = dataNode;
return {
key: ValueLabel,
value,
key: ValueLabel
rootDataNode: dataNode,
};
}

Expand Down
Loading