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
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondecTab()decrements indentationvoiddirectPrint(String text)Prints a piece of text regardless of mute status Don't call this, this is dangerous and irregular design.incTab()increments indentationbooleanisMuted()voidreset()resets to the initial statevoidsetMuted(boolean muted)voidsetOriginSourceTabulationSize(int originSourceTabulationSize)voidsetOriginSourceUsesTabulations(boolean originSourceUsesTabulations)toString()writes the piece of text if not mutedwriteCodeSnippet(String token)writes a code snippet - represents arbitrary code ofCtCodeSnippetExpressionorCtCodeSnippetStatementwriteComment(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:TokenWriterWrites one separator. It is -> or :: or one of these characters: (){}[];,.:@=<>?&|- Specified by:
writeSeparatorin interfaceTokenWriter
-
writeOperator
Description copied from interface:TokenWriterWrites one operator. = > < ! ~ ? : == <= >= != && || ++ -- + - * / & | ^ % << >> >>> += -= *= /= &= |= ^= %= <<= >>= >>>= instanceof- Specified by:
writeOperatorin interfaceTokenWriter
-
writeLiteral
Description copied from interface:TokenWriterwrites literal. It can be a String, Character or an number- Specified by:
writeLiteralin interfaceTokenWriter
-
writeKeyword
Description copied from interface:TokenWriterwrites 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:
writeKeywordin interfaceTokenWriter
-
writeIdentifier
Description copied from interface:TokenWriterwrites a java identifier.- Specified by:
writeIdentifierin interfaceTokenWriter
-
writeCodeSnippet
Description copied from interface:TokenWriterwrites a code snippet - represents arbitrary code ofCtCodeSnippetExpressionorCtCodeSnippetStatement- Specified by:
writeCodeSnippetin interfaceTokenWriter
-
writeComment
Description copied from interface:TokenWriterwrites a comment- Specified by:
writeCommentin interfaceTokenWriter
-
writeln
Description copied from interface:TokenWriterwrites new line (EOL)- Specified by:
writelnin interfaceTokenWriter
-
incTab
Description copied from interface:TokenWriterincrements indentation- Specified by:
incTabin interfaceTokenWriter
-
decTab
Description copied from interface:TokenWriterdecrements indentation- Specified by:
decTabin interfaceTokenWriter
-
getPrinterHelper
- Specified by:
getPrinterHelperin interfaceTokenWriter- Returns:
PrinterHelperused by this TokenWriter. Note that in the future, will return an interface eg IPrinterHelper instead.
-
reset
public void reset()Description copied from interface:TokenWriterresets to the initial state- Specified by:
resetin interfaceTokenWriter
-
writeSpace
Description copied from interface:TokenWriterWrites a single space.- Specified by:
writeSpacein 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
-