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

source-map

Utilities for building source maps (v3) for a compiler

27 unstable releases

0.14.10 Feb 10, 2024
0.14.7 Nov 24, 2023
0.13.0 Jun 27, 2023
0.12.0 Mar 18, 2023
0.2.0 Jul 26, 2021

#363 in Web programming

Download history 194/week @ 2023-12-22 145/week @ 2023-12-29 253/week @ 2024-01-05 111/week @ 2024-01-12 30/week @ 2024-01-19 9/week @ 2024-01-26 4/week @ 2024-02-02 23/week @ 2024-02-09 43/week @ 2024-02-16 81/week @ 2024-02-23 72/week @ 2024-03-01 48/week @ 2024-03-08 89/week @ 2024-03-15 514/week @ 2024-03-22 60/week @ 2024-03-29 16/week @ 2024-04-05

692 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–1MB
~21K SLoC