Factored out common support for code completion.
authorJan Vrany <jan.vrany@fit.cvut.cz>
Mon, 05 Aug 2013 10:27:05 +0100
changeset 52 3ca8f7181ed5
parent 51 a37e5df13fab
child 53 84e9840dd522
Factored out common support for code completion.
SmallSenseEditSupport.st
SmallSenseJavaEditSupport.st
SmallSenseSmalltalkEditSupport.st
abbrev.stc
smallsense.rc
--- a/SmallSenseEditSupport.st	Sun Aug 04 02:29:30 2013 +0100
+++ b/SmallSenseEditSupport.st	Mon Aug 05 10:27:05 2013 +0100
@@ -64,15 +64,29 @@
 
 !SmallSenseEditSupport methodsFor:'event handling'!
 
+doKeyPressKeyComplete                                                  
+    "Not supported in generic edit support"
+
+    textView flash.
+    ^ true
+
+    "Created: / 04-08-2013 / 02:31:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 keyPress: key x:x y:y in: view
 
     "Handles an event in given view (a subview of codeView).
      If the method returns true, the event will not be processed
      by the view."
 
+    key == #CodeCompletion  ifTrue: [
+        ^ self doKeyPressKeyComplete. 
+    ].
+
     ^false
 
     "Created: / 24-07-2013 / 23:31:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 04-08-2013 / 02:32:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !SmallSenseEditSupport methodsFor:'private'!
--- a/SmallSenseJavaEditSupport.st	Sun Aug 04 02:29:30 2013 +0100
+++ b/SmallSenseJavaEditSupport.st	Mon Aug 05 10:27:05 2013 +0100
@@ -36,10 +36,10 @@
         ^ self keyPressOpenCurly
     ].
 
-    ^ false.
+    ^ super keyPress: key x:x y:y in: view
 
     "Created: / 07-03-2010 / 09:36:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 04-08-2013 / 01:54:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 04-08-2013 / 03:06:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 keyPressOpenCurly
