Class TextOutputFormatter
- java.lang.Object
-
- com.strobel.decompiler.languages.java.TextOutputFormatter
-
- All Implemented Interfaces:
IOutputFormatter
public class TextOutputFormatter extends java.lang.Object implements IOutputFormatter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTextOutputFormatter.LineNumberModewhether or not to emit debug line number comments into the source code
-
Field Summary
Fields Modifier and Type Field Description private intbraceLevelWithinTypeprivate booleanfirstUsingDeclarationprivate booleaninDocumentationCommentprivate intlastObservedLineNumberwhen writing out line numbers, keeps track of the most recently used one to avoid redundancyprivate booleanlastUsingDeclarationprivate TextOutputFormatter.LineNumberModelineNumberModeprivate java.util.List<LineNumberPosition>lineNumberPositionsmaps original line numbers to decompiler-emitted line numbers and columnsprivate java.util.Stack<AstNode>nodeStackprivate OffsetToLineNumberConverteroffset2LineNumberconverts from bytecode offset to line numberprivate ITextOutputoutputprivate java.util.Stack<TextLocation>startLocations
-
Constructor Summary
Constructors Constructor Description TextOutputFormatter(ITextOutput output, TextOutputFormatter.LineNumberMode lineNumberMode)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseBrace(BraceStyle style)voidendNode(AstNode node)private java.lang.ObjectgetCurrentDefinition()private java.lang.ObjectgetCurrentLocalDefinition()private java.lang.ObjectgetCurrentLocalReference()private MemberReferencegetCurrentMemberReference()private ModuleReferencegetCurrentModuleReference()private PackageReferencegetCurrentPackageReference()private MemberReferencegetCurrentTypeReference()java.util.List<LineNumberPosition>getLineNumberPositions()Returns the mapping from original to decompiler-emitted line numbers.voidindent()private static booleanisDefinition(AstNode node)private booleanisImportDeclaration(AstNode node)voidnewLine()voidopenBrace(BraceStyle style)voidresetLineNumberOffsets(OffsetToLineNumberConverter offset2LineNumber)instructs 'this' formatter to forget what it used to know about the sequence of line number offsets in the source codevoidspace()voidstartNode(AstNode node)voidunindent()voidwriteComment(CommentType commentType, java.lang.String content)voidwriteDelimiter(java.lang.String token)voidwriteIdentifier(java.lang.String identifier)voidwriteKeyword(java.lang.String keyword)voidwriteLabel(java.lang.String label)voidwriteLiteral(java.lang.String value)voidwriteOperator(java.lang.String token)voidwriteTextBlock(java.lang.String value)voidwriteTextLiteral(java.lang.String value)voidwriteToken(java.lang.String token)
-
-
-
Field Detail
-
output
private final ITextOutput output
-
nodeStack
private final java.util.Stack<AstNode> nodeStack
-
braceLevelWithinType
private int braceLevelWithinType
-
inDocumentationComment
private boolean inDocumentationComment
-
firstUsingDeclaration
private boolean firstUsingDeclaration
-
lastUsingDeclaration
private boolean lastUsingDeclaration
-
lineNumberMode
private TextOutputFormatter.LineNumberMode lineNumberMode
-
lastObservedLineNumber
private int lastObservedLineNumber
when writing out line numbers, keeps track of the most recently used one to avoid redundancy
-
offset2LineNumber
private OffsetToLineNumberConverter offset2LineNumber
converts from bytecode offset to line number
-
lineNumberPositions
private final java.util.List<LineNumberPosition> lineNumberPositions
maps original line numbers to decompiler-emitted line numbers and columns
-
startLocations
private final java.util.Stack<TextLocation> startLocations
-
-
Constructor Detail
-
TextOutputFormatter
public TextOutputFormatter(ITextOutput output, TextOutputFormatter.LineNumberMode lineNumberMode)
-
-
Method Detail
-
startNode
public void startNode(AstNode node)
- Specified by:
startNodein interfaceIOutputFormatter
-
endNode
public void endNode(AstNode node)
- Specified by:
endNodein interfaceIOutputFormatter
-
writeLabel
public void writeLabel(java.lang.String label)
- Specified by:
writeLabelin interfaceIOutputFormatter
-
writeIdentifier
public void writeIdentifier(java.lang.String identifier)
- Specified by:
writeIdentifierin interfaceIOutputFormatter
-
writeKeyword
public void writeKeyword(java.lang.String keyword)
- Specified by:
writeKeywordin interfaceIOutputFormatter
-
writeOperator
public void writeOperator(java.lang.String token)
- Specified by:
writeOperatorin interfaceIOutputFormatter
-
writeDelimiter
public void writeDelimiter(java.lang.String token)
- Specified by:
writeDelimiterin interfaceIOutputFormatter
-
writeToken
public void writeToken(java.lang.String token)
- Specified by:
writeTokenin interfaceIOutputFormatter
-
writeLiteral
public void writeLiteral(java.lang.String value)
- Specified by:
writeLiteralin interfaceIOutputFormatter
-
writeTextLiteral
public void writeTextLiteral(java.lang.String value)
- Specified by:
writeTextLiteralin interfaceIOutputFormatter
-
writeTextBlock
public void writeTextBlock(java.lang.String value)
- Specified by:
writeTextBlockin interfaceIOutputFormatter
-
space
public void space()
- Specified by:
spacein interfaceIOutputFormatter
-
openBrace
public void openBrace(BraceStyle style)
- Specified by:
openBracein interfaceIOutputFormatter
-
closeBrace
public void closeBrace(BraceStyle style)
- Specified by:
closeBracein interfaceIOutputFormatter
-
indent
public void indent()
- Specified by:
indentin interfaceIOutputFormatter
-
unindent
public void unindent()
- Specified by:
unindentin interfaceIOutputFormatter
-
newLine
public void newLine()
- Specified by:
newLinein interfaceIOutputFormatter
-
writeComment
public void writeComment(CommentType commentType, java.lang.String content)
- Specified by:
writeCommentin interfaceIOutputFormatter
-
getCurrentDefinition
private java.lang.Object getCurrentDefinition()
-
getCurrentTypeReference
private MemberReference getCurrentTypeReference()
-
getCurrentModuleReference
private ModuleReference getCurrentModuleReference()
-
getCurrentPackageReference
private PackageReference getCurrentPackageReference()
-
getCurrentMemberReference
private MemberReference getCurrentMemberReference()
-
getCurrentLocalReference
private java.lang.Object getCurrentLocalReference()
-
getCurrentLocalDefinition
private java.lang.Object getCurrentLocalDefinition()
-
isDefinition
private static boolean isDefinition(AstNode node)
-
isImportDeclaration
private boolean isImportDeclaration(AstNode node)
-
resetLineNumberOffsets
public void resetLineNumberOffsets(OffsetToLineNumberConverter offset2LineNumber)
Description copied from interface:IOutputFormatterinstructs 'this' formatter to forget what it used to know about the sequence of line number offsets in the source code- Specified by:
resetLineNumberOffsetsin interfaceIOutputFormatter
-
getLineNumberPositions
public java.util.List<LineNumberPosition> getLineNumberPositions()
Returns the mapping from original to decompiler-emitted line numbers.
-
-