Package com.strobel.decompiler
Class LineNumberFormatter
- java.lang.Object
-
- com.strobel.decompiler.LineNumberFormatter
-
public class LineNumberFormatter extends java.lang.Object
ALineNumberFormatter
is used to rewrite an existing .java file, introducing line number information. It can handle either, or both, of the following jobs:- Introduce line numbers as leading comments.
- Stretch the file so that the line number comments match the physical lines.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LineNumberFormatter.LineNumberOption
-
Field Summary
Fields Modifier and Type Field Description private java.io.File
_file
private java.util.EnumSet<LineNumberFormatter.LineNumberOption>
_options
private java.util.List<LineNumberPosition>
_positions
-
Constructor Summary
Constructors Constructor Description LineNumberFormatter(java.io.File file, java.util.List<LineNumberPosition> lineNumberPositions, java.util.EnumSet<LineNumberFormatter.LineNumberOption> options)
Constructs an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.List<java.lang.String>
breakLines(java.util.List<LineNumberPosition> o_LineBrokenPositions)
Processes_file
, breaking apart any lines on which multiple line-number markers appear in different columns.private void
emitFormatted(java.util.List<java.lang.String> brokenLines, java.util.List<LineNumberPosition> lineBrokenPositions)
void
reformatFile()
Rewrites the file passed to 'this' constructor so that the actual line numbers match the recipe passed to 'this' constructor.
-
-
-
Field Detail
-
_positions
private final java.util.List<LineNumberPosition> _positions
-
_file
private final java.io.File _file
-
_options
private final java.util.EnumSet<LineNumberFormatter.LineNumberOption> _options
-
-
Constructor Detail
-
LineNumberFormatter
public LineNumberFormatter(java.io.File file, java.util.List<LineNumberPosition> lineNumberPositions, java.util.EnumSet<LineNumberFormatter.LineNumberOption> options)
Constructs an instance.- Parameters:
file
- the file whose line numbers should be fixedlineNumberPositions
- a recipe for how to fix the line numbers in 'file'.options
- controls how 'this' represents line numbers in the resulting file
-
-
Method Detail
-
reformatFile
public void reformatFile() throws java.io.IOException
Rewrites the file passed to 'this' constructor so that the actual line numbers match the recipe passed to 'this' constructor.- Throws:
java.io.IOException
-
breakLines
private java.util.List<java.lang.String> breakLines(java.util.List<LineNumberPosition> o_LineBrokenPositions) throws java.io.IOException
Processes_file
, breaking apart any lines on which multiple line-number markers appear in different columns.- Returns:
- the list of broken lines
- Throws:
java.io.IOException
-
emitFormatted
private void emitFormatted(java.util.List<java.lang.String> brokenLines, java.util.List<LineNumberPosition> lineBrokenPositions) throws java.io.IOException
- Throws:
java.io.IOException
-
-