|
Class: RBFormatter
Object
|
+--RBProgramNodeVisitor
|
+--RBFormatter
- Package:
- stx:goodies/refactoryBrowser/parser
- Category:
- Refactory-Parser
- Version:
- rev:
1.96
date: 2023/11/23 11:05:54
- user: cg
- file: RBFormatter.st directory: goodies/refactoryBrowser/parser
- module: stx stc-classLibrary: parser
defaults
-
blockArgumentsOnNewLine
-
return the blockArgumentsOnNewLine flag; if on, block arguments
are on a new line.
defaults to true in original formatter; false in ST/X
-
blockArgumentsOnNewLine: aBoolean
-
set/clear the blockArgumentsOnNewLine flag; if on, block arguments
are on a new line.
defaults to true in original formatter; false in ST/X
-
cStyleBlocks
-
return the cStyleBlocks flag; if on, blocks are formatted
the c-style (k&r style); if off, they are formatted the lisp-style.
defaults to false in original formatter; true in ST/X
-
cStyleBlocks: aBoolean
-
set/clear the cStyleBlocks flag; if on, blocks are formatted
the c-style (k&r style); if off, they are formatted the lisp-style.
defaults to false in original formatter; true in ST/X
-
emptyLineAfterMethodComment
-
return the emptyLineAfterMethodComment flag; if on, an empty line
is inserted after the method's initial comment.
defaults to false in original formatter; true in ST/X
-
emptyLineAfterMethodComment: aBoolean
-
set/clear the emptyLineAfterMethodComment flag; if on, an empty line
is inserted after the method's initial comment.
defaults to false in original formatter; true in ST/X
-
emptyLineAfterTemporaries
-
return the emptyLineAfterTemporaries flag; if on, an empty line
is inserted after the locals declaration part.
defaults to false in original formatter; true in ST/X
-
emptyLineAfterTemporaries: aBoolean
-
set/clear the emptyLineAfterTemporaries flag; if on, an empty line
is inserted after the locals declaration part.
defaults to false in original formatter; true in ST/X
-
maxLengthForSingleLineBlocks
-
return the maxLengthForSingleLineBlocks setting;
blocks with code longer than this are broken into multiple lines.
defaults to false in original formatter; true in ST/X
-
maxLengthForSingleLineBlocks: anInteger
-
set the maxLengthForSingleLineBlocks value;
blocks with code longer than this are broken into multiple lines.
defaults to false in original formatter; true in ST/X
-
periodAfterLastStatementPolicy
-
return the periodAfterLastStatementPolicy flag;
this can be one of #keep, #add or #remove
-
periodAfterLastStatementPolicy: aSymbol
-
set the periodAfterLastStatementPolicy flag;
this can be one of #keep, #add or #remove
-
spaceAfterBlockStart
-
return the spaceAfterBlockStart flag; if on, a space character
is inserted after a [ token.
-
spaceAfterBlockStart: aBoolean
-
set/clear the spaceAfterBlockStart flag; if on, a space character
is inserted after a [ token.
-
spaceAfterKeywordSelector
-
return the spaceAfterKeywordSelector flag; if on, a space character
is inserted after a : in a keyword message (to separate the arg).
defaults to true in original formatter; false in ST/X
-
spaceAfterKeywordSelector: aBoolean
-
set/clear the spaceAfterKeywordSelector flag; if on, a space character
is inserted after a : in a keyword message (to separate the arg).
defaults to true in original formatter; false in ST/X
-
spaceAfterReturnToken
-
return the spaceAfterReturn flag; if on, a space character
is inserted after a ^ token.
defaults to false in original formatter; true in ST/X
-
spaceAfterReturnToken: aBoolean
-
set/clear the spaceAfterReturn flag; if on, a space character
is inserted after a ^ token.
defaults to false in original formatter; true in ST/X
-
spaceAroundTemporaries
-
return the spaceAroundTemporariesr flag; if on, a space character
is inserted before the first and after the last local variable
in the locals declaration part (i.e. as in | foo bar |)
defaults to true in original formatter; false in ST/X
-
spaceAroundTemporaries: aBoolean
-
set/clear the spaceAroundTemporariesr flag; if on, a space character
is inserted before the first and after the last local variable
in the locals declaration part (i.e. as in | foo bar |)
defaults to true in original formatter; false in ST/X
-
spaceBeforeBlockEnd
-
return the spaceBeforeBlockEnd flag; if on, a space character
is inserted before a ] token.
-
spaceBeforeBlockEnd: aBoolean
-
set/clear the spaceBeforeBlockEnd flag; if on, a space character
is inserted before a ] token.
-
tabIndent
-
the indent; defaults to 8 in original formatter;
4 in ST/X
-
tabIndent: newIndent
-
set the indent; defaults to 8 in original formatter;
4 in ST/X
formatting-public
-
format: aMethodSource
-
ignore any error
Usage example(s):
RBFormatter format:'foo ^ self'
|
initialization
-
initializeSettings
-
self initialize
-
initializeSettingsForBR
-
BR original settings
-
initializeSettingsForSTX
-
ST/X settings
accessing
-
codeStream
-
-
firstLineLength
-
-
format: aNode
-
-
isMultiLine
-
-
lastLineLength
-
-
rewriteOldAssignments: aBoolean
-
if true (which is the default), old style assignments '_'
are formatted as ':='.
There is only one use of turning this off: when the original
source is to be preserve (i.e. when generating code for an old ST,
or showing a searchString's original pattern)
-
suppressAfterComment: something
-
-
suppressBeforeComment: something
-
additions - ST/X
-
addTab
-
copying-private
-
postCopy
-
initialize-release
-
initialize
-
private
-
crNoIndent
-
-
for: aValue do: doBlock separatedBy: separatorBlock
-
This is implemented here since IBM Smalltalk doesn't implement a do:separatedBy: method
-
indent
-
-
indent: anInteger while: aBlock
-
-
indentOnly
-
-
indentWhile: aBlock
-
-
lineLength
-
-
lineStart: aPosition
-
-
maxLineSize
-
-
maximumArgumentsPerLine
-
-
needsParenthesisFor: aNode
-
if original code had parentheses - generate them again
-
possiblyIndent
-
cr-tab - but only if not already at beginning
-
precedenceOf: parentSelector greaterThan: childSelector
-
Put parentheses around things that are preceived to have 'lower' precedence. For example, 'a + b * c'
-> '(a + b) * c' but 'a * b + c' -> 'a * b + c'
-
selectorsToLeaveOnLine
-
-
selectorsToStartOnNewLine
-
private-formatting
-
formatArrayNodeExpressions: statements
-
-
formatArrayNodeExpressions: statements singleLine: singleLine
-
or:[ PeriodAfterLastStatementPolicy == #keep
and:[ aSequenceNode lastHasPeriod]]
-
formatLiteral: aLiteralNode
-
to preserve the original radix...
-
formatLiteralArray: aLiteralNode
-
needSpace := false.
-
formatLiteralValue: aValue
-
-
formatMessage: aMessageNode cascade: cascadeBoolean
-
-
formatMessage: aMessageNode cascade: cascadeBoolean newLine: newLine
-
(aMessageNode arguments size > 0
and:[(self startMessageSendOnNewLine: aMessageNode)]) ifTrue:[
howMuchIndent := 0.
].
-
formatMessageSelector: selectorParts withArguments: formattedArgs multiline: multiLine
-
-
formatMethodPatternFor: aMethodNode
-
-
formatPragma: aPragmaNode
-
-
formatStatementsFor: aSequenceNode
-
self formatStatementComments:(stat commentsAfter) for:stat.
-
formatSymbol: aSymbol
-
Format the symbol, if it's not a selector then we must put quotes around it. The and: case below,
handles the VisualWorks problem of not accepting two bars as a symbol.
-
formatTagFor: aMethodNode
-
-
formatTemporariesFor: aSequenceNode
-
-
newLinesFor: aString startingAt: anIndex
-
private-formatting-comments
-
formatArgumentComments: comments for: aNode
-
-
formatBlockCommentFor: aNode
-
-
formatComments: comments for: aNode spaceAfter: spaceafter
-
-
formatComments: comments for: aNode spaceBefore: spaceBefore spaceAfter: spaceafter
-
crs := self newLinesFor: source startingAt: eachComment first.
(crs - 1 max: 0) timesRepeat: [codeStream cr].
crs == 0 ifTrue: [self addTab] ifFalse: [self indent].
-
formatMethodComment: aComment for: aNode indentBefore: indentBefore
-
-
formatMethodComment: aComment for: aNode indentBefore: indentBefore indentAfter: indentAfter
-
source isNil ifTrue: [^self].
-
formatMethodCommentFor: aNode indentBefore: aBoolean
-
-
formatMethodComments: comments for: aNode indentBefore: indentBefore
-
source := aNode source.
-
formatMethodCommentsAfter: comments for: aNode
-
special case for comment-only methods: leave as is
-
formatMethodCommentsAfterRightBar: comments for: aNode
-
-
formatStatementCommentFor: aNode
-
-
formatStatementComments: comments for: aNode
-
this:
-
formatStatementCommentsBefore: comments for: aNode
-
-
formatTemporaryComments: comments for: aNode
-
testing
-
startMessageSendOnNewLine: aMessageNode
-
-
tagBeforeTemporaries
-
visiting
-
visitNode: aNode
-
visiting-comments
-
formatCommentsAfter: comments for: aNode
-
-
formatCommentsBefore: comments for: aNode
-
-
formatMethodCommentsBefore: comments for: aNode
-
-
formatSequenceCommentsBefore: comments for: aNode
-
visitor-double dispatching
-
acceptArrayNode: anArrayNode
-
try as single line first
-
acceptAssignmentNode: anAssignmentNode
-
oldStyle ifTrue:[' _ '] ifFalse:[' := ']).
-
acceptBlockNode: aBlockNode
-
I am the receiver of a message (i.e. typically a control structure)
-
acceptBlockNodeCStyle: aBlockNode
-
-
acceptCascadeNode: aCascadeNode
-
-
acceptLiteralNode: aLiteralNode
-
-
acceptMessageNode: aMessageNode
-
pre-generate the code for the receiver into a string.
-
acceptMethodNode: aMethodNode
-
self formatMethodCommentFor: aMethodNode indentBefore: true.
-
acceptOptimizedNode: anOptimizedNode
-
-
acceptPragmaNode: aLiteralNode
-
-
acceptReturnNode: aReturnNode
-
-
acceptSTXPrimitiveCCodeNode: aPrimitiveNode
-
-
acceptSTXPrimitiveValueCCodeNode: aPrimitiveNode
-
-
acceptSequenceNode: aSequenceNode
-
self formatMethodCommentFor: aSequenceNode indentBefore: false.
-
acceptVariableNode: aVariableNode
-
-
formatBlockArguments: aBlockNode
-
-
whichArgIsToBeFormattedKRLikeIn: selector
-
for CStyle (kernigham-ritchie style) formatting of blocks arguments.
Return the arg-index or nil or #both
|