mirror of
https://github.com/tenrok/BBob.git
synced 2026-06-20 20:00:33 +03:00
feat: add start and end positions of tag nodes (#246)
Closes #134 * feat: Add start and end positions of tag nodes Improves accuracy of row/col error reporting. Now targets the start of the relevant token instead of the end. * Simplify language for TagNode and Token * Update static TagNode.create to ingest setStart() logic improve readability of end pos offset for no attr tags
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import Token, { TYPE_WORD, TYPE_TAG, TYPE_ATTR_NAME, TYPE_ATTR_VALUE, TYPE_SPACE, TYPE_NEW_LINE } from '../src/Token'
|
||||
import Token, { TYPE_WORD, TYPE_TAG, TYPE_ATTR_NAME, TYPE_ATTR_VALUE, TYPE_SPACE, TYPE_NEW_LINE } from '../src/Token';
|
||||
|
||||
describe('Token', () => {
|
||||
test('isEmpty', () => {
|
||||
const token = new Token();
|
||||
|
||||
expect(token.isEmpty()).toBeTruthy()
|
||||
expect(token.isEmpty()).toBeTruthy();
|
||||
});
|
||||
test('isText', () => {
|
||||
const token = new Token(TYPE_WORD);
|
||||
@@ -56,6 +56,16 @@ describe('Token', () => {
|
||||
|
||||
expect(token.getColumn()).toBe(14);
|
||||
});
|
||||
test('getStartPos', () => {
|
||||
const token = new Token(TYPE_TAG, 'my-tag', 12, 14, 50);
|
||||
|
||||
expect(token.getStart()).toBe(50);
|
||||
});
|
||||
test('getEndPos', () => {
|
||||
const token = new Token(TYPE_TAG, 'my-tag', 12, 14, 50, 60);
|
||||
|
||||
expect(token.getEnd()).toBe(60);
|
||||
});
|
||||
test('toString', () => {
|
||||
const tokenEnd = new Token(TYPE_TAG, '/my-tag', 12, 14);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user