-
I attempted to add queries for YANG over the weekend, but I quickly realized that for this language, icons are completely unhelpful: YANG is a language with deeply nested structures, and the node types are:
The GPS line in the screenshot above would be FAR more helpful if it said:
Can you see a way to achieve this? 🤔 I either have to include the keyword in the capture in the query, or I have to prepend the container type in the transformation function somehow. I haven't thought of a way to do either yet. In the syntax tree, each statement basically looks like The syntax tree for the screenshot above looks like this: The current query looks like this: ((module module_name: (identifier) @container-name) @scope-root)
((statement
(statement_keyword "container")
(argument) @container-name) @scope-root)
((statement
(statement_keyword "grouping")
(argument) @function-name) @scope-root)
((statement
(statement_keyword "list")
(argument) @class-name) @scope-root)
((statement
(statement_keyword "leaf")
(argument) @method-name) @scope-root) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Never mind! Somehow, after asking this question I immediately figured it out. Turns out it was trivial to achieve with a transformation function. ["yang"] = function(capture_name, capture_text)
if capture_name == "container-name" then
return "container "..capture_text
elseif capture_name == "grouping-name" then
return "grouping "..capture_text
elseif capture_name == "list-name" then
return "list "..capture_text
elseif capture_name == "leaf-name" then
return "leaf "..capture_text
-- ...
else
return capture_text
end
end |
Beta Was this translation helpful? Give feedback.
Never mind! Somehow, after asking this question I immediately figured it out. Turns out it was trivial to achieve with a transformation function.