summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
diff options
context:
space:
mode:
authorMiles Sabin <miles@milessabin.com>2010-01-15 14:12:20 +0000
committerMiles Sabin <miles@milessabin.com>2010-01-15 14:12:20 +0000
commit135ec1392770b301925e2e9c660f7a67e4615ee9 (patch)
tree846d54796b54e449d8f917d307669aa473ab9173 /src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
parent2d324f4506191ba9059e14fa7482c2276b5f255a (diff)
downloadscala-135ec1392770b301925e2e9c660f7a67e4615ee9.tar.gz
scala-135ec1392770b301925e2e9c660f7a67e4615ee9.tar.bz2
scala-135ec1392770b301925e2e9c660f7a67e4615ee9.zip
Fixes for various Scaladoc-related positions re...
Fixes for various Scaladoc-related positions regressions with tests. Review by dubochet.
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 91fd7dbdc8..b86356ba94 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -421,17 +421,19 @@ self =>
def joinComment(trees: => List[Tree]): List[Tree] = {
val doc = in.flushDoc
if ((doc ne null) && doc.raw.length > 0) {
- val ts = trees
- val main = ts.find(_.pos.isOpaqueRange)
- ts map {
+ val joined = trees map {
t =>
val dd = DocDef(doc, t)
- val pos = doc.pos.withEnd(t.pos.endOrPoint)
- dd setPos (
- if (main exists (_ eq t)) pos
- else pos.makeTransparent
- )
+ val defnPos = t.pos
+ val pos = doc.pos.withEnd(defnPos.endOrPoint)
+ dd setPos (if (defnPos.isOpaqueRange) pos else pos.makeTransparent)
}
+ joined.find(_.pos.isOpaqueRange) foreach {
+ main =>
+ val mains = List(main)
+ joined foreach { t => if (t ne main) ensureNonOverlapping(t, mains) }
+ }
+ joined
}
else trees
}
@@ -2463,14 +2465,15 @@ self =>
val stats = new ListBuffer[Tree]
while (in.token != RBRACE && in.token != EOF) {
if (in.token == PACKAGE) {
+ in.flushDoc
val start = in.skipToken()
stats += {
if (in.token == OBJECT) makePackageObject(start, objectDef(in.offset, NoMods))
else packaging(start)
}
} else if (in.token == IMPORT) {
+ in.flushDoc
stats ++= importClause()
- // XXX: IDE hook this all.
} else if (in.token == CLASS ||
in.token == CASECLASS ||
in.token == TRAIT ||
@@ -2501,6 +2504,7 @@ self =>
var self: ValDef = emptyValDef
val stats = new ListBuffer[Tree]
if (isExprIntro) {
+ in.flushDoc
val first = expr(InTemplate) // @S: first statement is potentially converted so cannot be stubbed.
if (in.token == ARROW) {
first match {
@@ -2521,8 +2525,10 @@ self =>
}
while (in.token != RBRACE && in.token != EOF) {
if (in.token == IMPORT) {
+ in.flushDoc
stats ++= importClause()
} else if (isExprIntro) {
+ in.flushDoc
stats += statement(InTemplate)
} else if (isDefIntro || isModifier || in.token == LBRACKET /*todo: remove */ || in.token == AT) {
stats ++= joinComment(nonLocalDefOrDcl)
@@ -2621,6 +2627,7 @@ self =>
while (in.token == SEMI) in.nextToken()
val start = in.offset
if (in.token == PACKAGE) {
+ in.flushDoc
in.nextToken()
if (in.token == OBJECT) {
ts += makePackageObject(start, objectDef(in.offset, NoMods))
@@ -2648,10 +2655,14 @@ self =>
}
ts.toList
}
- val start = caseAwareTokenOffset max 0
topstats() match {
case List(stat @ PackageDef(_, _)) => stat
- case stats => makePackaging(start, atPos(o2p(start)) { Ident(nme.EMPTY_PACKAGE_NAME) }, stats)
+ case stats =>
+ val start = stats match {
+ case Nil => 0
+ case _ => wrappingPos(stats).startOrPoint
+ }
+ makePackaging(start, atPos(start, start, start) { Ident(nme.EMPTY_PACKAGE_NAME) }, stats)
}
}
}