nixd
Loading...
Searching...
No Matches
ConvertToInherit.h
Go to the documentation of this file.
1/// \file
2/// \brief Code action for converting bindings to inherit syntax.
3///
4/// Transforms:
5/// - { x = x; } -> { inherit x; }
6/// - { a = lib.a; } -> { inherit (lib) a; }
7
8#pragma once
9
10#include <lspserver/Protocol.h>
11
12#include <nixf/Sema/ParentMap.h>
13
14#include <llvm/ADT/StringRef.h>
15
16#include <string>
17#include <vector>
18
19namespace nixf {
20class Node;
21} // namespace nixf
22
23namespace nixd {
24
25/// \brief Add code action to convert binding to inherit syntax.
26///
27/// This action is offered when the cursor is on a binding that matches
28/// one of these patterns:
29/// - { attrName = attrName; } -> { inherit attrName; }
30/// - { attrName = source.attrName; } -> { inherit (source) attrName; }
31///
32/// The action is NOT offered when:
33/// - The binding has a multi-segment path (e.g., x.y = z)
34/// - The attribute name is dynamic/interpolated
35/// - The value doesn't match the attribute name
36/// - The select expression has a default value
37void addConvertToInheritAction(const nixf::Node &N,
38 const nixf::ParentMapAnalysis &PM,
39 const std::string &FileURI, llvm::StringRef Src,
40 std::vector<lspserver::CodeAction> &Actions);
41
42} // namespace nixd
ParentMap analysis.
void addConvertToInheritAction(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 binding to inherit syntax.