@@ -74,14 +74,17 @@
     scanner := (Smalltalk at:#JavaScanner) for: (service textView listAt: service textView cursorLine) string.
 
     [ 
-        token := scanner nextToken.
-        (token ~~ #EOF and:[ scanner tokenEndPosition + 1 < service textView cursorCol ]) whileTrue.
+        [ 
+            token := scanner nextToken.
+            (token ~~ #EOF and:[ scanner tokenEndPosition + 1 < service textView cursorCol ])
+        ] whileTrue.
     ] on: Error do:[
         token := nil.
     ].
     ^ token
 
     "Created: / 04-08-2013 / 02:00:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 04-08-2013 / 03:10:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 tokensAtCursorLine
--- a/SmallSenseSmalltalkEditSupport.st	Sun Aug 04 02:29:30 2013 +0100
+++ b/SmallSenseSmalltalkEditSupport.st	Mon Aug 05 10:27:05 2013 +0100
@@ -35,6 +35,77 @@
 
 !SmallSenseSmalltalkEditSupport methodsFor:'event handling'!
 
+doKeyPressKeyComplete
+    |cls 
+"/     crsrPos interval node checkedNode
+"/     char start stop selectorSoFar matchingSelectors
+    codeView |
+
+    codeView := service codeView.
+
+    cls := codeView classHolder value.
+    cls isNil ifTrue:[
+        codeView showInfo:'No class'.
+        ^ true.
+    ].
+    UserInformation handle:[:ex |
+        codeView showInfo:(ex messageText).
+        ex proceed.
+    ] do:[
+        codeView withWaitCursorDo:[
+            codeView textView keyRelease: #Control_L x:0 y:0.
+            SmallSenseCompletionWindow openForView: codeView class: cls.
+        ]
+    ].
+    ^ true.
+
+"/
+"/    interval := self selectedInterval.
+"/    interval isEmpty ifTrue:[
+"/        crsrPos := codeView characterPositionOfCursor - 1.
+"/        char := codeView characterUnderCursor.
+"/        [crsrPos > 1 and:[char isSeparator or:['.' includes:char]]] whileTrue:[
+"/            crsrPos := crsrPos - 1.
+"/            char := codeView characterAtCharacterPosition:crsrPos.
+"/        ].
+"/        interval := crsrPos to:crsrPos.
+"/    ].
+"/
+"/    node := self findNodeForInterval:interval allowErrors:true.
+"/    [node isNil] whileTrue:[
+"/        "/ expand to the left ...
+"/        interval start > 1 ifFalse:[
+"/            self showInfo:'No parseNode found'.
+"/            ^ self.
+"/        ].
+"/        interval start:(interval start - 1).
+"/        node := self findNodeForInterval:interval allowErrors:true.
+"/    ].
+"/
+"/    node isVariable ifTrue:[
+"/        self codeCompletionForVariable:node inClass:cls.
+"/        ^ self.
+"/    ].
+"/
+"/    checkedNode := node.
+"/    [checkedNode notNil] whileTrue:[
+"/        checkedNode isMessage ifTrue:[
+"/            self codeCompletionForMessage:checkedNode inClass:cls.
+"/            ^ self
+"/        ].
+"/        checkedNode isMethod ifTrue:[
+"/            self codeCompletionForMethod:checkedNode inClass:cls.
+"/            ^ self.
+"/        ].
+"/        checkedNode := checkedNode parent.
+"/    ].
+"/
+"/    self showInfo:'Node is neither variable nor message.'.
+
+    "Created: / 04-08-2013 / 02:33:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 04-08-2013 / 11:38:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 keyPress: key x:x y:y in: view
 
     "Handles an event in given view (a subview of codeView).
@@ -48,10 +119,6 @@
     lastTypedKey1 := lastTypedKey0.
     lastTypedKey0 := key.
 
-    key == #'CodeCompletion'  ifTrue: [
-        self complete. 
-        ^ true
-    ].
     key == $^ ifTrue:[
         ^ self keyPressReturnToken
     ].
@@ -59,10 +126,10 @@
         ^ self keyPressReturn
     ]. 
 
-    ^ false.
+    ^ super keyPress: key x:x y:y in: view
 
     "Created: / 07-03-2010 / 09:36:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 26-07-2013 / 12:13:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 04-08-2013 / 02:31:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 keyPressReturn
@@ -127,79 +194,6 @@
 
 !SmallSenseSmalltalkEditSupport methodsFor:'private'!
 
-complete
-    |cls 
-"/     crsrPos interval node checkedNode
-"/     char start stop selectorSoFar matchingSelectors
-    codeView |
-
-    codeView := service codeView.
-
-    cls := codeView classHolder value.
-    cls isNil ifTrue:[
-        codeView showInfo:'No class'.
-        ^ self.
-    ].
-    UserInformation handle:[:ex |
-        codeView showInfo:(ex messageText).
-        ex proceed.
-    ] do:[
-        codeView withWaitCursorDo:[
-            codeView textView keyRelease: #Control_L x:0 y:0.
-            SmallSenseCompletionWindow openForView: codeView class: cls.
-        ]
-    ].
-    ^ self.
-
-"/
-"/    interval := self selectedInterval.
-"/    interval isEmpty ifTrue:[
-"/        crsrPos := codeView characterPositionOfCursor - 1.
-"/        char := codeView characterUnderCursor.
-"/        [crsrPos > 1 and:[char isSeparator or:['.' includes:char]]] whileTrue:[
-"/            crsrPos := crsrPos - 1.
-"/            char := codeView characterAtCharacterPosition:crsrPos.
-"/        ].
-"/        interval := crsrPos to:crsrPos.
-"/    ].
-"/
-"/    node := self findNodeForInterval:interval allowErrors:true.
-"/    [node isNil] whileTrue:[
-"/        "/ expand to the left ...
-"/        interval start > 1 ifFalse:[
-"/            self showInfo:'No parseNode found'.
-"/            ^ self.
-"/        ].
-"/        interval start:(interval start - 1).
-"/        node := self findNodeForInterval:interval allowErrors:true.
-"/    ].
-"/
-"/    node isVariable ifTrue:[
-"/        self codeCompletionForVariable:node inClass:cls.
-"/        ^ self.
-"/    ].
-"/
-"/    checkedNode := node.
-"/    [checkedNode notNil] whileTrue:[
-"/        checkedNode isMessage ifTrue:[
-"/            self codeCompletionForMessage:checkedNode inClass:cls.
-"/            ^ self
-"/        ].
-"/        checkedNode isMethod ifTrue:[
-"/            self codeCompletionForMethod:checkedNode inClass:cls.
-"/            ^ self.
-"/        ].
-"/        checkedNode := checkedNode parent.
-"/    ].
-"/
-"/    self showInfo:'Node is neither variable nor message.'.
-
-    "Modified: / 04-07-2006 / 18:48:26 / fm"
-    "Modified: / 20-11-2006 / 12:30:59 / cg"
-    "Created: / 07-03-2010 / 09:37:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 24-07-2013 / 23:29:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
 tokensAtCursorLine
     | scanner token |
 
--- a/abbrev.stc	Sun Aug 04 02:29:30 2013 +0100
+++ b/abbrev.stc	Mon Aug 05 10:27:05 2013 +0100
@@ -7,18 +7,18 @@
 SmallSenseCriticsWindow SmallSenseCriticsWindow jv:smallsense 'SmallSense-Interface' 1
 SmallSenseEditService SmallSenseEditService jv:smallsense 'SmallSense-Services' 0
 SmallSenseEditSupport SmallSenseEditSupport jv:smallsense 'SmallSense-Services' 0
-SmallSenseFinderTests SmallSenseFinderTests jv:smallsense 'SmallSense-Tests' 0
+SmallSenseFinderTests SmallSenseFinderTests jv:smallsense 'SmallSense-Tests' 1
 SmallSenseInfo SmallSenseInfo jv:smallsense 'SmallSense-Model' 0
 SmallSenseManager SmallSenseManager jv:smallsense 'SmallSense-Model' 0
 SmallSensePO SmallSensePO jv:smallsense 'SmallSense-Interface-PO' 0
 SmallSenseParseNodeInspector SmallSenseParseNodeInspector jv:smallsense 'SmallSense-Interface' 1
 SmallSenseParseNodeVisitor SmallSenseParseNodeVisitor jv:smallsense 'SmallSense-Core' 0
 SmallSenseParser SmallSenseParser jv:smallsense 'SmallSense-Core' 3
-SmallSenseParserTests SmallSenseParserTests jv:smallsense 'SmallSense-Tests' 0
+SmallSenseParserTests SmallSenseParserTests jv:smallsense 'SmallSense-Tests' 1
 SmallSensePosition SmallSensePosition jv:smallsense 'SmallSense-Core' 0
 SmallSenseQuickFixer SmallSenseQuickFixer jv:smallsense 'SmallSense-Lint' 0
 SmallSenseRecognizer SmallSenseRecognizer jv:smallsense 'SmallSense-Core' 0
-SmallSenseRecognizerTests SmallSenseRecognizerTests jv:smallsense 'SmallSense-Tests' 0
+SmallSenseRecognizerTests SmallSenseRecognizerTests jv:smallsense 'SmallSense-Tests' 1
 SmallSenseResultSet SmallSenseResultSet jv:smallsense 'SmallSense-Core' 0
 SmallSenseSelectorNode SmallSenseSelectorNode jv:smallsense 'SmallSense-Core' 0
 SmallSenseService SmallSenseService jv:smallsense 'SmallSense-Services' 0
--- a/smallsense.rc	Sun Aug 04 02:29:30 2013 +0100
+++ b/smallsense.rc	Mon Aug 05 10:27:05 2013 +0100
@@ -25,7 +25,7 @@
       VALUE "LegalCopyright", "Copyright Claus Gittinger 1988-2011\nCopyright eXept Software AG 1998-2011\0"
       VALUE "ProductName", "Smalltalk/X\0"
       VALUE "ProductVersion", "6.2.3.0\0"
-      VALUE "ProductDate", "Sun, 04 Aug 2013 01:28:53 GMT\0"
+      VALUE "ProductDate", "Mon, 05 Aug 2013 09:26:01 GMT\0"
     END
 
   END