Skip to content

Commit

Permalink
some barebones documentation on the new origin
Browse files Browse the repository at this point in the history
  • Loading branch information
Naum-Tomov committed Oct 12, 2023
1 parent 76a0ebf commit fe6e030
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/parsers/vct/parsers/transform/ToCol.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,18 @@ abstract class ToCol[G](val baseOrigin: Origin, val blameProvider: BlameProvider
def nodes: Seq[ParserRuleContext] = Seq(pure, inline, threadLocal, static, bipAnnotation).flatten
}

/**
* Used to convert ParserRuleContext nodes into origin implicitly
* @param node the node we want the origin of
* @return a constructed Origin based on the (implicitly) given node
*/
implicit def origin(implicit node: ParserRuleContext): Origin = {
Origin(baseOrigin.originContents ++ ctxToOrigin(node.start, node.stop).originContents)
}

/**
* Helper function used to deduce a node's position in the origin, used by the implicit origin method
*/
def ctxToOrigin(start: Token, stop: Token): Origin = {
val startLineIdx = start.getLine - 1
val startColIdx = start.getCharPositionInLine
Expand Down

0 comments on commit fe6e030

Please sign in to comment.