fix: deprecate ts_utils get_node_text #88 (#98)

This commit is contained in:
Daniel Mathiot
2022-06-13 08:33:43 +02:00
committed by GitHub
parent a4b2fd5ba5
commit 3a37832265
3 changed files with 11 additions and 16 deletions

View File

@@ -1,4 +1,3 @@
local ts_utils = require("nvim-treesitter.ts_utils")
local nodes_utils = require("neogen.utilities.nodes")
local extractors = require("neogen.utilities.extractors")
local locator = require("neogen.locators.default")
@@ -110,7 +109,7 @@ return {
-- Check if function is a static method. If so, will not remove the first parameter
if node:parent():type() == "decorated_definition" then
local decorator = nodes_utils:matching_child_nodes(node:parent(), "decorator")
decorator = ts_utils.get_node_text(decorator[1])[1]
decorator = vim.treesitter.query.get_node_text(decorator[1], 0)
if decorator == "@staticmethod" then
remove_identifier = false
end
@@ -185,7 +184,7 @@ return {
for _, assignment in pairs(nodes["assignment"]) do
local left_side = assignment:field("left")[1]
local left_attribute = left_side:field("attribute")[1]
left_attribute = ts_utils.get_node_text(left_attribute)[1]
left_attribute = vim.treesitter.query.get_node_text(left_attribute, 0)
if left_attribute and not vim.startswith(left_attribute, "_") then
table.insert(results[i.ClassAttribute], left_attribute)
end
@@ -233,7 +232,7 @@ return {
if child:type() == "comment" then
local start_row = child:start()
if start_row == 0 then
if vim.startswith(ts_utils.get_node_text(node, 0)[1], "#!") then
if vim.startswith(vim.treesitter.query.get_node_text(node, 0), "#!") then
return 1, 0
end
end