Crate source_map

Source
Expand description

§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

Modules§

encodings
global_store

Structs§

BaseSpan
A start and end. Also contains trace of original source (depending on T)
Counter
Counts text until a limit. Used for telling whether the text is greater than some threshold
End
The byte start
LineColumnPosition
Zero based
LineColumnSpan
Zero based
LineStarts
Contains the byte indexes of when line starts
MapFileStore
NoPathMap
Position
A scalar/singular byte wise position. Zero based
Source
SourceId
A identifier for a crate::Source
SourceMap
SourceMapBuilder
Struct for building a source map (v3)
Start
The byte start
StringWithOptionalSourceMap
Building a source along with its source map
WithPathMap
Writable

Traits§

FileSystem
Nullable
PathMap
ToString
A trait for defining behavior of adding content to a buffer. As well as register markers for source maps

Type Aliases§

Span
SpanWithSource