summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSean McDirmid <sean.mcdirmid@gmail.com>2006-09-22 12:29:49 +0000
committerSean McDirmid <sean.mcdirmid@gmail.com>2006-09-22 12:29:49 +0000
commitc8964378fb5f7b0087120dcb2105315bd1d45201 (patch)
tree8fbfc37df1203eb306f9e29f0bbbd862a095c421 /src
parentf5934f7970816ece828d1f453d3ea45dfe3bf896 (diff)
downloadscala-c8964378fb5f7b0087120dcb2105315bd1d45201.tar.gz
scala-c8964378fb5f7b0087120dcb2105315bd1d45201.tar.bz2
scala-c8964378fb5f7b0087120dcb2105315bd1d45201.zip
Fixed scala doc to include docs for abstract va...
Fixed scala doc to include docs for abstract variables and vars. Fixed display of traits. Also updated the IDE to work in the same way.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala31
-rw-r--r--src/compiler/scala/tools/nsc/PositionConfiguration.scala4
-rw-r--r--src/compiler/scala/tools/nsc/ast/Trees.scala31
-rw-r--r--src/compiler/scala/tools/nsc/doc/DocGenerator.scala24
-rw-r--r--src/compiler/scala/tools/nsc/models/Models.scala72
-rw-r--r--src/compiler/scala/tools/nsc/models/SemanticTokens.scala3
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala10
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala7
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala4
10 files changed, 116 insertions, 72 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 399e6802d6..ce75abe609 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -232,7 +232,9 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
}
object analyzer extends Analyzer {
- val global: Global.this.type = Global.this
+ val global: Global.this.type = {
+ Global.this
+ }
}
object superAccessors extends SuperAccessors {
@@ -615,19 +617,16 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
def forCLDC: Boolean = settings.target.value == "cldc"
def onlyPresentation = settings.doc.value
// position stuff
- val positionConfiguration: PositionConfiguration = new PositionConfiguration {
- type PositionType = Int
- def coercePosToInt(pos: PositionType): Int = pos
- def coerceIntToPos(pos: Int): PositionType = pos
- val NoPos: PositionType = Position.NOPOS
- val FirstPos: PositionType = Position.FIRSTPOS
- }
- final type PositionType = positionConfiguration.PositionType
- final val FirstPos = positionConfiguration.FirstPos
- final val NoPos = positionConfiguration.NoPos
- final def coerceIntToPos(pos: Int): PositionType =
- positionConfiguration.coerceIntToPos(pos)
- implicit final def coercePosToInt(pos: PositionType): Int =
- positionConfiguration.coercePosToInt(pos)
-
+ protected val positionConfiguration : PositionConfiguration = new PositionConfiguration {
+ type PositionType = Int;
+ def coercePosToInt(pos : PositionType) : Int = pos;
+ def coerceIntToPos(pos : Int) : PositionType = pos;
+ val NoPos : PositionType = Position.NOPOS;
+ val FirstPos : PositionType = Position.FIRSTPOS;
+ }
+ final type PositionType = positionConfiguration.PositionType;
+ final def FirstPos = positionConfiguration.FirstPos;
+ final def NoPos = positionConfiguration.NoPos;
+ final def coerceIntToPos(pos : Int) : PositionType = positionConfiguration.coerceIntToPos(pos);
+ implicit final def coercePosToInt(pos : PositionType) : Int = positionConfiguration.coercePosToInt(pos);
}
diff --git a/src/compiler/scala/tools/nsc/PositionConfiguration.scala b/src/compiler/scala/tools/nsc/PositionConfiguration.scala
index 66acca5a00..26176ce31a 100644
--- a/src/compiler/scala/tools/nsc/PositionConfiguration.scala
+++ b/src/compiler/scala/tools/nsc/PositionConfiguration.scala
@@ -1,8 +1,6 @@
package scala.tools.nsc;
-import scala.tools.nsc.reporters._
-import scala.tools.nsc.util.Position;
-trait PositionConfiguration {
+abstract class PositionConfiguration {
type PositionType;
def coercePosToInt(pos : PositionType) : Int;
def coerceIntToPos(pos : Int) : PositionType;
diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala
index 04d1821d27..f2e9851201 100644
--- a/src/compiler/scala/tools/nsc/ast/Trees.scala
+++ b/src/compiler/scala/tools/nsc/ast/Trees.scala
@@ -17,19 +17,26 @@ trait Trees requires Global {
var nodeCount = 0
case class Modifiers(flags: int, privateWithin: Name) {
- def isPrivate = (flags & PRIVATE ) != 0
- def isProtected = (flags & PROTECTED) != 0
- def isVariable = (flags & MUTABLE ) != 0
- def isArgument = (flags & PARAM ) != 0
- def isAccessor = (flags & ACCESSOR ) != 0
- def isOverride = (flags & OVERRIDE ) != 0
- def isAbstract = (flags & ABSTRACT ) != 0
- def isCase = (flags & CASE ) != 0
- def isSealed = (flags & SEALED ) != 0
- def isFinal = (flags & FINAL ) != 0
- def isTrait = (flags & TRAIT ) != 0
+ def isPrivate = hasFlag(PRIVATE )
+ def isProtected = hasFlag(PROTECTED)
+ def isVariable = hasFlag(MUTABLE )
+ def isArgument = hasFlag(PARAM )
+ def isAccessor = hasFlag(ACCESSOR )
+ def isOverride = hasFlag(OVERRIDE )
+ def isAbstract = hasFlag(ABSTRACT )
+ def isDeferred = hasFlag(DEFERRED )
+ def isCase = hasFlag(CASE )
+ def isSealed = hasFlag(SEALED )
+ def isFinal = hasFlag(FINAL )
+ def isTrait = hasFlag(TRAIT )
def isPublic = !isPrivate && !isProtected
- def hasFlag(flag: int) = (flags & flag) != 0
+ def hasFlag(flag: int) = (flag & flags) != 0
+ def & (flag: Int): Modifiers = {
+ val flags1 = flags & flag
+ if (flags1 == flags) this
+ else Modifiers(flags1, privateWithin) setAttr attributes
+ }
+
def | (flag: int): Modifiers = {
val flags1 = flags | flag
if (flags1 == flags) this
diff --git a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala
index 0558dc7ea7..c81de38f62 100644
--- a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala
+++ b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala
@@ -63,13 +63,16 @@ abstract class DocGenerator extends Models {
* @param target ...
* @return ...
*/
- def urlFor(sym: Symbol, target: String): NodeSeq = try {
- if (sym.sourceFile == null) Text(sym.fullNameString('.'))
+ def urlFor(tree: Tree, target: String): NodeSeq = try {
+ val sym = tree.symbol;
+ if (sym == NoSymbol)
+ Text(tree.asInstanceOf[ValOrDefDef].name.toString());
+ else if (sym.sourceFile == null) Text(sym.fullNameString('.'))
else aref(urlFor(sym), target, sym.nameString)
} catch {
case e: Error =>
//System.err.println("SYM=" + sym)
- Text(sym.toString())
+ Text(tree.symbol.toString())
}
def urlFor(tpe: Type, target: String): NodeSeq = try {
@@ -195,7 +198,7 @@ abstract class DocGenerator extends Models {
<tr><td style="white-space;nowrap;">
{ {
for (val mmbr <- classes(kind).toList) yield
- br(urlFor(mmbr.tree.symbol, contentFrame));
+ br(urlFor(mmbr.tree, contentFrame));
} }
</td></tr>
</table>
@@ -221,6 +224,11 @@ abstract class DocGenerator extends Models {
NodeSeq.Empty
}
+ private def nameFor(tree : Tree) = {
+ if (tree.symbol == NoSymbol) tree.asInstanceOf[ValOrDefDef].name.toString();
+ else tree.symbol.nameString;
+ }
+
def fullHeader(mmbr: HasTree): NodeSeq = <span>{ {
if (!mmbr.isInstanceOf[ImplMod]) {
<a name = {Utility.escape(mmbr.tree.symbol.nameString)}></a>;
@@ -228,7 +236,7 @@ abstract class DocGenerator extends Models {
} }<dl><dt>
{ { for (val str <- stringsFor(mmbr.mods)) yield (Text(str + " ")) } }
<code>{ Text(codeFor(mmbr.kind)) }</code>
- <em>{ Text(mmbr.tree.symbol.nameString) }</em>
+ <em>{ Text(nameFor(mmbr.tree)) }</em>
{ typesFor(mmbr) }{ argsFor(mmbr)}{resultFor(mmbr) }
</dt> { extendsFor(mmbr) }
</dl> { fullComment(mmbr) } <hr/>
@@ -252,7 +260,8 @@ abstract class DocGenerator extends Models {
val x = <table cellpadding="3" class="member" summary="">
<tr><td colspan="2" class="title">{Text(labelFor(kind))} Summary</td></tr>
{ {
- for (val mmbr <- map(kind).toList) yield shortHeader(mmbr);
+ for (val mmbr <- map(kind).toList) yield
+ shortHeader(mmbr);
} }
</table>;
br(x);
@@ -297,7 +306,7 @@ abstract class DocGenerator extends Models {
</td>
<td class="signature">
<code>{Text(codeFor(mmbr.kind))}</code>
- <em>{urlFor(mmbr.tree.symbol, contentFrame)}</em>
+ <em>{urlFor(mmbr.tree, contentFrame)}</em>
{ typesFor(mmbr) }
{ argsFor(mmbr) }
{resultFor(mmbr) }
@@ -579,6 +588,7 @@ abstract class DocGenerator extends Models {
def organize0(mmbr: HasTree, map0: ListMap[Kind, TreeSet[HasTree]]) = {
var map = map0
+ assert(mmbr.kind != null);
if (!map.contains(mmbr.kind))
map = map.update(mmbr.kind, new TreeSet[HasTree])
val sz = map(mmbr.kind).size
diff --git a/src/compiler/scala/tools/nsc/models/Models.scala b/src/compiler/scala/tools/nsc/models/Models.scala
index 413ce39fa9..ac5782abdd 100644
--- a/src/compiler/scala/tools/nsc/models/Models.scala
+++ b/src/compiler/scala/tools/nsc/models/Models.scala
@@ -50,10 +50,11 @@ abstract class Models {
if (mods.isProtected) modString = "protected" :: modString
if (mods.isOverride ) modString = "override" :: modString
if (mods.isAbstract ) modString = "abstract" :: modString
+ if (mods.isDeferred ) modString = "abstract" :: modString
if (mods.isCase ) modString = "case" :: modString
if (mods.isSealed ) modString = "sealed" :: modString
if (mods.isFinal ) modString = "final" :: modString
- if (mods.isTrait ) modString = "mixin" :: modString
+ //if (mods.isTrait ) modString = "trait" :: modString
modString
}
@@ -67,21 +68,31 @@ abstract class Models {
case _ => labelFor(kind) + "s"
}
- def kindOf(term0: Symbol) = {
- if (term0.isVariable) VAR
- else if (term0.isValueParameter) ARG
- else if (term0.isMethod) {
- if (term0.nameString.equals("this")) CONSTRUCTOR
- else DEF
- }
- else if (term0.isClass) CLASS
- else if (term0.isModule) OBJECT
- else if (term0.isValue) VAL
- else if (term0.isTypeParameter) TPARAM
- else if (term0.isType) TPARAM
- else {
- // System.err.println("UNRECOGNIZED SYMBOL: " + term0 + " " + name);
- null
+ def kindOf(tree: Tree) = {
+ val term0 = tree.symbol;
+ if (term0 != NoSymbol) {
+ if (term0.isVariable) VAR
+ else if (term0.isValueParameter) ARG
+ else if (term0.isMethod) {
+ if (term0.nameString.equals("this")) CONSTRUCTOR
+ else DEF
+ }
+ else if (term0.isClass) {
+ if (tree.asInstanceOf[MemberDef].mods.isTrait) TRAIT;
+ else CLASS
+ }
+ else if (term0.isModule) OBJECT
+ else if (term0.isValue) VAL
+ else if (term0.isTypeParameter) TPARAM
+ else if (term0.isType) TPARAM
+ else {
+ // System.err.println("UNRECOGNIZED SYMBOL: " + term0 + " " + name);
+ null
+ }
+ } else {
+ val ddef = tree.asInstanceOf[ValOrDefDef];
+ if (ddef.mods.hasFlag(symtab.Flags.MUTABLE)) VAR;
+ else VAL;
}
}
@@ -156,7 +167,7 @@ abstract class Models {
else -1
}
- def kind = kindOf(tree.symbol)
+ def kind = kindOf(tree)
//override def add(from: Composite, model: HasTree): Unit = { parent.add(from, model) }
//override def remove(from: Composite, model: HasTree): Unit = { parent.remove(from, model) }
@@ -212,6 +223,8 @@ abstract class Models {
updated = true
val add = modelFor(mmbr2, this)
add.update(mmbr2)
+ add.mods0 = mods1(mmbr1) &
+ ~symtab.Flags.ACCESSOR & ~symtab.Flags.SYNTHETIC
val sz = members.size
members += (add)
assert(members.size == sz + 1)
@@ -299,21 +312,34 @@ abstract class Models {
override def member(tree: Tree, members: List[Tree]): Tree = {
val tree0 = if (tree.isInstanceOf[DefDef]) {
val ddef = tree.asInstanceOf[DefDef]
+ ddef.mods
if (ddef.mods.isAccessor && ddef.symbol != null) {
- val sym = ddef.symbol.accessed
- val ret = for (val member <- members; member.symbol == sym) yield {
- member;
- }
+ val sym0 = ddef.symbol;
+ if (sym0.isSetter) return null;
+ assert(sym0.isGetter);
+ val sym = sym0.accessed
+ val ret = if (sym == NoSymbol) {
+ val sym = analyzer.underlying(sym0);
+ //val name = nme.getterToSetter(sym0.name)
+ //val setter = sym0.owner.info.decl(name);
+ val isVar = sym.isVariable;
+ val mods = (ddef.mods |
+ (if (isVar) symtab.Flags.MUTABLE else 0) | symtab.Flags.DEFERRED) &
+ ~symtab.Flags.ACCESSOR & ~symtab.Flags.SYNTHETIC
+ val tree =
+ ValDef(mods, ddef.name, ddef.tpt, ddef.rhs).setPos(ddef.pos).setSymbol(sym);
+ tree :: Nil;
+ } else for (val member <- members; member.symbol == sym) yield member
if (ret.isEmpty) null
else ret.head
} else tree
} else super.member(tree, members)
def sym = tree0.symbol
- if (tree0 == null || sym.pos == NoPos) null
+ if (tree0 == null || tree0.pos == NoPos) null
else if (!acceptPrivate &&
tree0.isInstanceOf[ValOrDefDef] &&
- tree0.asInstanceOf[ValOrDefDef].mods.isPrivate) null
+ tree.asInstanceOf[ValOrDefDef].mods.isPrivate) null
else tree0
}
diff --git a/src/compiler/scala/tools/nsc/models/SemanticTokens.scala b/src/compiler/scala/tools/nsc/models/SemanticTokens.scala
index 158bc207eb..e191fc171d 100644
--- a/src/compiler/scala/tools/nsc/models/SemanticTokens.scala
+++ b/src/compiler/scala/tools/nsc/models/SemanticTokens.scala
@@ -154,6 +154,7 @@ class SemanticTokens(val compiler: Global) {
abstract class Semantic(val symbol: Symbol) extends Actual {
val name = NameTransformer.decode(symbol.name.toString()).toString().trim();
assert(symbol != NoSymbol);
+ def myOuter = Process.this
def tpe: Type = symbol.tpe;
@@ -490,7 +491,7 @@ class SemanticTokens(val compiler: Global) {
def buildSym(term: Symbol, pos: Int, isDef: Boolean, tpe: Type): Unit =
if (term.hasFlag(Flags.ACCESSOR))
- buildSym(term.accessed, pos, isDef, tpe)
+ buildSym(analyzer.underlying(term), pos, isDef, tpe)
else if (pos == NoPos) {
//System.err.println("NOPOS: " + term)
//Thread.dumpStack()
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index 420ce0eafb..66664a2306 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -23,11 +23,11 @@ trait Symbols requires SymbolTable {
type AttrInfo = Triple[Type, List[Constant], List[Pair[Name,Constant]]]
val emptySymbolArray = new Array[Symbol](0)
- type PositionType
- val NoPos: PositionType
- val FirstPos: PositionType
- implicit def coercePosToInt(pos: PositionType): Int
- def coerceIntToPos(pos: Int): PositionType
+ type PositionType;
+ def NoPos : PositionType;
+ def FirstPos : PositionType;
+ implicit def coercePosToInt(pos : PositionType) : Int;
+ def coerceIntToPos(pos : Int) : PositionType;
object RequiresIntsAsPositions {
implicit def coerceIntToPos0(pos: Int) =
coerceIntToPos(pos)
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala
index a0ac83d82c..27f355007b 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala
@@ -142,8 +142,11 @@ abstract class UnPickler {
case NONEsym =>
sym = NoSymbol
case _ =>
- val unusedPos : PositionType = if (tag > PosOffset) readNat() else Position.NOPOS
- val pos = if (true) FirstPos else unusedPos;
+ val unusedPos = {
+ if (tag > PosOffset) readNat();
+ else Position.NOPOS
+ }
+ val pos : PositionType = if (true) FirstPos else unusedPos;
val name = readNameRef()
val owner = readSymbolRef()
val flags = readNat()
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 69782a7483..f7e8803a64 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -19,6 +19,7 @@ trait Contexts requires Analyzer {
val NoContext = new Context {
override def implicitss: List[List[ImplicitInfo]] = List()
+ outer = this;
}
NoContext.enclClass = NoContext
NoContext.enclMethod = NoContext
@@ -68,7 +69,6 @@ trait Contexts requires Analyzer {
sc = sc.outer
}
}
-
class Context {
var unit: CompilationUnit = _
var tree: Tree = _ // Tree associated with this context
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index f9c9b92e29..588678c676 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1379,10 +1379,10 @@ trait Typers requires Analyzer {
if (!sym.exists) {
if (settings.debug.value) System.err.println("qual = "+qual+":"+qual.tpe+"\nSymbol="+qual.tpe.symbol+"\nsymbol-info = "+qual.tpe.symbol.info+"\nscope-id = "+qual.tpe.symbol.info.decls.hashCode()+"\nmembers = "+qual.tpe.members+"\nname = "+name+"\nfound = "+sym+"\nowner = "+context.enclClass.owner)
if (!qual.tpe.widen.isErroneous) {
- if (context.unit == null) assert(false, "("+qual+":"+qual.tpe+")."+name)
+ if (false && context.unit == null) assert(false, "("+qual+":"+qual.tpe+")."+name)
error(tree.pos,
decode(name)+" is not a member of "+qual.tpe.widen +
- (if (Position.line(context.unit.source, qual.pos) <
+ (if (context.unit != null && Position.line(context.unit.source, qual.pos) <
Position.line(context.unit.source, tree.pos))
"\npossible cause: maybe a semicolon is missing before `"+name+"'?"
else ""))