This is the only PR for M3 where the removal of case classes is combined with a fairly big refactoring as it allows to remove some old limitations now that we do no longer have to support low-level copy operations on DocumentTree.
The Document instances added to such a tree have three properties which represent a hierarchical structure within the document tree:
path: Path, the virtual path of the document with the tree
config: Config, the configuration instance which uses the config of the parent tree as a fallback
position: Position, the value that is used for auto-numbering of documents
In the past these values could go out of sync due to the existence of low-level copy methods on both, DocumentTree and Document. Now that both are regular classes the correct parent association can be managed internally, creating a much more robust representation of the virtual tree on top of being easier to evolve in a binary compatible manner. A Document instance can now safely be taken from one DocumentTree and inserted into another where internally a copy with adjusted parent context will be added instead.
Types within the laika.ast package which cease to be case classes:
The removal of a copy method is balanced by the introduction of mutator methods, in the most simple case just the withFoo pattern, but in some cases with additional methods for convenience, e.g. modifyConfig(ConfigBuilder => ConfigBuilder) which helps with the common case of just adding to existing properties.
This is the only PR for M3 where the removal of case classes is combined with a fairly big refactoring as it allows to remove some old limitations now that we do no longer have to support low-level copy operations on
DocumentTree
.The
Document
instances added to such a tree have three properties which represent a hierarchical structure within the document tree:path: Path
, the virtual path of the document with the treeconfig: Config
, the configuration instance which uses the config of the parent tree as a fallbackposition: Position
, the value that is used for auto-numbering of documentsIn the past these values could go out of sync due to the existence of low-level copy methods on both,
DocumentTree
andDocument
. Now that both are regular classes the correct parent association can be managed internally, creating a much more robust representation of the virtual tree on top of being easier to evolve in a binary compatible manner. ADocument
instance can now safely be taken from oneDocumentTree
and inserted into another where internally a copy with adjusted parent context will be added instead.Types within the
laika.ast
package which cease to be case classes:TreeCursor
DocumentCursor
Document
DocumentTree
DocumentTreeRoot
TemplateDocument
The removal of a
copy
method is balanced by the introduction of mutator methods, in the most simple case just thewithFoo
pattern, but in some cases with additional methods for convenience, e.g.modifyConfig(ConfigBuilder => ConfigBuilder)
which helps with the common case of just adding to existing properties.