From 964209d5f855f5933f5d5aa8b4d18fa5fa1fbc03 Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Thu, 30 Apr 2020 12:45:00 -0600 Subject: Remove unneeded proc, add more comments --- nimterop/getters.nim | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/nimterop/getters.nim b/nimterop/getters.nim index 05d9448..cae2d08 100644 --- a/nimterop/getters.nim +++ b/nimterop/getters.nim @@ -670,7 +670,6 @@ proc getCommentNodes*(gState: State, node: TSNode, maxSearch=1): seq[TSNode] = commentsFound = false while not commentsFound and i < maxSearch: - # Distance from the current node will tell us approximately if the # comment belongs to the node. The closer it is in terms of line # numbers, the more we can be sure it's the comment we want @@ -689,6 +688,9 @@ proc getCommentNodes*(gState: State, node: TSNode, maxSearch=1): seq[TSNode] = # If the line is out of range, skip searching prevSibling = nilNode + # Search above the current line for comments. When one is found + # keep going to retrieve successive comments for cases with multiple + # `//` style comments while ( not prevSibling.isNil and prevSibling.getName() == "comment" and @@ -700,9 +702,13 @@ proc getCommentNodes*(gState: State, node: TSNode, maxSearch=1): seq[TSNode] = prevSibling = prevSibling.tsNodePrevNamedSibling() commentsFound = true + # If we've already found comments above the current line, quit if commentsFound: break + # Search below or at the current line for comments. When one is found + # keep going to retrieve successive comments for cases with multiple + # `//` style comments while ( not nextSibling.isNil and nextSibling.getName() == "comment" and @@ -723,24 +729,6 @@ proc getCommentNodes*(gState: State, node: TSNode, maxSearch=1): seq[TSNode] = i += 1 -proc getNextCommentNodes*(gState: State, node: TSNode, maxSearch=1): seq[TSNode] = - ## Searches the next nodes up to maxSearch nodes away for a comment - - if gState.nocomments: - return - # We only want to search for the next comment node (ie: inline) - # but we want to keep the same interface as getPrevCommentNodes, - # so we keep a returned seq but only store one element - var sibling = node.tsNodeNextNamedSibling() - var i = 0 - # Search for the comment up to maxSearch nodes away - while not sibling.isNil and i < maxSearch: - if sibling.getName() == "comment": - result.add sibling - break - sibling = sibling.tsNodeNextNamedSibling() - i += 1 - proc getTSNodeNamedChildNames*(node: TSNode): seq[string] = if node.tsNodeNamedChildCount() != 0: for i in 0 .. node.tsNodeNamedChildCount()-1: -- cgit v1.2.3