A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
navigate.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_NAVIGATE_H_
18#define A11_FLOW_NAVIGATE_H_
19
20#include <cstddef>
21#include <optional>
22#include <string>
23#include <string_view>
24#include <vector>
25
26#include "a11/flow/catalogue.h"
27#include "a11/flow/diagnostic.h"
28#include "a11/flow/syntax.h"
29#include "a11/flow/vocabulary.h"
30
31namespace a11::flow {
32
33// Moving around a document: what is under the caret, what the file declares,
34// and where a name was bound.
35
44enum class SymbolClass {
45 kFlow,
46 kDto,
47 kField,
48 kPort,
49 kHeader,
51 kNode,
52 kCall,
58};
59
60std::string_view SymbolClassName(SymbolClass kind);
61
64 std::string name;
67 std::string detail;
69 std::string port_direction;
70 std::string port_type;
71 bool port_stream = false;
72 bool port_required = false;
77 std::vector<DocumentSymbol> children;
78};
79
83std::vector<DocumentSymbol> Symbols(std::string_view source);
84
89 bool found = false;
91 std::string text;
94 std::string summary;
97 std::string detail;
99 std::string markdown;
103 bool has_definition = false;
105 // Where it was declared, when it was declared in *another* file and something
106 // read that file: an action or a type the catalogue carries an origin for.
112 std::optional<catalogue::Origin> origin;
113};
114
117 std::string_view source, size_t offset,
119
120// An action, written out as the Markdown a reader wants to see: what it does,
121// then every port it has.
126std::string ActionMarkdown(const catalogue::ActionInfo& action);
127
131std::string PortMarkdown(std::string_view name, std::string_view type,
132 bool required, bool unary,
133 std::string_view description);
134
137std::string FlowMarkdown(const FlowPlan& flow);
138
140std::string ShapeMarkdown(const DtoPlan& shape);
141
142// One word or mark of the language, written out as reference: what it does,
143// what it takes, how it behaves, and a line of Flow using it.
156std::string WordMarkdown(std::string_view name, vocabulary::WordRole role);
157
161std::string StageMarkdown(std::string_view name);
162
164std::string BuiltinMarkdown(std::string_view name);
165
167inline constexpr std::string_view kSymbolsFormat = "flow.symbols/v1";
169inline constexpr std::string_view kHoverFormat = "flow.hover/v1";
171inline constexpr std::string_view kDefinitionFormat = "flow.definition/v1";
172
173} // namespace a11::flow
174
175#endif // A11_FLOW_NAVIGATE_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
std::string type
The type and what follows it: string required, list[a11.Chunk] stream.
Definition format.cc:51
std::string name
The name and its colon, which travel together because they always do.
Definition format.cc:49
std::string description
The description, quoted exactly as it was written.
Definition format.cc:53
WordRole
Which table a word is documented in.
Definition vocabulary.h:162
Definition boundary.cc:32
Description Describe(std::string_view source, size_t offset, const catalogue::Catalogue &known)
What is at offset, and where it came from.
Definition navigate.cc:632
std::string BuiltinMarkdown(std::string_view name)
A built-in function, the same way.
Definition navigate.cc:422
std::string_view SymbolClassName(SymbolClass kind)
Definition navigate.cc:474
std::string FlowMarkdown(const FlowPlan &flow)
A flow of the document, written out the same way: what it does, then its ports and which direction ea...
Definition navigate.cc:452
@ kPort
A port of this flow, or of a call.
@ kCall
A bound run/call step.
@ kField
A field of something: a status's code, a node's id.
@ kHeader
A header, under its alias.
@ kNode
A node of the flow's own.
@ kFlow
A flow of this file, offered as a call target.
@ kVariable
A loop variable, the index a loop binds, or what a repeat carries.
@ kBarrier
A bound wait/drain.
std::string PortMarkdown(std::string_view name, std::string_view type, bool required, bool unary, std::string_view description)
One port, written out as the Markdown a reader wants beside its name.
Definition navigate.cc:439
std::string WordMarkdown(std::string_view name, vocabulary::WordRole role)
One word or mark of the language, written out as reference: what it does, what it takes,...
Definition navigate.cc:406
std::string ActionMarkdown(const catalogue::ActionInfo &action)
An action, written out as the Markdown a reader wants to see: what it does, then every port it has.
Definition navigate.cc:426
constexpr std::string_view kHoverFormat
The format field of the hover envelope.
Definition navigate.h:169
std::string StageMarkdown(std::string_view name)
A pipeline stage, written out as reference.
Definition navigate.cc:418
constexpr std::string_view kSymbolsFormat
The format field of the symbols envelope.
Definition navigate.h:167
SymbolClass
Moving around a document: what is under the caret, what the file declares, and where a name was bound...
Definition navigate.h:44
@ kExternal
Something the language knows about but the document did not declare: an action, a registered type,...
std::vector< DocumentSymbol > Symbols(std::string_view source)
Every symbol a document declares, nested as it is written.
Definition navigate.cc:559
constexpr std::string_view kDefinitionFormat
The format field of the definition envelope.
Definition navigate.h:171
std::string ShapeMarkdown(const DtoPlan &shape)
A struct, written out the same way: how many fields, then each of them.
Definition navigate.cc:466
std::string shape
The shape this stream's values are, where the flow said so: a port typed with a struct,...
Definition resolve.cc:715
What is at one offset, described.
Definition navigate.h:86
std::optional< catalogue::Origin > origin
Where it was declared, when it was declared in another file and something read that file: an action o...
Definition navigate.h:112
Range definition
Definition navigate.h:104
Range range
What the word covers, so an editor can underline exactly it.
Definition navigate.h:101
std::string text
The word or construct itself, as written.
Definition navigate.h:91
std::string detail
Everything else worth reading: an action's description and its ports, a shape's fields,...
Definition navigate.h:97
std::string summary
One line: what it is. an action, ‘a port of 'search’`.
Definition navigate.h:94
std::string markdown
The same as Markdown, which is what an editor's hover wants.
Definition navigate.h:99
SymbolClass kind
Definition navigate.h:92
bool found
Whether anything is there at all.
Definition navigate.h:89
bool has_definition
Where it was declared, when it was declared in this document.
Definition navigate.h:103
One thing a document declares, and the things declared inside it.
Definition navigate.h:63
std::string name
Definition navigate.h:64
bool port_required
Definition navigate.h:72
std::vector< DocumentSymbol > children
Definition navigate.h:77
SymbolClass kind
Definition navigate.h:65
Range selection
Just the name, for "put the caret here".
Definition navigate.h:76
std::string port_type
Definition navigate.h:70
Range range
The whole construct, for "select this symbol".
Definition navigate.h:74
bool port_stream
Definition navigate.h:71
std::string detail
What an editor shows beside the name: a port's type, a call's action.
Definition navigate.h:67
std::string port_direction
Port metadata, populated only when kind is kPort.
Definition navigate.h:69
One compiled struct: a shape a port may be typed with.
Definition plan.h:80
One compiled flow: what a caller sees, and what the runtime will do.
Definition plan.h:149
Half-open span of source, [start, end).
Definition diagnostic.h:79
One action a flow may run or call.
Definition catalogue.h:88
long long offset
Definition main.cc:69