summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/CompilationUnits.scala
blob: 64a3cc97b10941e529339782e25e288ba750b85d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* NSC -- new scala compiler
 * Copyright 2005 LAMP/EPFL
 * @author  Martin Odersky
 */
// $Id$

package scala.tools.nsc;

import scala.tools.nsc.util.{SourceFile, Position};
import scala.tools.nsc.util.FreshNameCreator;
import scala.tools.nsc.io.AbstractFile;
import scala.collection.mutable.HashSet;

trait CompilationUnits requires Global {

  class CompilationUnit(val source: SourceFile) {

    /** the fresh name creator */
    val fresh = new FreshNameCreator;

    /** the content of the compilation unit in tree form */
    var body: Tree = EmptyTree;

    val depends = new HashSet[AbstractFile];

    def position(pos: int) = new Position(source, pos);

    val errorPositions = new HashSet[int]

    def error(pos: int, msg: String) = {
      if (!(errorPositions contains pos)) {
        errorPositions += pos;
        reporter.error(position(pos), msg);
      }
    }
    def warning(pos: int, msg: String) = reporter.warning(position(pos), msg);
    override def toString() = source.toString();

  }
}