Skip to content

Commit

Permalink
rename locateNearestNode to nearestNodeFromPos
Browse files Browse the repository at this point in the history
  • Loading branch information
nedpals committed Sep 9, 2023
1 parent 80eca10 commit b6a805e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion errgoengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (e *ErrgoEngine) Analyze(workingPath, msg string) (*CompiledErrorTemplate,

if nearest.StartPoint().Row != uint32(mainTraceNode.Line) {
cursor := sitter.NewTreeCursor(nearest)
nearest = locateNearestNode(cursor, mainTraceNode.Position)
nearest = nearestNodeFromPos(cursor, mainTraceNode.Position)
}

contextData.MainError = MainError{
Expand Down
4 changes: 2 additions & 2 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func WrapNode(doc *Document, n *sitter.Node) SyntaxNode {
}
}

func locateNearestNode(cursor *sitter.TreeCursor, pos Position) *sitter.Node {
func nearestNodeFromPos(cursor *sitter.TreeCursor, pos Position) *sitter.Node {
cursor.GoToFirstChild()
defer cursor.GoToParent()

Expand All @@ -89,7 +89,7 @@ func locateNearestNode(cursor *sitter.TreeCursor, pos Position) *sitter.Node {
if pointA.Row+1 == uint32(pos.Line) {
return currentNode
} else if uint32(pos.Line) >= pointA.Row+1 && uint32(pos.Line) <= pointB.Row+1 {
return locateNearestNode(cursor, pos)
return nearestNodeFromPos(cursor, pos)
} else if !cursor.GoToNextSibling() {
return nil
}
Expand Down

0 comments on commit b6a805e

Please sign in to comment.