mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-18 11:20:07 -04:00
parser: only use parse to get a tree
This will avoid using internal data.
This commit is contained in:
parent
f999dc4113
commit
6eca8d2f38
4 changed files with 4 additions and 4 deletions
|
|
@ -43,7 +43,7 @@ local function select_incremental(get_parent)
|
||||||
local csrow, cscol, cerow, cecol = visual_selection_range()
|
local csrow, cscol, cerow, cecol = visual_selection_range()
|
||||||
-- Initialize incremental selection with current selection
|
-- Initialize incremental selection with current selection
|
||||||
if not nodes or #nodes == 0 or not range_matches(nodes[#nodes]) then
|
if not nodes or #nodes == 0 or not range_matches(nodes[#nodes]) then
|
||||||
local root = parsers.get_parser().tree:root()
|
local root = parsers.get_parser():parse():root()
|
||||||
local node = root:named_descendant_for_range(csrow, cscol, cerow, cecol)
|
local node = root:named_descendant_for_range(csrow, cscol, cerow, cecol)
|
||||||
ts_utils.update_selection(buf, node)
|
ts_utils.update_selection(buf, node)
|
||||||
if nodes and #nodes > 0 then
|
if nodes and #nodes > 0 then
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,7 @@ function M.find_usages(node, scope_node, bufnr)
|
||||||
|
|
||||||
if not node_text or #node_text < 1 then return {} end
|
if not node_text or #node_text < 1 then return {} end
|
||||||
|
|
||||||
local scope_node = scope_node or parsers.get_parser(bufnr).tree:root()
|
local scope_node = scope_node or parsers.get_parser(bufnr):parse():root()
|
||||||
local usages = {}
|
local usages = {}
|
||||||
|
|
||||||
for match in M.iter_locals(bufnr, scope_node) do
|
for match in M.iter_locals(bufnr, scope_node) do
|
||||||
|
|
|
||||||
|
|
@ -397,7 +397,7 @@ end
|
||||||
function M.get_tree_root(bufnr)
|
function M.get_tree_root(bufnr)
|
||||||
local bufnr = bufnr or api.nvim_get_current_buf()
|
local bufnr = bufnr or api.nvim_get_current_buf()
|
||||||
|
|
||||||
return M.get_parser(bufnr).tree:root()
|
return M.get_parser(bufnr):parse():root()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- get language of given buffer
|
-- get language of given buffer
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ end
|
||||||
|
|
||||||
function TSRange:parent(range)
|
function TSRange:parent(range)
|
||||||
local parser = parsers.get_parser(self.buf, parsers.get_buf_lang(range))
|
local parser = parsers.get_parser(self.buf, parsers.get_buf_lang(range))
|
||||||
local root = parser.tree:root()
|
local root = parser:parse():root()
|
||||||
return root:named_descendant_for_range(self.start_pos[1], self.start_pos[2], self.end_pos[1], self.end_pos[2])
|
return root:named_descendant_for_range(self.start_pos[1], self.start_pos[2], self.end_pos[1], self.end_pos[2])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue