@@ -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
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
local ts_utils = require("nvim-treesitter.ts_utils")
|
||||
local helpers = require("neogen.utilities.helpers")
|
||||
|
||||
--- Tries to use the configuration to find all required content nodes from the parent node
|
||||
@@ -27,14 +26,13 @@ return function(parent_node, node_data)
|
||||
end
|
||||
|
||||
if not data.match or child_node:type() == data.match then
|
||||
if type(data.extract) == "function" then
|
||||
-- Extract content from it { [type] = { data } }
|
||||
for type, extracted_data in pairs(data.extract(child_node)) do
|
||||
result[type] = extracted_data
|
||||
end
|
||||
else
|
||||
-- if not extract function, get the text from the node (required: data.type)
|
||||
result[data.type] = ts_utils.get_node_text(child_node)
|
||||
if not type(data.extract) == "function" then
|
||||
return
|
||||
end
|
||||
|
||||
-- Extract content from it { [type] = { data } }
|
||||
for type, extracted_data in pairs(data.extract(child_node)) do
|
||||
result[type] = extracted_data
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
local ts_utils = require("nvim-treesitter.ts_utils")
|
||||
|
||||
return {
|
||||
--- Extract the content from each node from data
|
||||
--- @param _ any self
|
||||
@@ -14,7 +12,7 @@ return {
|
||||
return node:type()
|
||||
end
|
||||
local get_text = function(node)
|
||||
return ts_utils.get_node_text(node)[1]
|
||||
return vim.treesitter.query.get_node_text(node, 0)
|
||||
end
|
||||
if opts.type then
|
||||
result[k] = vim.tbl_map(get_type, v)
|
||||
|
||||
Reference in New Issue
Block a user