Skip to content

Commit 85d6a63

Browse files
Create unit tests for tree-sitter (#34)
* added some unit tests for the tree-sitter * updated github actions and rockspec
1 parent 2dad2a7 commit 85d6a63

File tree

7 files changed

+386
-16
lines changed

7 files changed

+386
-16
lines changed

.github/workflows/test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ jobs:
1616
- uses: actions/checkout@main
1717

1818
- name: Install Lua
19-
uses: leafo/gh-actions-lua@v8.0.0
19+
uses: leafo/gh-actions-lua@v10
2020
with:
2121
luaVersion: ${{ matrix.luaVersion }}
2222

2323
- name: Install LuaRocks
24-
uses: leafo/gh-actions-luarocks@v4.0.0
24+
uses: leafo/gh-actions-luarocks@v4
2525

2626
- name: Build
2727
run: scripts/setup_local_luarocks.sh

gen/teal_language_server/document.lua

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ local asserts = require("teal_language_server.asserts")
99
local tracing = require("teal_language_server.tracing")
1010

1111
local ltreesitter = require("ltreesitter")
12-
local teal_parser = ltreesitter.load("./teal.so", "teal")
12+
local teal_parser = ltreesitter.require("parser/teal", "teal")
1313

1414
local tl = require("tl")
1515

@@ -397,7 +397,7 @@ function Document:type_information_for_tokens(tokens, y, x)
397397
return nil
398398
end
399399

400-
function Document:_parser_token(y, x)
400+
function Document:_tree_sitter_token(y, x)
401401
local moved = self._tree_cursor:goto_first_child()
402402
local node = self._tree_cursor:current_node()
403403

@@ -487,21 +487,21 @@ function Document:_parser_token(y, x)
487487

488488
if y == start_point.row and y == end_point.row then
489489
if x >= start_point.column and x <= end_point.column then
490-
return self:_parser_token(y, x)
490+
return self:_tree_sitter_token(y, x)
491491
end
492492

493493
elseif y >= start_point.row and y <= end_point.row then
494-
return self:_parser_token(y, x)
494+
return self:_tree_sitter_token(y, x)
495495
end
496496

497497
moved = self._tree_cursor:goto_next_sibling()
498498
node = self._tree_cursor:current_node()
499499
end
500500
end
501501

502-
function Document:parser_token(y, x)
502+
function Document:tree_sitter_token(y, x)
503503
self._tree_cursor:reset(self._tree:root())
504-
return self:_parser_token(y, x)
504+
return self:_tree_sitter_token(y, x)
505505
end
506506

507507
class.setup(Document, "Document", {

gen/teal_language_server/misc_handlers.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function MiscHandlers:_get_node_info(params, pos)
167167
end
168168

169169
tracing.warning(_module_name, "Received request for completion at position: {}", { pos })
170-
local node_info = doc:parser_token(pos.line, pos.character)
170+
local node_info = doc:tree_sitter_token(pos.line, pos.character)
171171
if node_info == nil then
172172
tracing.warning(_module_name, "Unable to retrieve node info from tree-sitter parser", {})
173173
return nil

0 commit comments

Comments
 (0)