Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scip_indexer/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions scip_indexer/Debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
12 changes: 5 additions & 7 deletions scip_indexer/Debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#include "common/common.h"
#include "core/Error.h"

template <typename K, typename V, typename Fn> std::string map_to_string(const sorbet::UnorderedMap<K, V> m, Fn f) {
namespace sorbet::scip_indexer {

template <typename K, typename V, typename Fn> std::string showMap(const sorbet::UnorderedMap<K, V> &m, Fn f) {
std::ostringstream out;
out << "{";
auto i = -1;
Expand All @@ -25,7 +27,7 @@ template <typename K, typename V, typename Fn> std::string map_to_string(const s
return out.str();
}

template <typename T, typename Fn> std::string set_to_string(const sorbet::UnorderedSet<T> s, Fn f) {
template <typename T, typename Fn> std::string showSet(const sorbet::UnorderedSet<T> &s, Fn f) {
std::ostringstream out;
out << "{";
auto i = -1;
Expand All @@ -40,7 +42,7 @@ template <typename T, typename Fn> std::string set_to_string(const sorbet::Unord
return out.str();
}

template <typename T, typename Fn> std::string vec_to_string(const std::vector<T> v, Fn f) {
template <typename T, typename Fn> std::string showVec(const std::vector<T> &v, Fn f) {
std::ostringstream out;
out << "[";
for (auto i = 0; i < v.size(); ++i) {
Expand All @@ -53,10 +55,6 @@ template <typename T, typename Fn> std::string vec_to_string(const std::vector<T
return out.str();
}

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);
} // namespace sorbet::scip_indexer

Expand Down
2 changes: 1 addition & 1 deletion scip_indexer/SCIPIndexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ class AliasMap final {
}

string showRaw(const core::GlobalState &gs, core::FileRef file, const cfg::CFG &cfg) const {
return map_to_string(this->map, [&](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);
Expand Down
7 changes: 7 additions & 0 deletions scip_indexer/SCIPSymbolRef.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions scip_indexer/SCIPSymbolRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<core::Loc> 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
Expand Down