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
27namespace a11::flow {
28
35enum class ProposalKind {
43 kStage,
47 kType,
57 kFlow,
59 kPort,
61 kNode,
65 kCall,
71 kHeader,
73 kField,
74};
75
77struct Proposal {
79 std::string name;
84 std::string insert;
88 int caret = -1;
91 std::string tail;
93 std::string type;
94 // The whole of what is known about it, as Markdown, for the popup an editor
95 // shows beside the list.
104 std::string documentation;
105};
106
109 std::vector<Proposal> proposals;
113 std::string prefix;
122 size_t prefix_start = 0;
123};
124
151 std::string_view source, size_t offset,
153
155std::string_view ProposalKindName(ProposalKind kind);
156
158inline constexpr std::string_view kCompletionsFormat = "flow.completions/v1";
159
160} // namespace a11::flow
161
162#endif // A11_FLOW_COMPLETE_H_
Everything the tools know about the world, in one place.
Definition catalogue.h:119
static const Catalogue & Builtin()
The embedded snapshot: what a standalone tool knows with nothing configured.
Definition catalogue.cc:424
TokenKind kind
Definition format.cc:913
Definition boundary.cc:32
ProposalKind
What a proposal is, which is what an editor turns into an icon.
Definition complete.h:35
@ 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/drain.
CompleteResult CompleteAt(std::string_view source, size_t offset, const catalogue::Catalogue &known)
What may be written at offset in source.
Definition complete.cc:1461
constexpr std::string_view kCompletionsFormat
The format field of the completions envelope.
Definition complete.h:158
std::string_view ProposalKindName(ProposalKind kind)
The name of a proposal kind in the output format, in kebab case.
Definition complete.cc:1476
What may be written at an offset, and the word already typed there.
Definition complete.h:108
std::string prefix
The partial word the caret is in, if any.
Definition complete.h:113
std::vector< Proposal > proposals
Definition complete.h:109
size_t prefix_start
Where that word starts, so an editor knows what a proposal replaces.
Definition complete.h:122
One thing that may be written at an offset.
Definition complete.h:77
std::string tail
Grey text an editor shows after the name: what a stage takes, whether a port is required.
Definition complete.h:91
std::string type
The type of the thing proposed, where it has one: a port's declared type.
Definition complete.h:93
ProposalKind kind
Definition complete.h:80
int caret
Where the caret lands inside insert, in bytes.
Definition complete.h:88
std::string documentation
The whole of what is known about it, as Markdown, for the popup an editor shows beside the list.
Definition complete.h:104
std::string insert
The text to insert, which is name unless taking it writes more: a function takes its parentheses,...
Definition complete.h:84
std::string name
The word, as it would be read back: truncate, x.question.
Definition complete.h:79
long long offset
Definition main.cc:69