1
>
/*---------------------------------------------------------------------------------------------
concat23Trees.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { AstNode, AstNodeKind, ListAstNode } from './ast.js';
7
>
8
>
/**
9
>
* Concatenates a list of (2,3) AstNode's into a single (2,3) AstNode.
10
>
* This mutates the items of the input array!
11
>
* If all items have the same height, this method has runtime O(items.length).
12
>
* Otherwise, it has runtime O(items.length * max(log(items.length), items.max(i => i.height))).
13
>
*/
14
>
export function concat23Trees(items: AstNode[]): AstNode | null {
15
if (items.length === 0) {
16
return null;