Remove regex from comment processing
This commit is contained in:
parent
ffd6b9b5eb
commit
5895db1d18
1 changed files with 8 additions and 4 deletions
|
|
@ -1,7 +1,5 @@
|
||||||
import sets, strformat, strutils
|
import sets, strformat, strutils
|
||||||
|
|
||||||
import regex
|
|
||||||
|
|
||||||
import "."/[getters, globals]
|
import "."/[getters, globals]
|
||||||
import "."/treesitter/[api, c, cpp]
|
import "."/treesitter/[api, c, cpp]
|
||||||
|
|
||||||
|
|
@ -273,8 +271,14 @@ proc getCommentsStr*(gState: State, commentNodes: seq[TSNode]): string =
|
||||||
for commentNode in commentNodes:
|
for commentNode in commentNodes:
|
||||||
result &= "\n " & gState.getNodeVal(commentNode).strip()
|
result &= "\n " & gState.getNodeVal(commentNode).strip()
|
||||||
|
|
||||||
result = result.replace(re" *(//|/\*\*|\*\*/|/\*|\*/|\*)", "")
|
result = result.multiReplace(
|
||||||
result = result.multiReplace([("\n", "\n "), ("`", "")]).strip()
|
{
|
||||||
|
"/**": "", "**/": "", "/*": "",
|
||||||
|
"*/": "", "/*": "", "//": "",
|
||||||
|
"\n": "\n ", "`": ""
|
||||||
|
}
|
||||||
|
# need to replace this last otherwise it supercedes other replacements
|
||||||
|
).replace(" *", "").strip()
|
||||||
|
|
||||||
proc getCommentNodes*(gState: State, node: TSNode, maxSearch=1): seq[TSNode] =
|
proc getCommentNodes*(gState: State, node: TSNode, maxSearch=1): seq[TSNode] =
|
||||||
## Get a set of comment nodes in order of priority. Will search up to ``maxSearch``
|
## Get a set of comment nodes in order of priority. Will search up to ``maxSearch``
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue