diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js index f6253d55dd8..1d88c0fea0e 100644 --- a/build/gulpfile.vscode.js +++ b/build/gulpfile.vscode.js @@ -32,7 +32,7 @@ var baseModules = [ 'events', 'fs', 'getmac', 'glob', 'graceful-fs', 'http', 'http-proxy-agent', 'https', 'https-proxy-agent', 'iconv-lite', 'electron', 'net', 'os', 'path', 'readline', 'sax', 'semver', 'stream', 'string_decoder', 'url', - 'vscode-textmate', 'winreg', 'yauzl', 'native-keymap', 'weak', 'zlib' + 'vscode-textmate', 'winreg', 'yauzl', 'native-keymap', 'zlib' ]; // Build @@ -201,8 +201,7 @@ function packageTask(platform, arch, opts) { .pipe(util.cleanNodeModule('fsevents', ['binding.gyp', 'fsevents.cc', 'build/**', 'src/**', 'test/**'], true)) .pipe(util.cleanNodeModule('oniguruma', ['binding.gyp', 'build/**', 'src/**', 'deps/**'], true)) .pipe(util.cleanNodeModule('windows-mutex', ['binding.gyp', 'build/**', 'src/**'], true)) - .pipe(util.cleanNodeModule('native-keymap', ['binding.gyp', 'build/**', 'src/**', 'deps/**'], true)) - .pipe(util.cleanNodeModule('weak', ['binding.gyp', 'build/**', 'src/**'], true)); + .pipe(util.cleanNodeModule('native-keymap', ['binding.gyp', 'build/**', 'src/**', 'deps/**'], true)); var all = es.merge( api, diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index bf99d2f3dc6..6ffa2fe8eef 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -449,23 +449,6 @@ "from": "native-keymap@0.1.2", "resolved": "https://registry.npmjs.org/native-keymap/-/native-keymap-0.1.2.tgz" }, - "weak": { - "version": "1.0.1", - "from": "weak@1.0.1", - "resolved": "https://registry.npmjs.org/weak/-/weak-1.0.1.tgz", - "dependencies": { - "bindings": { - "version": "1.2.1", - "from": "bindings@>=1.2.1 <2.0.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz" - }, - "nan": { - "version": "2.2.0", - "from": "nan@>=2.0.5 <3.0.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.2.0.tgz" - } - } - }, "winreg": { "version": "0.0.12", "from": "winreg@0.0.12", diff --git a/package.json b/package.json index c538a5e278e..f81ad6b6dbf 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ "semver": "^4.2.0", "vscode-debugprotocol": "1.8.0-pre.3", "vscode-textmate": "^1.0.11", - "weak": "^1.0.1", "winreg": "0.0.12", "yauzl": "^2.3.1" }, diff --git a/src/typings/weak.d.ts b/src/typings/weak.d.ts deleted file mode 100644 index 39d1d930dc8..00000000000 --- a/src/typings/weak.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -declare namespace weak { - interface WeakRef { - // tagging - } -} - -declare const weak: WeakFunction; - -interface WeakFunction { - (obj: T, callback?: () => any): T & weak.WeakRef; - (obj: any, callback?: () => any): any & weak.WeakRef; - - get(ref: weak.WeakRef): any; - get(ref: weak.WeakRef): T; - - isDead(ref: weak.WeakRef): boolean; - isNearDeath(ref: weak.WeakRef): boolean; - isWeakRef(obj: any): boolean; -} - -declare module 'weak' { - export = weak; -} \ No newline at end of file diff --git a/src/vs/workbench/api/node/extHostDocuments.ts b/src/vs/workbench/api/node/extHostDocuments.ts index d70c8f25467..9a458cda396 100644 --- a/src/vs/workbench/api/node/extHostDocuments.ts +++ b/src/vs/workbench/api/node/extHostDocuments.ts @@ -26,7 +26,6 @@ import {IModeService} from 'vs/editor/common/services/modeService'; import {IUntitledEditorService} from 'vs/workbench/services/untitled/common/untitledEditorService'; import {ResourceEditorInput} from 'vs/workbench/common/editor/resourceEditorInput'; import {asWinJsPromise} from 'vs/base/common/async'; -import * as weak from 'weak'; export interface IModelAddedData { url: URI; @@ -170,14 +169,6 @@ export class ExtHostModelService { return asWinJsPromise(token => provider.provideTextDocumentContent(uri, token)); } - $isDocumentReferenced(uri: URI): TPromise { - const key = uri.toString(); - const document = this._documentData[key]; - if (document) { - return TPromise.as(document.isDocumentReferenced); - } - } - public _acceptModelAdd(initData: IModelAddedData): void { let data = new ExtHostDocumentData(this._proxy, initData.url, initData.value.lines, initData.value.EOL, initData.modeId, initData.versionId, initData.isDirty); let key = data.document.uri.toString(); @@ -246,7 +237,7 @@ export class ExtHostDocumentData extends MirrorModel2 { private _languageId: string; private _isDirty: boolean; private _textLines: vscode.TextLine[]; - private _documentRef: weak.WeakRef & vscode.TextDocument; + private _document: vscode.TextDocument; constructor(proxy: MainThreadDocuments, uri: URI, lines: string[], eol: string, languageId: string, versionId: number, isDirty: boolean) { @@ -265,13 +256,9 @@ export class ExtHostDocumentData extends MirrorModel2 { } get document(): vscode.TextDocument { - // dereferences or creates the actual document for this - // document data. keeps a weak reference only such that - // we later when a document isn't needed anymore - - if (!this.isDocumentReferenced) { + if (!this._document) { const data = this; - const doc = { + this._document = { get uri() { return data._uri; }, get fileName() { return data._uri.fsPath; }, get isUntitled() { return data._uri.scheme !== 'file'; }, @@ -288,13 +275,8 @@ export class ExtHostDocumentData extends MirrorModel2 { validatePosition(pos) { return data.validatePosition(pos); }, getWordRangeAtPosition(pos) { return data.getWordRangeAtPosition(pos); } }; - this._documentRef = weak(doc); } - return weak.get(this._documentRef); - } - - get isDocumentReferenced(): boolean { - return weak.isWeakRef(this._documentRef) && !weak.isDead(this._documentRef); + return this._document; } _acceptLanguageId(newLanguageId: string): void { @@ -507,7 +489,7 @@ export class MainThreadDocuments { } })); - const handle = setInterval(() => this._runDocumentCleanup(), 30 * 1000); + const handle = setInterval(() => this._runDocumentCleanup(), 1000 * 60 * 3); this._toDispose.push({ dispose() { clearInterval(handle); } }); this._modelToDisposeMap = Object.create(null); @@ -676,13 +658,9 @@ export class MainThreadDocuments { TPromise.join(Object.keys(this._virtualDocumentSet).map(key => { let resource = URI.parse(key); - return this._proxy.$isDocumentReferenced(resource).then(referenced => { - if (!referenced) { - return this._editorService.inputToType({ resource }).then(input => { - if (!this._editorService.isVisible(input, true)) { - toBeDisposed.push(resource); - } - }); + return this._editorService.inputToType({ resource }).then(input => { + if (!this._editorService.isVisible(input, true)) { + toBeDisposed.push(resource); } }); })).then(() => {