nixd
Loading...
Searching...
No Matches
AddToFormals.h
Go to the documentation of this file.
1/// \file
2/// \brief Code action for adding undefined variables to lambda formals.
3///
4/// Transforms: {x}: y -> {x, y}: y
5/// This adds undefined variables to the formal parameter list of a lambda.
6
7#pragma once
8
10
11#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 add undefined variable to lambda formals.
26///
27/// This action is offered when:
28/// - The cursor is on an ExprVar (variable reference)
29/// - The variable is undefined (not found in any scope)
30/// - The enclosing lambda has a formals parameter list (e.g., {x, y}: body)
31///
32/// The action is NOT offered when:
33/// - The variable is already defined in any scope
34/// - There is no enclosing lambda
35/// - The enclosing lambda uses simple argument style (x: body) instead of
36/// formals
37///
38/// Transformation example: `{x}: y` -> `{x, y}: y`
39void addToFormalsAction(const nixf::Node &N, const nixf::ParentMapAnalysis &PM,
40 const nixf::VariableLookupAnalysis &VLA,
41 const std::string &FileURI, llvm::StringRef Src,
42 std::vector<lspserver::CodeAction> &Actions);
43
44} // namespace nixd
ParentMap analysis.
Lookup variable names, from it's parent scope.
void addToFormalsAction(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 add undefined variable to lambda formals.