chore(vscode): update to 1.53.2

These conflicts will be resolved in the following commits. We do it this way so
that PR review is possible.
This commit is contained in:
Joe Previte
2021-02-25 11:27:27 -07:00
1900 changed files with 83066 additions and 64589 deletions

View File

@@ -5,7 +5,7 @@
/* Based on @sergeche's work in his emmet plugin */
import { TextDocument, Position, Range, EndOfLine } from 'vscode';
import { TextDocument } from 'vscode';
/**
* A stream reader for VSCode's `TextDocument`
@@ -13,40 +13,37 @@ import { TextDocument, Position, Range, EndOfLine } from 'vscode';
*/
export class DocumentStreamReader {
private document: TextDocument;
private start: Position;
private _eof: Position;
private _sof: Position;
public pos: Position;
private _eol: string;
constructor(document: TextDocument, pos?: Position, limit?: Range) {
private start: number;
private _eof: number;
private _sof: number;
public pos: number;
constructor(document: TextDocument, pos?: number, limit?: [number, number]) {
this.document = document;
this.start = this.pos = pos ? pos : new Position(0, 0);
this._sof = limit ? limit.start : new Position(0, 0);
this._eof = limit ? limit.end : new Position(this.document.lineCount - 1, this._lineLength(this.document.lineCount - 1));
this._eol = this.document.eol === EndOfLine.LF ? '\n' : '\r\n';
this.start = this.pos = pos ? pos : 0;
this._sof = limit ? limit[0] : 0;
this._eof = limit ? limit[1] : document.getText().length;
}
/**
* Returns true only if the stream is at the start of the file.
*/
sof(): boolean {
return this.pos.isBeforeOrEqual(this._sof);
return this.pos <= this._sof;
}
/**
* Returns true only if the stream is at the end of the file.
*/
eof(): boolean {
return this.pos.isAfterOrEqual(this._eof);
return this.pos >= this._eof;
}
/**
* Creates a new stream instance which is limited to given range for given document
*/
limit(start: Position, end: Position): DocumentStreamReader {
return new DocumentStreamReader(this.document, start, new Range(start, end));
limit(start: number, end: number): DocumentStreamReader {
return new DocumentStreamReader(this.document, start, [start, end]);
}
/**
@@ -57,8 +54,7 @@ export class DocumentStreamReader {
if (this.eof()) {
return NaN;
}
const line = this.document.lineAt(this.pos.line).text;
return this.pos.character < line.length ? line.charCodeAt(this.pos.character) : this._eol.charCodeAt(this.pos.character - line.length);
return this.document.getText().charCodeAt(this.pos);
}
/**
@@ -70,19 +66,12 @@ export class DocumentStreamReader {
return NaN;
}
const line = this.document.lineAt(this.pos.line).text;
let code: number;
if (this.pos.character < line.length) {
code = line.charCodeAt(this.pos.character);
this.pos = this.pos.translate(0, 1);
} else {
code = this._eol.charCodeAt(this.pos.character - line.length);
this.pos = new Position(this.pos.line + 1, 0);
}
const code = this.document.getText().charCodeAt(this.pos);
this.pos++;
if (this.eof()) {
// restrict pos to eof, if in case it got moved beyond eof
this.pos = new Position(this._eof.line, this._eof.character);
this.pos = this._eof;
}
return code;
@@ -92,20 +81,11 @@ export class DocumentStreamReader {
* Backs up the stream n characters. Backing it up further than the
* start of the current token will cause things to break, so be careful.
*/
backUp(n: number) {
let row = this.pos.line;
let column = this.pos.character;
column -= (n || 1);
while (row >= 0 && column < 0) {
row--;
column += this._lineLength(row);
backUp(n: number): number {
this.pos -= n;
if (this.pos < 0) {
this.pos = 0;
}
this.pos = row < 0 || column < 0
? new Position(0, 0)
: new Position(row, column);
return this.peek();
}
@@ -120,29 +100,18 @@ export class DocumentStreamReader {
/**
* Returns contents for given range
*/
substring(from: Position, to: Position): string {
return this.document.getText(new Range(from, to));
substring(from: number, to: number): string {
return this.document.getText().substring(from, to);
}
/**
* Creates error object with current stream state
*/
error(message: string): Error {
const err = new Error(`${message} at row ${this.pos.line}, column ${this.pos.character}`);
const err = new Error(`${message} at offset ${this.pos}`);
return err;
}
/**
* Returns line length of given row, including line ending
*/
_lineLength(row: number): number {
if (row === this.document.lineCount - 1) {
return this.document.lineAt(row).text.length;
}
return this.document.lineAt(row).text.length + this._eol.length;
}
/**
* `match` can be a character code or a function that takes a character code
* and returns a boolean. If the next character in the stream 'matches'
@@ -167,6 +136,6 @@ export class DocumentStreamReader {
eatWhile(match: number | Function): boolean {
const start = this.pos;
while (!this.eof() && this.eat(match)) { }
return !this.pos.isEqual(start);
return this.pos !== start;
}
}