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 intcompareTo(CodeLocation other)booleanequals(java.lang.Object obj)java.lang.StringgetCodeLocation()Yields the string code location representation.intgetCol()Yields the column where this code element happens in the source file.intgetLine()Yields the line number where this code element happens in the source file.java.lang.StringgetSourceFile()Yields the source file name where this code element happens.inthashCode()java.lang.StringtoString()
-
-
-
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, usenullline- the line number where this code element happens in the source file. If unknown, use-1col- 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:CodeLocationYields the string code location representation.- Specified by:
getCodeLocationin 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-1if 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-1if the line number is unknown.- Returns:
- the column, or
-1
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
compareTo
public int compareTo(CodeLocation other)
- Specified by:
compareToin interfacejava.lang.Comparable<CodeLocation>
-
-