|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectappli.diff.ASResource
appli.diff.ASBeautifier
appli.diff.ASFormatter
Constructor Summary | |
ASFormatter()
Constructor of ASFormatter |
Method Summary | |
private void |
appendChar(char ch)
|
private void |
appendChar(char ch,
boolean canBreakLine)
append a character to the current formatted line. |
private void |
appendCurrentChar()
|
private void |
appendCurrentChar(boolean canBreakLine)
append the CURRENT character (curentChar)to the current formatted line. |
private void |
appendSequence(java.lang.String sequence)
|
private void |
appendSequence(java.lang.String sequence,
boolean canBreakLine)
append a String sequence to the current formatted line. |
private void |
appendSpacePad()
append a space to the current formattedline, UNLESS the last character is already a white-space character. |
private void |
breakLine()
register a line break for the formatted line. |
private boolean |
find(java.util.Vector v,
java.lang.String s)
Find the string in the vector |
private java.lang.String |
findHeader(java.util.Vector headers)
|
private java.lang.String |
findHeader(java.util.Vector headers,
boolean checkBoundry)
check if one of a set of headers has been reached in the current position of the current line. |
private BracketType |
getBracketType()
check if the currently reached open-bracket (i.e. '{') opens a: - a definition type block (such as a class or namespace), - a command block (such as a method block) - a static array this method takes for granted that the current character is an opening bracket. |
private boolean |
getNextChar()
get the next character, increasing the current placement in the process. |
private void |
goForward(int i)
jump over several characters. |
boolean |
hasMoreLines()
check if there are any indented lines ready to be read by nextLine() |
void |
init(ASSourceIterator si)
initialize the ASFormatter. |
private boolean |
isBeforeComment()
check if current placement is before a comment or line-comment |
private boolean |
isFormattingEnabled()
check if formatting options are enabled, in addition to indentation. |
private boolean |
isInExponent()
check if the currently reached '-' or '+' character is part of an exponent, i.e. 0.2E-5. |
private boolean |
isOneLineBlockReached()
check if a one-line bracket has been reached, i.e. if the currently reached '{' character is closed with a complimentry '}' elsewhere on the current line, . |
private boolean |
isPointerOrReference()
check if the currently reached '*' or '&' character is a pointer-or-reference symbol, or another operator. |
private boolean |
isSequenceReached(java.lang.String sequence)
check if a specific sequence exists in the current placement of the current line |
private boolean |
isUrinaryMinus()
check if the currently reached '-' character is a urinary minus this method takes for granted that the current character is a '-'. |
java.lang.String |
nextLine()
get the next formatted line. |
private char |
peekNextChar()
peek at the next unread character. |
void |
setBracketFormatMode(int mode)
set the bracket formatting mode. |
void |
setBreakBlocksMode(boolean state)
set option to break unrelated blocks of code with empty lines. |
void |
setBreakClosingHeaderBlocksMode(boolean state)
set option to break closing header blocks of code (such as 'else', 'catch', ...) with empty lines. |
void |
setBreakClosingHeaderBracketsMode(boolean state)
set closing header bracket breaking mode options: true brackets just before closing headers (e.g. |
void |
setBreakElseIfsMode(boolean state)
set 'else if()' breaking mode options: true 'else' headers will be broken from their succeeding 'if' headers. |
void |
setBreakOneLineBlocksMode(boolean state)
set option to break/not break one-line blocks |
void |
setOperatorPaddingMode(boolean state)
set operator padding mode. |
void |
setParenthesisPaddingMode(boolean state)
set parentheies padding mode. |
void |
setSingleStatementsMode(boolean state)
set option to break/not break lines consisting of multiple statements. |
void |
setTabSpaceConversionMode(boolean state)
set option to convert tabs to spaces. |
private void |
trimNewLine()
jump over the leading white space in the current line, IF the line does not begin a comment or is in a preprocessor definition. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static java.util.Vector preprocessorHeaders
private static java.util.Vector preDefinitionHeaders
private static java.util.Vector preCommandHeaders
private static java.util.Vector operators
private ASSourceIterator sourceIterator
private java.util.Stack preBracketHeaderStack
private java.util.Stack bracketTypeStack
private java.util.Stack parenStack
private java.lang.String readyFormattedLine
private java.lang.String currentLine
private java.lang.String formattedLine
private java.lang.String currentHeader
private java.lang.String previousOperator
private char currentChar
private char previousChar
private char previousNonWSChar
private char previousCommandChar
private char quoteChar
private int charNum
private BracketMode bracketFormatMode
private boolean isVirgin
private boolean shouldPadOperators
private boolean shouldPadParenthesies
private boolean shouldConvertTabs
private boolean isInLineComment
private boolean isInComment
private boolean isInPreprocessor
private boolean isInTemplate
private boolean doesLineStartComment
private boolean isInQuote
private boolean isSpecialChar
private boolean isNonParenHeader
private boolean foundQuestionMark
private boolean foundPreDefinitionHeader
private boolean foundPreCommandHeader
private boolean isInLineBreak
private boolean isInClosingBracketLineBreak
private boolean endOfCodeReached
private boolean isLineReady
private boolean isPreviousBracketBlockRelated
private boolean isInPotentialCalculation
private boolean shouldBreakOneLineBlocks
private boolean shouldReparseCurrentChar
private boolean shouldBreakOneLineStatements
private boolean shouldBreakLineAfterComments
private boolean shouldBreakClosingHeaderBrackets
private boolean shouldBreakElseIfs
private boolean passedSemicolon
private boolean passedColon
private boolean isImmediatelyPostComment
private boolean isImmediatelyPostLineComment
private boolean isImmediatelyPostEmptyBlock
private boolean shouldBreakBlocks
private boolean shouldBreakClosingHeaderBlocks
private boolean isPrependPostBlockEmptyLineRequested
private boolean isAppendPostBlockEmptyLineRequested
private boolean prependEmptyLine
private boolean foundClosingHeader
private int previousReadyFormattedLineLength
private boolean isInHeader
private boolean isImmediatelyPostHeader
Constructor Detail |
public ASFormatter()
Method Detail |
public void init(ASSourceIterator si)
init
in class ASBeautifier
si
- a pointer to the DYNAMICALLY CREATED ASSourceIterator object.public java.lang.String nextLine() throws java.io.IOException
nextLine
in class ASBeautifier
java.io.IOException
public boolean hasMoreLines()
hasMoreLines
in class ASBeautifier
private boolean isFormattingEnabled()
public void setBracketFormatMode(int mode)
mode
- the bracket formatting mode.public void setBreakClosingHeaderBracketsMode(boolean state)
public void setBreakElseIfsMode(boolean state)
public void setOperatorPaddingMode(boolean state)
public void setParenthesisPaddingMode(boolean state)
public void setBreakOneLineBlocksMode(boolean state)
state
- true = break, false = don't break.public void setSingleStatementsMode(boolean state)
state
- true = break, false = don't break.public void setTabSpaceConversionMode(boolean state)
state
- true = convert, false = don't convert.public void setBreakBlocksMode(boolean state)
state
- true = convert, false = don't convert.public void setBreakClosingHeaderBlocksMode(boolean state)
state
- true = convert, false = don't convert.private boolean isSequenceReached(java.lang.String sequence)
sequence
- the sequence to be checked
private void goForward(int i) throws java.io.IOException
i
- the number of characters to jump over.
java.io.IOException
private char peekNextChar()
private boolean isBeforeComment()
private boolean getNextChar() throws java.io.IOException
java.io.IOException
private void trimNewLine()
private void appendChar(char ch, boolean canBreakLine)
ch
- the character to append.canBreakLine
- if true, a registered line-breakprivate void appendChar(char ch)
private void appendCurrentChar(boolean canBreakLine)
canBreakLine
- if true, a registered line-breakprivate void appendCurrentChar()
private void appendSequence(java.lang.String sequence, boolean canBreakLine)
sequence
- the sequence to append.canBreakLine
- if true, a registered line-breakprivate void appendSequence(java.lang.String sequence)
private void appendSpacePad()
private void breakLine()
private BracketType getBracketType()
private boolean isPointerOrReference()
private boolean isUrinaryMinus()
private boolean isInExponent()
private boolean isOneLineBlockReached()
private java.lang.String findHeader(java.util.Vector headers, boolean checkBoundry)
headers
- a vector of headerscheckBoundry
-
private java.lang.String findHeader(java.util.Vector headers)
private boolean find(java.util.Vector v, java.lang.String s)
v
- Vectors
- String
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |