diff -r d55ab9c66bb3 -r ceb9ed115183 tools/JavaSourceDocument.st --- a/tools/JavaSourceDocument.st Mon Sep 09 13:25:14 2013 +0100 +++ b/tools/JavaSourceDocument.st Tue Sep 10 05:04:41 2013 +0100 @@ -107,6 +107,33 @@ "Created: / 08-09-2013 / 10:52:34 / Jan Vrany " ! +sourceOffsetToLine: offset + + |low "{ Class: SmallInteger}" + high "{ Class: SmallInteger}" + middle "{ Class: SmallInteger}" + element| + + " + we can of course use a binary search - since the elements are sorted + " + low := 1. + high := sourceLineEnds size. + [low > high] whileFalse:[ + middle := (low + high) // 2. + element := sourceLineEnds at:middle. + element < offset ifTrue:[ + "middleelement is smaller than object" + low := middle + 1 + ] ifFalse:[ + high := middle - 1 + ] + ]. + ^ low + + "Created: / 10-09-2013 / 03:40:19 / Jan Vrany " +! + sourceText ^ sourceText ! @@ -245,11 +272,15 @@ ]. ]. methodNode notNil ifTrue: [ + | line | + + line := (self sourceOffsetToLine: methodNode sourceStart) - + (self sourceOffsetToLine: methodNode declarationSourceStart) + 1. + source := JavaSourceRef new. source offset: methodNode declarationSourceStart. - source - length: methodNode declarationSourceEnd - methodNode declarationSourceStart - + 1. + source length: methodNode declarationSourceEnd - methodNode declarationSourceStart + 1. + source line: line. method setSource: source. ] ifFalse: [ self error: 'Cannot determine method!!'. @@ -259,7 +290,7 @@ ] "Created: / 07-09-2013 / 01:43:06 / Jan Vrany " - "Modified: / 09-09-2013 / 10:28:12 / Jan Vrany " + "Modified: / 10-09-2013 / 03:56:39 / Jan Vrany " ! initializeSourceTree