DoWhatIMeanSupport.st
changeset 3720 f37c0d1757e3
parent 3718 a720a0edb5c7
child 3731 eb92d54a47ac
--- a/DoWhatIMeanSupport.st	Fri Jul 03 14:23:36 2009 +0200
+++ b/DoWhatIMeanSupport.st	Tue Jul 14 15:22:30 2009 +0200
@@ -62,7 +62,7 @@
      If nonNil, we can make better guesses, because we actually know what a variables type
      is. This is not yet done, sigh"
     
-    |crsrPos char interval source node checkedNode|
+    |crsrPos char interval source node checkedNode count|
 
     cls isNil ifTrue:[
         self information:'No class'.
@@ -83,16 +83,26 @@
 
     source := codeView contentsAsString string.
 
+    "/ this is too naive and stupid; if there is a syntactic error,
+    "/ we will not find a node for a long time (stepping back more and more,
+    "/ until reaching the beginning). This leads to a thousand and more times reparsing
+    "/ without any progress.
+    "/ TODO: do it vice-versa, in that the parser does a callOut for every node generated
+    "/ as it parses the code. Stop, when the interval is hit.
+    "/ that will also work for syntactic incorrect source code.
     node := self findNodeForInterval:interval in:source allowErrors:true.
-    [node isNil] whileTrue:[
-        "/ expand to the left ...
-        interval start > 1 ifFalse:[
-            crsrPos := codeView characterPositionOfCursor.
-            self information:'No parseNode found'.
-            ^ self.
-        ].
-        interval start:(interval start - 1).
-        node := self findNodeForInterval:interval in:source allowErrors:true.
+"/    [node isNil] whileTrue:[
+"/        "/ expand to the left ...
+"/        interval start > 1 ifFalse:[
+"/            self information:'No parseNode found'.
+"/            ^ self.
+"/        ].
+"/        interval start:(interval start - 1).
+"/        node := self findNodeForInterval:interval in:source allowErrors:true.
+"/    ].
+    node isNil ifTrue:[
+        self information:'No parseNode found'.
+        ^ self.
     ].
 
     (node isVariable
@@ -854,7 +864,10 @@
                                     ].
                                 ].
                                 ^ nil]
-                rememberNodes:true.
+                rememberNodes:true
+                nodeGenerationCallback:[:node | 
+                    (node intersectsInterval:interval) ifTrue:[^ node].
+                ].
 "/                onError: [:str :err | errCount := (errCount?0) + 1. self halt.]
 "/                proceedAfterError:true.
         tree isNil ifTrue:[^ nil].
@@ -1791,5 +1804,5 @@
 !DoWhatIMeanSupport class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.55 2009-06-24 15:28:15 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.56 2009-07-14 13:22:30 cg Exp $'
 ! !