nixd
Toggle main menu visibility
Loading...
Searching...
No Matches
nixd
lib
Controller
CodeActions
WithToLet.h
Go to the documentation of this file.
1
/// \file
2
/// \brief Code action for converting `with` expressions to `let/inherit`.
3
///
4
/// Transforms: with lib; expr -> let inherit (lib) usedVars; in expr
5
/// This makes variable sources explicit and improves code clarity.
6
7
#pragma once
8
9
#include <
lspserver/Protocol.h
>
10
11
#include <
nixf/Sema/ParentMap.h
>
12
#include <
nixf/Sema/VariableLookup.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 `with` expression to `let/inherit`.
26
///
27
/// This action is offered when the cursor is on the `with` keyword.
28
/// It transforms `with source; body` into `let inherit (source) vars; in body`
29
/// where vars are all variables used from the with scope.
30
///
31
/// The action is NOT offered when:
32
/// - The cursor is not on the `with` keyword
33
/// - No variables are used from the with scope (unused with)
34
/// - The with body is directly another with expression (nested with chains)
35
void
addWithToLetAction
(
const
nixf::Node &N,
const
nixf::ParentMapAnalysis &PM,
36
const
nixf::VariableLookupAnalysis &VLA,
37
const
std::string &FileURI, llvm::StringRef Src,
38
std::vector<lspserver::CodeAction> &Actions);
39
40
}
// namespace nixd
ParentMap.h
ParentMap analysis.
VariableLookup.h
Lookup variable names, from it's parent scope.
nixf::Node
Definition
Basic.h:12
Protocol.h
nixd
Definition
CommandLine/Configuration.h:9
nixd::addWithToLetAction
void addWithToLetAction(const nixf::Node &N, const nixf::ParentMapAnalysis &PM, const nixf::VariableLookupAnalysis &VLA, const std::string &FileURI, llvm::StringRef Src, std::vector< lspserver::CodeAction > &Actions)
Add code action to convert with expression to let/inherit.
Definition
WithToLet.cpp:133
nixf
Definition
Diagnostic.h:19
Generated by
1.17.0