Package it.unive.lisa.program
Class SourceCodeLocation
- java.lang.Object
-
- it.unive.lisa.program.SourceCodeLocation
-
- All Implemented Interfaces:
CodeLocation
,java.lang.Comparable<CodeLocation>
public class SourceCodeLocation extends java.lang.Object implements CodeLocation
A location of an element in the source code represented by the path to the source code, the line and the column where the element appears.
-
-
Constructor Summary
Constructors Constructor Description SourceCodeLocation(java.lang.String sourceFile, int line, int col)
Builds the code element.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(CodeLocation other)
boolean
equals(java.lang.Object obj)
java.lang.String
getCodeLocation()
Yields the string code location representation.int
getCol()
Yields the column where this code element happens in the source file.int
getLine()
Yields the line number where this code element happens in the source file.java.lang.String
getSourceFile()
Yields the source file name where this code element happens.int
hashCode()
java.lang.String
toString()
-
-
-
Constructor Detail
-
SourceCodeLocation
public SourceCodeLocation(java.lang.String sourceFile, int line, int col)
Builds the code element.- Parameters:
sourceFile
- the source file where this code element happens. If unknown, usenull
line
- the line number where this code element happens in the source file. If unknown, use-1
col
- the column where this code element happens in the source file. If unknown, use-1
-
-
Method Detail
-
getCodeLocation
public java.lang.String getCodeLocation()
Description copied from interface:CodeLocation
Yields the string code location representation.- Specified by:
getCodeLocation
in interfaceCodeLocation
- Returns:
- the string code location representation
-
getSourceFile
public final java.lang.String getSourceFile()
Yields the source file name where this code element happens. This method returns the string"null"
if the source file is unknown.- Returns:
- the source file, or
null
-
getLine
public final int getLine()
Yields the line number where this code element happens in the source file. This method returns-1
if the line number is unknown.- Returns:
- the line number, or
-1
-
getCol
public final int getCol()
Yields the column where this code element happens in the source file. This method returns-1
if the line number is unknown.- Returns:
- the column, or
-1
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
compareTo
public int compareTo(CodeLocation other)
- Specified by:
compareTo
in interfacejava.lang.Comparable<CodeLocation>
-
-