Class SymbolWrites

java.lang.Object
org.ek9lang.compiler.support.SymbolWrites

public final class SymbolWrites extends Object
THE "where is this symbol written?" for the compiler's own analyses and the 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-flow if x := next() then x? included);
  • a MUTATING operator applied to it - += -= *= /= :~: :^: :=: ++ -- - decided by OperatorMap.isThisMutatingOperator(String), never a copied list. total += 5 performs NO store to total (Integer._addAss mutates the object in place), so a test that looks only for assignments misses most EK9 mutation.
  • the TARGET of a stream - cat items > total and >>, and the tee target (| tee in seen): every item is piped (|) into the object in place (operator >, >> or tee; D-1, 2026-10-19 - the value tracker and CompileTimeKnownText saw only assignments).

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.

Which operator writes one occurrence is WritingOperator (purely structural); which operator texts write are IsWritingOperator, IsAssignmentOperator and IsStreamTarget (no-statics lane S3, 2026-10-29: were writingOperator, isWritingOperator, isAssignmentOperator and isStreamTarget here; writesOf, isWrittenIn and isWrittenBetween are this class's instance methods).

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    One write.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The operator text of a write by a tee stage.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    isWrittenBetween(ParsedModule parsedModule, org.antlr.v4.runtime.tree.ParseTree region, Set<ISymbol> symbols, int afterTokenIndex, int beforeTokenIndex)
    Is any of symbols written in region strictly between two token positions (token indexes in the compiled token stream: pass first.getStop().getTokenIndex() and second.getStart().getTokenIndex() to ask "does anything change these between the two occurrences?").
    boolean
    isWrittenIn(ParsedModule parsedModule, org.antlr.v4.runtime.tree.ParseTree region, Set<ISymbol> symbols)
    Is any of symbols written anywhere in region.
    writesOf(ParsedModule parsedModule, org.antlr.v4.runtime.tree.ParseTree region, ISymbol symbol)
    Every write to symbol (or to a captured copy of it) in region, in source order.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • SymbolWrites

      public SymbolWrites()
  • Method Details

    • writesOf

      public List<SymbolWrites.Write> writesOf(ParsedModule parsedModule, org.antlr.v4.runtime.tree.ParseTree region, ISymbol symbol)
      Every write to symbol (or to a captured copy of it) in region, in source order.
    • isWrittenIn

      public boolean isWrittenIn(ParsedModule parsedModule, org.antlr.v4.runtime.tree.ParseTree region, Set<ISymbol> symbols)
      Is any of symbols written anywhere in region.
    • isWrittenBetween

      public boolean isWrittenBetween(ParsedModule parsedModule, org.antlr.v4.runtime.tree.ParseTree region, Set<ISymbol> symbols, int afterTokenIndex, int beforeTokenIndex)
      Is any of symbols written in region strictly between two token positions (token indexes in the compiled token stream: pass first.getStop().getTokenIndex() and second.getStart().getTokenIndex() to ask "does anything change these between the two occurrences?").