Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/test/simulation/fixtures/gen/4080.ts
13399 views
1
/**
2
* Represents a gap (before the first child, between two children, or after the last child) in a `LinkedOverlayNode`.
3
*/
4
class LinkedOverlayNodeGap {
5
6
constructor(
7
private readonly _originalText: string,
8
private readonly _parent: LinkedOverlayNode,
9
public readonly startIndex: number,
10
public readonly endIndex: number,
11
public readonly gapIndex: number,
12
) { }
13
public get range(): OffsetRange {
14
return new OffsetRange(this.startIndex, this.endIndex);
15
}
16
public get isFirstGapInParent(): boolean {
17
return this.gapIndex === 0;
18
}
19
public get isLastGapInParent(): boolean {
20
return this.gapIndex === this._parent.children.length;
21
}
22
public toString(): string {
23
return `NodeGap (${this.startIndex}-${this.endIndex} :: ${this._originalText.substring(this.startIndex, this.endIndex)})`;
24
}
25
public get text(): string {
26
return this._originalText.substring(this.startIndex, this.endIndex);
27
}
28
public get firstNonWhitespaceIndex(): number {
29
let index = this.startIndex;
30
while (index < this.endIndex) {
31
const charCode = this._originalText.charCodeAt(index);
32
if (charCode !== CharCode.Tab && charCode !== CharCode.Space && charCode !== CharCode.LineFeed) {
33
return index;
34
}
35
index++;
36
}
37
return this.endIndex;
38
}
39
40
public get lastNonWhitespaceIndex(): number {
41
42
}
43
44
public get nextLeaf(): LinkedOverlayNode | null {
45
const nextSibling = this._parent.childAt(this.gapIndex);
46
return nextSibling ? nextSibling.leftMostLeafChild : this._parent.nextLeaf;
47
}
48
}
49
50
51