A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
format.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_FORMAT_H_
18
#define A11_FLOW_FORMAT_H_
19
20
#include <string>
21
#include <string_view>
22
#include <vector>
23
24
#include "
a11/flow/diagnostic.h
"
25
26
namespace
a11::flow
{
27
31
struct
FormatOptions
{
33
int
indent
= 2;
35
bool
align_ports
=
true
;
36
};
37
39
struct
FormatResult
{
42
std::string
formatted
;
43
bool
changed
=
false
;
44
// One edit that turns the input into `formatted`, trimmed to the part that
45
// actually differs, so an editor applying it does not move the cursor or lose
46
// a selection over a file that only changed at the bottom.
51
std::vector<Edit>
edits
;
53
std::vector<Diagnostic>
diagnostics
;
54
};
55
88
FormatResult
Format
(std::string_view source,
FormatOptions
options = {});
89
90
}
// namespace a11::flow
91
92
#endif
// A11_FLOW_FORMAT_H_
diagnostic.h
a11::flow
Definition
boundary.cc:32
a11::flow::Format
FormatResult Format(std::string_view source, FormatOptions options)
Format Flow source.
Definition
format.cc:952
a11::flow::FormatOptions
What the formatter is allowed to decide.
Definition
format.h:31
a11::flow::FormatOptions::indent
int indent
Spaces per block level. Repository Flow files use two.
Definition
format.h:33
a11::flow::FormatOptions::align_ports
bool align_ports
Whether to align consecutive in and out declaration columns.
Definition
format.h:35
a11::flow::FormatResult
The formatted text, and what it took to get there.
Definition
format.h:39
a11::flow::FormatResult::changed
bool changed
Definition
format.h:43
a11::flow::FormatResult::edits
std::vector< Edit > edits
One edit that turns the input into formatted, trimmed to the part that actually differs,...
Definition
format.h:51
a11::flow::FormatResult::formatted
std::string formatted
The whole file as it should be.
Definition
format.h:42
a11::flow::FormatResult::diagnostics
std::vector< Diagnostic > diagnostics
Why the file was left alone, where it was.
Definition
format.h:53
cpp
a11
flow
format.h
Generated by
1.9.8