This repository was archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdiagnostic.hpp
More file actions
66 lines (52 loc) · 1.75 KB
/
diagnostic.hpp
File metadata and controls
66 lines (52 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef LIB_RUBY_PARSER_DIAGNOSTIC_HPP
#define LIB_RUBY_PARSER_DIAGNOSTIC_HPP
#include <cstddef>
#include "messages.hpp"
#include "loc.hpp"
#include "decoded_input.hpp"
namespace lib_ruby_parser
{
/// Equivalent of `lib_ruby_parser::ErrorLevel`
enum class ErrorLevel
{
WARNING,
ERROR
};
/// Equivalent of `lib_ruby_parser::Diagnostic`
class Diagnostic
{
public:
/// Level of the diagnostic (error/warning)
ErrorLevel level;
/// Message of the diagnsotic
DiagnosticMessage message;
/// Location of the diagnostic
Loc loc;
Diagnostic() = delete;
Diagnostic(ErrorLevel level, DiagnosticMessage message, Loc loc);
Diagnostic(const Diagnostic &) = delete;
Diagnostic &operator=(Diagnostic const &) = delete;
Diagnostic(Diagnostic &&) = default;
Diagnostic &operator=(Diagnostic &&) = default;
/// Render given diagnsostic on a given source input.
/// Equivalent of lib_ruby_parser::Diagnostic::render.
/// Return owned NULL-terminated string.
std::string render(const DecodedInput &input) const;
};
/// Equivalent of `Vec<lib_ruby_parser::Diagnostic`
class DiagnosticList
{
public:
Diagnostic *ptr;
size_t capacity;
size_t len;
DiagnosticList() = delete;
DiagnosticList(Diagnostic *ptr, size_t len, size_t capacity);
~DiagnosticList();
DiagnosticList(const DiagnosticList &) = delete;
DiagnosticList &operator=(DiagnosticList const &) = delete;
DiagnosticList(DiagnosticList &&);
DiagnosticList &operator=(DiagnosticList &&);
};
} // namespace lib_ruby_parser
#endif // LIB_RUBY_PARSER_DIAGNOSTIC_HPP