test: fix tests broken after 0.10 update (#6714)

This commit is contained in:
Riley Bruins 2024-05-31 20:33:56 -07:00 committed by GitHub
parent b7d50e59b1
commit f9773e4a5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 19 deletions

View file

@ -397,6 +397,7 @@ function M.swap_nodes(node_or_range1, node_or_range2, bufnr, cursor_to_second)
local edit1 = { range = range1, newText = table.concat(text2, "\n") } local edit1 = { range = range1, newText = table.concat(text2, "\n") }
local edit2 = { range = range2, newText = table.concat(text1, "\n") } local edit2 = { range = range2, newText = table.concat(text1, "\n") }
bufnr = bufnr == 0 and vim.api.nvim_get_current_buf() or bufnr
vim.lsp.util.apply_text_edits({ edit1, edit2 }, bufnr, "utf-8") vim.lsp.util.apply_text_edits({ edit1, edit2 }, bufnr, "utf-8")
if cursor_to_second then if cursor_to_second then

View file

@ -1,13 +1,12 @@
[ ((element
((element (start_tag
(start_tag (tag_name) @_not_void_element))
(tag_name) @_not_void_element)) (#not-any-of? @_not_void_element
(#not-any-of? @_not_void_element "area" "base" "basefont" "bgsound" "br" "col" "command" "embed" "frame" "hr" "image" "img"
"area" "base" "basefont" "bgsound" "br" "col" "command" "embed" "frame" "hr" "image" "img" "input" "isindex" "keygen" "link" "menuitem" "meta" "nextid" "param" "source" "track" "wbr")) @indent.begin
"input" "isindex" "keygen" "link" "menuitem" "meta" "nextid" "param" "source" "track" "wbr"))
(element (element
(self_closing_tag)) (self_closing_tag)) @indent.begin
] @indent.begin
((start_tag ((start_tag
(tag_name) @_void_element) (tag_name) @_void_element)

View file

@ -29,6 +29,7 @@ local function check_assertions(file)
) )
) )
local parser = parsers.get_parser(buf, lang) local parser = parsers.get_parser(buf, lang)
parser:parse(true)
local self = highlighter.new(parser, {}) local self = highlighter.new(parser, {})
@ -39,12 +40,13 @@ local function check_assertions(file)
local captures = {} local captures = {}
local highlights = {} local highlights = {}
self.tree:for_each_tree(function(tstree, tree) self:prepare_highlight_states(row, row + 1)
if not tstree then self:for_each_highlight_state(function(state)
if not state.tstree then
return return
end end
local root = tstree:root() local root = state.tstree:root()
local root_start_row, _, root_end_row, _ = root:range() local root_start_row, _, root_end_row, _ = root:range()
-- Only worry about trees within the line range -- Only worry about trees within the line range
@ -52,7 +54,7 @@ local function check_assertions(file)
return return
end end
local query = self:get_query(tree:lang()) local query = state.highlighter_query
-- Some injected languages may not have highlight queries. -- Some injected languages may not have highlight queries.
if not query:query() then if not query:query() then
@ -62,7 +64,7 @@ local function check_assertions(file)
local iter = query:query():iter_captures(root, self.bufnr, row, row + 1) local iter = query:query():iter_captures(root, self.bufnr, row, row + 1)
for capture, node, _ in iter do for capture, node, _ in iter do
local hl = query.hl_cache[capture] local hl = query:get_hl_from_capture(capture)
assert.is.truthy(hl) assert.is.truthy(hl)
assert.Truthy(node) assert.Truthy(node)

View file

@ -1,5 +1,4 @@
require "nvim-treesitter.highlight" -- yes, this is necessary to set the hlmap require "nvim-treesitter.highlight" -- yes, this is necessary to set the hlmap
local highlighter = require "vim.treesitter.highlighter"
local configs = require "nvim-treesitter.configs" local configs = require "nvim-treesitter.configs"
local parsers = require "nvim-treesitter.parsers" local parsers = require "nvim-treesitter.parsers"
local ts = vim.treesitter local ts = vim.treesitter
@ -21,8 +20,8 @@ local function check_assertions(file)
) )
local parser = parsers.get_parser(buf, lang) local parser = parsers.get_parser(buf, lang)
local self = highlighter.new(parser, {}) local self = parser
local top_level_root = parser:parse()[1]:root() local top_level_root = parser:parse(true)[1]:root()
for _, assertion in ipairs(assertions) do for _, assertion in ipairs(assertions) do
local row = assertion.position.row local row = assertion.position.row
@ -32,7 +31,7 @@ local function check_assertions(file)
assertion.expected_capture_name = neg_assert and assertion.expected_capture_name:sub(2) assertion.expected_capture_name = neg_assert and assertion.expected_capture_name:sub(2)
or assertion.expected_capture_name or assertion.expected_capture_name
local found = false local found = false
self.tree:for_each_tree(function(tstree, tree) self:for_each_tree(function(tstree, tree)
if not tstree then if not tstree then
return return
end end