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

@@ -1,5 +1,4 @@
import SerializerFactory from "../serialization/SerializerFactory.js"
import SubAttributesDeclaration from "./SubObject.js"
import UnionType from "./UnionType.js"
import Utility from "../Utility.js"
@@ -9,7 +8,7 @@ import Utility from "../Utility.js"
* @typedef {IEntity | String | Number | BigInt | Boolean} AnySimpleValue
* @typedef {AnySimpleValue | AnySimpleValue[]} AnyValue
* @typedef {{
* [key: String]: AttributeInformation | AnyValue | SubAttributesDeclaration
* [key: String]: AttributeInformation | AnyValue
* }} AttributeDeclarations
* @typedef {typeof IEntity} EntityConstructor
* @typedef {{
@@ -55,21 +54,10 @@ export default class IEntity {
const attributesNames = Object.keys(attributes)
const allAttributesNames = Utility.mergeArrays(attributesNames, valuesNames)
for (let attributeName of allAttributesNames) {
let value = Utility.objectGet(values, [attributeName])
let value = values[attributeName]
/** @type {AttributeInformation} */
let attribute = attributes[attributeName]
if (attribute instanceof SubAttributesDeclaration) {
target[attributeName] = {}
defineAllAttributes(
target[attributeName],
attribute.attributes,
values[attributeName],
attributeName + "."
)
continue
}
if (!suppressWarns) {
if (!(attributeName in attributes)) {
console.warn(
@@ -189,13 +177,6 @@ export default class IEntity {
/** @param {AttributeDeclarations} attributes */
static cleanupAttributes(attributes, prefix = "") {
for (const attributeName in attributes) {
if (attributes[attributeName] instanceof SubAttributesDeclaration) {
this.cleanupAttributes(
/** @type {SubAttributesDeclaration} */(attributes[attributeName]).attributes,
prefix + "." + attributeName
)
continue
}
if (attributes[attributeName].constructor !== Object) {
attributes[attributeName] = {
value: attributes[attributeName],