#source #maps #compiler #representation #position #map #source-file

source-map

Utilities for building source maps (v3) for a compiler

28 releases (14 breaking)

0.15.0 May 21, 2024
0.14.10 Feb 10, 2024
0.14.9 Jan 19, 2024
0.14.7 Nov 24, 2023
0.2.0 Jul 26, 2021

#15 in #position

Download history 41/week @ 2024-03-03 53/week @ 2024-03-10 394/week @ 2024-03-17 195/week @ 2024-03-24 66/week @ 2024-03-31 20/week @ 2024-04-07 10/week @ 2024-04-14 15/week @ 2024-04-21 18/week @ 2024-05-12 201/week @ 2024-05-19 59/week @ 2024-05-26 28/week @ 2024-06-02 23/week @ 2024-06-09 18/week @ 2024-06-16

148 downloads per month
Used in 6 crates (4 directly)

MIT license

49KB
1K SLoC

Source map

crates.io badge docs.rs badge

Utilities for building source maps (v3), handling source location representations and source files.

Includes

  • SpanWithSource, a structure which represents a section of a specific source
  • SpanWithoutSource, a structure which represents a general section without a specific source
  • SourceId, a identifier for a source file
  • StringWithOptionalSourceMap, along with the ToString trait makes generating string representations with and adding source markings trivial
  • A lsp-types-morphisms feature which allows conversion of position type to lsp-types
  • The MapFileStore struct and the FileSystem trait for storing source files and other information
  • Utilities for turning byte indices into line and column information

Source map generation example

See generated example on GitHub actions.

git clone https://github.com/kaleidawave/source-map
cd source-map
cargo run -F inline-source-map --example source_map_creation -- LICENSE LICENSE.map

View pairings generated by uploading LICENSE.map to evan w's source map visualizer

Dependencies

~0–7.5MB
~50K SLoC