Record Class SourceLocation
java.lang.Object
java.lang.Record
ca.mcscert.jpipe.model.SourceLocation
Immutable source position at which a named element was declared.
Line is 1-based (ANTLR convention); column is 0-based. The sentinel
UNKNOWN (line = 0) is used when no position is available — ANTLR
lines start at 1, so 0 is a safe sentinel that never conflicts with a real
location.
The optional source field names the file (or unit) the location
belongs to. It is null when the source is not tracked (e.g. in tests
or for programmatically created locations). When the load mechanism assembles
units from multiple files each location will carry its own source path,
making cross-file error messages unambiguous.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSourceLocation(int line, int column) Convenience constructor for location without a source file reference.SourceLocation(String source, int line, int column) Creates an instance of aSourceLocationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintcolumn()Returns the value of thecolumnrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanisKnown()True only when a real source position is stored.intline()Returns the value of thelinerecord component.source()Returns the value of thesourcerecord component.toString()Returns a string representation of this record class.
-
Field Details
-
UNKNOWN
Sentinel for "no location known".
-
-
Constructor Details
-
SourceLocation
public SourceLocation(int line, int column) Convenience constructor for location without a source file reference. -
SourceLocation
Creates an instance of aSourceLocationrecord class.- Parameters:
source- the value for thesourcerecord componentline- the value for thelinerecord componentcolumn- the value for thecolumnrecord component
-
-
Method Details
-
isKnown
public boolean isKnown()True only when a real source position is stored. -
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
source
Returns the value of thesourcerecord component.- Returns:
- the value of the
sourcerecord component
-
line
public int line()Returns the value of thelinerecord component.- Returns:
- the value of the
linerecord component
-
column
public int column()Returns the value of thecolumnrecord component.- Returns:
- the value of the
columnrecord component
-