Socket
Socket
Sign inDemoInstall

lezer-tree

Package Overview
Dependencies
0
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.13.1 to 0.13.2

6

CHANGELOG.md

@@ -0,1 +1,7 @@

## 0.13.2 (2021-02-17)
### New features
Add support for context tracking.
## 0.13.1 (2021-02-11)

@@ -2,0 +8,0 @@

34

dist/tree.es.js

@@ -281,3 +281,3 @@ /// The default maximum length of a `TreeBuffer` node.

return this.children.length <= BalanceBranchFactor ? this
: balanceRange(this.type, NodeType.none, this.children, this.positions, 0, this.children.length, 0, maxBufferLength, this.length);
: balanceRange(this.type, NodeType.none, this.children, this.positions, 0, this.children.length, 0, maxBufferLength, this.length, 0);
}

@@ -290,2 +290,10 @@ /// Build a tree from a postfix-ordered buffer of node information,

Tree.empty = new Tree(NodeType.none, [], [], 0);
// For trees that need a context hash attached, we're using this
// kludge which assigns an extra property directly after
// initialization (creating a single new object shape).
function withHash(tree, hash) {
if (hash)
tree.contextHash = hash;
return tree;
}
/// Tree buffers contain (type, start, end, endIndex) quads for each

@@ -736,8 +744,14 @@ /// node. In such a buffer, nodes are stored in prefix order (parents

let types = nodeSet.types;
let contextHash = 0;
function takeNode(parentStart, minPos, children, positions, inRepeat) {
let { id, start, end, size } = cursor;
let startPos = start - parentStart;
if (size < 0) { // Reused node
children.push(reused[id]);
positions.push(startPos);
if (size < 0) {
if (size == -1) { // Reused node
children.push(reused[id]);
positions.push(startPos);
}
else { // Context change
contextHash = id;
}
cursor.next();

@@ -770,5 +784,5 @@ return;

if (localInRepeat > -1 && localChildren.length > BalanceBranchFactor)
node = balanceRange(type, type, localChildren, localPositions, 0, localChildren.length, 0, maxBufferLength, end - start);
node = balanceRange(type, type, localChildren, localPositions, 0, localChildren.length, 0, maxBufferLength, end - start, contextHash);
else
node = new Tree(type, localChildren, localPositions, end - start);
node = withHash(new Tree(type, localChildren, localPositions, end - start), contextHash);
}

@@ -850,3 +864,3 @@ children.push(node);

}
function balanceRange(outerType, innerType, children, positions, from, to, start, maxBufferLength, length) {
function balanceRange(outerType, innerType, children, positions, from, to, start, maxBufferLength, length, contextHash) {
let localChildren = [], localPositions = [];

@@ -884,5 +898,5 @@ if (length <= maxBufferLength) {

else {
let inner = balanceRange(innerType, innerType, children, positions, groupFrom, i, groupStart, maxBufferLength, positions[i - 1] + children[i - 1].length - groupStart);
let inner = balanceRange(innerType, innerType, children, positions, groupFrom, i, groupStart, maxBufferLength, positions[i - 1] + children[i - 1].length - groupStart, contextHash);
if (innerType != NodeType.none && !containsType(inner.children, innerType))
inner = new Tree(NodeType.none, inner.children, inner.positions, inner.length);
inner = withHash(new Tree(NodeType.none, inner.children, inner.positions, inner.length), contextHash);
localChildren.push(inner);

@@ -893,3 +907,3 @@ }

}
return new Tree(outerType, localChildren, localPositions, length);
return withHash(new Tree(outerType, localChildren, localPositions, length), contextHash);
}

@@ -896,0 +910,0 @@ function containsType(nodes, type) {

{
"name": "lezer-tree",
"version": "0.13.1",
"version": "0.13.2",
"description": "Syntax tree data structure for the lezer parser",

@@ -5,0 +5,0 @@ "main": "dist/tree.cjs",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc