nixd
Loading...
Searching...
No Matches
nixd
lib
Controller
CodeActions
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
19
namespace
nixf
{
20
class
Node
;
21
}
// namespace nixf
22
23
namespace
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
37
void
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.h
ParentMap analysis.
nixf::Node
Definition
Basic.h:12
Protocol.h
nixd
Definition
CommandLine/Configuration.h:9
nixd::addConvertToInheritAction
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.
Definition
ConvertToInherit.cpp:15
nixf
Definition
Diagnostic.h:19
Generated by
1.15.0