Skip to content

Commit

Permalink
Alter metadata visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
wingio committed Nov 16, 2023
1 parent 01cfae9 commit 763a776
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public class Syntakts<C> internal constructor(
val newBuilder = rule.parse(matchResult)

if(debugOptions.storeMetadata) {
newBuilder.root._metadata = Node.MetaData(rule.name, rule.regex, matchResult)
newBuilder.root.setMetadata(rule.name, rule.regex, matchResult)
}

val parent = builder.root
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import xyz.wingio.syntakts.style.StyledTextBuilder
@Stable
public open class Node<C>(
private var _children: MutableCollection<Node<C>>? = null,
internal var _metadata: MetaData? = null
private var _metadata: MetaData? = null
) {

/**
Expand Down Expand Up @@ -56,6 +56,21 @@ public open class Node<C>(
_children = (_children ?: mutableListOf()).apply { add(child) }
}

/**
* Set node metadata
*
* @param ruleName Name of the rule that created this node
* @param rule The pattern used to create this node
* @param matchResult The matched text for this node
*/
public open fun setMetadata(
ruleName: String,
rule: Regex,
matchResult: MatchResult
) {
_metadata = MetaData(ruleName, rule, matchResult)
}

/**
* Render this node
*
Expand Down

0 comments on commit 763a776

Please sign in to comment.