diff options
author | paltherr <paltherr@epfl.ch> | 2003-06-16 12:37:20 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-06-16 12:37:20 +0000 |
commit | 9c9dfb24a48f11e175d8f82417e7b9c7ab78f7c7 (patch) | |
tree | eada2530c9586b6c61afaedffa30c023a4d12c49 /sources/scalac/Unit.java | |
parent | 97e75ddc91094834f60b868e16e14d3417359791 (diff) | |
download | scala-9c9dfb24a48f11e175d8f82417e7b9c7ab78f7c7.tar.gz scala-9c9dfb24a48f11e175d8f82417e7b9c7ab78f7c7.tar.bz2 scala-9c9dfb24a48f11e175d8f82417e7b9c7ab78f7c7.zip |
- Made SourceFile and Position scala-independan...
- Made SourceFile and Position scala-independant (moved them to
ch.epfl.lamp.util) - Added position arguments to methods of class
Reporter - Changed printing of positions to display the whole path not
only the file name.
Diffstat (limited to 'sources/scalac/Unit.java')
-rw-r--r-- | sources/scalac/Unit.java | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/sources/scalac/Unit.java b/sources/scalac/Unit.java index 5f215b80ec..bc96a972c7 100644 --- a/sources/scalac/Unit.java +++ b/sources/scalac/Unit.java @@ -8,9 +8,11 @@ package scalac; +import ch.epfl.lamp.util.SourceFile; +import ch.epfl.lamp.util.Position; + import scalac.util.*; import scalac.symtab.NameMangler; -import scalac.ast.parser.Sourcefile; import scalac.ast.Tree; import scala.compiler.typechecker.*; import java.io.*; @@ -30,7 +32,7 @@ public class Unit { /** the associated source code file */ - public final Sourcefile source; + public final SourceFile source; /** does this unit come from the interpreter console */ @@ -60,11 +62,12 @@ public class Unit { */ public int notes; - public Unit(Global global, Sourcefile source, boolean console) { + public Unit(Global global, SourceFile source, boolean console) { this.global = global; this.source = source; this.console = console; } + /* public void print(String message) { print(System.out, message); @@ -77,34 +80,17 @@ public class Unit { out.println("[[end " + message + "]]"); } */ - /** issue an error in this compilation unit - */ - public void error(String message) { - error(Position.NOPOS, message); - } /** issue an error in this compilation unit at a specific location */ public void error(int pos, String message) { - boolean hidden = source.testAndSetLog(pos, message); - if (!hidden) errors++; - global.reporter.error(source.getMessage(pos, message), hidden); - } - - /** issue a warning in this compilation unit - */ - public void warning(String message) { - warning(Position.NOPOS, message); + global.reporter.error(decode(pos), message); } /** issue a warning in this compilation unit at a specific location */ public void warning(int pos, String message) { - if (global.reporter.nowarn) return; - message = "warning: " + message; - boolean hidden = source.testAndSetLog(pos, message); - if (!hidden) warnings++; - global.reporter.warning(source.getMessage(pos, message), hidden); + global.reporter.warning(decode(pos), message); } /** return a string representation @@ -112,4 +98,14 @@ public class Unit { public String toString() { return source.toString(); } + + + private Position decode(int pos) { + Position position = new Position(pos); + if (position.file().id() == 0) + if (/* !!! source.id() > Position.FILE_MASK && */ position.line() != 0) + return source.getPosition(position.line(), position.column()); + return position; + } + } |