Parser.st
changeset 4077 b17a80570109
parent 4076 f1ea20016adc
child 4078 2ab3356da639
--- a/Parser.st	Mon Dec 12 12:10:18 2016 +0100
+++ b/Parser.st	Mon Dec 12 12:48:51 2016 +0100
@@ -4176,30 +4176,32 @@
             position:pos1 to:pos2.
     ].
 
-    requestor isNil ifTrue:[
+    requestor isStream ifTrue:[
         ^ aSelectorString
     ].
     parserFlags warnAboutPossiblyUnimplementedSelectors ifFalse:[
         ^ aSelectorString
     ].
 
-    "
-     check if the selector is known at all
+    nowhereImplemented := false.
+    "
+     quick check if the selector is known at all
      - if not, it cannot be understood
     "
-    nowhereImplemented := false.
-
     selectorSymbol := aSelectorString asSymbolIfInterned.
     selectorSymbol isNil ifTrue:[
         nowhereImplemented := true.
     ] ifFalse:[
-        "/ temporarily disabled - too slow.
-        (isSyntaxHighlighter 
-        or:[(requestor notNil and:[requestor isStream not])]) "self isSyntaxHighlighter" ifTrue:[
-            nowhereImplemented := (self class implementedInAnyClass:selectorSymbol) not.
-        ]
-    ].
-
+"/        "/ temporarily disabled - too slow.
+"/        (isSyntaxHighlighter 
+"/        or:[(requestor notNil and:[requestor isStream not])]) "self isSyntaxHighlighter" ifTrue:[
+"/            nowhereImplemented := (self class implementedInAnyClass:selectorSymbol) not.
+"/        ]
+    ].
+    receiver notNil ifTrue:[
+        selClass := self typeOfNode:receiver.
+    ].
+    
     nowhereImplemented ifTrue:[
         isSyntaxHighlighter ifFalse:[
             self classToCompileFor notNil ifTrue:[
@@ -4211,122 +4213,128 @@
                         severity:#warning priority:#high
                         equalityParameter:aSelectorString
                         checkAction:[:e |
-                            e problemMethod notNil
-                            and:[(e problemMethod sends:aSelectorString asSymbol)
+                            |m|
+                            (m := e problemMethod) notNil
+                            and:[(m sends:aSelectorString asSymbol)
                             and:[self class implementedInAnyClass:aSelectorString]] ]
                 ].
             ].
         ].
-
         err := ' is currently nowhere implemented'.
     ] ifFalse:[
-        receiver notNil ifTrue:[
-            selClass := self typeOfNode:receiver.
-            selClass notNil ifTrue:[
-                "this could be performed if selClass isNil, but it is too slow"
-                err := self checkSelector:selectorSymbol for:receiver inClass:selClass.
+        selClass notNil ifTrue:[
+            "class is known; can limit the search"
+            err := self checkSelector:selectorSymbol for:receiver inClass:selClass.
+        ] ifFalse:[
+            "class not known; this is slow"
+            (self class implementedInAnyClass:selectorSymbol) ifFalse:[
+                err := ' is currently nowhere implemented'.
+            ].    
+        ].
+    ].
+    err notNil ifTrue:[
+        isSyntaxHighlighter ifTrue:[
+            posVector do:[:p |
+                self markBadIdentifierFrom:(p start) to:(p stop).
+            ].
+        ] ifFalse:[
+            self classToCompileFor notNil ifTrue:[
+                Tools::ToDoListBrowser notNil ifTrue:[
+                    "/ experimental
+                    self
+                        notifyTodo:(selectorSymbol ,' ',err) position:posVector first
+                        className:(self classToCompileFor name) selector:selector
+                        severity:#warning priority:#high
+                        equalityParameter:selectorSymbol
+                        checkAction:[:e |
+                            |selClass m|
+
+                            selClass := self typeOfNode:receiver.
+                            (m := e problemMethod) notNil
+                            and:[(m sends:aSelectorString asSymbol)
+                            and:[(self checkSelector:selectorSymbol for:receiver inClass:selClass) notNil]]].
+                ].
+            ].
+        ].
+
+        (receiver isConstant or:[receiver isBlock]) ifTrue:[
+            err notNil ifTrue:[
+                err := err, ' in ' , selClass name , ' or any of its superclasses'.
+            ].
+        ] ifFalse:[(((recType := receiver type) == #GlobalVariable)
+                    or:[recType == #PrivateClass]) ifTrue:[
+            rec := receiver evaluate.
+            "/ don't check autoloaded classes - it may work after loading
+            (rec isNil
+             or:[rec isBehavior and:[rec isLoaded not]]) ifTrue:[
+                ^ aSelectorString
             ].
 
             err notNil ifTrue:[
-                isSyntaxHighlighter ifFalse:[
-                    self classToCompileFor notNil ifTrue:[
-                        Tools::ToDoListBrowser notNil ifTrue:[
-                            "/ experimental
-                            self
-                                notifyTodo:(selectorSymbol ,' ',err) position:posVector first
-                                className:(self classToCompileFor name) selector:selector
-                                severity:#warning priority:#high
-                                equalityParameter:selectorSymbol
-                                checkAction:[:e |
-                                    |selClass|
-
-                                    selClass := self typeOfNode:receiver.
-                                    e problemMethod notNil
-                                    and:[(e problemMethod sends:aSelectorString asSymbol)
-                                    and:[(self checkSelector:selectorSymbol for:receiver inClass:selClass) notNil]]].
-                        ].
-                    ].
+                (rec isBehavior
+                 and:[rec theNonMetaclass name = receiver name]) ifTrue:[
+                    err := err, ' in ' , rec theNonMetaclass name.
+                ] ifFalse:[
+                    err := err, ' in currently assigned value (is currently ' , rec classNameWithArticle , ')'.
+                ]
+            ].
+        ] ifFalse:[receiver isSuper ifTrue:[
+            receiver isHere ifFalse:[
+                err notNil ifTrue:[
+                    err := err, ' in superclass chain'.
                 ].
-            ].
-
-            (receiver isConstant or:[receiver isBlock]) ifTrue:[
+            ] ifTrue:[
                 err notNil ifTrue:[
-                    err := err, ' in ' , selClass name , ' or any of its superclasses'.
+                    err := err, ' in this class or superclass chain'.
                 ].
-            ] ifFalse:[(((recType := receiver type) == #GlobalVariable)
-                        or:[recType == #PrivateClass]) ifTrue:[
-                rec := receiver evaluate.
-                "/ don't check autoloaded classes - it may work after loading
-                (rec isNil
-                 or:[rec isBehavior and:[rec isLoaded not]]) ifTrue:[
-                    ^ aSelectorString
-                ].
-
-                err notNil ifTrue:[
-                    (rec isBehavior
-                     and:[rec theNonMetaclass name = receiver name]) ifTrue:[
-                        err := err, ' in ' , rec theNonMetaclass name.
+            ]
+        ] ifFalse:[receiver isSelf ifTrue:[
+            err notNil ifTrue:[
+                |subErr nOther|
+
+                "/ understood by all subclasses ?
+                nOther := 0.
+                classToCompileFor allSubclassesDo:[:eachSubclass |
+                    subErr isNil ifTrue:[
+                        selClass := eachSubclass.
+                        subErr := self checkSelector:selectorSymbol for:receiver inClass:selClass.
                     ] ifFalse:[
-                        err := err, ' in currently assigned value (is currently ' , rec classNameWithArticle , ')'.
+                        (self checkSelector:selectorSymbol for:receiver inClass:selClass) notNil ifTrue:[ nOther := nOther + 1 ].
                     ]
                 ].
-            ] ifFalse:[receiver isSuper ifTrue:[
-                receiver isHere ifFalse:[
-                    err notNil ifTrue:[
-                        err := err, ' in superclass chain'.
-                    ].
-                ] ifTrue:[
-                    err notNil ifTrue:[
-                        err := err, ' in this class or superclass chain'.
+                subErr notNil ifTrue:[
+                    nOther > 0 ifTrue:[
+                        err := subErr, (' in %1 other subclass(es), this class or superclass chain' bindWith:nOther)
+                    ] ifFalse:[
+                        err := subErr, ', in this class or superclass chain'
                     ].
-                ]
-            ] ifFalse:[receiver isSelf ifTrue:[
-                err notNil ifTrue:[
-                    |subErr nOther|
-
-                    "/ understood by all subclasses ?
-                    nOther := 0.
-                    classToCompileFor allSubclassesDo:[:eachSubclass |
-                        subErr isNil ifTrue:[
-                            selClass := eachSubclass.
-                            subErr := self checkSelector:selectorSymbol for:receiver inClass:selClass.
-                        ] ifFalse:[
-                            (self checkSelector:selectorSymbol for:receiver inClass:selClass) notNil ifTrue:[ nOther := nOther + 1 ].
-                        ]
+                ] ifFalse:[
+                    err := err, ', in this class or superclass chain'.
+                ].
+            ].
+        ] ifFalse:[(receiver isUnaryMessage
+                    and:[receiver selector == #class
+                    and:[receiver receiver isSelf]]) ifTrue:[
+            "it's a message to self class - can check this too ..."
+            err notNil ifTrue:[
+                classToCompileFor isMeta ifTrue:[
+                    err := err, ' for the classes class'.
+                    (self checkSelector:selectorSymbol for:receiver inClass:classToCompileFor) isNil ifTrue:[
+                        err := err, '...\\...but its implemented for the class itself. You probably do not want the #class message here.'.
+                        err := err withCRs.
                     ].
-                    subErr notNil ifTrue:[
-                        nOther > 0 ifTrue:[
-                            err := subErr, (' in %1 other subclass(es), this class or superclass chain' bindWith:nOther)
-                        ] ifFalse:[
-                            err := subErr, ', in this class or superclass chain'
-                        ].
-                    ] ifFalse:[
-                        err := err, ', in this class or superclass chain'.
+                ] ifFalse:[
+                    err := err, ' for my class'.
+                    (self checkSelector:selectorSymbol for:receiver inClass:classToCompileFor) isNil ifTrue:[
+                        err := err, '...\\...but its implemented for instances. You may want to remove the #class message.'.
+                        err := err withCRs.
                     ].
                 ].
-            ] ifFalse:[(receiver isUnaryMessage
-                        and:[receiver selector == #class
-                        and:[receiver receiver isSelf]]) ifTrue:[
-                "its a message to self class - can check this too ..."
-                err notNil ifTrue:[
-                    classToCompileFor isMeta ifTrue:[
-                        err := err, ' for the classes class'.
-                        (self checkSelector:selectorSymbol for:receiver inClass:classToCompileFor) isNil ifTrue:[
-                            err := err, '...\\...but its implemented for the class itself. You probably do not want the #class message here.'.
-                            err := err withCRs.
-                        ].
-                    ] ifFalse:[
-                        err := err, ' for my class'.
-                        (self checkSelector:selectorSymbol for:receiver inClass:classToCompileFor) isNil ifTrue:[
-                            err := err, '...\\...but its implemented for instances. You may want to remove the #class message.'.
-                            err := err withCRs.
-                        ].
-                    ].
-                ].
-            ] ifFalse:[
-                (self isPossiblyUninitializedLocal:receiver) ifTrue:[
+            ].
+        ] ifFalse:[
+            (self isPossiblyUninitializedLocal:receiver) ifTrue:[
 "/ (receiver isLocal and:[receiver token type isNil]) ifTrue:[
-                    "if it is an uninitialized variable ..."
+                "if it is an uninitialized variable ..."
 
 "/                ((modifiedLocalVars isNil or:[(modifiedLocalVars includes:receiver name) not])
 "/                 and:[hasPrimitiveCode not
@@ -4335,34 +4343,33 @@
 "/                 and:[alreadyWarnedUninitializedVars isNil
 "/                      or:[(alreadyWarnedUninitializedVars includes:receiver name) not]]]])
 "/                ifTrue:[
-                    ((#(at: at:put: basicAt: basicAt:put:) includes:selectorSymbol)
-                     or:[(nil respondsTo:selectorSymbol) not]) ifTrue:[
-                        "/ avoid trouble in miniTalk
-                        "/ during bootstrap
-                        nm := receiver name.
-                        Text notNil ifTrue:[
-                            nm := nm allItalic
-                        ].
-                        err := 'sent to possibly uninitialized variable ''' , nm , ''' here (?)'.
-                        alreadyWarnedUninitializedVars isNil ifTrue:[
-                            alreadyWarnedUninitializedVars := Set new
-                        ].
-                        alreadyWarnedUninitializedVars add:receiver name
-                    ]
+                ((#(at: at:put: basicAt: basicAt:put:) includes:selectorSymbol)
+                 or:[(nil respondsTo:selectorSymbol) not]) ifTrue:[
+                    "/ avoid trouble in miniTalk
+                    "/ during bootstrap
+                    nm := receiver name.
+                    Text notNil ifTrue:[
+                        nm := nm allItalic
+                    ].
+                    err := 'sent to possibly uninitialized variable ''' , nm , ''' here (?)'.
+                    alreadyWarnedUninitializedVars isNil ifTrue:[
+                        alreadyWarnedUninitializedVars := Set new
+                    ].
+                    alreadyWarnedUninitializedVars add:receiver name
+                ]
 "/                ]
-            ] ifFalse:[
-                (err notNil and:[selClass notNil]) ifTrue:[
-                    ((selClass == Boolean)
-                      and:[ receiver isMessage
-                      and:[ receiver selector == #'=' ]])
-                    ifTrue:[
-                        err := err, ' (message to Boolean; did you mean ":=" instead of "=" in the receiver?)'
-                    ] ifFalse:[
-                        err := err, ' (message to ' , selClass nameWithArticle , ')'.
-                    ]
-                ].
-            ]]]]]].
-        ]
+        ] ifFalse:[
+            (err notNil and:[selClass notNil]) ifTrue:[
+                ((selClass == Boolean)
+                  and:[ receiver isMessage
+                  and:[ receiver selector == #'=' ]])
+                ifTrue:[
+                    err := err, ' (message to Boolean; did you mean ":=" instead of "=" in the receiver?)'
+                ] ifFalse:[
+                    err := err, ' (message to ' , selClass nameWithArticle , ')'.
+                ]
+            ].
+        ]]]]]].
     ].
 
     err notNil ifTrue:[