14 const std::string &FileURI, llvm::StringRef Src,
15 std::vector<lspserver::CodeAction> &Actions) {
17 const nixf::Node *AttrNameNode = PM.
upTo(N, nixf::Node::NK_AttrName);
21 const auto &AN =
static_cast<const nixf::AttrName &
>(*AttrNameNode);
25 const std::string &Name = AN.id()->name();
28 FileURI,
toLSPRange(Src, AN.range()),
"\"" + Name +
"\""));
31 const std::string &Name = AN.staticName();
Code action for quoting/unquoting attribute names.
Convert between LSP and nixf types.
Shared utilities for code actions.
const Node * upTo(const Node &N, Node::NodeKind Kind) const
Search up until some kind of node is found.
bool isValidNixIdentifier(const std::string &S)
Check if a string is a valid Nix identifier that can be unquoted.
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.
void addAttrNameActions(const nixf::Node &N, const nixf::ParentMapAnalysis &PM, const std::string &FileURI, llvm::StringRef Src, std::vector< lspserver::CodeAction > &Actions)
Add refactoring code actions for attribute names (quote/unquote).
lspserver::Range toLSPRange(llvm::StringRef Code, const nixf::LexerCursorRange &R)
static const llvm::StringLiteral REFACTOR_REWRITE_KIND