Clone this repo:
  1. c30a4c1 remove redundant experiment (#68) by Phil Quitslund · 9 weeks ago master
  2. 49ff31e Remove dependency on package:charcode (#66) by Nate Bosch · 2 months ago
  3. df8f533 Bump SDK constraints for pub (#65) by Nate Bosch · 2 months ago 1.8.0-nullsafety.4
  4. f33a3b0 allow the 2.12 prerelease sdks (#64) by Jacob MacDonald · 3 months ago 1.8.0-nullsafety.3
  5. 5ce9304 Remove workaround for SDK bug. (#63) by Paul Berry · 4 months ago

source_span is a library for tracking locations in source code. It's designed to provide a standard representation for source code locations and spans so that disparate packages can easily pass them among one another, and to make it easy to generate human-friendly messages associated with a given piece of code.

The most commonly-used class is the package's namesake, SourceSpan. It represents a span of characters in some source file, and is often attached to an object that has been parsed to indicate where it was parsed from. It provides access to the text of the span via SourceSpan.text and can be used to produce human-friendly messages using SourceSpan.message().

When parsing code from a file, SourceFile is useful. Not only does it provide an efficient means of computing line and column numbers, SourceFile.span() returns special FileSpans that are able to provide more context for their error messages.