Refactored and fixes class name completion.
Currently handle aliases. Also complete private classes and classes on other
namespaces.
--- a/SmallSense__ClassPO.st Sat Jul 19 22:40:45 2014 +0100
+++ b/SmallSense__ClassPO.st Thu Jul 24 19:58:54 2014 +0100
@@ -57,16 +57,17 @@
namespace := nil.
showPrefix ifFalse:[
- namespace := klass isJavaClass
- ifTrue:[klass javaPackage]
- ifFalse:[klass nameSpace name].
- (namespace notNil and:[namespace ~~ #Smalltalk]) ifTrue:[
- ^ 'in ', namespace.
- ].
+ namespace := klass isJavaClass
+ ifTrue:[klass javaPackage]
+ ifFalse:[ | ns | ns := klass nameSpace. [ ns isNameSpace ] whileFalse:[ ns := ns nameSpace ]. ns name].
+ (namespace notNil and:[namespace ~~ #Smalltalk]) ifTrue:[
+ ^ 'in ', namespace.
+ ].
].
^ nil
"Created: / 20-05-2014 / 12:21:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 24-07-2014 / 17:31:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
icon
@@ -92,25 +93,26 @@
label
label isNil ifTrue:[
- showPrefix ifTrue:[
- label := klass name.
- (context notNil and:[klass isJavaClass]) ifTrue:[
- context language isJava ifTrue:[
- label := klass javaName
- ] ifFalse:[
- context language isSmalltalk ifTrue:[
- label := 'JAVA ' , (klass binaryName copyReplaceAll: $/ with: Character space)
- ]
- ]
- ].
- ] ifFalse:[
- label := klass nameWithoutPrefix.
- ].
+ showPrefix ifTrue:[
+ label := klass name.
+ (context notNil and:[klass isJavaClass]) ifTrue:[
+ context language isJava ifTrue:[
+ label := klass javaName
+ ] ifFalse:[
+ context language isSmalltalk ifTrue:[
+ label := 'JAVA ' , (klass binaryName copyReplaceAll: $/ with: Character space)
+ ]
+ ]
+ ].
+ ] ifFalse:[
+ label := klass nameWithoutNameSpacePrefix.
+ ].
].
^label
"Created: / 20-05-2014 / 11:29:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 24-07-2014 / 17:30:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
showPrefix
--- a/SmallSense__CompletionContext.st Sat Jul 19 22:40:45 2014 +0100
+++ b/SmallSense__CompletionContext.st Thu Jul 24 19:58:54 2014 +0100
@@ -83,10 +83,28 @@
"Modified (comment): / 13-05-2014 / 11:55:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+klass
+ "Return a class in which to complete, i.e., class whose source is being edited.
+ If there's no class set, return nil (for example, for XML there's no such thing
+ like class)"
+
+ | codeView |
+
+ codeView := self codeView.
+ ^ codeView isCodeView2
+ ifTrue: [ codeView klass ]
+ ifFalse: [ codeView editedClass ].
+
+ "Created: / 24-07-2014 / 12:09:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
language
+ "Return a programming language in which to complete. i.e., the language of edited source code"
+
^ support language
"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>"
!
node
--- a/SmallSense__PO.st Sat Jul 19 22:40:45 2014 +0100
+++ b/SmallSense__PO.st Thu Jul 24 19:58:54 2014 +0100
@@ -90,6 +90,12 @@
"Created: / 20-05-2014 / 10:43:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+forGlobalNamed: name
+ ^ VariablePO globalVariable: name
+
+ "Created: / 24-07-2014 / 16:50:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
subject: anObject
<resource: #obsolete>
--- a/SmallSense__SmalltalkCompletionEngine.st Sat Jul 19 22:40:45 2014 +0100
+++ b/SmallSense__SmalltalkCompletionEngine.st Thu Jul 24 19:58:54 2014 +0100
@@ -154,47 +154,38 @@
addGlobalsStartingWith: prefix
- | class ns cls environment |
+ | class namespace environment |
class := collector klass.
- ns := class nameSpace.
+ namespace := class nameSpace.
environment := context environment.
"nameSpace may return private class, sigh"
- [ ns isNameSpace ] whileFalse:[ ns := ns nameSpace ].
- ns keysDo:[:nm|
- (nm startsWith: prefix) ifTrue:[
- cls := ns classNamed: nm.
- (cls notNil and:[cls name = nm]) ifTrue:[
- (JavaPackage isNil or:[cls isJavaPackage not]) ifTrue:[
- result add:(((PO forClass: cls)) showPrefix: cls isJavaClass).
+ [ namespace isNameSpace ] whileFalse:[ namespace := namespace nameSpace ].
+
+ environment keysDo:[:name |
+ | value |
+
+ (self isGlobalKeyForClassVariable: name) ifFalse:[
+ value := environment at: name.
+ ((name startsWith: prefix) or:[(value isBehavior and:[(value nameWithoutPrefix startsWith: prefix) or:[value nameWithoutNameSpacePrefix startsWith: prefix]])]) ifTrue:[
+ (value notNil and:[value isBehavior]) ifTrue:[
+ "/ Check for aliases...
+ | clsnm |
+
+ clsnm := value name.
+ clsnm = name ifTrue:[
+ result add: (PO forClass: value)
+ ] ifFalse:[
+ result add: (PO forGlobalNamed: name)
+ ].
+ ] ifFalse:[
+ result add: (PO forGlobalNamed: name)
+ ].
]
- ] ifFalse:[
- (self isGlobalKeyForClassVariable: nm) ifFalse:[
- result add:(VariablePO globalVariable: nm)
- ].
].
].
- ].
- ns ~~ environment ifTrue:[
- environment keysDo:[:nm|
- (nm startsWith: prefix) ifTrue:[
- cls := environment classNamed: nm.
- (JavaPackage isNil or:[cls isJavaPackage not ]) ifTrue:[
- cls notNil ifTrue:[
- cls isBehavior ifTrue:[
- result add:(((PO forClass: cls)) showPrefix: cls isJavaClass).
- ] ifFalse:[
- (self isGlobalKeyForClassVariable: nm) ifFalse:[
- result add:(VariablePO globalVariable: nm).
- ].
- ]
- ]
- ]
- ]
- ].
- ]
"Created: / 26-11-2011 / 17:29:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 20-05-2014 / 09:58:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 24-07-2014 / 17:51:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
addJavaClassesInPackage: prefix
@@ -333,22 +324,6 @@
"Modified: / 30-07-2013 / 23:32:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-addPrivateClasses
- | class |
-
-
- class := collector klass theNonMetaclass.
- class privateClassesDo:[:pclass|
- | nm |
-
- nm := pclass fullName copyFrom: class fullName size + 3.
- result add:((PO forClass: pclass) ).
- ]
-
- "Created: / 06-08-2013 / 12:28:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 29-05-2014 / 15:36:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
addVariablesFor: node
| n klass |
@@ -554,10 +529,11 @@
self addGlobalsStartingWith:node name.
self addClassVariables.
self addPools.
- self addPrivateClasses.
] ifFalse:[
self addVariablesFor:node
]
+
+ "Modified: / 24-07-2014 / 19:11:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!SmalltalkCompletionEngine methodsFor:'queries'!
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SmallSense__SmalltalkCompletionEngineTests.st Thu Jul 24 19:58:54 2014 +0100
@@ -0,0 +1,171 @@
+"{ Encoding: utf8 }"
+
+"
+stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
+Copyright (C) 2013-2014 Jan Vrany
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+"
+"{ Package: 'stx:goodies/smallsense' }"
+
+"{ NameSpace: SmallSense }"
+
+CompletionEngineTests subclass:#SmalltalkCompletionEngineTests
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'SmallSense-Tests'
+!
+
+!SmalltalkCompletionEngineTests class methodsFor:'documentation'!
+
+copyright
+"
+stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
+Copyright (C) 2013-2014 Jan Vrany
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+"
+! !
+
+!SmalltalkCompletionEngineTests methodsFor:'accessing-classes'!
+
+completionEngineClass
+ "superclass SmallSense::CompletionEngineTests says that I am responsible to implement this method"
+
+ ^ SmalltalkCompletionEngine
+
+ "Created: / 24-07-2014 / 11:51:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!SmalltalkCompletionEngineTests methodsFor:'tests - classes'!
+
+test_classes_01a
+
+ context codeView classHolder value: self class.
+ context codeView codeAspect: #method.
+ self complete:'foo
+ ^ SmalltalkCompletionEngineTe┃'.
+
+ self assert: result notEmpty.
+ self assert: (result select:[:each | each isSmallSenseClassPO and:[each klass == SmalltalkCompletionEngineTests]]) size == 1.
+
+ "Created: / 24-07-2014 / 15:12:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_classes_01b
+
+ context codeView classHolder value: self class.
+ context codeView codeAspect: #method.
+ self complete:'foo
+ ^ OrderedColl┃'.
+
+ self assert: result notEmpty.
+ self assert: (result select:[:each | each isSmallSenseClassPO and:[each klass == OrderedCollection]]) size == 1.
+
+ "Created: / 24-07-2014 / 15:12:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_classes_01c
+
+ context codeView classHolder value: self class.
+ context codeView codeAspect: #method.
+ self complete:'foo
+ ^ OperatingSyst┃'.
+
+ self assert: result notEmpty.
+ self assert: (result select:[:each | each isSmallSenseVariablePO and:[each name = 'OperatingSystem' ]]) size == 1.
+
+ "Created: / 24-07-2014 / 15:14:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_classes_02a
+
+ context codeView classHolder value: self class.
+ context codeView codeAspect: #method.
+ self complete:'foo
+ ^ Phase┃'.
+
+ self assert: result notEmpty.
+ self assert: (result select:[:each | each isSmallSenseClassPO and:[each klass = SmalltalkInferencer::Phase1 ]]) size == 1.
+
+ "Created: / 24-07-2014 / 17:50:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_classes_02b
+
+ context codeView classHolder value: self class.
+ context codeView codeAspect: #method.
+ self complete:'foo
+ ^ SmalltalkInfe┃'.
+
+ self assert: result notEmpty.
+ self assert: (result select:[:each | each isSmallSenseClassPO and:[each klass = SmalltalkInferencer::Phase1 ]]) size == 1.
+
+ "Created: / 24-07-2014 / 17:50:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_classes_03
+
+ context codeView classHolder value: self class.
+ context codeView codeAspect: #method.
+ self complete:'foo
+ ^ ClassL┃'.
+
+ self assert: result notEmpty.
+ self assert: (result select:[:each | each isSmallSenseClassPO and:[each klass = Tools::ClassList ]]) size == 1.
+
+ "Created: / 24-07-2014 / 17:53:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_classes_04
+
+ context codeView classHolder value: SmalltalkInferencer.
+ context codeView codeAspect: #method.
+ self complete:'foo
+ ^ Pha┃'.
+
+ self assert: result notEmpty.
+ self assert: (result select:[:each | each isSmallSenseClassPO and:[each klass = SmalltalkInferencer::Phase1 ]]) size == 1.
+ self assert: (result select:[:each | each isSmallSenseClassPO and:[each klass = SmalltalkInferencer::Phase2 ]]) size == 1.
+
+ "Created: / 24-07-2014 / 19:10:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_classes_05
+
+ context codeView classHolder value: SmalltalkInferencer.
+ context codeView codeAspect: #method.
+ self complete:'foo
+ ^ Scree┃'.
+
+ self assert: result notEmpty.
+ self assert: (result select:[:each | each isSmallSenseVariablePO and:[each name = 'Screen' ]]) size == 1.
+
+ "Created: / 24-07-2014 / 19:54:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
--- a/abbrev.stc Sat Jul 19 22:40:45 2014 +0100
+++ b/abbrev.stc Thu Jul 24 19:58:54 2014 +0100
@@ -56,6 +56,7 @@
SmallSense::MethodPO SmallSense__MethodPO stx:goodies/smallsense 'SmallSense-Core-Interface-PO' 0
SmallSense::RecognizerTests SmallSense__RecognizerTests stx:goodies/smallsense 'SmallSense-Tests-Obsolete' 1
SmallSense::SmalltalkCompletionEngine SmallSense__SmalltalkCompletionEngine stx:goodies/smallsense 'SmallSense-Smalltalk' 0
+SmallSense::SmalltalkCompletionEngineTests SmallSense__SmalltalkCompletionEngineTests stx:goodies/smallsense 'SmallSense-Tests' 1
SmallSense::SmalltalkEditSupport SmallSense__SmalltalkEditSupport stx:goodies/smallsense 'SmallSense-Smalltalk' 0
SmallSense::SmalltalkInferencer SmallSense__SmalltalkInferencer stx:goodies/smallsense 'SmallSense-Smalltalk-Types-Inference' 0
SmallSense::SmalltalkParseNodeFinder SmallSense__SmalltalkParseNodeFinder stx:goodies/smallsense 'SmallSense-Smalltalk' 0
--- a/smallsense.rc Sat Jul 19 22:40:45 2014 +0100
+++ b/smallsense.rc Thu Jul 24 19:58:54 2014 +0100
@@ -25,7 +25,7 @@
VALUE "LegalCopyright", "Copyright Jan Vrany 2013-2014\0"
VALUE "ProductName", "SmallSense\0"
VALUE "ProductVersion", "6.2.4.0\0"
- VALUE "ProductDate", "Fri, 18 Jul 2014 05:53:56 GMT\0"
+ VALUE "ProductDate", "Thu, 24 Jul 2014 18:55:17 GMT\0"
END
END
--- a/stx_goodies_smallsense.st Sat Jul 19 22:40:45 2014 +0100
+++ b/stx_goodies_smallsense.st Thu Jul 24 19:58:54 2014 +0100
@@ -96,23 +96,23 @@
"list packages which are mandatory as a prerequisite.
This are packages containing superclasses of my classes and classes which
are extended by myself.
- They are mandatory, beacuse we need these packages as a prerequisite for loading and compiling.
+ They are mandatory, because we need these packages as a prerequisite for loading and compiling.
This method is generated automatically,
by searching along the inheritance chain of all of my classes."
^ #(
- #'stx:goodies/refactoryBrowser/helpers' "BrowserEnvironment - superclass of SmallSense::SmalltalkUnacceptedMethodEnvironment "
- #'stx:goodies/refactoryBrowser/lint' "RBLintRule - extended "
- #'stx:goodies/regex' "Regex::RxCharSetParser - superclass of SmallSense::TokenPatternParser::TokenSpecParser "
- #'stx:goodies/sunit' "TestAsserter - superclass of SmallSense::AbstractJavaCompletionEngineTests "
- #'stx:libbasic' "Collection - extended "
- #'stx:libcomp' "AbstractSyntaxHighlighter - superclass of SmallSense::SmalltalkParser "
- #'stx:libhtml' "HTMLDocumentFrame - extended "
- #'stx:libtool' "AbstractSettingsApplication - superclass of SmallSense::SettingsAppl "
- #'stx:libview' "DeviceGraphicsContext - extended "
- #'stx:libview2' "ApplicationModel - extended "
- #'stx:libwidg' "EditTextView - extended "
- #'stx:libwidg2' "DoWhatIMeanSupport - extended "
+ #'stx:goodies/refactoryBrowser/helpers' "BrowserEnvironment - superclass of SmallSense::SmalltalkUnacceptedMethodEnvironment"
+ #'stx:goodies/refactoryBrowser/lint' "RBLintRule - extended"
+ #'stx:goodies/regex' "Regex::RxCharSetParser - superclass of SmallSense::TokenPatternParser::TokenSpecParser"
+ #'stx:goodies/sunit' "TestAsserter - superclass of SmallSense::AbstractJavaCompletionEngineTests"
+ #'stx:libbasic' "Collection - extended"
+ #'stx:libcomp' "AbstractSyntaxHighlighter - superclass of SmallSense::SmalltalkParser"
+ #'stx:libhtml' "HTMLDocumentFrame - extended"
+ #'stx:libtool' "AbstractSettingsApplication - superclass of SmallSense::SettingsAppl"
+ #'stx:libview' "DisplaySurface - extended"
+ #'stx:libview2' "ApplicationModel - extended"
+ #'stx:libwidg' "EditTextView - extended"
+ #'stx:libwidg2' "DoWhatIMeanSupport - extended"
)
!
@@ -124,11 +124,11 @@
by searching all classes (and their packages) which are referenced by my classes."
^ #(
- #'stx:goodies/refactoryBrowser/parser' "RBFormatter - referenced by SmallSense::SmalltalkEditSupport>>electricInsertSnippetAfterDoubleColon "
- #'stx:libbasic2' "BackgroundQueueProcessingJob - referenced by SmallSense::Manager>>initialize "
- #'stx:libbasic3' "ChangeSet - referenced by RBTransformationRule>>fixes: "
- #'stx:libjava' "Java - referenced by SmallSense::JavaCompletionEngineEnvironmentResource>>tearDown "
- #'stx:libjava/tools' "GroovyScanner - referenced by SmallSense::GroovyCompletionEngineSimple>>scannerClass "
+ #'stx:goodies/refactoryBrowser/parser' "RBFormatter - referenced by SmallSense::SmalltalkEditSupport>>electricInsertSnippetAfterDoubleColon"
+ #'stx:libbasic2' "BackgroundQueueProcessingJob - referenced by SmallSense::Manager>>initialize"
+ #'stx:libbasic3' "ChangeSet - referenced by RBTransformationRule>>fixes:"
+ #'stx:libjava' "Java - referenced by SmallSense::JavaCompletionEngineEnvironmentResource>>tearDown"
+ #'stx:libjava/tools' "GroovyScanner - referenced by SmallSense::GroovyCompletionEngineSimple>>scannerClass"
)
!
@@ -222,6 +222,7 @@
#'SmallSense::MethodPO'
(#'SmallSense::RecognizerTests' autoload)
#'SmallSense::SmalltalkCompletionEngine'
+ (#'SmallSense::SmalltalkCompletionEngineTests' autoload)
#'SmallSense::SmalltalkEditSupport'
#'SmallSense::SmalltalkInferencer'
#'SmallSense::SmalltalkParseNodeFinder'