Skip to content

Support for SourceMaps #6

@dinusv

Description

@dinusv
SourcePosition{ column, row, offset }
PositionSection{ SourcePosition position; }

// usage

*compose << "{" << pos(node->startPos()) << slice(node, source) << pos(node->endPos()) << "}";

When calling flatten, instead of using parts.push_back(content), implement a new class: SectionCollector.

el::JSSection* section = new el::JSSection;
section->from = 0;
section->to   = static_cast<int>(contents.size());

LanguageNodesToJs lnt;
lnt.convert(node, contents, section->m_children, 0, ctx);

auto sc = new SectionCollector(SectionCollector::Minified);
section->collect(contents, sc);
sc->getSourceMap();
sc->getSource();
sc->append(content);
sc->appendPosition(position); // here, section collector will know the position

Testing

Add .m.json files for readability:

ParserTest01.lv
ParserTest01.lv.m.json
{
    "file" : "generated_file",
    "sources": ["source_file"],
    "mappings" : [
        { "o": { "line": 1, "column" : 1  }, "g": { "line" : 1, "column" : 12 } }
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    new featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions