Skip to content

Commit 2c17c94

Browse files
test: Mark write accesses separately. (#6)
1 parent d5fb306 commit 2c17c94

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

scip_indexer/SCIPIndexer.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,10 @@ class CFGTraversal final {
524524
this->emitLocalOccurrence(cfg, bb, send->recv.occurrence(), ValueCategory::RValue);
525525
}
526526

527+
// TODO:(varun) For arrays, hashes etc., try to identify if the function
528+
// matches a known operator (e.g. []=), and emit an appropriate 'WriteAccess'
529+
// symbol role for it.
530+
527531
// Emit reference for the method being called
528532
if (send->fun.exists() && !isTemporary(gs, core::LocalVariable(send->fun, 1))) {
529533
// HACK(varun): We should probably add a helper function to check

test/scip/testdata/syntax.rb.snapshot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
if x == 2
3232
# ^ reference local 1~#2634721084
3333
z += y
34-
# ^ reference local 3~#2634721084
34+
# ^ reference (write) local 3~#2634721084
3535
# ^ reference local 3~#2634721084
3636
# ^ reference local 2~#2634721084
3737
else
3838
z += x
3939
# ^ reference local 3~#2634721084
40-
# ^ reference local 3~#2634721084
40+
# ^ reference (write) local 3~#2634721084
4141
# ^ reference local 1~#2634721084
4242
end
4343
z

test/scip_test_runner.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,14 @@ void formatSnapshot(const scip::Document &document, std::ostream &out) {
188188
}
189189
bool isDefinition = ((unsigned(occ.symbol_roles()) & unsigned(scip::SymbolRole::Definition)) > 0);
190190

191+
string symbolRole = "";
192+
if (!isDefinition && (occ.symbol_roles() & scip::SymbolRole::WriteAccess)) {
193+
symbolRole = (occ.symbol_roles() & scip::SymbolRole::ReadAccess) ? "(read+write) " : "(write) ";
194+
}
195+
191196
out << '#' << string(range.start.column - 1, ' ') << string(range.end.column - range.start.column, '^')
192-
<< ' ' << string(isDefinition ? "definition" : "reference") << ' ' << formatSymbol(occ.symbol());
197+
<< ' ' << string(isDefinition ? "definition" : "reference") << ' ' << symbolRole
198+
<< formatSymbol(occ.symbol());
193199
if (!(isDefinition && symbolTable.contains(occ.symbol()))) {
194200
out << '\n';
195201
occ_i++;

0 commit comments

Comments
 (0)