Skip to content

Commit 3be845c

Browse files
authored
Add some more debugging information (sorbet#3926)
These functions are handy to have in a debugger.
1 parent 5d1a8e1 commit 3be845c

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

core/Files.h

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class FileRef final {
1919
FileRef() : _id(0){};
2020
FileRef(unsigned int id);
2121

22+
FileRef(FileRef &f) = default;
2223
FileRef(const FileRef &f) = default;
2324
FileRef(FileRef &&f) = default;
2425
FileRef &operator=(const FileRef &f) = default;

core/Loc.cc

+6
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@ string LocOffsets::showRaw(const Context ctx) const {
204204
string LocOffsets::showRaw(const MutableContext ctx) const {
205205
return Loc(ctx.file, *this).showRaw(ctx);
206206
}
207+
string LocOffsets::showRaw(const GlobalState &gs, const FileRef file) const {
208+
return Loc(file, *this).showRaw(gs);
209+
}
210+
string LocOffsets::showRaw() const {
211+
return fmt::format("LocOffsets {{beginPos={}, endPos={}}}", beginPos(), endPos());
212+
}
207213

208214
string Loc::showRaw(const GlobalState &gs) const {
209215
string_view path;

core/Loc.h

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ struct LocOffsets {
3636

3737
std::string showRaw(const Context ctx) const;
3838
std::string showRaw(const MutableContext ctx) const;
39+
std::string showRaw(const GlobalState &gs, const FileRef file) const;
40+
std::string showRaw() const;
3941
};
4042
CheckSize(LocOffsets, 8, 4);
4143

parser/Builder.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,13 @@ string Dedenter::dedent(string_view str) {
6868

6969
class Builder::Impl {
7070
public:
71-
Impl(GlobalState &gs, core::FileRef file) : gs_(gs) {
71+
Impl(GlobalState &gs, core::FileRef file) : gs_(gs), file_(file) {
7272
this->maxOff_ = file.data(gs).source().size();
7373
foreignNodes_.emplace_back();
7474
}
7575

7676
GlobalState &gs_;
77+
core::FileRef file_;
7778
u2 uniqueCounter_ = 1;
7879
u4 maxOff_;
7980
ruby_parser::base_driver *driver_;

0 commit comments

Comments
 (0)