Giter VIP home page Giter VIP logo

source-map's Introduction

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

source-map's People

Contributors

h-plus-time avatar kaleidawave avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

source-map's Issues

Latest source-map breaks enzo_parser

If I just add enzo crate to a project I get a bunch of errors. I had to pin the version of source-map to get the build to work.

error[E0433]: failed to resolve: could not find `StringWithSourceMap` in `source_map`
  --> /Users/amcclenaghan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ezno-parser-0.1.3/src/modules.rs:81:29
   |
81 |         let mut buf = source_map::StringWithSourceMap::new();
   |                                   ^^^^^^^^^^^^^^^^^^^ could not find `StringWithSourceMap` in `source_map`

error[E0599]: no associated item named `NULL_SPAN` found for struct `BaseSpan` in the current scope
   --> /Users/amcclenaghan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ezno-parser-0.1.3/src/errors.rs:170:51
    |
170 |     ParseError::new(ParseErrors::LexingFailed, Span::NULL_SPAN)
    |                                                      ^^^^^^^^^ associated item not found in `BaseSpan<()>`

   Compiling oxc v0.7.0
error[E0599]: no associated item named `NULL_SPAN` found for struct `BaseSpan` in the current scope
    --> /Users/amcclenaghan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ezno-parser-0.1.3/src/expressions/mod.rs:1808:38
     |
1808 |             SpreadExpression::Empty => &Span::NULL_SPAN,
     |                                               ^^^^^^^^^ associated item not found in `BaseSpan<()>`

error[E0599]: no associated item named `NULL_SPAN` found for struct `BaseSpan` in the current scope
   --> /Users/amcclenaghan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ezno-parser-0.1.3/src/extensions/jsx.rs:237:33
    |
237 |             JSXNode::LineBreak => &Span::NULL_SPAN,
    |                                          ^^^^^^^^^ associated item not found in `BaseSpan<()>`

error[E0061]: this function takes 1 argument but 0 arguments were supplied
   --> /Users/amcclenaghan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ezno-parser-0.1.3/src/modules.rs:88:17
    |
88  |         let mut buf = source_map::Counter::new();
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^-- an argument of type `usize` is missing
    |
note: associated function defined here
   --> /Users/amcclenaghan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/source-map-0.14.10/src/to_string.rs:215:12
    |
215 |     pub fn new(max: usize) -> Self {
    |            ^^^
help: provide the argument
    |
88  |         let mut buf = source_map::Counter::new(/* usize */);
    |                                               ~~~~~~~~~~~~~

error[E0599]: no associated item named `NULL` found for struct `SourceId` in the current scope
   --> /Users/amcclenaghan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ezno-parser-0.1.3/src/visiting.rs:313:15
    |
313 |                 SourceId::NULL
    |                           ^^^^ associated item not found in `SourceId`
    |
note: if you're trying to build a new `SourceId`, consider using `SourceId::new` which returns `SourceId`
   --> /Users/amcclenaghan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/source-map-0.14.10/src/source_id.rs:18:5
    |
18  |     pub fn new(filesystem: &mut impl FileSystem, path: PathBuf, content: String) -> Self {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
258 +     use source_map::Nullable;
    |

error[E0599]: no associated item named `NULL_SPAN` found for struct `BaseSpan` in the current scope
   --> /Users/amcclenaghan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ezno-parser-0.1.3/src/visiting.rs:413:21
    |
413 |                     None => &Span::NULL_SPAN,
    |                                    ^^^^^^^^^ associated item not found in `BaseSpan<()>`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.