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
4 changes: 4 additions & 0 deletions scip_indexer/SCIPIndexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,10 @@ class CFGTraversal final {
this->emitLocalOccurrence(cfg, bb, send->recv.occurrence(), ValueCategory::RValue);
}

// TODO:(varun) For arrays, hashes etc., try to identify if the function
// matches a known operator (e.g. []=), and emit an appropriate 'WriteAccess'
// symbol role for it.

// Emit reference for the method being called
if (send->fun.exists() && !isTemporary(gs, core::LocalVariable(send->fun, 1))) {
// HACK(varun): We should probably add a helper function to check
Expand Down
4 changes: 2 additions & 2 deletions test/scip/testdata/syntax.rb.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
if x == 2
# ^ reference local 1~#2634721084
z += y
# ^ reference local 3~#2634721084
# ^ reference (write) local 3~#2634721084
# ^ reference local 3~#2634721084
# ^ reference local 2~#2634721084
else
z += x
# ^ reference local 3~#2634721084
# ^ reference local 3~#2634721084
# ^ reference (write) local 3~#2634721084
# ^ reference local 1~#2634721084
end
z
Expand Down
8 changes: 7 additions & 1 deletion test/scip_test_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,14 @@ void formatSnapshot(const scip::Document &document, std::ostream &out) {
}
bool isDefinition = ((unsigned(occ.symbol_roles()) & unsigned(scip::SymbolRole::Definition)) > 0);

string symbolRole = "";
if (!isDefinition && (occ.symbol_roles() & scip::SymbolRole::WriteAccess)) {
symbolRole = (occ.symbol_roles() & scip::SymbolRole::ReadAccess) ? "(read+write) " : "(write) ";
}

out << '#' << string(range.start.column - 1, ' ') << string(range.end.column - range.start.column, '^')
<< ' ' << string(isDefinition ? "definition" : "reference") << ' ' << formatSymbol(occ.symbol());
<< ' ' << string(isDefinition ? "definition" : "reference") << ' ' << symbolRole
<< formatSymbol(occ.symbol());
if (!(isDefinition && symbolTable.contains(occ.symbol()))) {
out << '\n';
occ_i++;
Expand Down