@lezer/common 0.16.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +9 -10
- package/dist/index.js +9 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
// FIXME profile adding a per-Tree TreeNode cache, validating it by
|
|
6
6
|
// parent pointer
|
|
7
|
-
/// The default maximum length of a `TreeBuffer` node
|
|
7
|
+
/// The default maximum length of a `TreeBuffer` node.
|
|
8
8
|
const DefaultBufferLength = 1024;
|
|
9
9
|
let nextPropID = 0;
|
|
10
10
|
class Range {
|
|
@@ -67,7 +67,7 @@ NodeProp.contextHash = new NodeProp({ perNode: true });
|
|
|
67
67
|
NodeProp.lookAhead = new NodeProp({ perNode: true });
|
|
68
68
|
/// This per-node prop is used to replace a given node, or part of a
|
|
69
69
|
/// node, with another tree. This is useful to include trees from
|
|
70
|
-
/// different languages.
|
|
70
|
+
/// different languages in mixed-language parsers.
|
|
71
71
|
NodeProp.mounted = new NodeProp({ perNode: true });
|
|
72
72
|
/// A mounted tree, which can be [stored](#common.NodeProp^mounted) on
|
|
73
73
|
/// a tree node to indicate that parts of its content are
|
|
@@ -113,6 +113,7 @@ class NodeType {
|
|
|
113
113
|
this.id = id;
|
|
114
114
|
this.flags = flags;
|
|
115
115
|
}
|
|
116
|
+
/// Define a node type.
|
|
116
117
|
static define(spec) {
|
|
117
118
|
let props = spec.props && spec.props.length ? Object.create(null) : noProps;
|
|
118
119
|
let flags = (spec.top ? 1 /* Top */ : 0) | (spec.skipped ? 2 /* Skipped */ : 0) |
|
|
@@ -194,7 +195,7 @@ class NodeSet {
|
|
|
194
195
|
throw new RangeError("Node type ids should correspond to array positions when creating a node set");
|
|
195
196
|
}
|
|
196
197
|
/// Create a copy of this set with some node properties added. The
|
|
197
|
-
/// arguments to this method
|
|
198
|
+
/// arguments to this method can be created with
|
|
198
199
|
/// [`NodeProp.add`](#common.NodeProp.add).
|
|
199
200
|
extend(...props) {
|
|
200
201
|
let newTypes = [];
|
|
@@ -404,7 +405,7 @@ class FlatBufferCursor {
|
|
|
404
405
|
/// Tree buffers contain (type, start, end, endIndex) quads for each
|
|
405
406
|
/// node. In such a buffer, nodes are stored in prefix order (parents
|
|
406
407
|
/// before children, with the endIndex of the parent indicating which
|
|
407
|
-
/// children belong to it)
|
|
408
|
+
/// children belong to it).
|
|
408
409
|
class TreeBuffer {
|
|
409
410
|
/// Create a tree buffer.
|
|
410
411
|
constructor(
|
|
@@ -1308,7 +1309,10 @@ class NodeWeakMap {
|
|
|
1308
1309
|
/// [`applyChanges`](#common.TreeFragment^applyChanges) method to
|
|
1309
1310
|
/// update fragments for document changes.
|
|
1310
1311
|
class TreeFragment {
|
|
1311
|
-
/// Construct a tree fragment.
|
|
1312
|
+
/// Construct a tree fragment. You'll usually want to use
|
|
1313
|
+
/// [`addTree`](#common.TreeFragment^addTree) and
|
|
1314
|
+
/// [`applyChanges`](#common.TreeFragment^applyChanges) instead of
|
|
1315
|
+
/// calling this directly.
|
|
1312
1316
|
constructor(
|
|
1313
1317
|
/// The start of the unchanged range pointed to by this fragment.
|
|
1314
1318
|
/// This refers to an offset in the _updated_ document (as opposed
|
|
@@ -1423,11 +1427,6 @@ class StringInput {
|
|
|
1423
1427
|
/// function, runs the resulting [inner parses](#common.NestedParse),
|
|
1424
1428
|
/// and then [mounts](#common.NodeProp^mounted) their results onto the
|
|
1425
1429
|
/// tree.
|
|
1426
|
-
///
|
|
1427
|
-
/// The nesting function is passed a cursor to provide context for a
|
|
1428
|
-
/// node, but _should not_ move that cursor, only inspect its
|
|
1429
|
-
/// properties and optionally access its
|
|
1430
|
-
/// [node object](#common.TreeCursor.node).
|
|
1431
1430
|
function parseMixed(nest) {
|
|
1432
1431
|
return (parse, input, fragments, ranges) => new MixedParse(parse, nest, input, fragments, ranges);
|
|
1433
1432
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// FIXME profile adding a per-Tree TreeNode cache, validating it by
|
|
2
2
|
// parent pointer
|
|
3
|
-
/// The default maximum length of a `TreeBuffer` node
|
|
3
|
+
/// The default maximum length of a `TreeBuffer` node.
|
|
4
4
|
const DefaultBufferLength = 1024;
|
|
5
5
|
let nextPropID = 0;
|
|
6
6
|
class Range {
|
|
@@ -63,7 +63,7 @@ NodeProp.contextHash = new NodeProp({ perNode: true });
|
|
|
63
63
|
NodeProp.lookAhead = new NodeProp({ perNode: true });
|
|
64
64
|
/// This per-node prop is used to replace a given node, or part of a
|
|
65
65
|
/// node, with another tree. This is useful to include trees from
|
|
66
|
-
/// different languages.
|
|
66
|
+
/// different languages in mixed-language parsers.
|
|
67
67
|
NodeProp.mounted = new NodeProp({ perNode: true });
|
|
68
68
|
/// A mounted tree, which can be [stored](#common.NodeProp^mounted) on
|
|
69
69
|
/// a tree node to indicate that parts of its content are
|
|
@@ -109,6 +109,7 @@ class NodeType {
|
|
|
109
109
|
this.id = id;
|
|
110
110
|
this.flags = flags;
|
|
111
111
|
}
|
|
112
|
+
/// Define a node type.
|
|
112
113
|
static define(spec) {
|
|
113
114
|
let props = spec.props && spec.props.length ? Object.create(null) : noProps;
|
|
114
115
|
let flags = (spec.top ? 1 /* Top */ : 0) | (spec.skipped ? 2 /* Skipped */ : 0) |
|
|
@@ -190,7 +191,7 @@ class NodeSet {
|
|
|
190
191
|
throw new RangeError("Node type ids should correspond to array positions when creating a node set");
|
|
191
192
|
}
|
|
192
193
|
/// Create a copy of this set with some node properties added. The
|
|
193
|
-
/// arguments to this method
|
|
194
|
+
/// arguments to this method can be created with
|
|
194
195
|
/// [`NodeProp.add`](#common.NodeProp.add).
|
|
195
196
|
extend(...props) {
|
|
196
197
|
let newTypes = [];
|
|
@@ -400,7 +401,7 @@ class FlatBufferCursor {
|
|
|
400
401
|
/// Tree buffers contain (type, start, end, endIndex) quads for each
|
|
401
402
|
/// node. In such a buffer, nodes are stored in prefix order (parents
|
|
402
403
|
/// before children, with the endIndex of the parent indicating which
|
|
403
|
-
/// children belong to it)
|
|
404
|
+
/// children belong to it).
|
|
404
405
|
class TreeBuffer {
|
|
405
406
|
/// Create a tree buffer.
|
|
406
407
|
constructor(
|
|
@@ -1304,7 +1305,10 @@ class NodeWeakMap {
|
|
|
1304
1305
|
/// [`applyChanges`](#common.TreeFragment^applyChanges) method to
|
|
1305
1306
|
/// update fragments for document changes.
|
|
1306
1307
|
class TreeFragment {
|
|
1307
|
-
/// Construct a tree fragment.
|
|
1308
|
+
/// Construct a tree fragment. You'll usually want to use
|
|
1309
|
+
/// [`addTree`](#common.TreeFragment^addTree) and
|
|
1310
|
+
/// [`applyChanges`](#common.TreeFragment^applyChanges) instead of
|
|
1311
|
+
/// calling this directly.
|
|
1308
1312
|
constructor(
|
|
1309
1313
|
/// The start of the unchanged range pointed to by this fragment.
|
|
1310
1314
|
/// This refers to an offset in the _updated_ document (as opposed
|
|
@@ -1419,11 +1423,6 @@ class StringInput {
|
|
|
1419
1423
|
/// function, runs the resulting [inner parses](#common.NestedParse),
|
|
1420
1424
|
/// and then [mounts](#common.NodeProp^mounted) their results onto the
|
|
1421
1425
|
/// tree.
|
|
1422
|
-
///
|
|
1423
|
-
/// The nesting function is passed a cursor to provide context for a
|
|
1424
|
-
/// node, but _should not_ move that cursor, only inspect its
|
|
1425
|
-
/// properties and optionally access its
|
|
1426
|
-
/// [node object](#common.TreeCursor.node).
|
|
1427
1426
|
function parseMixed(nest) {
|
|
1428
1427
|
return (parse, input, fragments, ranges) => new MixedParse(parse, nest, input, fragments, ranges);
|
|
1429
1428
|
}
|