Completion: fix in Smalltalk completion - include last double colon for keyword selectors
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sat, 07 Mar 2015 10:53:11 +0000
changeset 447 2d45c613a5bd
parent 446 59afe5adfbf7
child 448 cc62f655db88
Completion: fix in Smalltalk completion - include last double colon for keyword selectors Due to a bug in MethodPO, double colon was not inserted after l;ast keyword. This commit fixes the bug and includes a test for it.
SmallSense__CompletionContext.st
SmallSense__CompletionEngineTests.st
SmallSense__EditSupportTests.st
SmallSense__GroovyCompletionEngineSimpleTests.st
SmallSense__JavaCompletionEngineTests.st
SmallSense__MethodPO.st
SmallSense__SmalltalkCompletionEngineTests.st
SmallSense__SmalltalkEditSupportTests.st
--- a/SmallSense__CompletionContext.st	Fri Mar 06 07:09:06 2015 +0000
+++ b/SmallSense__CompletionContext.st	Sat Mar 07 10:53:11 2015 +0000
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
 stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
 Copyright (C) 2013-2015 Jan Vrany
@@ -80,10 +82,9 @@
 language
     "Return a programming language in which to complete. i.e., the language of edited source code"
 
-    ^ support language
+    ^ self textView editedLanguage
 
-    "Modified: / 21-01-2014 / 23:16:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified (comment): / 24-07-2014 / 12:00:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-03-2015 / 10:38:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 node
--- a/SmallSense__CompletionEngineTests.st	Fri Mar 06 07:09:06 2015 +0000
+++ b/SmallSense__CompletionEngineTests.st	Sat Mar 07 10:53:11 2015 +0000
@@ -76,6 +76,12 @@
     ^ self subclassResponsibility
 
     "Created: / 22-05-2014 / 16:38:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+completionLanguage
+    ^ self subclassResponsibility
+
+    "Created: / 07-03-2015 / 10:35:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !CompletionEngineTests methodsFor:'running'!
@@ -85,6 +91,7 @@
 
     engine := self completionEngineClass new.
     codeView := Tools::CodeView2 new.
+    codeView languageHolder value: self completionLanguage.
     service := EditService new.
     service registerIn: codeView.  
     support := GenericEditSupport new.
@@ -94,7 +101,7 @@
     context environment: self environment.
 
     "Created: / 22-05-2014 / 16:50:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified (format): / 12-02-2015 / 00:08:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-03-2015 / 10:36:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 tearDown
--- a/SmallSense__EditSupportTests.st	Fri Mar 06 07:09:06 2015 +0000
+++ b/SmallSense__EditSupportTests.st	Sat Mar 07 10:53:11 2015 +0000
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
 stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
 Copyright (C) 2013-2015 Jan Vrany
--- a/SmallSense__GroovyCompletionEngineSimpleTests.st	Fri Mar 06 07:09:06 2015 +0000
+++ b/SmallSense__GroovyCompletionEngineSimpleTests.st	Sat Mar 07 10:53:11 2015 +0000
@@ -58,6 +58,12 @@
     ^ GroovyCompletionEngineSimple
 
     "Created: / 22-05-2014 / 16:39:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+completionLanguage
+    ^ GroovyLanguage instance
+
+    "Created: / 07-03-2015 / 10:35:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !GroovyCompletionEngineSimpleTests methodsFor:'tests - analysis'!
--- a/SmallSense__JavaCompletionEngineTests.st	Fri Mar 06 07:09:06 2015 +0000
+++ b/SmallSense__JavaCompletionEngineTests.st	Sat Mar 07 10:53:11 2015 +0000
@@ -60,6 +60,12 @@
     ^ JavaCompletionEngine
 
     "Created: / 07-08-2014 / 02:00:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+completionLanguage
+    ^ JavaLanguage instance
+
+    "Created: / 07-03-2015 / 10:35:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaCompletionEngineTests methodsFor:'tests'!
--- a/SmallSense__MethodPO.st	Fri Mar 06 07:09:06 2015 +0000
+++ b/SmallSense__MethodPO.st	Sat Mar 07 10:53:11 2015 +0000
@@ -142,13 +142,14 @@
             ^ selector
         ].
     ].
-    ^ String 
-        fromStringCollection: (selector tokensBasedOn: $:)
-        separatedBy: ':  '.
+    ^selector isKeyword ifTrue:[
+        String streamContents: [:s | selector keywords do:[:kw | s nextPutAll: kw; space; space ] ]
+    ] ifFalse:[ 
+        selector
+    ].
 
     "Created: / 02-10-2013 / 02:33:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 15-05-2014 / 13:02:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 20-05-2014 / 10:29:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-03-2015 / 10:43:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !MethodPO methodsFor:'accessing-private'!
--- a/SmallSense__SmalltalkCompletionEngineTests.st	Fri Mar 06 07:09:06 2015 +0000
+++ b/SmallSense__SmalltalkCompletionEngineTests.st	Sat Mar 07 10:53:11 2015 +0000
@@ -60,6 +60,12 @@
     ^ SmalltalkCompletionEngine
 
     "Created: / 24-07-2014 / 11:51:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+completionLanguage
+    ^ SmalltalkLanguage instance
+
+    "Created: / 07-03-2015 / 10:35:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !SmalltalkCompletionEngineTests methodsFor:'tests - classes'!
@@ -177,3 +183,24 @@
     "Modified: / 12-02-2015 / 00:11:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!SmalltalkCompletionEngineTests methodsFor:'tests - methods'!
+
+test_methods_01a    
+    | po_between_and |
+
+    codeView classHolder value: self class.
+    codeView codeAspect: #method. 
+    self complete:'foo
+    ^ 1 betwee┃'.
+
+    po_between_and := result detect:[:each | each isSmallSenseMethodPO and:[each selector == #between:and:]] ifNone:[ nil ].
+
+    self assert: po_between_and notNil.
+
+    po_between_and insert.
+
+    self assert: (codeView list at: 2) = '    ^ 1 between:  and:  '
+
+    "Created: / 07-03-2015 / 10:30:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
--- a/SmallSense__SmalltalkEditSupportTests.st	Fri Mar 06 07:09:06 2015 +0000
+++ b/SmallSense__SmalltalkEditSupportTests.st	Sat Mar 07 10:53:11 2015 +0000
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
 stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
 Copyright (C) 2013-2015 Jan Vrany
@@ -223,7 +221,6 @@
     "Created: / 04-03-2015 / 08:14:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
-
 !SmalltalkEditSupportTests methodsFor:'tests - indent-on-paste'!
 
 test_indent_on_paste_01a