Fix debug output
This commit is contained in:
parent
f7bc37f2b3
commit
8c57fbf602
1 changed files with 16 additions and 17 deletions
|
|
@ -74,11 +74,16 @@ proc searchAstForNode(ast: ref Ast, node: TSNode, nimState: NimState): bool =
|
||||||
if ast.isNil:
|
if ast.isNil:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if nimState.gState.debug:
|
||||||
|
nimState.nodeBranch.add $node.tsNodeType()
|
||||||
|
echo "#" & spaces(nimState.nodeBranch.len * 2) & nimState.nodeBranch[^1]
|
||||||
|
|
||||||
if ast.children.len != 0:
|
if ast.children.len != 0:
|
||||||
if childNames.contains(ast.regex) or
|
if childNames.contains(ast.regex) or
|
||||||
(childNames.len == 0 and ast.recursive):
|
(childNames.len == 0 and ast.recursive):
|
||||||
if node.getTSNodeNamedChildCountSansComments() != 0:
|
if node.getTSNodeNamedChildCountSansComments() != 0:
|
||||||
var flag = true
|
var flag = true
|
||||||
|
|
||||||
for i in 0 .. node.tsNodeNamedChildCount()-1:
|
for i in 0 .. node.tsNodeNamedChildCount()-1:
|
||||||
if $node.tsNodeNamedChild(i).tsNodeType() != "comment":
|
if $node.tsNodeNamedChild(i).tsNodeType() != "comment":
|
||||||
let
|
let
|
||||||
|
|
@ -89,30 +94,24 @@ proc searchAstForNode(ast: ref Ast, node: TSNode, nimState: NimState): bool =
|
||||||
else:
|
else:
|
||||||
ast
|
ast
|
||||||
|
|
||||||
if nimState.gState.debug:
|
|
||||||
nimState.nodeBranch.add $node.tsNodeType()
|
|
||||||
echo "#" & spaces(nimState.nodeBranch.len) & nimState.nodeBranch[^1]
|
|
||||||
|
|
||||||
if not searchAstForNode(astChild, nodeChild, nimState):
|
if not searchAstForNode(astChild, nodeChild, nimState):
|
||||||
if nimState.gState.debug:
|
|
||||||
echo "#" & spaces(nimState.nodeBranch.len) & &" {$nodeChild.tsNodeType()} unexpected"
|
|
||||||
discard nimState.nodeBranch.pop()
|
|
||||||
flag = false
|
flag = false
|
||||||
break
|
break
|
||||||
|
|
||||||
if nimState.gState.debug:
|
|
||||||
discard nimState.nodeBranch.pop()
|
|
||||||
if nimState.nodeBranch.len == 0:
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
if flag:
|
if flag:
|
||||||
return node.saveNodeData(nimState)
|
result = node.saveNodeData(nimState)
|
||||||
else:
|
else:
|
||||||
echo "#" & spaces(nimState.nodeBranch.len+1) & $node.tsNodeType()
|
result = node.saveNodeData(nimState)
|
||||||
return node.saveNodeData(nimState)
|
else:
|
||||||
|
if nimState.gState.debug:
|
||||||
|
echo "#" & spaces(nimState.nodeBranch.len * 2) & &" {ast.getRegexForAstChildren()} !=~ {childNames}"
|
||||||
elif node.getTSNodeNamedChildCountSansComments() == 0:
|
elif node.getTSNodeNamedChildCountSansComments() == 0:
|
||||||
echo "#" & spaces(nimState.nodeBranch.len+1) & $node.tsNodeType()
|
result = node.saveNodeData(nimState)
|
||||||
return node.saveNodeData(nimState)
|
|
||||||
|
if nimState.gState.debug:
|
||||||
|
discard nimState.nodeBranch.pop()
|
||||||
|
if nimstate.nodeBranch.len == 0:
|
||||||
|
echo ""
|
||||||
|
|
||||||
proc searchAst(root: TSNode, astTable: AstTable, nimState: NimState) =
|
proc searchAst(root: TSNode, astTable: AstTable, nimState: NimState) =
|
||||||
var
|
var
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue