extensions.st
changeset 147 5c835893f71b
parent 137 12232e62cf54
child 150 f3e694a9aa12
equal deleted inserted replaced
146:dfb2ae961d9c 147:5c835893f71b
   346     ^ selectedClasses
   346     ^ selectedClasses
   347 
   347 
   348     "Created: / 24-08-2013 / 21:53:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   348     "Created: / 24-08-2013 / 21:53:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   349 ! !
   349 ! !
   350 
   350 
       
   351 !Tools::NewSystemBrowser methodsFor:'private-searching-smallsense'!
       
   352 
       
   353 searchCompletionBlock_SmallSense
       
   354     "This returns a class/selector name completion block that uses
       
   355      standard DoWhatIMeanSupport"
       
   356     
       
   357     ^ [:patternString | self smallSenseSearchCompletion:patternString ]
       
   358 
       
   359     "Created: / 25-11-2013 / 12:27:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   360 ! !
       
   361 
       
   362 !Tools::NewSystemBrowser methodsFor:'private-searching-smallsense'!
       
   363 
       
   364 smallSenseSearchCompletion:patternString 
       
   365     "/sorry, no method search yet"
       
   366     
       
   367     ^ self smallSenseSearchCompletionNewForClass:patternString
       
   368 
       
   369     "Modified: / 04-08-2011 / 19:05:28 / cg"
       
   370     "Created: / 04-12-2011 / 22:22:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   371 ! !
       
   372 
       
   373 !Tools::NewSystemBrowser methodsFor:'private-searching-smallsense'!
       
   374 
       
   375 smallSenseSearchCompletionBlock
       
   376     "This returns a class/selector name completion block that uses
       
   377      standard DoWhatIMeanSupport"
       
   378     
       
   379     ^ [:patternString | self smallSenseSearchCompletion:patternString ]
       
   380 
       
   381     "Modified: / 04-08-2011 / 19:05:28 / cg"
       
   382     "Created: / 04-12-2011 / 22:13:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   383 ! !
       
   384 
       
   385 !Tools::NewSystemBrowser methodsFor:'private-searching-smallsense'!
       
   386 
       
   387 smallSenseSearchCompletionEntryForClass:aClass showPrefix:showPrefix 
       
   388     ^ (SmallSense::ClassPO new)
       
   389         klass:aClass;
       
   390         showPrefix:showPrefix.
       
   391 
       
   392     "Created: / 06-04-2012 / 12:55:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   393     "Modified: / 25-11-2013 / 12:16:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   394 ! !
       
   395 
       
   396 !Tools::NewSystemBrowser methodsFor:'private-searching-smallsense'!
       
   397 
       
   398 smallSenseSearchCompletionNewForClass:patternString 
       
   399     | env  pattern  matcher  matches  relax  withPrefix |
       
   400 
       
   401     patternString isEmptyOrNil ifTrue:[
       
   402         ^ #( '' #() )
       
   403     ].
       
   404     env := self theSingleSelectedNamespace ? #Smalltalk.
       
   405     env = NavigatorModel nameListEntryForALL ifTrue:[
       
   406         env := #Smalltalk
       
   407     ].
       
   408     env := Smalltalk at:env.
       
   409     withPrefix := patternString includes:$:.
       
   410     pattern := StringPattern readFrom:patternString onError:[ ^ #( '' #() ) ].
       
   411     withPrefix ifTrue:[
       
   412         matcher := [:cls | pattern match:cls name ]
       
   413     ] ifFalse:[
       
   414         matcher := [:cls | pattern match:cls nameWithoutPrefix ]
       
   415     ].
       
   416     relax := 1.
       
   417     [
       
   418         matches isEmptyOrNil and:[ relax <= 3 ]
       
   419     ] whileTrue:[
       
   420         matches := OrderedCollection new.
       
   421         env 
       
   422             keysDo:[:nm | 
       
   423                 | cls |
       
   424 
       
   425                 cls := env at:nm.
       
   426                 (cls notNil 
       
   427                     and:[ cls isBehavior and:[ (matches includesIdentical:cls) not ] ]) 
       
   428                         ifTrue:[
       
   429                             (matcher value:cls) ifTrue:[
       
   430                                 matches add:cls
       
   431                             ].
       
   432                         ].
       
   433             ].
       
   434         relax := relax + 1.
       
   435     ].
       
   436     matches isEmpty ifTrue:[
       
   437         ^ #( nil #() )
       
   438     ] ifFalse:[
       
   439         matches := matches 
       
   440                 collect:[:cls | 
       
   441                     self smallSenseSearchCompletionEntryForClass:cls showPrefix:withPrefix
       
   442                 ].
       
   443         ^ {
       
   444             matches first.
       
   445             matches
       
   446         }
       
   447     ]
       
   448 
       
   449     "Created: / 06-04-2012 / 12:56:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   450 ! !
       
   451 
   351 !UserPreferences methodsFor:'accessing-SmallSense'!
   452 !UserPreferences methodsFor:'accessing-SmallSense'!
   352 
   453 
   353 smallSenseBackgroundLintEnabled
   454 smallSenseBackgroundLintEnabled
   354     "Return true if SmallSense background source checking is enabled"
   455     "Return true if SmallSense background source checking is enabled"
   355 
   456