diff options
author | Lex Spoon <lex@lexspoon.org> | 2007-10-10 01:04:46 +0000 |
---|---|---|
committer | Lex Spoon <lex@lexspoon.org> | 2007-10-10 01:04:46 +0000 |
commit | 3a28527889a39471be700d1992b067dcc219a84b (patch) | |
tree | 00cc24d7eddd1365fa3a8a89f2b2ae2e47d439c1 | |
parent | 8090763f46e04d4433bd40ca72616d9479c5091a (diff) | |
download | scala-3a28527889a39471be700d1992b067dcc219a84b.tar.gz scala-3a28527889a39471be700d1992b067dcc219a84b.tar.bz2 scala-3a28527889a39471be700d1992b067dcc219a84b.zip |
fixed a (sometimes) off-by-one error with Compo...
fixed a (sometimes) off-by-one error with CompoundSourceFile
-rw-r--r-- | src/compiler/scala/tools/nsc/util/SourceFile.scala | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/util/SourceFile.scala b/src/compiler/scala/tools/nsc/util/SourceFile.scala index df74995d64..e2b430393c 100644 --- a/src/compiler/scala/tools/nsc/util/SourceFile.scala +++ b/src/compiler/scala/tools/nsc/util/SourceFile.scala @@ -159,18 +159,13 @@ extends BatchSourceFile(name, contents) { /** The usual constructor. Specify a name for the compound file and * a list of component sources. - * - * @param name ... - * @param components ... */ def this(name: String, components: BatchSourceFile*) = { - /* Note that the contents leaves off the final SU character - * of all components */ this( name, components.toList, Array.concat(components.toList.map(comp => - comp.content.slice(0, comp.content.length-1).toArray):_*)) + CompoundSourceFile.stripSU(comp.content).toArray):_*)) } /** Create an instance with the specified components and a generic name. */ @@ -191,6 +186,14 @@ extends BatchSourceFile(name, contents) } } +object CompoundSourceFile { + private[util] def stripSU(chars: Array[Char]) = + if (chars.length > 0 && chars.last == SourceFile.SU) + chars.slice(0, chars.length-1) + else + chars +} + /** One portion of an underlying file. The fragment includes * the indeces from the specified start (inclusively) to stop |