A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
complete.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 The A11 Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef A11_FLOW_COMPLETE_H_
18#define A11_FLOW_COMPLETE_H_
19
20#include <cstddef>
21#include <string>
22#include <string_view>
23#include <vector>
24
25#include "a11/flow/catalogue.h"
26#include "a11/flow/limits.h"
27
28namespace a11::flow {
29
30struct LinkedModule;
31
33enum class ProposalKind {
41 kStage,
45 kType,
55 kFlow,
57 kPort,
59 kNode,
63 kCall,
69 kHeader,
71 kField,
72};
73
75struct Proposal {
77 std::string name;
80 std::string insert;
82 std::string filter;
84 int caret = -1;
86 size_t replace_start = std::string::npos;
89 std::string tail;
91 std::string type;
93 std::string documentation;
94};
95
98 std::vector<Proposal> proposals;
100 std::string prefix;
102 size_t prefix_start = 0;
103};
104
109 std::string_view source, size_t offset,
112 CompilationBudget* absl_nullable budget = nullptr,
113 const LinkedModule* absl_nullable linked = nullptr);
114
116std::string_view ProposalKindName(ProposalKind kind);
117
119inline constexpr std::string_view kCompletionsFormat = "flow.completions/v1";
120
121} // namespace a11::flow
122
123#endif // A11_FLOW_COMPLETE_H_
Everything the tools know about the world, in one place.
Definition catalogue.h:91
static const Catalogue & Builtin()
The embedded snapshot: what a standalone tool knows with nothing configured.
Definition catalogue.cc:503
TokenKind kind
Definition format.cc:1372
CompilationLimits limits
Definition main.cc:148
LinkedModule linked
Definition lsp.cc:290
CompilationBudget budget
Definition lsp.cc:289
catalogue::Catalogue known
Definition lsp.cc:291
Definition catalogue.cc:29
ProposalKind
Completion categories published by flow.completions/v1.
Definition complete.h:33
@ kConstant
true, false, null, it.
@ kPort
A port of this flow, or of a call.
@ kDeclaration
A word that declares something: in, header, describe.
@ kStatement
A word that opens a statement: run, wait, for.
@ kCall
A bound run/call step.
@ kField
A field of something: a status's code, a node's id.
@ kLogLevel
A log level, as log and logf name one.
@ kStage
A pipeline stage, offered after a |.
@ kHeader
A header, under its alias.
@ kModifier
A word that follows a call: tee, timeout, forward headers.
@ kNode
A node of the flow's own.
@ kFunction
One of the fixed functions.
@ kFlow
A flow of this file, offered as a call target.
@ kStatusCode
A canonical status code, as fail names one.
@ kPortModifier
What a port says about itself: stream, required.
@ kVariable
A loop variable, the index a loop binds, or what a repeat carries.
@ kBarrier
A bound wait/close.
constexpr std::string_view kCompletionsFormat
The format field of the completions envelope.
Definition complete.h:119
CompleteResult CompleteAt(std::string_view source, size_t offset, const catalogue::Catalogue &known, CompilationLimits limits, CompilationBudget *budget, const LinkedModule *linked)
Definition complete.cc:1903
std::string_view ProposalKindName(ProposalKind kind)
The name of a proposal kind in the output format, in kebab case.
Definition complete.cc:1933
std::uint32_t offset
Definition runtime_streams.cc:36
Host-controlled bounds shared by parsing, linking and semantic analysis.
Definition limits.h:24
What may be written at an offset, and the word already typed there.
Definition complete.h:97
std::string prefix
Partial word at the caret; proposals remain unfiltered.
Definition complete.h:100
std::vector< Proposal > proposals
Definition complete.h:98
size_t prefix_start
Start of the replacement range; equals the caret for an empty prefix.
Definition complete.h:102
One thing that may be written at an offset.
Definition complete.h:75
std::string tail
Grey text an editor shows after the name: what a stage takes, whether a port is required.
Definition complete.h:89
std::string type
The type of the thing proposed, where it has one: a port's declared type.
Definition complete.h:91
ProposalKind kind
Definition complete.h:78
int caret
Caret byte offset in insert; -1 places it at the end.
Definition complete.h:84
std::string filter
Text matched while the visible label includes an invocation verb.
Definition complete.h:82
std::string documentation
Markdown documentation shared with hover results; empty when unavailable.
Definition complete.h:93
std::string insert
Text inserted for this proposal, including required syntax.
Definition complete.h:80
size_t replace_start
Optional document offset overriding the common prefix replacement.
Definition complete.h:86
std::string name
The word, as it would be read back: truncate, x.question.
Definition complete.h:77