diff options
author | Martin Odersky <odersky@gmail.com> | 2011-01-09 14:33:41 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2011-01-09 14:33:41 +0000 |
commit | 785621901acb1888f168c2b2075e85a64af70fb8 (patch) | |
tree | 29ba5e499c4b07bde75dc33b86afb6c70b5ed6b0 /src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | |
parent | d94210996beabaf1256f0b4fcdaf210e8431c2e5 (diff) | |
download | scala-785621901acb1888f168c2b2075e85a64af70fb8.tar.gz scala-785621901acb1888f168c2b2075e85a64af70fb8.tar.bz2 scala-785621901acb1888f168c2b2075e85a64af70fb8.zip |
Implemented toplevel browsing in IDE, so that s...
Implemented toplevel browsing in IDE, so that source files newer than
their class files are scanned for contained classes and modules. That
way, top-level symbols with names different than their enclosing class
can still be identified. I believe the same strategy should be used by
IDE/sbt builders. Reviw by plocinik
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index ba913bf693..e71cb98fc2 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -151,8 +151,8 @@ self => def warning(offset: Int, msg: String) {} def deprecationWarning(offset: Int, msg: String) {} - def syntaxError(offset: Int, msg: String): Unit = throw new MalformedInput - def incompleteInputError(msg: String): Unit = throw new MalformedInput + def syntaxError(offset: Int, msg: String): Unit = throw new MalformedInput(offset, msg) + def incompleteInputError(msg: String): Unit = throw new MalformedInput(source.content.length - 1, msg) /** the markup parser */ lazy val xmlp = new MarkupParser(this, true) @@ -170,14 +170,21 @@ self => def skipBraces[T](body: T): T = { accept(LBRACE) - while (in.token != EOF && in.token != RBRACE) - if (in.token == XMLSTART) xmlLiteral() else in.nextToken() - body + var openBraces = 1 + while (in.token != EOF && openBraces > 0) { + if (in.token == XMLSTART) xmlLiteral() + else { + if (in.token == LBRACE) openBraces += 1 + else if (in.token == RBRACE) openBraces -= 1 + in.nextToken() + } + } + body } override def blockExpr(): Tree = skipBraces(EmptyTree) - override def templateStatSeq(isPre: Boolean) = skipBraces(emptyValDef, List()) + override def templateBody(isPre: Boolean) = skipBraces(emptyValDef, List(EmptyTree)) } class UnitParser(val unit: global.CompilationUnit, patches: List[BracePatch]) extends SourceFileParser(unit.source) { |