The view on the location of an AST node, undefined if the node has none.
Combines with optional chaining, so a single ?. replaces the usual undefined dance:
SourceLocation.at(node)?.startLine.
Checks if two locations are equal, file included.
Formats a source location as a human-readable string.
Creates a source location from a source range and a file name.
Optionalfile: stringThe source location of an AST node, file included.
undefined if the given range is undefined
ReadonlygetEnd: Accessor<ReadonlygetEndColumn: Accessor<ReadonlygetEndLine: Accessor<Returns the file part of a source location, or undefined if no file is set.
ReadonlygetRange: Accessor<Returns the source range part of a source location, file excluded.
ReadonlygetStart: Accessor<ReadonlygetStartColumn: Accessor<ReadonlygetStartLine: Accessor<Returns an invalid source location (i.e., with an invalid range and no file).
Checks if the first location is a subset of the second location. For this, they must be in the same file!
ReadonlyisValid: (Maps the file part of a source location using the given mapper function.
Merges multiple source locations into a single source location that spans from the earliest start to the latest end.
If the locations are from different files, undefined is returned.
Files may be undefined themselves, but if there is at least one defined file, they must all be the same defined file for the merge to succeed.
Readonlyname: "SourceLocation"Readonlyview: Accessor<Wraps the location in a view offering property access (loc.startLine, loc.file) and methods.
The view does not copy the tuple; see SourceLocationView for when to use it.
Utility functions for source locations.
As every SourceRange is a location without a file, the readers of SourceRange apply to locations as well; the ones re-exported here save you the detour via SourceLocation.getRange.