Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
0a2d071e
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0a2d071e
编写于
11月 08, 2018
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Strict null checking config
上级
f742c33a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
18 deletion
+28
-18
src/tsconfig.strictNullChecks.json
src/tsconfig.strictNullChecks.json
+12
-2
src/vs/base/node/config.ts
src/vs/base/node/config.ts
+16
-16
未找到文件。
src/tsconfig.strictNullChecks.json
浏览文件 @
0a2d071e
...
...
@@ -66,6 +66,7 @@
"./vs/base/common/jsonFormatter.ts"
,
"./vs/base/common/paths.ts"
,
"./vs/base/common/uriIpc.ts"
,
"./vs/base/node/config.ts"
,
"./vs/base/node/console.ts"
,
"./vs/base/node/crypto.ts"
,
"./vs/base/node/decoder.ts"
,
...
...
@@ -94,6 +95,7 @@
"./vs/base/parts/ipc/test/node/testApp.ts"
,
"./vs/base/parts/ipc/test/node/testService.ts"
,
"./vs/base/parts/quickopen/common/quickOpen.ts"
,
"./vs/base/parts/quickopen/common/quickOpenScorer.ts"
,
"./vs/base/test/browser/ui/grid/util.ts"
,
"./vs/base/test/common/json.test.ts"
,
"./vs/base/test/common/jsonEdit.test.ts"
,
...
...
@@ -468,6 +470,12 @@
"./vs/platform/quickOpen/common/quickOpen.ts"
,
"./vs/platform/quickinput/common/quickInput.ts"
,
"./vs/platform/registry/common/platform.ts"
,
"./vs/platform/remote/common/remoteAuthorityResolver.ts"
,
"./vs/platform/remote/common/remoteHosts.ts"
,
"./vs/platform/remote/node/remoteAgentConnection.ts"
,
"./vs/platform/remote/node/remoteAgentFileSystemChannel.ts"
,
"./vs/platform/remote/node/remoteAuthorityResolverChannel.ts"
,
"./vs/platform/remote/node/remoteAuthorityResolverService.ts"
,
"./vs/platform/request/electron-browser/requestService.ts"
,
"./vs/platform/request/electron-main/requestService.ts"
,
"./vs/platform/request/node/request.ts"
,
...
...
@@ -652,10 +660,13 @@
"./vs/workbench/services/keybinding/common/macLinuxFallbackKeyboardMapper.ts"
,
"./vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts"
,
"./vs/workbench/services/keybinding/common/windowsKeyboardMapper.ts"
,
"./vs/workbench/services/keybinding/electron-browser/keybindingService.ts"
,
"./vs/workbench/services/mode/common/workbenchModeService.ts"
,
"./vs/workbench/services/notification/common/notificationService.ts"
,
"./vs/workbench/services/panel/common/panelService.ts"
,
"./vs/workbench/services/part/common/partService.ts"
,
"./vs/workbench/services/remote/node/remoteAgentEnvironmentChannel.ts"
,
"./vs/workbench/services/remote/node/remoteAgentService.ts"
,
"./vs/workbench/services/scm/common/scm.ts"
,
"./vs/workbench/services/scm/common/scmService.ts"
,
"./vs/workbench/services/search/common/searchHelpers.ts"
,
...
...
@@ -680,8 +691,7 @@
"./vs/workbench/services/themes/common/workbenchThemeService.ts"
,
"./vs/workbench/services/title/common/titleService.ts"
,
"./vs/workbench/services/workspace/common/workspaceEditing.ts"
,
"./vs/workbench/test/electron-browser/api/mock.ts"
,
"./vs/base/parts/quickopen/common/quickOpenScorer.ts"
"./vs/workbench/test/electron-browser/api/mock.ts"
],
"exclude"
:
[
"./typings/require-monaco.d.ts"
,
...
...
src/vs/base/node/config.ts
浏览文件 @
0a2d071e
...
...
@@ -13,7 +13,7 @@ import * as extfs from 'vs/base/node/extfs';
import
{
isWindows
}
from
'
vs/base/common/platform
'
;
export
interface
IConfigurationChangeEvent
<
T
>
{
config
:
T
;
config
?
:
T
;
}
export
interface
IConfigWatcher
<
T
>
{
...
...
@@ -21,8 +21,8 @@ export interface IConfigWatcher<T> {
hasParseErrors
:
boolean
;
reload
(
callback
:
(
config
:
T
)
=>
void
):
void
;
getConfig
():
T
;
getValue
<
V
>
(
key
:
string
,
fallback
?:
V
):
V
;
getConfig
():
T
|
undefined
;
getValue
<
V
>
(
key
:
string
,
fallback
?:
V
):
V
|
undefined
;
}
export
interface
IConfigOptions
<
T
>
{
...
...
@@ -30,7 +30,7 @@ export interface IConfigOptions<T> {
defaultConfig
?:
T
;
changeBufferDelay
?:
number
;
parse
?:
(
content
:
string
,
errors
:
any
[])
=>
T
;
initCallback
?:
(
config
:
T
)
=>
void
;
initCallback
?:
(
config
:
T
|
undefined
)
=>
void
;
}
/**
...
...
@@ -42,11 +42,11 @@ export interface IConfigOptions<T> {
* - configurable defaults
*/
export
class
ConfigWatcher
<
T
>
implements
IConfigWatcher
<
T
>
,
IDisposable
{
private
cache
:
T
;
private
cache
?
:
T
;
private
parseErrors
:
json
.
ParseError
[];
private
disposed
:
boolean
;
private
loaded
:
boolean
;
private
timeoutHandle
:
NodeJS
.
Timer
;
private
timeoutHandle
:
any
;
private
disposables
:
IDisposable
[];
private
readonly
_onDidUpdateConfiguration
:
Emitter
<
IConfigurationChangeEvent
<
T
>>
;
private
configName
:
string
;
...
...
@@ -85,12 +85,12 @@ export class ConfigWatcher<T> implements IConfigWatcher<T>, IDisposable {
});
}
private
updateCache
(
value
:
T
):
void
{
private
updateCache
(
value
:
T
|
undefined
):
void
{
this
.
cache
=
value
;
this
.
loaded
=
true
;
}
private
loadSync
():
T
{
private
loadSync
():
T
|
undefined
{
try
{
return
this
.
parse
(
fs
.
readFileSync
(
this
.
_path
).
toString
());
}
catch
(
error
)
{
...
...
@@ -98,7 +98,7 @@ export class ConfigWatcher<T> implements IConfigWatcher<T>, IDisposable {
}
}
private
loadAsync
(
callback
:
(
config
:
T
)
=>
void
):
void
{
private
loadAsync
(
callback
:
(
config
:
T
|
undefined
)
=>
void
):
void
{
fs
.
readFile
(
this
.
_path
,
(
error
,
raw
)
=>
{
if
(
error
)
{
return
callback
(
this
.
options
.
defaultConfig
);
...
...
@@ -108,8 +108,8 @@ export class ConfigWatcher<T> implements IConfigWatcher<T>, IDisposable {
});
}
private
parse
(
raw
:
string
):
T
{
let
res
:
T
;
private
parse
(
raw
:
string
):
T
|
undefined
{
let
res
:
T
|
undefined
;
try
{
this
.
parseErrors
=
[];
res
=
this
.
options
.
parse
?
this
.
options
.
parse
(
raw
,
this
.
parseErrors
)
:
json
.
parse
(
raw
,
this
.
parseErrors
);
...
...
@@ -156,7 +156,7 @@ export class ConfigWatcher<T> implements IConfigWatcher<T>, IDisposable {
));
}
private
onConfigFileChange
(
eventType
:
string
,
filename
:
string
,
isParentFolder
:
boolean
):
void
{
private
onConfigFileChange
(
eventType
:
string
,
filename
:
string
|
undefined
,
isParentFolder
:
boolean
):
void
{
if
(
isParentFolder
)
{
// Windows: in some cases the filename contains artifacts from the absolute path
...
...
@@ -177,10 +177,10 @@ export class ConfigWatcher<T> implements IConfigWatcher<T>, IDisposable {
}
// we can get multiple change events for one change, so we buffer through a timeout
this
.
timeoutHandle
=
global
.
setTimeout
(()
=>
this
.
reload
(),
this
.
options
.
changeBufferDelay
);
this
.
timeoutHandle
=
global
.
setTimeout
(()
=>
this
.
reload
(),
this
.
options
.
changeBufferDelay
||
0
);
}
public
reload
(
callback
?:
(
config
:
T
)
=>
void
):
void
{
public
reload
(
callback
?:
(
config
:
T
|
undefined
)
=>
void
):
void
{
this
.
loadAsync
(
currentConfig
=>
{
if
(
!
objects
.
equals
(
currentConfig
,
this
.
cache
))
{
this
.
updateCache
(
currentConfig
);
...
...
@@ -194,13 +194,13 @@ export class ConfigWatcher<T> implements IConfigWatcher<T>, IDisposable {
});
}
public
getConfig
():
T
{
public
getConfig
():
T
|
undefined
{
this
.
ensureLoaded
();
return
this
.
cache
;
}
public
getValue
<
V
>
(
key
:
string
,
fallback
?:
V
):
V
{
public
getValue
<
V
>
(
key
:
string
,
fallback
?:
V
):
V
|
undefined
{
this
.
ensureLoaded
();
if
(
!
key
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录