mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
Shell: Move AST::create() into the header and use it
This commit is contained in:
parent
ef782c805f
commit
cdebdaea2d
2 changed files with 13 additions and 13 deletions
|
@ -123,18 +123,6 @@ void AK::Formatter<Shell::AST::Command>::format(FormatBuilder& builder, const Sh
|
||||||
|
|
||||||
namespace Shell::AST {
|
namespace Shell::AST {
|
||||||
|
|
||||||
template<typename T, typename... Args>
|
|
||||||
static inline NonnullRefPtr<T> create(Args... args)
|
|
||||||
{
|
|
||||||
return adopt(*new T(args...));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
static inline NonnullRefPtr<T> create(std::initializer_list<NonnullRefPtr<Value>> arg)
|
|
||||||
{
|
|
||||||
return adopt(*new T(arg));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void print_indented(const String& str, int indent)
|
static inline void print_indented(const String& str, int indent)
|
||||||
{
|
{
|
||||||
for (auto i = 0; i < indent; ++i)
|
for (auto i = 0; i < indent; ++i)
|
||||||
|
@ -1829,7 +1817,7 @@ RefPtr<Value> Pipe::run(RefPtr<Shell> shell)
|
||||||
if (first_in_right.pipeline) {
|
if (first_in_right.pipeline) {
|
||||||
last_in_left.pipeline = first_in_right.pipeline;
|
last_in_left.pipeline = first_in_right.pipeline;
|
||||||
} else {
|
} else {
|
||||||
auto pipeline = adopt(*new Pipeline);
|
auto pipeline = create<Pipeline>();
|
||||||
last_in_left.pipeline = pipeline;
|
last_in_left.pipeline = pipeline;
|
||||||
first_in_right.pipeline = pipeline;
|
first_in_right.pipeline = pipeline;
|
||||||
}
|
}
|
||||||
|
|
12
Shell/AST.h
12
Shell/AST.h
|
@ -41,6 +41,18 @@
|
||||||
|
|
||||||
namespace Shell::AST {
|
namespace Shell::AST {
|
||||||
|
|
||||||
|
template<typename T, typename... Args>
|
||||||
|
static inline NonnullRefPtr<T> create(Args... args)
|
||||||
|
{
|
||||||
|
return adopt(*new T(args...));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
static inline NonnullRefPtr<T> create(std::initializer_list<NonnullRefPtr<Value>> arg)
|
||||||
|
{
|
||||||
|
return adopt(*new T(arg));
|
||||||
|
}
|
||||||
|
|
||||||
struct HighlightMetadata {
|
struct HighlightMetadata {
|
||||||
bool is_first_in_list { true };
|
bool is_first_in_list { true };
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue