From cc17e81340483b29028c61297fa6230e9113231b Mon Sep 17 00:00:00 2001 From: barsdeveloper Date: Sun, 12 Feb 2023 11:06:49 +0100 Subject: [PATCH] More robust checks --- js/Utility.js | 2 +- js/entity/ObjectEntity.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/js/Utility.js b/js/Utility.js index af7d3c3..3e3512b 100755 --- a/js/Utility.js +++ b/js/Utility.js @@ -323,7 +323,7 @@ export default class Utility { } /** @param {String} value */ - static formatStringName(value) { + static formatStringName(value = "") { return value // Remove leading b (for boolean values) or newlines .replace(/^\s*b/, "") diff --git a/js/entity/ObjectEntity.js b/js/entity/ObjectEntity.js index fd92c36..d3c39a4 100755 --- a/js/entity/ObjectEntity.js +++ b/js/entity/ObjectEntity.js @@ -304,7 +304,7 @@ export default class ObjectEntity extends IEntity { getType() { let classValue = this.getClass() - if (classValue === Configuration.nodeType.macro) { + if (this.MacroGraphReference?.MacroGraph?.path) { return this.MacroGraphReference.MacroGraph.path } return classValue @@ -407,7 +407,7 @@ export default class ObjectEntity extends IEntity { || nodeClass.includes("Debug", Math.max(0, nodeClass.lastIndexOf("."))) } - hasHIDAttribute() { + getHIDAttribute() { return this.InputKey ?? this.AxisKey ?? this.InputAxisKey } @@ -423,15 +423,15 @@ export default class ObjectEntity extends IEntity { if (!this.TargetType) { return "Bad cast node" // Target type not found } - return `Cast To ${this.TargetType.getName()}` + return `Cast To ${this.TargetType?.getName()}` case Configuration.nodeType.enumLiteral: - return `Literal enum ${this.Enum.getName()}` + return `Literal enum ${this.Enum?.getName()}` case Configuration.nodeType.event: return `Event ${(this.EventReference?.MemberName ?? "").replace(/^Receive/, "")}` case Configuration.nodeType.executionSequence: return "Sequence" case Configuration.nodeType.forEachElementInEnum: - return `For Each ${this.Enum.getName()}` + return `For Each ${this.Enum?.getName()}` case Configuration.nodeType.forEachLoopWithBreak: return "For Each Loop with Break" case Configuration.nodeType.ifThenElse: @@ -441,7 +441,7 @@ export default class ObjectEntity extends IEntity { case Configuration.nodeType.variableSet: return "SET" } - const keyNameSymbol = this.hasHIDAttribute() + const keyNameSymbol = this.getHIDAttribute() if (keyNameSymbol) { const keyName = keyNameSymbol.toString() let title = ObjectEntity.keyName(keyName) ?? Utility.formatStringName(keyName) @@ -453,7 +453,7 @@ export default class ObjectEntity extends IEntity { return title } if (this.getClass() === Configuration.nodeType.macro) { - return Utility.formatStringName(this.MacroGraphReference.getMacroName()) + return Utility.formatStringName(this.MacroGraphReference?.getMacroName()) } let memberName = this.FunctionReference?.MemberName if (memberName) { @@ -580,7 +580,7 @@ export default class ObjectEntity extends IEntity { if (this.getClass() === Configuration.nodeType.macro) { return SVGIcon.macro } - const hidValue = this.hasHIDAttribute()?.toString() + const hidValue = this.getHIDAttribute()?.toString() if (hidValue) { if (hidValue.includes("Mouse")) { return SVGIcon.mouse