76
return child;
77
}
79
>
lastChild(): Node {
80
return this._children[this._children.length - 1];
81
}
83
>
dispose() {
84
this._children.splice(0, this._children.length);
85
}
87
>
88
>
export enum TokenQuality {
89
>
None = 0,
90
>
ViewportGuess = 1,
91
>
EditGuess = 2,
92
>
Accurate = 3
93
>
}
94
>
95
>
type Node = ListNode | LeafNode;
96
>
97
>
// Exported for tests
98
>
export interface LeafNode {
99
>
readonly length: number;
100
>
token: number;
101
>
tokenQuality: TokenQuality;
102
>
height: 0;
103
>
}
104
>
105
>
export interface TokenUpdate {
106
>
readonly startOffsetInclusive: number;
107
>
readonly length: number;
108
>
readonly token: number;
109
>
}
110
>
111
function isLeaf(node: Node): node is LeafNode {
112
return (node as LeafNode).token !== undefined;
113
}
115
>
// Heavily inspired by https://github.com/microsoft/vscode/blob/4eb2658d592cb6114a7a393655574176cc790c5b/src/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/concat23Trees.ts#L108-L109
116
function append(node: Node, nodeToAppend: Node): Node {
117
let curNode = node;