summaryrefslogtreecommitdiff
path: root/sources/ch/epfl/lamp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/ch/epfl/lamp')
-rw-r--r--sources/ch/epfl/lamp/util/SourceFile.java22
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;