[Enh] extension to find class in bropwser to look for globals too

Stephan B. Wessels stephan.wessels at sdrc.com
Wed Nov 10 15:31:33 UTC 1999


--------------C5ABE9FEFC041B56A607A82F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


This change set builds upon the latest find class changes for the browser where
a "." is used to limit the search.  The new feature here is that you can type in
the name of a Global variable (in addition to class names of course) and it will
find the class for that global.

So for instance if you find a global named Display you can find class on Display
and it will take you to that global's class in the browser.

The change to the browser code was pretty simple but some minor refactoring had
to be done.  The current find class code has been broken into 2 parts.  One that
queries the developer for the class to find and one that then actually finds the
specified class.

 - Steve



--------------C5ABE9FEFC041B56A607A82F
Content-Type: text/plain; charset=us-ascii;
 name="findglobal.9Nove535pm.cs"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="findglobal.9Nove535pm.cs"


'From Squeak2.7alpha of 8 November 1999 [latest update: #1592] on 9 November 1999 at 5:35:26 pm'!

!Browser methodsFor: 'system category functions' stamp: 'sbw 10/23/1999 17:44'!
classNotFound
	self changed: #flash.
	^nil! !

!Browser methodsFor: 'system category functions' stamp: 'sbw 10/23/1999 19:08'!
findClass
	| foundClass |
	foundClass _ self findClassQuery.
	foundClass isNil ifTrue: [^ nil].
	self systemCategoryListIndex: (self systemCategoryList indexOf: foundClass category).
	self classListIndex: (self classList indexOf: foundClass name)! !

!Browser methodsFor: 'system category functions' stamp: 'sbw 11/9/1999 17:32'!
findClassQuery
	"Search for a class or global by name.  Modified so that if only 1 class   
	 matches the user-supplied string then the pop-up menu is bypassed.     
	Answers a class or nil."
	| pattern foundClass classNames index global |
	self okToChange ifFalse: [^ self classNotFound].
	pattern _ FillInTheBlank request: 'Class/Global name or fragment?'.
	pattern isEmpty ifTrue: [^ self classNotFound].
	classNames _ pattern last = $.
		ifTrue: [Smalltalk classNames select: [:nm | nm asLowercase = pattern allButLast asLowercase]]
		ifFalse: [Smalltalk classNames asArray select: [:n | n includesSubstring: pattern caseSensitive: false]].
	(Smalltalk includesKey: pattern asSymbol) ifTrue: [
		global _ Smalltalk at: pattern asSymbol.
		(global isKindOf: Class) ifFalse: [
			classNames _ Array with: global class name]].
	classNames isEmpty ifTrue: [^ self classNotFound].
	index _ classNames size = 1
				ifTrue: [1]
				ifFalse: [(PopUpMenu labelArray: classNames lines: #()) startUp].
	index = 0 ifTrue: [^ self classNotFound].
	foundClass _ Smalltalk at: (classNames at: index).
	^ foundClass! !



--------------C5ABE9FEFC041B56A607A82F--





More information about the Squeak-dev mailing list