Package spoon.support.sniper.internal
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 toDefaultTokenWriter
with the decorator pattern, untilsetMuted(boolean)
is called with true Then all tokens are ignored.
-
-
Constructor Summary
Constructors Constructor Description MutableTokenWriter(Environment env)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TokenWriter
decTab()
decrements indentationvoid
directPrint(String text)
Prints a piece of text regardless of mute status Don't call this, this is dangerous and irregular design.PrinterHelper
getPrinterHelper()
TokenWriter
incTab()
increments indentationboolean
isMuted()
void
reset()
resets to the initial statevoid
setMuted(boolean muted)
void
setOriginSourceTabulationSize(int originSourceTabulationSize)
void
setOriginSourceUsesTabulations(boolean originSourceUsesTabulations)
String
toString()
TokenWriter
write(String text)
writes the piece of text if not mutedTokenWriter
writeCodeSnippet(String token)
writes a code snippet - represents arbitrary code ofCtCodeSnippetExpression
orCtCodeSnippetStatement
TokenWriter
writeComment(CtComment comment)
writes a commentTokenWriter
writeIdentifier(String token)
writes a java identifier.TokenWriter
writeKeyword(String token)
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 whileTokenWriter
writeLiteral(String token)
writes literal.TokenWriter
writeln()
writes new line (EOL)TokenWriter
writeOperator(String token)
Writes one operator.TokenWriter
writeSeparator(String token)
Writes one separator.TokenWriter
writeSpace()
Writes a single space.
-
-
-
Constructor Detail
-
MutableTokenWriter
public MutableTokenWriter(Environment env)
-
-
Method Detail
-
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 interfaceTokenWriter
-
writeOperator
public TokenWriter writeOperator(String token)
Description copied from interface:TokenWriter
Writes one operator. = > < ! ~ ? : == <= >= != && || ++ -- + - * / & | ^ % << >> >>> += -= *= /= &= |= ^= %= <<= >>= >>>= instanceof- Specified by:
writeOperator
in interfaceTokenWriter
-
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 interfaceTokenWriter
-
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 interfaceTokenWriter
-
writeIdentifier
public TokenWriter writeIdentifier(String token)
Description copied from interface:TokenWriter
writes a java identifier.- Specified by:
writeIdentifier
in interfaceTokenWriter
-
writeCodeSnippet
public TokenWriter writeCodeSnippet(String token)
Description copied from interface:TokenWriter
writes a code snippet - represents arbitrary code ofCtCodeSnippetExpression
orCtCodeSnippetStatement
- Specified by:
writeCodeSnippet
in interfaceTokenWriter
-
writeComment
public TokenWriter writeComment(CtComment comment)
Description copied from interface:TokenWriter
writes a comment- Specified by:
writeComment
in interfaceTokenWriter
-
writeln
public TokenWriter writeln()
Description copied from interface:TokenWriter
writes new line (EOL)- Specified by:
writeln
in interfaceTokenWriter
-
incTab
public TokenWriter incTab()
Description copied from interface:TokenWriter
increments indentation- Specified by:
incTab
in interfaceTokenWriter
-
decTab
public TokenWriter decTab()
Description copied from interface:TokenWriter
decrements indentation- Specified by:
decTab
in interfaceTokenWriter
-
getPrinterHelper
public PrinterHelper getPrinterHelper()
- Specified by:
getPrinterHelper
in interfaceTokenWriter
- 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 interfaceTokenWriter
-
writeSpace
public TokenWriter writeSpace()
Description copied from interface:TokenWriter
Writes a single space.- Specified by:
writeSpace
in interfaceTokenWriter
-
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
-
-