Tools__CodeNavigationService.st
changeset 11740 fa674978dc41
parent 10878 3424d00f9155
child 11741 3b6f1c31139f
--- a/Tools__CodeNavigationService.st	Fri Aug 10 12:45:42 2012 +0200
+++ b/Tools__CodeNavigationService.st	Fri Aug 10 20:34:12 2012 +0200
@@ -342,15 +342,16 @@
 !
 
 elementAtLine:line col:colArg 
-    |characterPosition index element col|
+    |characterPosition syntaxElements index element col|
 
     "/ if beyond end of line, do not advance into next line
     col := colArg min:(textView listAt:line) size.
 
     characterPosition := textView characterPositionOfLine:line col:col.
-    index := SortedCollection binarySearch: (codeView syntaxElements) forIndexOf: characterPosition.
-    index > (codeView syntaxElements) size ifTrue:[^nil].
-    element := (codeView syntaxElements) at:index ifAbsent:nil.
+    syntaxElements := codeView syntaxElements.
+    index := syntaxElements indexForInserting:characterPosition.
+    index > syntaxElements size ifTrue:[^nil].
+    element := syntaxElements at:index ifAbsent:nil.
     element notNil ifTrue:[
         (characterPosition between: element start - 1 and: element stop) ifTrue:[^element].
     ].
@@ -461,14 +462,14 @@
 !
 
 highlightElementAtLine:line col:col 
-    |characterPosition index element |
-
+    |characterPosition syntaxElements index element|
 
     characterPosition := textView characterPositionOfLine:line col:col.
-    index := SortedCollection binarySearch: (codeView syntaxElements) forIndexOf: characterPosition.
-    index > (codeView syntaxElements) size ifTrue:[^self highlightElement: nil].
-    element := (codeView syntaxElements) at: index.
-    (characterPosition between: element start and: element stop) ifFalse:[^self highlightElement: nil].
+    syntaxElements := codeView syntaxElements.
+    index := syntaxElements indexForInserting:characterPosition.
+    index > syntaxElements size ifTrue:[self highlightElement:nil. ^ self].
+    element := syntaxElements at:index.
+    (characterPosition between: element start and: element stop) ifFalse:[element := nil].
     self highlightElement:element
 
     "Created: / 14-02-2010 / 16:17:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -594,7 +595,7 @@
 !CodeNavigationService class methodsFor:'documentation'!
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.16 2011-11-18 14:06:42 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.17 2012-08-10 18:34:12 stefan Exp $'
 !
 
 version_SVN