extensions.st
changeset 174 3e08d765d86f
parent 137 12232e62cf54
child 176 df6d3225d1e4
--- a/extensions.st	Tue Nov 19 13:02:56 2013 +0000
+++ b/extensions.st	Wed Feb 26 19:06:00 2014 +0100
@@ -233,6 +233,15 @@
     "Modified: / 26-11-2011 / 11:49:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!PrimitiveNode methodsFor:'accessing-SmallSense'!
+
+inferedType
+
+    ^ SmallSense::Type withClass: UndefinedObject "/ Not really true, should be 'void'
+
+    "Created: / 08-12-2013 / 22:25:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !RBLintRule methodsFor:'accessing'!
 
 fixes: aSmallSenseQuickFixer
@@ -348,6 +357,107 @@
     "Created: / 24-08-2013 / 21:53:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!Tools::NewSystemBrowser methodsFor:'private-searching-smallsense'!
+
+searchCompletionBlock_SmallSense
+    "This returns a class/selector name completion block that uses
+     standard DoWhatIMeanSupport"
+    
+    ^ [:patternString | self smallSenseSearchCompletion:patternString ]
+
+    "Created: / 25-11-2013 / 12:27:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Tools::NewSystemBrowser methodsFor:'private-searching-smallsense'!
+
+smallSenseSearchCompletion:patternString 
+    "/sorry, no method search yet"
+    
+    ^ self smallSenseSearchCompletionNewForClass:patternString
+
+    "Modified: / 04-08-2011 / 19:05:28 / cg"
+    "Created: / 04-12-2011 / 22:22:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Tools::NewSystemBrowser methodsFor:'private-searching-smallsense'!
+
+smallSenseSearchCompletionBlock
+    "This returns a class/selector name completion block that uses
+     standard DoWhatIMeanSupport"
+    
+    ^ [:patternString | self smallSenseSearchCompletion:patternString ]
+
+    "Modified: / 04-08-2011 / 19:05:28 / cg"
+    "Created: / 04-12-2011 / 22:13:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Tools::NewSystemBrowser methodsFor:'private-searching-smallsense'!
+
+smallSenseSearchCompletionEntryForClass:aClass showPrefix:showPrefix 
+    ^ (SmallSense::ClassPO new)
+        klass:aClass;
+        showPrefix:showPrefix.
+
+    "Created: / 06-04-2012 / 12:55:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 25-11-2013 / 12:16:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Tools::NewSystemBrowser methodsFor:'private-searching-smallsense'!
+
+smallSenseSearchCompletionNewForClass:patternString 
+    | env  pattern  matcher  matches  relax  withPrefix |
+
+    patternString isEmptyOrNil ifTrue:[
+        ^ #( '' #() )
+    ].
+    env := self theSingleSelectedNamespace ? #Smalltalk.
+    env = NavigatorModel nameListEntryForALL ifTrue:[
+        env := #Smalltalk
+    ].
+    env := Smalltalk at:env.
+    withPrefix := patternString includes:$:.
+    pattern := StringPattern readFrom:patternString onError:[ ^ #( '' #() ) ].
+    withPrefix ifTrue:[
+        matcher := [:cls | pattern match:cls name ]
+    ] ifFalse:[
+        matcher := [:cls | pattern match:cls nameWithoutPrefix ]
+    ].
+    relax := 1.
+    [
+        matches isEmptyOrNil and:[ relax <= 3 ]
+    ] whileTrue:[
+        matches := OrderedCollection new.
+        env 
+            keysDo:[:nm | 
+                | cls |
+
+                cls := env at:nm.
+                (cls notNil 
+                    and:[ cls isBehavior and:[ (matches includesIdentical:cls) not ] ]) 
+                        ifTrue:[
+                            (matcher value:cls) ifTrue:[
+                                matches add:cls
+                            ].
+                        ].
+            ].
+        relax := relax + 1.
+    ].
+    matches isEmpty ifTrue:[
+        ^ #( nil #() )
+    ] ifFalse:[
+        matches := matches 
+                collect:[:cls | 
+                    self smallSenseSearchCompletionEntryForClass:cls showPrefix:withPrefix
+                ].
+        ^ {
+            matches first.
+            matches
+        }
+    ]
+
+    "Created: / 06-04-2012 / 12:56:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !UserPreferences methodsFor:'accessing-SmallSense'!
 
 smallSenseBackgroundLintEnabled
@@ -402,6 +512,30 @@
 
 !UserPreferences methodsFor:'accessing-SmallSense'!
 
+smallSenseCompleteIfUnambiguous
+
+    ^self at:#smallSenseCompleteIfUnambiguous ifAbsent:[false]
+
+    "Created: / 18-01-2014 / 23:08:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!UserPreferences methodsFor:'accessing-SmallSense'!
+
+smallSenseCompleteIfUnambiguous: aBoolean
+
+    ^self at:#smallSenseCompleteIfUnambiguous put: aBoolean.
+
+    "
+    UserPreferences current smallSenseCompleteIfUnambiguous
+    UserPreferences current smallSenseCompleteIfUnambiguous: true.
+    UserPreferences current smallSenseCompleteIfUnambiguous: false.
+    "
+
+    "Created: / 18-01-2014 / 23:08:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!UserPreferences methodsFor:'accessing-SmallSense'!
+
 smallSenseEnabled
     "Return true if SmallSense is enabled"