1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 08:28:11 +00:00

Shell: Show descriptions about syntax errors

The description contains an error message and where in the source the
error happened.
This commit is contained in:
AnotherTest 2020-06-28 18:42:57 +04:30 committed by Andreas Kling
parent 034be8e74c
commit d6de2b5828
5 changed files with 90 additions and 43 deletions

View file

@ -333,11 +333,21 @@ public:
virtual bool would_execute() const { return false; }
const Position& position() const { return m_position; }
void set_is_syntax_error() { m_is_syntax_error = true; }
void set_is_syntax_error(const SyntaxError& error_node)
{
m_is_syntax_error = true;
m_syntax_error_node = error_node;
}
virtual const SyntaxError& syntax_error_node() const
{
ASSERT(is_syntax_error());
return *m_syntax_error_node;
}
protected:
Position m_position;
bool m_is_syntax_error { false };
RefPtr<const SyntaxError> m_syntax_error_node;
};
class PathRedirectionNode : public Node {
@ -766,9 +776,11 @@ private:
class SyntaxError final : public Node {
public:
SyntaxError(Position);
SyntaxError(Position, String);
virtual ~SyntaxError();
const String& error_text() const { return m_syntax_error_text; }
private:
virtual void dump(int level) const override;
virtual RefPtr<Value> run(RefPtr<Shell>) override;
@ -776,6 +788,9 @@ private:
virtual HitTestResult hit_test_position(size_t) override { return { nullptr, nullptr }; }
virtual String class_name() const override { return "SyntaxError"; }
virtual bool is_syntax_error() const override { return true; }
virtual const SyntaxError& syntax_error_node() const override;
String m_syntax_error_text;
};
class Tilde final : public Node {