--- a/Smalltalk.st Tue Aug 08 11:43:19 2000 +0200
+++ b/Smalltalk.st Tue Aug 08 14:48:31 2000 +0200
@@ -1865,6 +1865,59 @@
"Created: 11.10.1996 / 18:10:43 / cg"
!
+methodProtocolCompletion:aPartialProtocolName
+ "given a partial method protocol name, return an array consisting of
+ 2 entries: 1st: collection consisting of matching protocols
+ 2nd: the longest match"
+
+ |matches best lcName|
+
+ matches := IdentitySet new.
+
+ "/ search for exact match
+ self allClassesDo:[:aClass |
+ aClass allSelectorsAndMethodsDo:[:aSelector :aMethod |
+ |protocol|
+
+ protocol := aMethod category.
+ (protocol startsWith:aPartialProtocolName) ifTrue:[
+ matches add:protocol
+ ]
+ ].
+ ].
+ matches isEmpty ifTrue:[
+ "/ search for case-ignoring match
+ lcName := aPartialProtocolName asLowercase.
+ self allClassesDo:[:aClass |
+ aClass allSelectorsAndMethodsDo:[:aSelector :aMethod |
+ |protocol|
+
+ protocol := aMethod category.
+ (protocol asLowercase startsWith:lcName) ifTrue:[
+ matches add:protocol
+ ]
+ ].
+ ].
+ ].
+
+ matches isEmpty ifTrue:[
+ ^ Array with:aPartialProtocolName with:(Array with:aPartialProtocolName)
+ ].
+ matches size == 1 ifTrue:[
+ ^ Array with:matches first with:(matches asArray)
+ ].
+ matches := matches asSortedCollection.
+ best := matches longestCommonPrefix.
+ ^ Array with:best with:matches asArray
+
+ "
+ Smalltalk methodProtocolCompletion:'doc'
+ Smalltalk methodProtocolCompletion:'docu'
+ Smalltalk methodProtocolCompletion:'documenta'
+ "
+
+!
+
numberOfGlobals
"return the number of global variables in the system"
@@ -5664,5 +5717,5 @@
!Smalltalk class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.459 2000-08-08 09:43:19 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.460 2000-08-08 12:48:31 cg Exp $'
! !