[Pkg] The Trunk: ToolBuilder-Kernel-topa.91.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Oct 20 08:45:43 UTC 2015


Tobias Pape uploaded a new version of ToolBuilder-Kernel to project The Trunk:
http://source.squeak.org/trunk/ToolBuilder-Kernel-topa.91.mcz

==================== Summary ====================

Name: ToolBuilder-Kernel-topa.91
Author: topa
Time: 20 October 2015, 10:45:19.628 am
UUID: 63d2a49c-5a31-4fcd-a2ff-8c24c045b1d3
Ancestors: ToolBuilder-Kernel-topa.90

Don't bother displaying emty lists to chose from

=============== Diff against ToolBuilder-Kernel-topa.90 ===============

Item was changed:
  ----- Method: UIManager>>classOrTraitFrom:pattern:label: (in category 'system introspecting') -----
  classOrTraitFrom: environment pattern: pattern label: label
  	"If there is a class or trait whose name exactly given by pattern, return it.
  	If there is only one class or trait in the given environment whose name matches pattern, return it.
  	Otherwise, put up a menu offering the names of all classes that match pattern, and return the class chosen, else nil if nothing chosen.
  	This method ignores separator characters in the pattern"
  	
  	| toMatch potentialNames names exactMatch lines reducedIdentifiers selectedIndex |
  	toMatch := pattern copyWithoutAll: Character separators.
  	toMatch ifEmpty: [ ^nil ].
  	"If there's a class or trait named as pattern, then return it."
  	Symbol hasInterned: pattern ifTrue: [ :symbol |
  		environment at: symbol ifPresent: [ :maybeClassOrTrait |
  			((maybeClassOrTrait isKindOf: Class) or: [
  				maybeClassOrTrait isTrait ])
  					ifTrue: [ ^maybeClassOrTrait ] ] ].
  	"No exact match, look for potential matches."
  	toMatch := pattern asLowercase copyWithout: $..
  	potentialNames := (environment classAndTraitNames) asOrderedCollection.
  	names := pattern last = $. "This is some old hack, using String>>#match: may be better."
  		ifTrue: [ potentialNames select: [ :each | each asLowercase = toMatch ] ]
  		ifFalse: [
  			potentialNames select: [ :each |
  				each includesSubstring: toMatch caseSensitive: false ] ].
  	exactMatch := names detect: [ :each | each asLowercase = toMatch ] ifNone: [ nil ].
  	lines := OrderedCollection new.
  	exactMatch ifNotNil: [ lines add: 1 ].
  	"Also try some fuzzy matching."
  	reducedIdentifiers := pattern suggestedTypeNames select: [ :each |
  		potentialNames includes: each ].
  	reducedIdentifiers ifNotEmpty: [
  		names addAll: reducedIdentifiers.
  		lines add: 1 + names size + reducedIdentifiers size ].
  	"Let the user select if there's more than one possible match. This may give surprising results."
+ 	names size = 0 ifTrue: [^ nil "nothing matches"].
+ 	
  	selectedIndex := names size = 1
  		ifTrue: [ 1 ]
  		ifFalse: [
  			exactMatch ifNotNil: [ names addFirst: exactMatch ].
  			self chooseFrom: names lines: lines title: label ].
  	selectedIndex = 0 ifTrue: [ ^nil ].
  	^environment at: (names at: selectedIndex) asSymbol!



More information about the Packages mailing list