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 class
TextOutputFormatter.LineNumberMode
whether or not to emit debug line number comments into the source code
-
Field Summary
Fields Modifier and Type Field Description private int
braceLevelWithinType
private boolean
firstUsingDeclaration
private boolean
inDocumentationComment
private int
lastObservedLineNumber
when writing out line numbers, keeps track of the most recently used one to avoid redundancyprivate boolean
lastUsingDeclaration
private TextOutputFormatter.LineNumberMode
lineNumberMode
private java.util.List<LineNumberPosition>
lineNumberPositions
maps original line numbers to decompiler-emitted line numbers and columnsprivate java.util.Stack<AstNode>
nodeStack
private OffsetToLineNumberConverter
offset2LineNumber
converts from bytecode offset to line numberprivate ITextOutput
output
private 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 void
closeBrace(BraceStyle style)
void
endNode(AstNode node)
private java.lang.Object
getCurrentDefinition()
private java.lang.Object
getCurrentLocalDefinition()
private java.lang.Object
getCurrentLocalReference()
private MemberReference
getCurrentMemberReference()
private ModuleReference
getCurrentModuleReference()
private PackageReference
getCurrentPackageReference()
private MemberReference
getCurrentTypeReference()
java.util.List<LineNumberPosition>
getLineNumberPositions()
Returns the mapping from original to decompiler-emitted line numbers.void
indent()
private static boolean
isDefinition(AstNode node)
private boolean
isImportDeclaration(AstNode node)
void
newLine()
void
openBrace(BraceStyle style)
void
resetLineNumberOffsets(OffsetToLineNumberConverter offset2LineNumber)
instructs 'this' formatter to forget what it used to know about the sequence of line number offsets in the source codevoid
space()
void
startNode(AstNode node)
void
unindent()
void
writeComment(CommentType commentType, java.lang.String content)
void
writeDelimiter(java.lang.String token)
void
writeIdentifier(java.lang.String identifier)
void
writeKeyword(java.lang.String keyword)
void
writeLabel(java.lang.String label)
void
writeLiteral(java.lang.String value)
void
writeOperator(java.lang.String token)
void
writeTextBlock(java.lang.String value)
void
writeTextLiteral(java.lang.String value)
void
writeToken(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:
startNode
in interfaceIOutputFormatter
-
endNode
public void endNode(AstNode node)
- Specified by:
endNode
in interfaceIOutputFormatter
-
writeLabel
public void writeLabel(java.lang.String label)
- Specified by:
writeLabel
in interfaceIOutputFormatter
-
writeIdentifier
public void writeIdentifier(java.lang.String identifier)
- Specified by:
writeIdentifier
in interfaceIOutputFormatter
-
writeKeyword
public void writeKeyword(java.lang.String keyword)
- Specified by:
writeKeyword
in interfaceIOutputFormatter
-
writeOperator
public void writeOperator(java.lang.String token)
- Specified by:
writeOperator
in interfaceIOutputFormatter
-
writeDelimiter
public void writeDelimiter(java.lang.String token)
- Specified by:
writeDelimiter
in interfaceIOutputFormatter
-
writeToken
public void writeToken(java.lang.String token)
- Specified by:
writeToken
in interfaceIOutputFormatter
-
writeLiteral
public void writeLiteral(java.lang.String value)
- Specified by:
writeLiteral
in interfaceIOutputFormatter
-
writeTextLiteral
public void writeTextLiteral(java.lang.String value)
- Specified by:
writeTextLiteral
in interfaceIOutputFormatter
-
writeTextBlock
public void writeTextBlock(java.lang.String value)
- Specified by:
writeTextBlock
in interfaceIOutputFormatter
-
space
public void space()
- Specified by:
space
in interfaceIOutputFormatter
-
openBrace
public void openBrace(BraceStyle style)
- Specified by:
openBrace
in interfaceIOutputFormatter
-
closeBrace
public void closeBrace(BraceStyle style)
- Specified by:
closeBrace
in interfaceIOutputFormatter
-
indent
public void indent()
- Specified by:
indent
in interfaceIOutputFormatter
-
unindent
public void unindent()
- Specified by:
unindent
in interfaceIOutputFormatter
-
newLine
public void newLine()
- Specified by:
newLine
in interfaceIOutputFormatter
-
writeComment
public void writeComment(CommentType commentType, java.lang.String content)
- Specified by:
writeComment
in 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:IOutputFormatter
instructs 'this' formatter to forget what it used to know about the sequence of line number offsets in the source code- Specified by:
resetLineNumberOffsets
in interfaceIOutputFormatter
-
getLineNumberPositions
public java.util.List<LineNumberPosition> getLineNumberPositions()
Returns the mapping from original to decompiler-emitted line numbers.
-
-