diff options
author | Sean McDirmid <sean.mcdirmid@gmail.com> | 2006-02-01 13:51:26 +0000 |
---|---|---|
committer | Sean McDirmid <sean.mcdirmid@gmail.com> | 2006-02-01 13:51:26 +0000 |
commit | 0ec22a89f29607d02c0a5419beaed73d07abc488 (patch) | |
tree | 8be84d75e2676f4d31a0034c6b76e4957e290884 /src/compiler | |
parent | c9a4b1fd73e4900814f32fca4c740aa027036230 (diff) | |
download | scala-0ec22a89f29607d02c0a5419beaed73d07abc488.tar.gz scala-0ec22a89f29607d02c0a5419beaed73d07abc488.tar.bz2 scala-0ec22a89f29607d02c0a5419beaed73d07abc488.zip |
Some cosmetic changes in non-plugin files.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/ant/Scalac.scala | 1 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/Global.scala | 27 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/Trees.scala | 11 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/models/SemanticTokens.scala | 3 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala | 6 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 8 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/util/ClassPath.scala | 15 |
7 files changed, 41 insertions, 30 deletions
diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala index d9c69858ae..4a1369ffdb 100644 --- a/src/compiler/scala/tools/ant/Scalac.scala +++ b/src/compiler/scala/tools/ant/Scalac.scala @@ -8,6 +8,7 @@ package scala.tools.ant { + import java.io.File import java.net.{URL, URLClassLoader} import java.util.{ArrayList, Vector} diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 72fa167f8e..add033d6d4 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -79,6 +79,10 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable val copy = new LazyTreeCopier(); + val comments = + if (onlyPresentation) new HashMap[Symbol,String]; + else null; + // reporting ------------------------------------------------------- def error(msg: String) = reporter.error(null, msg); @@ -118,7 +122,9 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable new SourceReader(charset.newDecoder()); } - val classPath = new ClassPath.Build( + val classPath0 = new ClassPath(onlyPresentation); + + val classPath = new classPath0.Build( settings.classpath.value, settings.sourcepath.value, settings.outdir.value, @@ -286,12 +292,7 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable private var curRun: Run = NoRun; override def currentRun: Run = curRun; - class TyperRun extends Run { - override val terminalPhase : Phase = typerPhase.next.next; - //override val terminalPhase : Phase = superAccessors.next; - } - - + def onlyPresentation = false; class Run extends CompilerRun { var currentUnit : CompilationUnit = _; @@ -329,11 +330,6 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable (phaseDescriptors.length+1) * fileset.size); - - override val terminalPhase : Phase = new GlobalPhase(p) { - def name = "terminal"; - def apply(unit: CompilationUnit): unit = {} - } override def phaseNamed(name: String): Phase = { var p: Phase = firstPhase; while (p.next != p && p.name != name) p = p.next; @@ -351,6 +347,13 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable private var unitbuf = new ListBuffer[CompilationUnit]; private var fileset = new HashSet[AbstractFile]; + override val terminalPhase : Phase = + if (onlyPresentation) typerPhase.next.next; + else new GlobalPhase(p) { + def name = "terminal"; + def apply(unit: CompilationUnit): unit = {} + } + private def addUnit(unit: CompilationUnit): unit = { unitbuf += unit; fileset += unit.source.getFile(); diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index df93143a1a..8037fcd1f2 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -525,12 +525,11 @@ mixin class Trees requires Global { def setOriginal(tree : Tree) : this.type = { tree match { - case tt : TypeTree => - System.err.println("Illegal: " + this + " to " + tree); - Thread.dumpStack(); - case _ => + case tt : TypeTree => + System.err.println("Illegal: " + this + " to " + tree); + Thread.dumpStack(); + case _ => } - original = tree; setPos(tree.pos); } @@ -538,8 +537,6 @@ mixin class Trees requires Global { val ret = super.setPos(pos); ret; } - - override def isEmpty = tpe == null || tpe == NoType; } diff --git a/src/compiler/scala/tools/nsc/models/SemanticTokens.scala b/src/compiler/scala/tools/nsc/models/SemanticTokens.scala index 2247536e8e..42bc102208 100644 --- a/src/compiler/scala/tools/nsc/models/SemanticTokens.scala +++ b/src/compiler/scala/tools/nsc/models/SemanticTokens.scala @@ -269,8 +269,9 @@ class SemanticTokens(val compiler: Global) { case tpe0 : RefinedType => tree match { case cpt : CompoundTypeTree => buildTs(cpt.templ.parents, tpe0.parents); + case _ : TypeTree => - System.err.println("UNKNOWN TPE13: " + dbg(tree) + " tpe0=" + tpe0 + " " + tpe0.parents); + // System.err.println("UNKNOWN TPE13: " + dbg(tree) + " tpe0=" + tpe0 + " " + tpe0.parents); case _ => System.err.println("UNKNOWN TPE5: " + dbg(tree) + " tpe0=" + tpe0 + " " + tpe0.parents); } diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala index ee98853107..f8d9d37cfb 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala @@ -87,7 +87,7 @@ abstract class SymbolLoaders { /** Load contents of a package */ - class PackageLoader(directory: ClassPath.Context) extends SymbolLoader { + class PackageLoader(directory: global.classPath0.Context) extends SymbolLoader { // System.err.println("PACKAGE LOADER: " + directory); protected def sourceString = directory.toString(); @@ -127,8 +127,8 @@ abstract class SymbolLoaders { assert(module.linkedClass == clazz, clazz); } - val classes = new HashMap[String, ClassPath.Context]; - val packages = new HashMap[String, ClassPath.Context]; + val classes = new HashMap[String, global.classPath0.Context]; + val packages = new HashMap[String, global.classPath0.Context]; for (val dir <- directory.entries) if (dir.location != null) { val it = dir.location.list(); while (it.hasNext()) { diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 87ddef778e..b419df7de5 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1165,9 +1165,11 @@ mixin class Typers requires Analyzer { } typed(defn, mode, pt) - case DocDef(comment, defn) => - typed(defn, mode, pt) - + case DocDef(comment, defn) => { + val ret = typed(defn, mode, pt) + if (onlyPresentation) comments(defn . symbol) = comment; + ret + } case block @ Block(_, _) => newTyper(context.makeNewScope(tree, context.owner)) .typedBlock(block, mode, pt) diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala index af7287bdb5..aff5a64916 100644 --- a/src/compiler/scala/tools/nsc/util/ClassPath.scala +++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala @@ -21,7 +21,7 @@ import java.util.StringTokenizer; * * @author Sean McDirmid */ -object ClassPath { +class ClassPath(onlyPresentation : Boolean) { class Source(val location : AbstractFile, val compile : Boolean) { // assert(location != null, "cannot find source location"); @@ -52,8 +52,9 @@ object ClassPath { else { val ret = find0(entries.tail); val head = entries.head; - val clazz = if (head.location == null) null; - else head.location.lookupPath(name + (if (!isDir) ".class" else ""), isDir); + val clazz = if (head.location == null) null; + else head.location.lookupPath(name + (if (!isDir) ".class" else ""), isDir); + val source0 = if (head.source == null) null; else { val source1 = head.source.location.lookupPath(name + (if (isDir) "" else ".scala"), isDir); @@ -111,11 +112,17 @@ object ClassPath { else toString(entries0.head) + ":::" + toString(entries0.tail); def isSourceFile = { + def head = entries.head; def clazz = head.location; def source = if (head.source == null) null else head.source.location; - if (entries.isEmpty || entries.isEmpty || source == null || !head.source.compile || !source.getFile().isFile()) false; + def isPredef = source.getName().equals("Predef.scala"); + + if (entries.isEmpty || entries.isEmpty || source == null) false; + else if (!onlyPresentation && !head.source.compile) false; + else if (source.isDirectory()) false; else if (clazz == null) true; + else if (onlyPresentation && !isPredef) true; else if (source.lastModified() > clazz.lastModified()) true; else false; } |