diff options
author | Eugene Vigdorchik <eugenevigdorchik@epfl.ch> | 2010-09-22 10:34:23 +0000 |
---|---|---|
committer | Eugene Vigdorchik <eugenevigdorchik@epfl.ch> | 2010-09-22 10:34:23 +0000 |
commit | 39a8b1042e04a5b838ac5688e014c29680bf0561 (patch) | |
tree | 92eeffb562eed6faf61b3b331844b76191964cc3 /src/compiler | |
parent | 03cd602835e373f47b7c8de55b063a0cc0838eaf (diff) | |
download | scala-39a8b1042e04a5b838ac5688e014c29680bf0561.tar.gz scala-39a8b1042e04a5b838ac5688e014c29680bf0561.tar.bz2 scala-39a8b1042e04a5b838ac5688e014c29680bf0561.zip |
do not cache lineIndices for MutableSourceFile.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/util/SourceFile.scala | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/util/SourceFile.scala b/src/compiler/scala/tools/nsc/util/SourceFile.scala index d925e2ceba..b0c819fc08 100644 --- a/src/compiler/scala/tools/nsc/util/SourceFile.scala +++ b/src/compiler/scala/tools/nsc/util/SourceFile.scala @@ -85,9 +85,10 @@ class ScriptSourceFile(underlying: BatchSourceFile, content: Array[Char], overri else new OffsetPosition(underlying, pos.point + start) } -trait LineOffsetMapper { +sealed trait LineOffsetMapper { def content : Array[Char] def length : Int + def lineIndices : Array[Int] def isLineBreak(idx: Int) = if (idx >= length) false else { @@ -104,7 +105,6 @@ trait LineOffsetMapper { buf += cs.length // sentinel, so that findLine below works smoother buf.toArray } - private lazy val lineIndices: Array[Int] = calculateLineIndices(content) def lineToOffset(index : Int): Int = lineIndices(index) @@ -139,6 +139,8 @@ class BatchSourceFile(val file : AbstractFile, val content: Array[Char]) extends val length = content.length def start = 0 def isSelfContained = true + + lazy val lineIndices: Array[Int] = calculateLineIndices(content) } /** a file whose contents do change over time */ @@ -155,4 +157,6 @@ class MutableSourceFile(val file : AbstractFile, var content: Array[Char]) exten def length = content.length def start = 0 def isSelfContained = true + + def lineIndices : Array[Int] = calculateLineIndices(content) } |