actually it should be: ------------- formatStatementCommentsFor: aStatementNode originalSource isNil ifTrue: [ ^ self ]. FormatCommentWithStatements ifFalse: [ ^ self ]. aStatementNode statementComments do: [ :each | | count | count := self newLinesBeforeStartingAt: each first. (count) > 0 ifTrue: [ self newLines: count ] ifFalse: [ codeStream tab ].
codeStream nextPutAll: (originalSource copyFrom: each first to: each last) ] -------------- to allow having comments on top of sections of code. On Wed, Aug 20, 2014 at 10:20 PM, Peter Uhnák <i.uh...@gmail.com> wrote: > Ah! > > RBConfigurableFormatter class>>settingsOn: is missing one setting > ---- > (aBuilder setting: #retainBlankLinesBetweenStatements) > label: 'Retain blank lines between statements'. > ---- > > > As for the comments, I looked at > RBConfigurableFormatter>>formatStatementCommentsFor: > one idea might be to look at the space between end of the statement and > beginning of the comment and if there is newline present then preserve it. > > something like > -------------------------- > formatStatementCommentsFor: aStatementNode > originalSource isNil > ifTrue: [ ^ self ]. > FormatCommentWithStatements > ifFalse: [ ^ self ]. > aStatementNode statementComments > do: [ :each | > (self newLinesBeforeStartingAt: each first) > 0 > ifTrue: [ self newLine ] > ifFalse: [ codeStream tab ]. > > codeStream nextPutAll: (originalSource copyFrom: each first to: each last) > ] > --------------------------- > > There should be also an accompanying setting > #retainBlankLineBeforeComments. > > Peter > > > On Wed, Aug 20, 2014 at 7:45 PM, stepharo <steph...@free.fr> wrote: > >> Hi peter >> >> >> Is it possible to configure formatter to preserve empty lines and line >> comments? >> >> >> I do not know :) >> >> >> >> e.g. >> -------------- >> myMethod >> someCode. >> < empty line that I would like to preserve > >> moreCode. >> --------------- >> >> But I think that should be customizable. >> >> >> >> the formatter also automatically puts comments on the end of the >> previous statement. >> e.g. >> ------ >> someCode. >> "a comment" >> moreCode. >> >> >> If I recall, the problem is that comments are not a node but an attribute >> of a node. >> We should try to fix that. It is not clear where you always want to put >> them. >> >> >> ---- >> ends up as >> ---- >> someCode. "a comment" >> moreCode. >> ----- >> >> Both those behaviors seems odd to me. >> >> I've seen empty newlines and line comments in Pharo code... so either I >> missed some setting or people just don't use the formatter? >> >> I use the formatter and I would like to use it much more systemaitcally. >> >> >> Thanks, >> Peter >> >> >> >