Know location fix

This commit is contained in:
barsdeveloper
2023-05-01 14:42:01 +02:00
parent 74a9dd7ca3
commit fff40b7619
11 changed files with 239 additions and 144 deletions

View File

@@ -14,6 +14,7 @@ import KeyBindingEntity from "../entity/KeyBindingEntity.js"
import LinearColorEntity from "../entity/LinearColorEntity.js"
import LocalizedTextEntity from "../entity/LocalizedTextEntity.js"
import MacroGraphReferenceEntity from "../entity/MacroGraphReferenceEntity.js"
import MirroredEntity from "../entity/MirroredEntity.js"
import NaturalNumberEntity from "../entity/NaturalNumberEntity.js"
import ObjectEntity from "../entity/ObjectEntity.js"
import ObjectReferenceEntity from "../entity/ObjectReferenceEntity.js"
@@ -172,6 +173,8 @@ export default class Grammar {
? this.unknownValue
: P.alt(acc, cur)
)
} else if (type instanceof MirroredEntity) {
return this.grammarFor(type.type.attributes[type.key])
} else if (attribute?.constructor === Object) {
result = this.grammarFor(undefined, type)
} else {
@@ -331,8 +334,9 @@ export default class Grammar {
valueSeparator,
).chain(([attributeName, _1]) => {
const attributeKey = attributeName.split(Configuration.keysSeparator)
const attributeValue = this.getAttribute(entityType, attributeKey)
return this
.grammarFor(this.getAttribute(entityType, attributeKey))
.grammarFor(attributeValue)
.map(attributeValue =>
values => Utility.objectSet(values, attributeKey, attributeValue, true)
)
@@ -688,7 +692,6 @@ export default class Grammar {
this.customProperty,
this.createAttributeGrammar(ObjectEntity),
this.inlinedArrayEntry,
// Legacy subobject
this.subObjectEntity
)
)

View File

@@ -13,6 +13,7 @@ import KeyBindingEntity from "../entity/KeyBindingEntity.js"
import LinearColorEntity from "../entity/LinearColorEntity.js"
import LocalizedTextEntity from "../entity/LocalizedTextEntity.js"
import MacroGraphReferenceEntity from "../entity/MacroGraphReferenceEntity.js"
import MirroredEntity from "../entity/MirroredEntity.js"
import ObjectEntity from "../entity/ObjectEntity.js"
import ObjectReferenceEntity from "../entity/ObjectReferenceEntity.js"
import ObjectSerializer from "./ObjectSerializer.js"
@@ -54,7 +55,6 @@ export default function initializeSerializerFactory() {
(array, insideString) =>
`(${array
.map(v =>
// @ts-expect-error
SerializerFactory.getSerializer(Utility.getType(v)).write(v, insideString) + ","
)
.join("")
@@ -104,7 +104,6 @@ export default function initializeSerializerFactory() {
(v, insideString) => {
let result = FormatTextEntity.lookbehind + "("
+ v.value.map(v =>
// @ts-expect-error
SerializerFactory.getSerializer(Utility.getType(v)).write(v, insideString)
).join(", ")
+ ")"
@@ -163,6 +162,11 @@ export default function initializeSerializerFactory() {
new Serializer(MacroGraphReferenceEntity, Serializer.bracketsWrapped)
)
SerializerFactory.registerSerializer(
MirroredEntity,
new Serializer(MirroredEntity)
)
SerializerFactory.registerSerializer(
Number,
new ToStringSerializer(Number)