Tests for various entity classes and update entity class implementations

This commit is contained in:
barsdeveloper
2024-06-03 00:11:30 +02:00
parent 5314228b33
commit 8fed17b20f
11 changed files with 309 additions and 210 deletions

View File

@@ -6,6 +6,7 @@ import StringEntity from "./StringEntity.js"
export default class FormatTextEntity extends IPrintableEntity {
static attributeSeparator = ", "
static lookbehind = ["LOCGEN_FORMAT_NAMED", "LOCGEN_FORMAT_ORDERED"]
/** @type {P<FormatTextEntity>} */
static grammar = P.lazy(() => P.seq(
@@ -53,4 +54,16 @@ export default class FormatTextEntity extends IPrintableEntity {
: ""
return result
}
toString(
insideString = false,
indentation = "",
printKey = this.Self().printKey,
) {
const separator = this.Self().attributeSeparator
return this.lookbehind + "("
+ this.values.map(v => v.toString(insideString)).join(separator)
+ (this.Self().trailing ? separator : "")
+ ")"
}
}