SmallSense__SmalltalkParseNodeFinder.st
changeset 184 0da7032dfd5a
parent 176 df6d3225d1e4
child 191 49c0c66eb21a
--- a/SmallSense__SmalltalkParseNodeFinder.st	Mon Mar 31 21:40:25 2014 +0200
+++ b/SmallSense__SmalltalkParseNodeFinder.st	Mon Mar 31 22:31:38 2014 +0200
@@ -27,22 +27,28 @@
     "Created: / 29-01-2014 / 10:20:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-findNodeIn: source tree: tree comments: comments position: pos
-    | i s |
+findNodeIn:source tree:tree comments:comments position:pos 
+    | i s e |
 
     position := pos - 1.
     i := 1.
-    [ i < comments size and:[ (s :=comments at:i) notNil ] ] whileTrue:[ 
-        (pos >= s and:[ pos <= (s + (comments at: i + 1) - 1)]) ifTrue:[ 
+    [
+        i < comments size and:[ (s := comments at:i) notNil ]
+    ] whileTrue:[
+        e := s + (comments at:i + 1) - 1.
+        (pos between:s and:e) ifTrue:[
             ^ nil -> pos.
         ].
         i := i + 2.
     ].
-
-    self visit: tree.
-    ^(match ? previous) ->  pos.
+    (s notNil and:[ source size == e ]) ifTrue:[ 
+        ^ nil -> pos.     
+    ].
+    self visit:tree.
+    ^ (match ? previous) -> pos.
 
     "Created: / 29-01-2014 / 10:20:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 31-03-2014 / 22:15:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !SmalltalkParseNodeFinder methodsFor:'visiting'!