提交 7c4c828d 编写于 作者: J Johannes Rieken

no more weakness

上级 8fe4d6de
......@@ -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,
......
......@@ -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",
......
/*---------------------------------------------------------------------------------------------
* 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 {
<T>(obj: T, callback?: () => any): T & weak.WeakRef;
(obj: any, callback?: () => any): any & weak.WeakRef;
get(ref: weak.WeakRef): any;
get<T>(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
......@@ -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<boolean> {
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(() => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册