Class MutableTokenWriter

java.lang.Object
spoon.support.sniper.internal.MutableTokenWriter
All Implemented Interfaces:
TokenWriter

public class MutableTokenWriter extends Object implements TokenWriter
TokenWriter which simply delegates to DefaultTokenWriter with the decorator pattern, until setMuted(boolean) is called with true Then all tokens are ignored.
  • Constructor Details

    • MutableTokenWriter

      public MutableTokenWriter(Environment env)
  • Method Details

    • isMuted

      public boolean isMuted()
      Returns:
      true if tokens are ignored. false if they are forwarded to `delegate`
    • setMuted

      public void setMuted(boolean muted)
      Parameters:
      muted - true if tokens are ignored. false if they are forwarded to `delegate`
    • setOriginSourceUsesTabulations

      public void setOriginSourceUsesTabulations(boolean originSourceUsesTabulations)
      Parameters:
      originSourceUsesTabulations - whether or not the origin source uses tabs for indentation.
    • setOriginSourceTabulationSize

      public void setOriginSourceTabulationSize(int originSourceTabulationSize)
      Parameters:
      originSourceTabulationSize - the amount of indentation used in the origin source.
    • writeSeparator

      public TokenWriter writeSeparator(String token)
      Description copied from interface: TokenWriter
      Writes one separator. It is -> or :: or one of these characters: (){}[];,.:@=<>?&|
      Specified by:
      writeSeparator in interface TokenWriter
    • writeOperator

      public TokenWriter writeOperator(String token)
      Description copied from interface: TokenWriter
      Writes one operator. = > < ! ~ ? : == <= >= != && || ++ -- + - * / & | ^ % << >> >>> += -= *= /= &= |= ^= %= <<= >>= >>>= instanceof
      Specified by:
      writeOperator in interface TokenWriter
    • writeLiteral

      public TokenWriter writeLiteral(String token)
      Description copied from interface: TokenWriter
      writes literal. It can be a String, Character or an number
      Specified by:
      writeLiteral in interface TokenWriter
    • writeKeyword

      public TokenWriter writeKeyword(String token)
      Description copied from interface: TokenWriter
      writes a keyword abstract continue for new switch assert default goto package synchronized boolean do if private this break double implements protected throw byte else import public throws case enum instanceof return transient catch extends int short try char final interface static void class finally long strictfp volatile const float native super while
      Specified by:
      writeKeyword in interface TokenWriter
    • writeIdentifier

      public TokenWriter writeIdentifier(String token)
      Description copied from interface: TokenWriter
      writes a java identifier.
      Specified by:
      writeIdentifier in interface TokenWriter
    • writeCodeSnippet

      public TokenWriter writeCodeSnippet(String token)
      Description copied from interface: TokenWriter
      writes a code snippet - represents arbitrary code of CtCodeSnippetExpression or CtCodeSnippetStatement
      Specified by:
      writeCodeSnippet in interface TokenWriter
    • writeComment

      public TokenWriter writeComment(CtComment comment)
      Description copied from interface: TokenWriter
      writes a comment
      Specified by:
      writeComment in interface TokenWriter
    • writeln

      public TokenWriter writeln()
      Description copied from interface: TokenWriter
      writes new line (EOL)
      Specified by:
      writeln in interface TokenWriter
    • incTab

      public TokenWriter incTab()
      Description copied from interface: TokenWriter
      increments indentation
      Specified by:
      incTab in interface TokenWriter
    • decTab

      public TokenWriter decTab()
      Description copied from interface: TokenWriter
      decrements indentation
      Specified by:
      decTab in interface TokenWriter
    • getPrinterHelper

      public PrinterHelper getPrinterHelper()
      Specified by:
      getPrinterHelper in interface TokenWriter
      Returns:
      PrinterHelper used by this TokenWriter. Note that in the future, will return an interface eg IPrinterHelper instead.
    • reset

      public void reset()
      Description copied from interface: TokenWriter
      resets to the initial state
      Specified by:
      reset in interface TokenWriter
    • writeSpace

      public TokenWriter writeSpace()
      Description copied from interface: TokenWriter
      Writes a single space.
      Specified by:
      writeSpace in interface TokenWriter
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • directPrint

      public void directPrint(String text)
      Prints a piece of text regardless of mute status Don't call this, this is dangerous and irregular design.
    • write

      public TokenWriter write(String text)
      writes the piece of text if not muted