diff options
author | Paul Phillips <paulp@improving.org> | 2012-11-13 00:14:40 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-11-19 11:55:06 -0800 |
commit | d5e3f85946af966111f88af90a666a709df0ba6f (patch) | |
tree | edb2d3cfae76679bc0311f3c22d01779a2f32ef3 /src/compiler/scala/tools/nsc/ast/parser/Scanners.scala | |
parent | 645c2676dd6699ac24a57dfe750386bbdb827ee8 (diff) | |
download | scala-d5e3f85946af966111f88af90a666a709df0ba6f.tar.gz scala-d5e3f85946af966111f88af90a666a709df0ba6f.tar.bz2 scala-d5e3f85946af966111f88af90a666a709df0ba6f.zip |
Revert "Commenting out unused members."
This reverts commit 951fc3a486.
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Scanners.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Scanners.scala | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index b346ce0a14..1be5fb1782 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -10,8 +10,7 @@ import scala.reflect.internal.util._ import scala.reflect.internal.Chars._ import Tokens._ import scala.annotation.switch -import scala.collection.{ mutable, immutable } -import mutable.{ ListBuffer, ArrayBuffer } +import scala.collection.mutable.{ ListBuffer, ArrayBuffer } import scala.xml.Utility.{ isNameStart } /** See Parsers.scala / ParsersCommon for some explanation of ScannersCommon. @@ -27,7 +26,7 @@ trait ScannersCommon { trait ScannerCommon extends CommonTokenData { // things to fill in, in addition to buf, decodeUni which come from CharArrayReader - // def warning(off: Int, msg: String): Unit + def warning(off: Int, msg: String): Unit def error (off: Int, msg: String): Unit def incompleteInputError(off: Int, msg: String): Unit def deprecationWarning(off: Int, msg: String): Unit @@ -52,7 +51,7 @@ trait Scanners extends ScannersCommon { type Offset = Int /** An undefined offset */ - // val NoOffset: Offset = -1 + val NoOffset: Offset = -1 trait TokenData extends CommonTokenData { @@ -89,7 +88,7 @@ trait Scanners extends ScannersCommon { def isAtEnd = charOffset >= buf.length - // def flush = { charOffset = offset; nextChar(); this } + def flush = { charOffset = offset; nextChar(); this } def resume(lastCode: Int) = { token = lastCode @@ -101,7 +100,7 @@ trait Scanners extends ScannersCommon { /** the last error offset */ - // var errOffset: Offset = NoOffset + var errOffset: Offset = NoOffset /** A character buffer for literals */ @@ -1064,7 +1063,7 @@ trait Scanners extends ScannersCommon { def syntaxError(off: Offset, msg: String) { error(off, msg) token = ERROR - // errOffset = off + errOffset = off } /** generate an error at the current token offset @@ -1077,7 +1076,7 @@ trait Scanners extends ScannersCommon { def incompleteInputError(msg: String) { incompleteInputError(offset, msg) token = EOF - // errOffset = offset + errOffset = offset } override def toString() = token match { @@ -1242,7 +1241,7 @@ trait Scanners extends ScannersCommon { override val decodeUni: Boolean = !settings.nouescape.value // suppress warnings, throw exception on errors - // def warning(off: Offset, msg: String): Unit = () + def warning(off: Offset, msg: String): Unit = () def deprecationWarning(off: Offset, msg: String): Unit = () def error (off: Offset, msg: String): Unit = throw new MalformedInput(off, msg) def incompleteInputError(off: Offset, msg: String): Unit = throw new MalformedInput(off, msg) @@ -1253,7 +1252,7 @@ trait Scanners extends ScannersCommon { class UnitScanner(unit: CompilationUnit, patches: List[BracePatch]) extends SourceFileScanner(unit.source) { def this(unit: CompilationUnit) = this(unit, List()) - // override def warning(off: Offset, msg: String) = unit.warning(unit.position(off), msg) + override def warning(off: Offset, msg: String) = unit.warning(unit.position(off), msg) override def deprecationWarning(off: Offset, msg: String) = unit.deprecationWarning(unit.position(off), msg) override def error (off: Offset, msg: String) = unit.error(unit.position(off), msg) override def incompleteInputError(off: Offset, msg: String) = unit.incompleteInputError(unit.position(off), msg) @@ -1312,7 +1311,7 @@ trait Scanners extends ScannersCommon { } class ParensAnalyzer(unit: CompilationUnit, patches: List[BracePatch]) extends UnitScanner(unit, patches) { - val balance = mutable.Map(RPAREN -> 0, RBRACKET -> 0, RBRACE -> 0) + var balance = scala.collection.mutable.Map(RPAREN -> 0, RBRACKET -> 0, RBRACE -> 0) init() @@ -1434,17 +1433,17 @@ trait Scanners extends ScannersCommon { else bp :: insertPatch(bps, patch) } - // def leftColumn(offset: Int) = - // if (offset == -1) -1 else column(lineStart(line(offset))) + def leftColumn(offset: Int) = + if (offset == -1) -1 else column(lineStart(line(offset))) - // def rightColumn(offset: Int, default: Int) = - // if (offset == -1) -1 - // else { - // val rlin = line(offset) - // if (lineStart(rlin) == offset) column(offset) - // else if (rlin + 1 < lineStart.length) column(lineStart(rlin + 1)) - // else default - // } + def rightColumn(offset: Int, default: Int) = + if (offset == -1) -1 + else { + val rlin = line(offset) + if (lineStart(rlin) == offset) column(offset) + else if (rlin + 1 < lineStart.length) column(lineStart(rlin + 1)) + else default + } def insertRBrace(): List[BracePatch] = { def insert(bps: List[BracePair]): List[BracePatch] = bps match { @@ -1487,16 +1486,16 @@ trait Scanners extends ScannersCommon { delete(bracePairs) } - // def imbalanceMeasure: Int = { - // def measureList(bps: List[BracePair]): Int = - // (bps map measure).sum - // def measure(bp: BracePair): Int = - // (if (bp.lindent != bp.rindent) 1 else 0) + measureList(bp.nested) - // measureList(bracePairs) - // } + def imbalanceMeasure: Int = { + def measureList(bps: List[BracePair]): Int = + (bps map measure).sum + def measure(bp: BracePair): Int = + (if (bp.lindent != bp.rindent) 1 else 0) + measureList(bp.nested) + measureList(bracePairs) + } - // def improves(patches1: List[BracePatch]): Boolean = - // imbalanceMeasure > new ParensAnalyzer(unit, patches1).imbalanceMeasure + def improves(patches1: List[BracePatch]): Boolean = + imbalanceMeasure > new ParensAnalyzer(unit, patches1).imbalanceMeasure override def error(offset: Int, msg: String) {} } |