-
Notifications
You must be signed in to change notification settings - Fork 188
/
SourceLocation.java
46 lines (36 loc) · 1.05 KB
/
SourceLocation.java
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
43
44
45
46
/*
* Copyright (C) 2020 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.axiom.concepts;
public class SourceLocation {
private final String sourceName;
private final int line;
private final int character;
private SourceLocation(String sourceName, int line, int character) {
this.sourceName = sourceName;
this.line = line;
this.character = character;
}
public static SourceLocation from(String source, int line, int pos) {
return new SourceLocation(source, line, pos);
}
@Override
public String toString() {
return sourceName + "["+ line + ":" + character + "]";
}
public String getSource() {
return sourceName;
}
public int getLine() {
return line;
}
public int getChar() {
return character;
}
public static SourceLocation runtime() {
return SourceLocation.from("IN-MEMORY", 0, 0);
}
}