Skip to content
Open

0.9.0 #5399

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
75 changes: 75 additions & 0 deletions monaco-lsp-client/src/IDisposable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
export interface IDisposable {
dispose(): void;
}

export class Disposable implements IDisposable {
static None = Object.freeze<IDisposable>({ dispose() { } });

private _store = new DisposableStore();

constructor() { }

public dispose(): void {
this._store.dispose();
}

protected _register<T extends IDisposable>(t: T): T {
if ((t as any) === this) {
throw new Error('Cannot register a disposable on itself!');
}
return this._store.add(t);
}
}

export class DisposableStore implements IDisposable {
static DISABLE_DISPOSED_WARNING = false;

private _toDispose = new Set<IDisposable>();
private _isDisposed = false;

public dispose(): void {
if (this._isDisposed) {
return;
}

this._isDisposed = true;
this.clear();
}

public clear(): void {
if (this._toDispose.size === 0) {
return;
}

try {
for (const item of this._toDispose) {
item.dispose();
}
} finally {
this._toDispose.clear();
}
}

public add<T extends IDisposable>(t: T): T {
if (!t) {
return t;
}
if ((t as any) === this) {
throw new Error('Cannot register a disposable on itself!');
}

if (this._isDisposed) {
if (!DisposableStore.DISABLE_DISPOSED_WARNING) {
console.warn(
new Error(
'Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!'
).stack
);
}
} else {
this._toDispose.add(t);
}

return t;
}
}
74 changes: 0 additions & 74 deletions monaco-lsp-client/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,75 +1 @@
export interface IDisposable {
dispose(): void;
}

export class Disposable implements IDisposable {
static None = Object.freeze<IDisposable>({ dispose() { } });

private _store = new DisposableStore();

constructor() { }

public dispose(): void {
this._store.dispose();
}

protected _register<T extends IDisposable>(t: T): T {
if ((t as any) === this) {
throw new Error('Cannot register a disposable on itself!');
}
return this._store.add(t);
}
}

export class DisposableStore implements IDisposable {
static DISABLE_DISPOSED_WARNING = false;

private _toDispose = new Set<IDisposable>();
private _isDisposed = false;

public dispose(): void {
if (this._isDisposed) {
return;
}

this._isDisposed = true;
this.clear();
}

public clear(): void {
if (this._toDispose.size === 0) {
return;
}

try {
for (const item of this._toDispose) {
item.dispose();
}
} finally {
this._toDispose.clear();
}
}

public add<T extends IDisposable>(t: T): T {
if (!t) {
return t;
}
if ((t as any) === this) {
throw new Error('Cannot register a disposable on itself!');
}

if (this._isDisposed) {
if (!DisposableStore.DISABLE_DISPOSED_WARNING) {
console.warn(
new Error(
'Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!'
).stack
);
}
} else {
this._toDispose.add(t);
}

return t;
}
}
35 changes: 35 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,38 @@
{
<<<<<<< HEAD
"name": "monaco-editor",
"private": true,
"version": "0.9.0",
"description": "A browser based code editor",
"author": "Microsoft Corporation",
"license": "MIT",
"scripts": {
"simpleserver": "gulp simpleserver",
"release": "gulp release",
"website": "gulp website"
},
"typings": "./monaco.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/monaco-editor"
},
"devDependencies": {
"clean-css": "^3.4.20",
"event-stream": "^3.3.2",
"gulp": "^3.9.1",
"gulp-typedoc": "^2.0.0",
"http-server": "^0.9.0",
"monaco-css": "1.3.2",
"monaco-editor-core": "0.9.0",
"monaco-html": "1.3.1",
"monaco-json": "1.3.1",
"monaco-languages": "0.8.0",
"monaco-typescript": "2.2.0",
"rimraf": "^2.5.2",
"typedoc": "^0.5.0",
"uncss": "^0.14.1"
}
=======
"name": "monaco-editor",
"version": "0.56.0",
"vscodeRef": "f487add297079a02eb836810185b165e50cadabc",
Expand Down Expand Up @@ -103,4 +137,5 @@
"process": false,
"buffer": false
}
>>>>>>> main
}
Loading