Fix in SmalltalkCompletion: do not offer non-object instvars
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sat, 08 Aug 2015 02:55:51 +0100
changeset 882 e1e21ed824b5
parent 881 9a58acda666b
child 883 9c644e7c1d97
Fix in SmalltalkCompletion: do not offer non-object instvars i.e., those ending with *. They do not keep an object so they cannot be accessed directly. Moreover, its name is not a valid variable name.
SmallSense__SmalltalkCompletionEngine.st
--- a/SmallSense__SmalltalkCompletionEngine.st	Sat Aug 01 06:17:30 2015 +0100
+++ b/SmallSense__SmalltalkCompletionEngine.st	Sat Aug 08 02:55:51 2015 +0100
@@ -338,13 +338,17 @@
         klass instVarNames do:[:nm |
             | po |
 
-            po := VariablePO instanceVariable: nm in: klass.
-            "/ Raise relevance if the instvar is already used in the code...
-            (usedInstVars includes: nm) ifTrue:[
-                po relevance: (po relevance + 10).
+            "/ Check for non-object instvars - they cannot be referenced
+            "/ directly!!
+            (nm last == $*) ifFalse:[
+                po := VariablePO instanceVariable: nm in: klass.
+                "/ Raise relevance if the instvar is already used in the code...
+                (usedInstVars includes: nm) ifTrue:[
+                    po relevance: (po relevance + 10).
+                ].
+
+                result add: po.
             ].
-
-            result add: po.
         ].
         "/ When on class side (i.e., in class method), do not complete
         "/ instance variables of Class / ClassDescription / Behaviour
@@ -381,7 +385,7 @@
     ]
 
     "Created: / 31-07-2013 / 00:32:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 20-05-2014 / 10:09:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 08-08-2015 / 02:52:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !SmalltalkCompletionEngine methodsFor:'completion-private'!