Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
955f02aa
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
955f02aa
编写于
3月 31, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into gallery
上级
f0376cfa
1d136522
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
83 addition
and
16 deletion
+83
-16
src/vs/base/common/lifecycle.ts
src/vs/base/common/lifecycle.ts
+8
-10
src/vs/base/test/common/lifecycle.test.ts
src/vs/base/test/common/lifecycle.test.ts
+52
-0
src/vs/platform/configuration/common/configurationService.ts
src/vs/platform/configuration/common/configurationService.ts
+22
-5
src/vs/workbench/services/configuration/node/configurationService.ts
...bench/services/configuration/node/configurationService.ts
+1
-1
未找到文件。
src/vs/base/common/lifecycle.ts
浏览文件 @
955f02aa
...
...
@@ -14,19 +14,17 @@ export interface IDisposable {
dispose
():
void
;
}
export
function
dispose
<
T
extends
IDisposable
>
(
disposable
:
T
):
T
;
export
function
dispose
<
T
extends
IDisposable
>
(
...
disposables
:
T
[]
):
T
;
export
function
dispose
<
T
extends
IDisposable
>
(
disposables
:
T
[]):
T
[];
export
function
dispose
<
T
extends
IDisposable
>
(...
disposables
:
T
[]):
T
[];
export
function
dispose
<
T
extends
IDisposable
>
(
arg
:
any
):
T
[]
{
if
(
isArray
(
arg
))
{
const
disposables
:
T
[]
=
arg
;
disposables
.
forEach
(
d
=>
d
&&
d
.
dispose
());
return
[];
export
function
dispose
<
T
extends
IDisposable
>
(...
disposables
:
T
[]):
T
[]
{
const
first
=
disposables
[
0
];
if
(
isArray
(
first
))
{
disposables
=
first
as
any
as
T
[];
}
const
disposable
:
T
=
arg
;
disposable
.
dispose
();
return
null
;
disposables
.
forEach
(
d
=>
d
&&
d
.
dispose
());
return
[];
}
export
function
combinedDisposable
(
disposables
:
IDisposable
[]):
IDisposable
;
...
...
src/vs/base/test/common/lifecycle.test.ts
0 → 100644
浏览文件 @
955f02aa
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
class
Disposable
implements
IDisposable
{
isDisposed
=
false
;
dispose
()
{
this
.
isDisposed
=
true
;
}
}
suite
(
'
Lifecycle
'
,
()
=>
{
test
(
'
dispose single disposable
'
,
()
=>
{
const
disposable
=
new
Disposable
();
assert
(
!
disposable
.
isDisposed
);
dispose
(
disposable
);
assert
(
disposable
.
isDisposed
);
});
test
(
'
dispose disposable array
'
,
()
=>
{
const
disposable
=
new
Disposable
();
const
disposable2
=
new
Disposable
();
assert
(
!
disposable
.
isDisposed
);
assert
(
!
disposable2
.
isDisposed
);
dispose
([
disposable
,
disposable2
]);
assert
(
disposable
.
isDisposed
);
assert
(
disposable2
.
isDisposed
);
});
test
(
'
dispose disposables
'
,
()
=>
{
const
disposable
=
new
Disposable
();
const
disposable2
=
new
Disposable
();
assert
(
!
disposable
.
isDisposed
);
assert
(
!
disposable2
.
isDisposed
);
dispose
(
disposable
,
disposable2
);
assert
(
disposable
.
isDisposed
);
assert
(
disposable2
.
isDisposed
);
});
});
\ No newline at end of file
src/vs/platform/configuration/common/configurationService.ts
浏览文件 @
955f02aa
...
...
@@ -11,6 +11,7 @@ import objects = require('vs/base/common/objects');
import
errors
=
require
(
'
vs/base/common/errors
'
);
import
uri
from
'
vs/base/common/uri
'
;
import
model
=
require
(
'
./model
'
);
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
import
lifecycle
=
require
(
'
vs/base/common/lifecycle
'
);
import
collections
=
require
(
'
vs/base/common/collections
'
);
import
{
IConfigurationService
,
ConfigurationServiceEventTypes
}
from
'
./configuration
'
;
...
...
@@ -42,8 +43,11 @@ interface ILoadConfigResult {
}
export
abstract
class
ConfigurationService
extends
eventEmitter
.
EventEmitter
implements
IConfigurationService
,
lifecycle
.
IDisposable
{
public
serviceId
=
IConfigurationService
;
private
static
RELOAD_CONFIGURATION_DELAY
=
50
;
public
onDidUpdateConfiguration
:
Event
<
{
config
:
any
}
>
;
protected
contextService
:
IWorkspaceContextService
;
...
...
@@ -54,6 +58,7 @@ export abstract class ConfigurationService extends eventEmitter.EventEmitter imp
private
bulkFetchFromWorkspacePromise
:
winjs
.
TPromise
<
any
>
;
private
workspaceFilePathToConfiguration
:
{
[
relativeWorkspacePath
:
string
]:
winjs
.
TPromise
<
model
.
IConfigFile
>
};
private
callOnDispose
:
Function
;
private
reloadConfigurationScheduler
:
RunOnceScheduler
;
constructor
(
contextService
:
IWorkspaceContextService
,
eventService
:
IEventService
,
workspaceSettingsRootFolder
:
string
=
'
.vscode
'
)
{
super
();
...
...
@@ -65,7 +70,7 @@ export abstract class ConfigurationService extends eventEmitter.EventEmitter imp
this
.
workspaceFilePathToConfiguration
=
Object
.
create
(
null
);
let
unbind
=
this
.
eventService
.
addListener
(
Files
.
EventType
.
FILE_CHANGES
,
(
events
)
=>
this
.
handleFileEvents
(
events
));
let
subscription
=
(
<
IConfigurationRegistry
>
Registry
.
as
(
Extensions
.
Configuration
)).
onDidRegisterConfiguration
(()
=>
this
.
reload
AndEmit
());
let
subscription
=
(
<
IConfigurationRegistry
>
Registry
.
as
(
Extensions
.
Configuration
)).
onDidRegisterConfiguration
(()
=>
this
.
reload
Configuration
());
this
.
callOnDispose
=
()
=>
{
unbind
();
subscription
.
dispose
();
...
...
@@ -81,6 +86,10 @@ export abstract class ConfigurationService extends eventEmitter.EventEmitter imp
protected
abstract
resolveStat
(
resource
:
uri
):
winjs
.
TPromise
<
IStat
>
;
public
dispose
():
void
{
if
(
this
.
reloadConfigurationScheduler
)
{
this
.
reloadConfigurationScheduler
.
dispose
();
}
this
.
callOnDispose
=
lifecycle
.
cAll
(
this
.
callOnDispose
);
super
.
dispose
();
...
...
@@ -175,11 +184,19 @@ export abstract class ConfigurationService extends eventEmitter.EventEmitter imp
});
}
protected
reloadAndEmit
():
winjs
.
TPromise
<
void
>
{
return
this
.
reloadConfiguration
().
then
((
config
)
=>
this
.
emit
(
ConfigurationServiceEventTypes
.
UPDATED
,
{
config
:
config
}));
protected
reloadConfiguration
():
void
{
if
(
!
this
.
reloadConfigurationScheduler
)
{
this
.
reloadConfigurationScheduler
=
new
RunOnceScheduler
(()
=>
{
this
.
doReloadConfiguration
().
then
((
config
)
=>
this
.
emit
(
ConfigurationServiceEventTypes
.
UPDATED
,
{
config
:
config
})).
done
(
null
,
errors
.
onUnexpectedError
);
},
ConfigurationService
.
RELOAD_CONFIGURATION_DELAY
);
}
if
(
!
this
.
reloadConfigurationScheduler
.
isScheduled
())
{
this
.
reloadConfigurationScheduler
.
schedule
();
}
}
private
r
eloadConfiguration
(
section
?:
string
):
winjs
.
TPromise
<
any
>
{
private
doR
eloadConfiguration
(
section
?:
string
):
winjs
.
TPromise
<
any
>
{
this
.
loadConfigurationPromise
=
null
;
return
this
.
loadConfiguration
(
section
);
...
...
@@ -219,7 +236,7 @@ export abstract class ConfigurationService extends eventEmitter.EventEmitter imp
}
if
(
affectedByChanges
)
{
this
.
reload
AndEmit
();
this
.
reload
Configuration
();
}
}
}
src/vs/workbench/services/configuration/node/configurationService.ts
浏览文件 @
955f02aa
...
...
@@ -94,7 +94,7 @@ export class ConfigurationService extends CommonConfigurationService {
private
onOptionsChanged
(
e
:
OptionsChangeEvent
):
void
{
if
(
e
.
key
===
'
globalSettings
'
)
{
this
.
reload
AndEmit
();
this
.
reload
Configuration
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录