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.
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<readonly [Line, Column, Line, Column, string | undefined], Column>ReadonlygetEndLine: Accessor<readonly [Line, Column, Line, Column, string | undefined], Line>Returns the file part of a source location, or undefined if no file is set.
ReadonlygetRange: Accessor<readonly [Line, Column, Line, Column, string | undefined], SourceRange>Returns the source range part of a source location, file excluded.
ReadonlygetStart: Accessor<ReadonlygetStartColumn: Accessor<readonly [Line, Column, Line, Column, string | undefined], Column>ReadonlygetStartLine: Accessor<readonly [Line, Column, Line, Column, string | undefined], Line>ReadonlyisValid: (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.