Package spoon.support.sniper.internal
Class MutableTokenWriter
java.lang.Object
spoon.support.sniper.internal.MutableTokenWriter
- All Implemented Interfaces:
TokenWriter
TokenWriter
which simply delegates
to DefaultTokenWriter
with the decorator pattern, until setMuted(boolean)
is called with true
Then all tokens are ignored.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondecTab()
decrements indentationvoid
directPrint(String text)
Prints a piece of text regardless of mute status Don't call this, this is dangerous and irregular design.incTab()
increments indentationboolean
isMuted()
void
reset()
resets to the initial statevoid
setMuted(boolean muted)
void
setOriginSourceTabulationSize(int originSourceTabulationSize)
void
setOriginSourceUsesTabulations(boolean originSourceUsesTabulations)
toString()
writes the piece of text if not mutedwriteCodeSnippet(String token)
writes a code snippet - represents arbitrary code ofCtCodeSnippetExpression
orCtCodeSnippetStatement
writeComment(CtComment comment)
writes a commentwriteIdentifier(String token)
writes a java identifier.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 whilewriteLiteral(String token)
writes literal.writeln()
writes new line (EOL)writeOperator(String token)
Writes one operator.writeSeparator(String token)
Writes one separator.Writes a single space.
-
Constructor Details
-
MutableTokenWriter
-
-
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
Description copied from interface:TokenWriter
Writes one separator. It is -> or :: or one of these characters: (){}[];,.:@=<>?&|- Specified by:
writeSeparator
in interfaceTokenWriter
-
writeOperator
Description copied from interface:TokenWriter
Writes one operator. = > < ! ~ ? : == <= >= != && || ++ -- + - * / & | ^ % << >> >>> += -= *= /= &= |= ^= %= <<= >>= >>>= instanceof- Specified by:
writeOperator
in interfaceTokenWriter
-
writeLiteral
Description copied from interface:TokenWriter
writes literal. It can be a String, Character or an number- Specified by:
writeLiteral
in interfaceTokenWriter
-
writeKeyword
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
Description copied from interface:TokenWriter
writes a java identifier.- Specified by:
writeIdentifier
in interfaceTokenWriter
-
writeCodeSnippet
Description copied from interface:TokenWriter
writes a code snippet - represents arbitrary code ofCtCodeSnippetExpression
orCtCodeSnippetStatement
- Specified by:
writeCodeSnippet
in interfaceTokenWriter
-
writeComment
Description copied from interface:TokenWriter
writes a comment- Specified by:
writeComment
in interfaceTokenWriter
-
writeln
Description copied from interface:TokenWriter
writes new line (EOL)- Specified by:
writeln
in interfaceTokenWriter
-
incTab
Description copied from interface:TokenWriter
increments indentation- Specified by:
incTab
in interfaceTokenWriter
-
decTab
Description copied from interface:TokenWriter
decrements indentation- Specified by:
decTab
in interfaceTokenWriter
-
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
Description copied from interface:TokenWriter
Writes a single space.- Specified by:
writeSpace
in interfaceTokenWriter
-
toString
-
directPrint
Prints a piece of text regardless of mute status Don't call this, this is dangerous and irregular design. -
write
writes the piece of text if not muted
-