Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve compiler errors that appear due to useDefineForClassFields #241544

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/vs/base/common/arrays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -702,12 +702,14 @@ export function compareUndefinedSmallest<T>(comparator: Comparator<T>): Comparat

export class ArrayQueue<T> {
private firstIdx = 0;
private lastIdx = this.items.length - 1;
private lastIdx: number;

/**
* Constructs a queue that is backed by the given array. Runtime is O(1).
*/
constructor(private readonly items: readonly T[]) { }
constructor(private readonly items: readonly T[]) {
this.lastIdx = this.items.length - 1;
}

get length(): number {
return this.lastIdx - this.firstIdx + 1;
Expand Down
14 changes: 8 additions & 6 deletions src/vs/base/parts/ipc/common/ipc.mp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,17 @@ export interface MessagePort {
*/
export class Protocol implements IMessagePassingProtocol {

readonly onMessage = Event.fromDOMEventEmitter<VSBuffer>(this.port, 'message', (e: MessageEvent) => {
if (e.data) {
return VSBuffer.wrap(e.data);
}
return VSBuffer.alloc(0);
});
readonly onMessage: Event<VSBuffer>;

constructor(private port: MessagePort) {

this.onMessage = Event.fromDOMEventEmitter<VSBuffer>(this.port, 'message', (e: MessageEvent) => {
if (e.data) {
return VSBuffer.wrap(e.data);
}
return VSBuffer.alloc(0);
});

// we must call start() to ensure messages are flowing
port.start();
}
Expand Down
14 changes: 8 additions & 6 deletions src/vs/base/parts/ipc/node/ipc.mp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ import { assertType } from '../../../common/types.js';
*/
class Protocol implements IMessagePassingProtocol {

readonly onMessage = Event.fromNodeEventEmitter<VSBuffer>(this.port, 'message', (e: MessageEvent) => {
if (e.data) {
return VSBuffer.wrap(e.data);
}
return VSBuffer.alloc(0);
});
readonly onMessage: Event<VSBuffer>;

constructor(private port: MessagePortMain) {

this.onMessage = Event.fromNodeEventEmitter<VSBuffer>(this.port, 'message', (e: MessageEvent) => {
if (e.data) {
return VSBuffer.wrap(e.data);
}
return VSBuffer.alloc(0);
});

// we must call start() to ensure messages are flowing
port.start();
}
Expand Down
14 changes: 10 additions & 4 deletions src/vs/base/parts/storage/node/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ export class SQLiteStorageDatabase implements IStorageDatabase {
private static readonly BUSY_OPEN_TIMEOUT = 2000; // timeout in ms to retry when opening DB fails with SQLITE_BUSY
private static readonly MAX_HOST_PARAMETERS = 256; // maximum number of parameters within a statement

private readonly name = basename(this.path);
private readonly name: string;

private readonly logger = new SQLiteStorageDatabaseLogger(this.options.logging);
private readonly logger: SQLiteStorageDatabaseLogger;

private readonly whenConnected = this.connect(this.path);
private readonly whenConnected: Promise<IDatabaseConnection>;

constructor(private readonly path: string, private readonly options: ISQLiteStorageDatabaseOptions = Object.create(null)) { }
constructor(private readonly path: string, private readonly options: ISQLiteStorageDatabaseOptions = Object.create(null)) {
this.name = basename(this.path);

this.logger = new SQLiteStorageDatabaseLogger(this.options.logging);

this.whenConnected = this.connect(this.path);
}

async getItems(): Promise<Map<string, string>> {
const connection = await this.whenConnected;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import { IProductService } from '../../../../platform/product/common/productServ

export class CodeCacheCleaner extends Disposable {

private readonly _DataMaxAge = this.productService.quality !== 'stable'
? 1000 * 60 * 60 * 24 * 7 // roughly 1 week (insiders)
: 1000 * 60 * 60 * 24 * 30 * 3; // roughly 3 months (stable)
private readonly _DataMaxAge: number;

constructor(
currentCodeCachePath: string | undefined,
Expand All @@ -25,6 +23,10 @@ export class CodeCacheCleaner extends Disposable {
) {
super();

this._DataMaxAge = this.productService.quality !== 'stable'
? 1000 * 60 * 60 * 24 * 7 // roughly 1 week (insiders)
: 1000 * 60 * 60 * 24 * 30 * 3; // roughly 3 months (stable)

// Cached data is stored as user data and we run a cleanup task every time
// the editor starts. The strategy is to delete all files that are older than
// 3 months (1 week respectively)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ interface ILanguagePackFile {

export class LanguagePackCachedDataCleaner extends Disposable {

private readonly _DataMaxAge = this.productService.quality !== 'stable'
? 1000 * 60 * 60 * 24 * 7 // roughly 1 week (insiders)
: 1000 * 60 * 60 * 24 * 30 * 3; // roughly 3 months (stable)
private readonly _DataMaxAge: number;

constructor(
@INativeEnvironmentService private readonly environmentService: INativeEnvironmentService,
Expand All @@ -44,6 +42,10 @@ export class LanguagePackCachedDataCleaner extends Disposable {
) {
super();

this._DataMaxAge = this.productService.quality !== 'stable'
? 1000 * 60 * 60 * 24 * 7 // roughly 1 week (insiders)
: 1000 * 60 * 60 * 24 * 30 * 3; // roughly 3 months (stable)

// We have no Language pack support for dev version (run from source)
// So only cleanup when we have a build version.
if (this.environmentService.isBuilt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,19 +619,19 @@ export class TextAreaInput extends Disposable {

export class TextAreaWrapper extends Disposable implements ICompleteTextAreaWrapper {

public readonly onKeyDown = this._register(new DomEmitter(this._actual, 'keydown')).event;
public readonly onKeyPress = this._register(new DomEmitter(this._actual, 'keypress')).event;
public readonly onKeyUp = this._register(new DomEmitter(this._actual, 'keyup')).event;
public readonly onCompositionStart = this._register(new DomEmitter(this._actual, 'compositionstart')).event;
public readonly onCompositionUpdate = this._register(new DomEmitter(this._actual, 'compositionupdate')).event;
public readonly onCompositionEnd = this._register(new DomEmitter(this._actual, 'compositionend')).event;
public readonly onBeforeInput = this._register(new DomEmitter(this._actual, 'beforeinput')).event;
public readonly onInput = <Event<InputEvent>>this._register(new DomEmitter(this._actual, 'input')).event;
public readonly onCut = this._register(new DomEmitter(this._actual, 'cut')).event;
public readonly onCopy = this._register(new DomEmitter(this._actual, 'copy')).event;
public readonly onPaste = this._register(new DomEmitter(this._actual, 'paste')).event;
public readonly onFocus = this._register(new DomEmitter(this._actual, 'focus')).event;
public readonly onBlur = this._register(new DomEmitter(this._actual, 'blur')).event;
public readonly onKeyDown: Event<KeyboardEvent>;
public readonly onKeyPress: Event<KeyboardEvent>;
public readonly onKeyUp: Event<KeyboardEvent>;
public readonly onCompositionStart: Event<CompositionEvent>;
public readonly onCompositionUpdate: Event<CompositionEvent>;
public readonly onCompositionEnd: Event<CompositionEvent>;
public readonly onBeforeInput: Event<InputEvent>;
public readonly onInput: Event<InputEvent>;
public readonly onCut: Event<ClipboardEvent>;
public readonly onCopy: Event<ClipboardEvent>;
public readonly onPaste: Event<ClipboardEvent>;
public readonly onFocus: Event<FocusEvent>;
public readonly onBlur: Event<FocusEvent>;

public get ownerDocument(): Document {
return this._actual.ownerDocument;
Expand All @@ -646,6 +646,21 @@ export class TextAreaWrapper extends Disposable implements ICompleteTextAreaWrap
private readonly _actual: HTMLTextAreaElement
) {
super();

this.onKeyDown = this._register(new DomEmitter(this._actual, 'keydown')).event;
this.onKeyPress = this._register(new DomEmitter(this._actual, 'keypress')).event;
this.onKeyUp = this._register(new DomEmitter(this._actual, 'keyup')).event;
this.onCompositionStart = this._register(new DomEmitter(this._actual, 'compositionstart')).event;
this.onCompositionUpdate = this._register(new DomEmitter(this._actual, 'compositionupdate')).event;
this.onCompositionEnd = this._register(new DomEmitter(this._actual, 'compositionend')).event;
this.onBeforeInput = this._register(new DomEmitter(this._actual, 'beforeinput')).event;
this.onInput = <Event<InputEvent>>this._register(new DomEmitter(this._actual, 'input')).event;
this.onCut = this._register(new DomEmitter(this._actual, 'cut')).event;
this.onCopy = this._register(new DomEmitter(this._actual, 'copy')).event;
this.onPaste = this._register(new DomEmitter(this._actual, 'paste')).event;
this.onFocus = this._register(new DomEmitter(this._actual, 'focus')).event;
this.onBlur = this._register(new DomEmitter(this._actual, 'blur')).event;

this._ignoreSelectionChangeTime = 0;

this._register(this.onKeyDown(() => inputLatency.onKeyDown()));
Expand Down
65 changes: 44 additions & 21 deletions src/vs/editor/browser/observableCodeEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import { equalsIfDefined, itemsEquals } from '../../base/common/equals.js';
import { Disposable, DisposableStore, IDisposable, toDisposable } from '../../base/common/lifecycle.js';
import { IObservable, IObservableWithChange, ITransaction, TransactionImpl, autorun, autorunOpts, derived, derivedOpts, derivedWithSetter, observableFromEvent, observableSignal, observableValue, observableValueOpts } from '../../base/common/observable.js';
import { EditorOption, FindComputedEditorOptionValueById } from '../common/config/editorOptions.js';
import { IObservable, IObservableWithChange, ISettableObservable, ITransaction, TransactionImpl, autorun, autorunOpts, derived, derivedOpts, derivedWithSetter, observableFromEvent, observableSignal, observableValue, observableValueOpts } from '../../base/common/observable.js';
import { EditorLayoutInfo, EditorMinimapLayoutInfo, EditorOption, FindComputedEditorOptionValueById } from '../common/config/editorOptions.js';
import { LineRange } from '../common/core/lineRange.js';
import { OffsetRange } from '../common/core/offsetRange.js';
import { Position } from '../common/core/position.js';
Expand Down Expand Up @@ -71,6 +71,32 @@ export class ObservableCodeEditor extends Disposable {
private constructor(public readonly editor: ICodeEditor) {
super();

this._model = observableValue(this, this.editor.getModel());
this.model = this._model;

this.isReadonly = observableFromEvent(this, this.editor.onDidChangeConfiguration, () => this.editor.getOption(EditorOption.readOnly));

this._versionId = observableValueOpts<number | null, IModelContentChangedEvent | undefined>({ owner: this, lazy: true }, this.editor.getModel()?.getVersionId() ?? null);
this.versionId = this._versionId;

this._selections = observableValueOpts<Selection[] | null, ICursorSelectionChangedEvent | undefined>(
{ owner: this, equalsFn: equalsIfDefined(itemsEquals(Selection.selectionsEqual)), lazy: true },
this.editor.getSelections() ?? null
);
this.selections = this._selections;

this.scrollTop = observableFromEvent(this.editor.onDidScrollChange, () => this.editor.getScrollTop());
this.scrollLeft = observableFromEvent(this.editor.onDidScrollChange, () => this.editor.getScrollLeft());

this.layoutInfo = observableFromEvent(this.editor.onDidLayoutChange, () => this.editor.getLayoutInfo());
this.layoutInfoContentLeft = this.layoutInfo.map(l => l.contentLeft);
this.layoutInfoDecorationsLeft = this.layoutInfo.map(l => l.decorationsLeft);
this.layoutInfoWidth = this.layoutInfo.map(l => l.width);
this.layoutInfoMinimap = this.layoutInfo.map(l => l.minimap);
this.layoutInfoVerticalScrollbarWidth = this.layoutInfo.map(l => l.verticalScrollbarWidth);

this.contentWidth = observableFromEvent(this.editor.onDidContentSizeChange, () => this.editor.getContentWidth());

this._register(this.editor.onBeginUpdate(() => this._beginUpdate()));
this._register(this.editor.onEndUpdate(() => this._endUpdate()));

Expand Down Expand Up @@ -149,19 +175,16 @@ export class ObservableCodeEditor extends Disposable {
}
}

private readonly _model = observableValue(this, this.editor.getModel());
public readonly model: IObservable<ITextModel | null> = this._model;
private readonly _model: ISettableObservable<ITextModel | null, void>;
public readonly model: IObservable<ITextModel | null>;

public readonly isReadonly = observableFromEvent(this, this.editor.onDidChangeConfiguration, () => this.editor.getOption(EditorOption.readOnly));
public readonly isReadonly: IObservable<boolean>;

private readonly _versionId = observableValueOpts<number | null, IModelContentChangedEvent | undefined>({ owner: this, lazy: true }, this.editor.getModel()?.getVersionId() ?? null);
public readonly versionId: IObservableWithChange<number | null, IModelContentChangedEvent | undefined> = this._versionId;
private readonly _versionId: ISettableObservable<number | null, IModelContentChangedEvent | undefined>;
public readonly versionId: IObservableWithChange<number | null, IModelContentChangedEvent | undefined>;

private readonly _selections = observableValueOpts<Selection[] | null, ICursorSelectionChangedEvent | undefined>(
{ owner: this, equalsFn: equalsIfDefined(itemsEquals(Selection.selectionsEqual)), lazy: true },
this.editor.getSelections() ?? null
);
public readonly selections: IObservableWithChange<Selection[] | null, ICursorSelectionChangedEvent | undefined> = this._selections;
private readonly _selections: ISettableObservable<Selection[] | null, ICursorSelectionChangedEvent | undefined>;
public readonly selections: IObservableWithChange<Selection[] | null, ICursorSelectionChangedEvent | undefined>;


public readonly positions = derivedOpts<readonly Position[] | null>(
Expand Down Expand Up @@ -225,17 +248,17 @@ export class ObservableCodeEditor extends Disposable {
public readonly onDidType = observableSignal<string>(this);
public readonly onDidPaste = observableSignal<IPasteEvent>(this);

public readonly scrollTop = observableFromEvent(this.editor.onDidScrollChange, () => this.editor.getScrollTop());
public readonly scrollLeft = observableFromEvent(this.editor.onDidScrollChange, () => this.editor.getScrollLeft());
public readonly scrollTop: IObservable<number>;
public readonly scrollLeft: IObservable<number>;

public readonly layoutInfo = observableFromEvent(this.editor.onDidLayoutChange, () => this.editor.getLayoutInfo());
public readonly layoutInfoContentLeft = this.layoutInfo.map(l => l.contentLeft);
public readonly layoutInfoDecorationsLeft = this.layoutInfo.map(l => l.decorationsLeft);
public readonly layoutInfoWidth = this.layoutInfo.map(l => l.width);
public readonly layoutInfoMinimap = this.layoutInfo.map(l => l.minimap);
public readonly layoutInfoVerticalScrollbarWidth = this.layoutInfo.map(l => l.verticalScrollbarWidth);
public readonly layoutInfo: IObservable<EditorLayoutInfo>;
public readonly layoutInfoContentLeft: IObservable<number>;
public readonly layoutInfoDecorationsLeft: IObservable<number>;
public readonly layoutInfoWidth: IObservable<number>;
public readonly layoutInfoMinimap: IObservable<EditorMinimapLayoutInfo>;
public readonly layoutInfoVerticalScrollbarWidth: IObservable<number>;

public readonly contentWidth = observableFromEvent(this.editor.onDidContentSizeChange, () => this.editor.getContentWidth());
public readonly contentWidth: IObservable<number>;

public getOption<T extends EditorOption>(id: T): IObservable<FindComputedEditorOptionValueById<T>> {
return observableFromEvent(this, cb => this.editor.onDidChangeConfiguration(e => {
Expand Down
3 changes: 2 additions & 1 deletion src/vs/editor/browser/view/viewLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,12 @@ export class RenderedLinesCollection<T extends ILine> {
export class VisibleLinesCollection<T extends IVisibleLine> {

public readonly domNode: FastDomNode<HTMLElement> = this._createDomNode();
private readonly _linesCollection: RenderedLinesCollection<T> = new RenderedLinesCollection<T>(this._lineFactory);
private readonly _linesCollection: RenderedLinesCollection<T>;

constructor(
private readonly _lineFactory: ILineFactory<T>
) {
this._linesCollection = new RenderedLinesCollection<T>(this._lineFactory);
}

private _createDomNode(): FastDomNode<HTMLElement> {
Expand Down
14 changes: 10 additions & 4 deletions src/vs/editor/browser/widget/codeEditor/codeEditorWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2029,18 +2029,24 @@ const enum BooleanEventValue {
}

export class BooleanEventEmitter extends Disposable {
private readonly _onDidChangeToTrue: Emitter<void> = this._register(new Emitter<void>(this._emitterOptions));
public readonly onDidChangeToTrue: Event<void> = this._onDidChangeToTrue.event;
private readonly _onDidChangeToTrue: Emitter<void>;
public readonly onDidChangeToTrue: Event<void>;

private readonly _onDidChangeToFalse: Emitter<void> = this._register(new Emitter<void>(this._emitterOptions));
public readonly onDidChangeToFalse: Event<void> = this._onDidChangeToFalse.event;
private readonly _onDidChangeToFalse: Emitter<void>;
public readonly onDidChangeToFalse: Event<void>;

private _value: BooleanEventValue;

constructor(
private readonly _emitterOptions: EmitterOptions
) {
super();
this._onDidChangeToTrue = this._register(new Emitter<void>(this._emitterOptions));
this.onDidChangeToTrue = this._onDidChangeToTrue.event;

this._onDidChangeToFalse = this._register(new Emitter<void>(this._emitterOptions));
this.onDidChangeToFalse = this._onDidChangeToFalse.event;

this._value = BooleanEventValue.NotSet;
}

Expand Down
Loading
Loading