From d8d2c7f502baebab1f1994dfaec843139eded747 Mon Sep 17 00:00:00 2001 From: paltherr Date: Tue, 24 Jun 2003 12:16:28 +0000 Subject: - Added method getShortName --- sources/ch/epfl/lamp/util/SourceFile.java | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'sources/ch/epfl') 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; -- cgit v1.2.3