class: Explainer
authorClaus Gittinger <cg@exept.de>
Thu, 20 Jun 2013 18:44:27 +0200
changeset 3193 581cfb33f8ac
parent 3192 4a3a9fa54b94
child 3194 364362530bcd
class: Explainer changed: #explainMessageNode:in:forClass:short:interval: #explainSyntax:short: some more explanations for beginners; better hint with inplausible selectors
Explainer.st
--- a/Explainer.st	Wed Jun 19 08:37:27 2013 +0200
+++ b/Explainer.st	Thu Jun 20 18:44:27 2013 +0200
@@ -128,7 +128,7 @@
      boldSelectorString globalValue recClassSet
      implMethod implMethodComment info implMethods comments definer 
      instances classesOfInstVars implementingClasses canBeNil
-     bestMatches|
+     bestMatches hint|
 
     selector := node selector.      
     selectorString := selector printString contractTo:30.
@@ -147,13 +147,21 @@
                     with:(implementingClasses size - 1)
             ].
 
+            (#('self'  'super' 'true' 'false' 'thisContext') includes:selector) ifTrue:[
+                ^ ('NOT understood here: %1 (missing period after previous statement?)' bindWith:selector allBold),hint
+            ].
+
+            (recClassSet contains:[:cls | cls isMeta not and:[cls theMetaclass canUnderstand:selector]]) ifTrue:[
+                hint := '. But class understands it - did you mean "rcvr class ',selector,'..." ?'.
+            ].
             bestMatches := Parser findBestSelectorsFor:selector in:srchClass.
             bestMatches size > 0 ifTrue:[
-                ^ 'NOT understood here: %1 (Best guess: %2)'
-                    bindWith:selector
+                ^ ('NOT understood here: %1 (best guess is: "%2" from %3)'
+                    bindWith:selector allBold
                     with:(bestMatches first "allBold")
+                    with:(srchClass whichClassIncludesSelector:bestMatches first) name) , hint
             ].
-            ^ 'NOT understood here: %1' bindWith:selector "allBold"
+            ^ ('NOT understood here: %1' bindWith:selector allBold),hint
         ].
     ].
 
@@ -1428,6 +1436,27 @@
 '
     ].
 
+    (string withoutSeparators startsWith:'"/') ifTrue:[
+        shortText ifTrue:[
+            ^ 'an end-of-line comment'.
+        ].
+        ^ '"/ comment 
+EOL (end-of-line) comment
+
+anything up to the end of line is a comment and ignored (but not inside a string).
+'
+    ].
+    (string withoutSeparators startsWith:'"') ifTrue:[
+        shortText ifTrue:[
+            ^ 'a comment'.
+        ].
+        ^ '" comment ... "
+comment
+
+anything between double quotes is a comment and ignored (but not inside a string).
+'
+    ].
+
     "/ is it a symbol without hash-character ?
     "/
 "/    string knownAsSymbol ifTrue:[
@@ -1480,10 +1509,10 @@
 !Explainer class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Explainer.st,v 1.123 2013-05-29 17:25:03 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Explainer.st,v 1.124 2013-06-20 16:44:27 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libcomp/Explainer.st,v 1.123 2013-05-29 17:25:03 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Explainer.st,v 1.124 2013-06-20 16:44:27 cg Exp $'
 ! !