17 const std::string &FileURI, llvm::StringRef Src,
18 std::vector<lspserver::CodeAction> &Actions) {
20 const nixf::Node *InheritNode = PM.
upTo(N, nixf::Node::NK_Inherit);
31 if (Names.size() != 1)
34 const auto &Name = Names[0];
41 if (!Name->isStatic())
44 const std::string &AttrName = Name->staticName();
47 std::ostringstream NewText;
48 NewText << AttrName <<
" = ";
52 NewText <<
Inherit.expr()->src(Src) <<
"." << AttrName;
61 "Convert to explicit binding",
Convert between LSP and nixf types.
Code action for converting inherit to explicit binding.
Shared utilities for code actions.
const std::vector< std::shared_ptr< AttrName > > & names() const
const Node * upTo(const Node &N, Node::NodeKind Kind) const
Search up until some kind of node is found.
void addInheritToBindingAction(const nixf::Node &N, const nixf::ParentMapAnalysis &PM, const std::string &FileURI, llvm::StringRef Src, std::vector< lspserver::CodeAction > &Actions)
Add code action to convert inherit to explicit binding.
lspserver::CodeAction createSingleEditAction(const std::string &Title, llvm::StringLiteral Kind, const std::string &FileURI, const lspserver::Range &EditRange, std::string NewText)
Create a CodeAction with a single text edit.
lspserver::Range toLSPRange(llvm::StringRef Code, const nixf::LexerCursorRange &R)
static const llvm::StringLiteral REFACTOR_REWRITE_KIND