diff options
author | paltherr <paltherr@epfl.ch> | 2003-06-24 12:16:28 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-06-24 12:16:28 +0000 |
commit | d8d2c7f502baebab1f1994dfaec843139eded747 (patch) | |
tree | 9e9b06662a0e925c67ed10790d251812bbebc5b3 /sources/ch/epfl | |
parent | 9753961477f1f648656ec130675ed1b78f4f73b1 (diff) | |
download | scala-d8d2c7f502baebab1f1994dfaec843139eded747.tar.gz scala-d8d2c7f502baebab1f1994dfaec843139eded747.tar.bz2 scala-d8d2c7f502baebab1f1994dfaec843139eded747.zip |
- Added method getShortName
Diffstat (limited to 'sources/ch/epfl')
-rw-r--r-- | sources/ch/epfl/lamp/util/SourceFile.java | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/sources/ch/epfl/lamp/util/SourceFile.java b/sources/ch/epfl/lamp/util/SourceFile.java index 68a6739cab..05168d7617 100644 --- a/sources/ch/epfl/lamp/util/SourceFile.java +++ b/sources/ch/epfl/lamp/util/SourceFile.java @@ -89,6 +89,20 @@ public class SourceFile { this.encoding = encoding; } + /** Returns the short name (name without path) of this source file. */ + public String getShortName() { + int start = name.lastIndexOf(File.separatorChar); + return start < 0 ? name : name.substring(start + 1); + } + + /** + * Returns an instance of Position representing the given line and + * column of this source file. + */ + public Position getPosition(int line, int column) { + return new Position(this, line, column); + } + /** Returns the content of the given line. */ public String getLine(int line) { int index = lineNumber <= line ? nextIndex : (lineNumber = 0); @@ -114,14 +128,6 @@ public class SourceFile { } } - /** - * Returns an instance of Position representing the given line and - * column of this source file. - */ - public Position getPosition(int line, int column) { - return new Position(this, line, column); - } - /** Returns the name of this source file. */ public String toString() { return name; |