Source Code Formatting using ENVY/QA

If you are creating source code by software you might perhaps be tired of formatting the source code by adding nextPutAll: messages everywhere.

On the other hand it may be very interesting to get similiar looking code everywhere and then – more or less – you perhaps might look at ENVY/QA, which includes a SourceCode Formatter.

As I mentioned in an earlier posting you might compile a method within VASmalltalk with a code sequence like:

		compile: 'squareXXYY ^(x * x) + (y * y).'
		notifying: nil
		ifNewAddTo: CLDT
		categorizeIn: #('calculation' 'calc-protocol')

By using ENVA/QA it might look like:

		compile: ('squareXXYY ^(x * x) + (y * y).' formatViaENVYQAInClass: Point)
		notifying: nil
		ifNewAddTo: CLDT
		categorizeIn: #('calculation' 'calc-protocol')

and String>>formatViaENVYQAInClass: may look like:

String>>formatViaENVYQAInClass: actualClass
	| formatterClass sourceString |

	(formatterClass := Smalltalk classAt: 'CfFormatter' ifAbsent: [nil]) notNil
		ifTrue: [
			(sourceString := formatterClass new formatText: self class: actualClass width: 100)
					ifFalse: [^Transcript compilerError: sourceString]]
		ifFalse: [sourceString := self].


and then you get similiar formatted source code …

This entry was posted in Smalltalk. Bookmark the permalink.