Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
comments
  • Loading branch information
n-young-db committed Apr 29, 2024
commit 70dfc02aa9e498ccfd53a7a7f3e6f54badddfcdf
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]]

override val origin: Origin = CurrentOrigin.get

/**
* A mutable map for holding auxiliary information of this tree node. It will be carried over
* when this node is copied via `makeCopy`, or transformed via `transformUp`/`transformDown`.
*/
private[this] var _tags: mutable.Map[TreeNodeTag[_], Any] = null
private def tags: mutable.Map[TreeNodeTag[_], Any] = {
if (_tags eq null) {
Expand Down Expand Up @@ -158,6 +162,12 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]]
}
}

def resetTags(): Unit = {
if (!(_tags eq null)) {
tags.clear()
}
}

def setTagValue[T](tag: TreeNodeTag[T], value: T): Unit = {
tags(tag) = value
}
Expand All @@ -171,7 +181,9 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]]
}

def unsetTagValue[T](tag: TreeNodeTag[T]): Unit = {
tags -= tag
if (!(_tags eq null)) {
tags -= tag
}
}

/**
Expand Down