Incorporating the Code Formatter in Envy QA into VA9

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Incorporating the Code Formatter in Envy QA into VA9

Steven LaFavor
VA 9.1

One of the things that I have noticed on larger (and smaller) Smalltalk development teams is that everyone has their own way of how they like code formatted.  And since the envy repository treats it as a string, even adding a space will trigger the need to "save" a method.   And over the life of a project, with developers coming and going, how the code looks/formats can go a great way in is its readability.

With the Envy QA apps now as part of the VA standard, I made a slight modification to some internal coding so that it doesn't matter how anyone saved their code in the repository.  You can see it as you would like it formatted without having to resave it.

In CompiledMethod>>sourceString

"Return the source code for the receiver."

| source |

##PR = ##'1PQCXCI'.
self isDoit
ifTrue: [source := (self at: self size) value]
ifFalse: [
| residentClass |
canSee: (
self isPrivate
ifTrue: [#readPrivateSource]
ifFalse: [#readPublicSource])
ifNot: [^nil].
residentClass := self methodClass residentClass.
source := (residentClass notNil and: [residentClass classHasSourceFor: self])
ifTrue: [residentClass classSuppliedSourceFor: self] "Ask the class for its source"
ifFalse: [
EmLibrary cache
methodSourceAt: self filePointer
decompress: true]. "No class-supplied source, get it from the library"
(Smalltalk classAt: #CfFormatter) notNil
ifTrue: [
source := CfFormatter new
formatText: source
class: residentClass
width: nil]].
^EmImageSupport sourceFilter filter: source
I throw this out there for any one to use, or tell me that I've missed something, or that they know of a less "intrusive" way to do this.......

Any thoughts?   I've found it to be incredibly helpful to set up my CfFormatter settings the way I like it, and then be able to peruse code in a format that makes it easier for me to read and understand.....

You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit