Fixing various bugs in the grammar

This commit is contained in:
barsdeveloper
2023-03-28 14:32:16 +02:00
parent 3dcbfb6ff0
commit 53a99a426e
24 changed files with 302 additions and 437 deletions

View File

@@ -17,7 +17,6 @@ import RotatorEntity from "./RotatorEntity.js"
import SimpleSerializationRotatorEntity from "./SimpleSerializationRotatorEntity.js"
import SimpleSerializationVector2DEntity from "./SimpleSerializationVector2DEntity.js"
import SimpleSerializationVectorEntity from "./SimpleSerializationVectorEntity.js"
import SubAttributesDeclaration from "./SubObject.js"
import UnionType from "./UnionType.js"
import Utility from "../Utility.js"
import Vector2DEntity from "./Vector2DEntity.js"
@@ -53,73 +52,71 @@ export default class PinEntity extends IEntity {
}
static lookbehind = "Pin"
static attributes = {
PinId: {
"PinId": {
type: GuidEntity,
},
PinName: "",
PinFriendlyName: {
"PinName": "",
"PinFriendlyName": {
type: new UnionType(LocalizedTextEntity, FormatTextEntity, String),
showDefault: false,
},
PinToolTip: {
"PinToolTip": {
type: String,
showDefault: false,
},
Direction: {
"Direction": {
type: String,
showDefault: false,
},
PinType: new SubAttributesDeclaration({
PinCategory: "",
PinSubCategory: "",
PinSubCategoryObject: {
type: ObjectReferenceEntity,
},
PinSubCategoryMemberReference: {
type: FunctionReferenceEntity,
value: null,
},
PinValueType: {
type: PinTypeEntity,
value: null,
},
ContainerType: {
type: PathSymbolEntity,
},
bIsReference: false,
bIsConst: false,
bIsWeakPointer: false,
bIsUObjectWrapper: false,
bSerializeAsSinglePrecisionFloat: false,
}),
LinkedTo: {
"PinType.PinCategory": "",
"PinType.PinSubCategory": "",
"PinType.PinSubCategoryObject": {
type: ObjectReferenceEntity,
},
"PinType.PinSubCategoryMemberReference": {
type: FunctionReferenceEntity,
value: null,
},
"PinType.PinValueType": {
type: PinTypeEntity,
value: null,
},
"PinType.ContainerType": {
type: PathSymbolEntity,
},
"PinType.bIsReference": false,
"PinType.bIsConst": false,
"PinType.bIsWeakPointer": false,
"PinType.bIsUObjectWrapper": false,
"PinType.bSerializeAsSinglePrecisionFloat": false,
"LinkedTo": {
type: [PinReferenceEntity],
showDefault: false,
},
DefaultValue: {
"DefaultValue": {
/** @param {PinEntity} pinEntity */
type: pinEntity => pinEntity.getEntityType(true) ?? String,
serialized: true,
showDefault: false,
},
AutogeneratedDefaultValue: {
"AutogeneratedDefaultValue": {
type: String,
showDefault: false,
},
DefaultObject: {
"DefaultObject": {
type: ObjectReferenceEntity,
showDefault: false,
value: null,
},
PersistentGuid: {
"PersistentGuid": {
type: GuidEntity,
},
bHidden: false,
bNotConnectable: false,
bDefaultValueIsReadOnly: false,
bDefaultValueIsIgnored: false,
bAdvancedView: false,
bOrphanedPin: false,
"bHidden": false,
"bNotConnectable": false,
"bDefaultValueIsReadOnly": false,
"bDefaultValueIsIgnored": false,
"bAdvancedView": false,
"bOrphanedPin": false,
}
static {
@@ -128,46 +125,42 @@ export default class PinEntity extends IEntity {
constructor(values = {}, suppressWarns = false) {
super(values, suppressWarns)
/** @type {GuidEntity} */ this.PinId
/** @type {String} */ this.PinName
/** @type {LocalizedTextEntity | String} */ this.PinFriendlyName
/** @type {String} */ this.PinToolTip
/** @type {String} */ this.Direction
/**
* @type {{
* PinCategory: String,
* PinSubCategory: String,
* PinSubCategoryObject: ObjectReferenceEntity,
* PinSubCategoryMemberReference: FunctionReferenceEntity,
* PinValueType: PinTypeEntity,
* ContainerType: PathSymbolEntity,
* bIsReference: Boolean,
* bIsConst: Boolean,
* bIsWeakPointer: Boolean,
* bIsUObjectWrapper: Boolean,
* bSerializeAsSinglePrecisionFloat: Boolean,
* }}
*/ this.PinType
/** @type {PinReferenceEntity[]} */ this.LinkedTo
/** @type {T} */ this.DefaultValue
/** @type {String} */ this.AutogeneratedDefaultValue
/** @type {ObjectReferenceEntity} */ this.DefaultObject
/** @type {GuidEntity} */ this.PersistentGuid
/** @type {Boolean} */ this.bHidden
/** @type {Boolean} */ this.bNotConnectable
/** @type {Boolean} */ this.bDefaultValueIsReadOnly
/** @type {Boolean} */ this.bDefaultValueIsIgnored
/** @type {Boolean} */ this.bAdvancedView
/** @type {Boolean} */ this.bOrphanedPin
this["PinId"] ??= /** @type {GuidEntity} */(undefined)
this["PinName"] ??= /** @type {String} */(undefined)
this["PinFriendlyName"] ??= /** @type {LocalizedTextEntity | String} */(undefined)
this["PinToolTip"] ??= /** @type {String} */(undefined)
this["Direction"] ??= /** @type {String} */(undefined)
this["PinType.PinCategory"] ??= /** @type {String} */(undefined)
this["PinType.PinSubCategory"] ??= /** @type {String} */(undefined)
this["PinType.PinSubCategoryObject"] ??= /** @type {ObjectReferenceEntity} */(undefined)
this["PinType.PinSubCategoryMemberReference"] ??= /** @type {FunctionReferenceEntity} */(undefined)
this["PinType.PinValueType"] ??= /** @type {PinTypeEntity} */(undefined)
this["PinType.ContainerType"] ??= /** @type {PathSymbolEntity} */(undefined)
this["PinType.bIsReference"] ??= /** @type {Boolean} */(undefined)
this["PinType.bIsConst"] ??= /** @type {Boolean} */(undefined)
this["PinType.bIsWeakPointer"] ??= /** @type {Boolean} */(undefined)
this["PinType.bIsUObjectWrapper"] ??= /** @type {Boolean} */(undefined)
this["PinType.bIsUObjectWrapper"] ??= /** @type {Boolean} */(undefined)
this["LinkedTo"] ??= /** @type {PinReferenceEntity[]} */(undefined)
this["DefaultValue"] ??= /** @type {T} */(undefined)
this["AutogeneratedDefaultValue"] ??= /** @type {String} */(undefined)
this["DefaultObject"] ??= /** @type {ObjectReferenceEntity} */(undefined)
this["PersistentGuid"] ??= /** @type {GuidEntity} */(undefined)
this["bHidden"] ??= /** @type {Boolean} */(undefined)
this["bNotConnectable"] ??= /** @type {Boolean} */(undefined)
this["bDefaultValueIsReadOnly"] ??= /** @type {Boolean} */(undefined)
this["bDefaultValueIsIgnored"] ??= /** @type {Boolean} */(undefined)
this["bAdvancedView"] ??= /** @type {Boolean} */(undefined)
this["bOrphanedPin"] ??= /** @type {Boolean} */(undefined)
}
getType() {
const subCategory = this.PinType.PinSubCategoryObject
if (this.PinType.PinCategory === "struct" || this.PinType.PinCategory === "object") {
const subCategory = this["PinType.PinSubCategoryObject"]
if (this["PinType.PinCategory"] === "struct" || this["PinType.PinCategory"] === "object") {
return subCategory.path
}
if (
this.PinType.PinCategory === "byte"
this["PinType.PinCategory"] === "byte"
&& (
subCategory.type === Configuration.nodeType.enum
|| subCategory.type === Configuration.nodeType.userDefinedEnum
@@ -175,7 +168,7 @@ export default class PinEntity extends IEntity {
) {
return "enum"
}
return this.PinType.PinCategory
return this["PinType.PinCategory"]
}
getEntityType(alternative = false) {
@@ -190,51 +183,51 @@ export default class PinEntity extends IEntity {
getDisplayName() {
let matchResult = null
if (
this.PinToolTip
this["PinToolTip"]
// Match up until the first \n excluded or last character
&& (matchResult = this.PinToolTip.match(/\s*(.+?(?=\n)|.+\S)\s*/))
&& (matchResult = this["PinToolTip"].match(/\s*(.+?(?=\n)|.+\S)\s*/))
) {
return Utility.formatStringName(matchResult[1])
}
return Utility.formatStringName(this.PinName)
return Utility.formatStringName(this["PinName"])
}
/** @param {PinEntity} other */
copyTypeFrom(other) {
this.PinType.PinCategory = other.PinType.PinCategory
this.PinType.PinSubCategory = other.PinType.PinSubCategory
this.PinType.PinSubCategoryObject = other.PinType.PinSubCategoryObject
this.PinType.PinSubCategoryMemberReference = other.PinType.PinSubCategoryMemberReference
this.PinType.PinValueType = other.PinType.PinValueType
this.PinType.ContainerType = other.PinType.ContainerType
this.PinType.bIsReference = other.PinType.bIsReference
this.PinType.bIsConst = other.PinType.bIsConst
this.PinType.bIsWeakPointer = other.PinType.bIsWeakPointer
this.PinType.bIsUObjectWrapper = other.PinType.bIsUObjectWrapper
this.PinType.bSerializeAsSinglePrecisionFloat = other.PinType.bSerializeAsSinglePrecisionFloat
this["PinType.PinCategory"] = other["PinType.PinCategory"]
this["PinType.PinSubCategory"] = other["PinType.PinSubCategory"]
this["PinType.PinSubCategoryObject"] = other["PinType.PinSubCategoryObject"]
this["PinType.PinSubCategoryMemberReference"] = other["PinType.PinSubCategoryMemberReference"]
this["PinType.PinValueType"] = other["PinType.PinValueType"]
this["PinType.ContainerType"] = other["PinType.ContainerType"]
this["PinType.bIsReference"] = other["PinType.bIsReference"]
this["PinType.bIsConst"] = other["PinType.bIsConst"]
this["PinType.bIsWeakPointer"] = other["PinType.bIsWeakPointer"]
this["PinType.bIsUObjectWrapper"] = other["PinType.bIsUObjectWrapper"]
this["PinType.bSerializeAsSinglePrecisionFloat"] = other["PinType.bSerializeAsSinglePrecisionFloat"]
}
getDefaultValue(maybeCreate = false) {
if (this.DefaultValue === undefined && maybeCreate) {
this.DefaultValue = new (this.getEntityType(true))()
if (this["DefaultValue"] === undefined && maybeCreate) {
this["DefaultValue"] = new (this.getEntityType(true))()
}
return this.DefaultValue
return this["DefaultValue"]
}
isExecution() {
return this.PinType.PinCategory === "exec"
return this["PinType.PinCategory"] === "exec"
}
isHidden() {
return this.bHidden
return this["bHidden"]
}
isInput() {
return !this.bHidden && this.Direction != "EGPD_Output"
return !this["bHidden"] && this["Direction"] != "EGPD_Output"
}
isOutput() {
return !this.bHidden && this.Direction == "EGPD_Output"
return !this["bHidden"] && this["Direction"] == "EGPD_Output"
}
isLinked() {
@@ -248,12 +241,12 @@ export default class PinEntity extends IEntity {
linkTo(targetObjectName, targetPinEntity) {
const linkFound = this.LinkedTo?.some(pinReferenceEntity =>
pinReferenceEntity.objectName.toString() == targetObjectName
&& pinReferenceEntity.pinGuid.valueOf() == targetPinEntity.PinId.valueOf()
&& pinReferenceEntity.pinGuid.valueOf() == targetPinEntity["PinId"].valueOf()
)
if (!linkFound) {
(this.LinkedTo ??= []).push(new PinReferenceEntity({
objectName: targetObjectName,
pinGuid: targetPinEntity.PinId,
pinGuid: targetPinEntity["PinId"],
}))
return true
}
@@ -267,7 +260,7 @@ export default class PinEntity extends IEntity {
unlinkFrom(targetObjectName, targetPinEntity) {
const indexElement = this.LinkedTo?.findIndex(pinReferenceEntity => {
return pinReferenceEntity.objectName.toString() == targetObjectName
&& pinReferenceEntity.pinGuid.valueOf() == targetPinEntity.PinId.valueOf()
&& pinReferenceEntity.pinGuid.valueOf() == targetPinEntity["PinId"].valueOf()
})
if (indexElement >= 0) {
this.LinkedTo.splice(indexElement, 1)
@@ -280,13 +273,13 @@ export default class PinEntity extends IEntity {
}
getSubCategory() {
return this.PinType.PinSubCategoryObject.path
return this["PinType.PinSubCategoryObject"].path
}
/** @return {CSSResult} */
pinColor() {
return Configuration.pinColor[this.getType()]
?? Configuration.pinColor[this.PinType.PinCategory]
?? Configuration.pinColor[this["PinType.PinCategory"]]
?? Configuration.pinColor["default"]
}
}