Class SymbolWrites
mcp.oracle tools - use this,
never a by-name test such as body.contains("this." + name) or a set of assigned NAMES.
It lives in compiler-main (moved down from compiler-services, 2026-10-04) so a phase-5 analysis - the
infinite stream source check, phase5/NeverEndingIterationMarker - reads the SAME write set the
refactoring editors do, rather than a second write-finder.
A write is any place the symbol's value can change:
- an assignment to it -
::==:=?(a pre-flowif x := next() then x?included); - a MUTATING operator applied to it -
+=-=*=/=:~::^::=:++--- decided byOperatorMap.isThisMutatingOperator(String), never a copied list.total += 5performs NO store tototal(Integer._addAssmutates the object in place), so a test that looks only for assignments misses most EK9 mutation.
Built on RecordedSymbols, so it is by symbol IDENTITY: a same-named local in another scope, a longer name
sharing a prefix (countLimit vs count), a comment or a String is never a write. A write through a
dynamic function's captured copy counts (the copy shares the object). A property written through any object counts
(other.total += 1 writes the property total). A mutating METHOD call (items.add(x)) is not a
write here: only the grammar's assignments and operators are.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisWritingOperator(String operator) Doesoperatorwrite the thing it is applied to - an assignment, or a mutating operator.static booleanisWrittenBetween(ParsedModule parsedModule, org.antlr.v4.runtime.tree.ParseTree region, Set<ISymbol> symbols, int afterTokenIndex, int beforeTokenIndex) Is any ofsymbolswritten inregionstrictly between two token positions (token indexes in the compiled token stream: passfirst.getStop().getTokenIndex()andsecond.getStart().getTokenIndex()to ask "does anything change these between the two occurrences?").static booleanisWrittenIn(ParsedModule parsedModule, org.antlr.v4.runtime.tree.ParseTree region, Set<ISymbol> symbols) Is any ofsymbolswritten anywhere inregion.static List<SymbolWrites.Write> writesOf(ParsedModule parsedModule, org.antlr.v4.runtime.tree.ParseTree region, ISymbol symbol) Every write tosymbol(or to a captured copy of it) inregion, in source order.static StringwritingOperator(org.antlr.v4.runtime.ParserRuleContext node) The operator that writes the thingnodenames, or null when this occurrence only reads it.
-
Method Details
-
writesOf
public static List<SymbolWrites.Write> writesOf(ParsedModule parsedModule, org.antlr.v4.runtime.tree.ParseTree region, ISymbol symbol) Every write tosymbol(or to a captured copy of it) inregion, in source order. -
isWrittenIn
public static boolean isWrittenIn(ParsedModule parsedModule, org.antlr.v4.runtime.tree.ParseTree region, Set<ISymbol> symbols) Is any ofsymbolswritten anywhere inregion. -
isWrittenBetween
public static boolean isWrittenBetween(ParsedModule parsedModule, org.antlr.v4.runtime.tree.ParseTree region, Set<ISymbol> symbols, int afterTokenIndex, int beforeTokenIndex) Is any ofsymbolswritten inregionstrictly between two token positions (token indexes in the compiled token stream: passfirst.getStop().getTokenIndex()andsecond.getStart().getTokenIndex()to ask "does anything change these between the two occurrences?"). -
isWritingOperator
Doesoperatorwrite the thing it is applied to - an assignment, or a mutating operator. -
writingOperator
The operator that writes the thingnodenames, or null when this occurrence only reads it. Purely structural (it needs no recorded symbol), so a caller holding an identifier occurrence - of the compiled tree or of a re-parsed body - asks HERE whether it is written rather than re-deriving the grammar's write positions.- Parameters:
node- the identifier node of the occurrence (asRecordedSymbols.Reference.node())
-