Skip to content

Commit 66a5565

Browse files
committed
test: refactor parser initialization in test suite
1 parent 29696a3 commit 66a5565

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/server/features_formatting_test.v

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ fn test_large_file() {
1616
ls.setup_vpaths()
1717

1818
uri := lsp.document_uri_from_path(test_file)
19-
res := parser.parse_code(src)
19+
20+
mut p := parser.Parser.new()
21+
defer { p.free() }
22+
res := p.parse_code(src)
2023
psi_file := psi.new_psi_file(uri.path(), res.tree, res.source_text)
2124
ls.opened_files[uri] = analyzer.OpenedFile{
2225
uri: uri

src/tools/project-checker.v

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,12 @@ pub fn (mut i Checker) check() {
109109

110110
pub fn (mut c Checker) check_file(path string) []ErrorInfo {
111111
content := os.read_file(path) or { return [] }
112-
res := parser.parse_code(content)
113112

114-
root := res.tree.root_node()
113+
mut p := parser.Parser.new()
114+
defer { p.free() }
115+
res := p.parse_code(content)
115116

117+
root := res.tree.root_node()
116118
errors := c.check_node(path, AstNode(root))
117119

118120
// unsafe { res.tree.free() }

0 commit comments

Comments
 (0)