diff --git a/scip_indexer/BUILD b/scip_indexer/BUILD index ddfe832fe..13f515d02 100644 --- a/scip_indexer/BUILD +++ b/scip_indexer/BUILD @@ -52,6 +52,7 @@ cc_library( "//sorbet_version", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", + "@com_google_absl//absl/strings", "@com_google_absl//absl/synchronization", "@cxxopts", "@spdlog", diff --git a/scip_indexer/Debug.cc b/scip_indexer/Debug.cc index 864afc810..1350b21ec 100644 --- a/scip_indexer/Debug.cc +++ b/scip_indexer/Debug.cc @@ -8,6 +8,8 @@ namespace sorbet::scip_indexer { +constexpr sorbet::core::ErrorClass SCIPRubyDebug{400, sorbet::core::StrictLevel::False}; + void _log_debug(const sorbet::core::GlobalState &gs, sorbet::core::Loc loc, std::string s) { if (auto e = gs.beginError(loc, SCIPRubyDebug)) { auto lines = absl::StrSplit(s, '\n'); diff --git a/scip_indexer/Debug.h b/scip_indexer/Debug.h index 215f98875..9000fbcc0 100644 --- a/scip_indexer/Debug.h +++ b/scip_indexer/Debug.h @@ -10,7 +10,9 @@ #include "common/common.h" #include "core/Error.h" -template std::string map_to_string(const sorbet::UnorderedMap m, Fn f) { +namespace sorbet::scip_indexer { + +template std::string showMap(const sorbet::UnorderedMap &m, Fn f) { std::ostringstream out; out << "{"; auto i = -1; @@ -25,7 +27,7 @@ template std::string map_to_string(const s return out.str(); } -template std::string set_to_string(const sorbet::UnorderedSet s, Fn f) { +template std::string showSet(const sorbet::UnorderedSet &s, Fn f) { std::ostringstream out; out << "{"; auto i = -1; @@ -40,7 +42,7 @@ template std::string set_to_string(const sorbet::Unord return out.str(); } -template std::string vec_to_string(const std::vector v, Fn f) { +template std::string showVec(const std::vector &v, Fn f) { std::ostringstream out; out << "["; for (auto i = 0; i < v.size(); ++i) { @@ -53,10 +55,6 @@ template std::string vec_to_string(const std::vectormap, [&](const cfg::LocalRef &local, auto &data) -> string { + return showMap(this->map, [&](const cfg::LocalRef &local, const auto &data) -> string { auto symRef = get<0>(data); auto offsets = get<1>(data); auto emitted = get<2>(data); diff --git a/scip_indexer/SCIPSymbolRef.cc b/scip_indexer/SCIPSymbolRef.cc index 0b18be141..4d1db0117 100644 --- a/scip_indexer/SCIPSymbolRef.cc +++ b/scip_indexer/SCIPSymbolRef.cc @@ -81,6 +81,13 @@ absl::Status UntypedGenericSymbolRef::symbolForExpr(const core::GlobalState &gs, return absl::OkStatus(); } +string UntypedGenericSymbolRef::showRaw(const core::GlobalState &gs) const { + if (this->name.exists()) { + return fmt::format("UGSR(owner: {}, name: {})", this->selfOrOwner.showFullName(gs), this->name.toString(gs)); + } + return fmt::format("UGSR(symbol: {})", this->selfOrOwner.showFullName(gs)); +} + string GenericSymbolRef::showRaw(const core::GlobalState &gs) const { switch (this->kind()) { case Kind::UndeclaredField: diff --git a/scip_indexer/SCIPSymbolRef.h b/scip_indexer/SCIPSymbolRef.h index ca0674116..4dfd6fc01 100644 --- a/scip_indexer/SCIPSymbolRef.h +++ b/scip_indexer/SCIPSymbolRef.h @@ -83,6 +83,8 @@ class UntypedGenericSymbolRef final { // Try to compute a scip::Symbol for this value. absl::Status symbolForExpr(const core::GlobalState &gs, const GemMetadata &metadata, std::optional loc, scip::Symbol &symbol) const; + + std::string showRaw(const core::GlobalState &gs) const; }; // A wrapper type to handle both top-level symbols (like classes) as well as