'From Squeak3.1alpha of 16 September 2001 [latest update: #4332] on 22 September 2001 at 11:19:59 pm'! "Change Set: FileContentBrowser Date: 23 April 2001 Author: Bijan Parsia Some minor tweaks to that most wonderful of tools, the FileContentBrowser, spurred by Richard O'Keefe's queries to the Squeak list. It (thus far) includes: 1) The ability to view bytecodes of browsed methods. (updated to work with 3.1a-4332 by Doug Way) 2) Richard's proposed changes to the wording of messages provided by PseudoClass>>comment and PseudoClass>>definition. 3) A tweak to PseudoClass>>definition so that if you click on the class name, it will pop up the definition already in the system. 4) Some stabs at class comments for FileContentsBrowser and PseudoClass"! !FileContentsBrowser commentStamp: '' prior: 0! I am a class browser view on a fileout (either a source file (.st) or change set (.cs)). I do not actually load the code into to the system, nor do I alter the classes in the image. Use me to vet code in a comfortable way before loading it into your image. From a FileList, I can be invoked by selecting a source file and selecting the "browse code" menu item from the yellow button menu. I use PseudoClass, PseudoClassOrganizers, and PseudoMetaclass to model the class structure of the source file.! !PseudoClass commentStamp: '' prior: 0! I provide an inert model of a Class, used by FileContentsBrowser to manipulate filedout code. Instead of a method dictionary or selectors onto CompiledMethods, I have a dictionary ("source") of selectors onto ChangeRecords, which were, in the case of FileContentsBrowser, parsed from a source or change set file.! !Browser methodsFor: 'accessing' stamp: 'dew 9/22/2001 23:09'! contents "Depending on the current selection, different information is retrieved. Answer a string description of that information. This information is the method of the currently selected class and message." | comment theClass latestCompiledMethod | latestCompiledMethod _ currentCompiledMethod. currentCompiledMethod _ nil. editSelection == #none ifTrue: [^ '']. editSelection == #editSystemCategories ifTrue: [^ systemOrganizer printString]. editSelection == #newClass ifTrue: [^ (theClass _ self selectedClass) ifNil: [Class template: self selectedSystemCategoryName] ifNotNil: [Class templateForSubclassOf: theClass category: self selectedSystemCategoryName]]. editSelection == #editClass ifTrue: [^ (theClass _ self selectedClassOrMetaClass) ifNil: [ "" ] ifNotNil: [ theClass definitionST80: Preferences printAlternateSyntax not]]. editSelection == #editComment ifTrue: [(theClass _ self selectedClass) ifNil: [^ '']. comment _ theClass comment. comment size = 0 ifTrue: [^ 'This class has not yet been commented.'] ifFalse: [^ comment]]. editSelection == #hierarchy ifTrue: [^ self selectedClassOrMetaClass printHierarchy]. editSelection == #editMessageCategories ifTrue: [^ self classOrMetaClassOrganizer printString]. editSelection == #newMessage ifTrue: [ ^ (theClass _ self selectedClassOrMetaClass) ifNil: [ "" ] ifNotNil: [ theClass sourceCodeTemplate]]. editSelection == #editMessage ifTrue: [self showingByteCodes ifTrue: [^ self selectedBytecodes]. currentCompiledMethod _ latestCompiledMethod. ^ self selectedMessage]. self error: 'Browser internal error: unknown edit selection.'! ! !Browser methodsFor: 'code pane' stamp: 'dew 9/22/2001 23:06'! selectedBytecodes ^ (self selectedClassOrMetaClass compiledMethodAt: self selectedMessageName) symbolic asText! ! !FileContentsBrowser methodsFor: 'edit pane' stamp: 'dew 9/22/2001 23:06'! selectedBytecodes "Compile the source code for the selected message selector and extract and return the bytecode listing." | class selector | class _ self selectedClassOrMetaClass. selector _ self selectedMessageName. contents _ class sourceCodeAt: selector. contents _ Compiler new parse: contents in: class notifying: nil. contents _ contents generate: #(0 0 0 0). ^ contents symbolic asText! ! !PseudoClass methodsFor: 'class' stamp: 'BJP 4/23/2001 13:50'! comment | rStr | rStr := self organization commentRemoteStr. ^rStr isNil ifTrue:[self name,' has not been commented in this file'] ifFalse:[rStr string]! ! !PseudoClass methodsFor: 'class' stamp: 'BJP 4/23/2001 14:58'! definition | link linkText defText | ^definition ifNil: [defText _ Text fromString: 'There is no class definition for '. link _ TextLink new. linkText _ link analyze: self name with: 'Definition'. linkText _ Text string: linkText attribute: link. defText append: linkText; append: ' in this file'].! !