Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect location info in SAXParser and RewritingStream #266

Closed
RReverser opened this issue Aug 9, 2018 · 0 comments · Fixed by #268
Closed

Incorrect location info in SAXParser and RewritingStream #266

RReverser opened this issue Aug 9, 2018 · 0 comments · Fixed by #268
Labels

Comments

@RReverser
Copy link
Collaborator

When concatenating consequent character tokens, streaming variants of the parser don't correctly merge location information.

I found related issue #153 where endOffset was fixed for SAXParser, but endLine and endCol are still invalid and correspond to the first token.

Test for the RewritingStream (not for SAXParser as initially I thought the problem is specific to the rewriter) as an example of the issue:

exports['RewritingStream - Should return location for entire text span'] = createRewriterTest({
    src: 'te\n st',
    expected: '',
    assignTokenHandlers: rewriter => {
        rewriter.on('text', token => {
            assert.deepStrictEqual(token, {
                text: 'te\n st',
                sourceCodeLocation: {
                    startLine: 1,
                    startCol: 1,
                    startOffset: 0,
                    endLine: 2, // returns 1 instead
                    endCol: 4, // returns 3 instead
                    endOffset: 6
                }
            });
        });
    }
});
@RReverser RReverser added the bug label Aug 9, 2018
RReverser added a commit that referenced this issue Aug 9, 2018
RReverser added a commit that referenced this issue Aug 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant