Remove unneeded proc, add more comments
This commit is contained in:
parent
0d65bcdd52
commit
964209d5f8
1 changed files with 7 additions and 19 deletions
|
|
@ -670,7 +670,6 @@ proc getCommentNodes*(gState: State, node: TSNode, maxSearch=1): seq[TSNode] =
|
||||||
commentsFound = false
|
commentsFound = false
|
||||||
|
|
||||||
while not commentsFound and i < maxSearch:
|
while not commentsFound and i < maxSearch:
|
||||||
|
|
||||||
# Distance from the current node will tell us approximately if the
|
# Distance from the current node will tell us approximately if the
|
||||||
# comment belongs to the node. The closer it is in terms of line
|
# 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
|
# 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
|
# If the line is out of range, skip searching
|
||||||
prevSibling = nilNode
|
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 (
|
while (
|
||||||
not prevSibling.isNil and
|
not prevSibling.isNil and
|
||||||
prevSibling.getName() == "comment" and
|
prevSibling.getName() == "comment" and
|
||||||
|
|
@ -700,9 +702,13 @@ proc getCommentNodes*(gState: State, node: TSNode, maxSearch=1): seq[TSNode] =
|
||||||
prevSibling = prevSibling.tsNodePrevNamedSibling()
|
prevSibling = prevSibling.tsNodePrevNamedSibling()
|
||||||
commentsFound = true
|
commentsFound = true
|
||||||
|
|
||||||
|
# If we've already found comments above the current line, quit
|
||||||
if commentsFound:
|
if commentsFound:
|
||||||
break
|
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 (
|
while (
|
||||||
not nextSibling.isNil and
|
not nextSibling.isNil and
|
||||||
nextSibling.getName() == "comment" and
|
nextSibling.getName() == "comment" and
|
||||||
|
|
@ -723,24 +729,6 @@ proc getCommentNodes*(gState: State, node: TSNode, maxSearch=1): seq[TSNode] =
|
||||||
|
|
||||||
i += 1
|
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] =
|
proc getTSNodeNamedChildNames*(node: TSNode): seq[string] =
|
||||||
if node.tsNodeNamedChildCount() != 0:
|
if node.tsNodeNamedChildCount() != 0:
|
||||||
for i in 0 .. node.tsNodeNamedChildCount()-1:
|
for i in 0 .. node.tsNodeNamedChildCount()-1:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue