Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0d096fed
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,发现更多精彩内容 >>
提交
0d096fed
编写于
10月 05, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avoid input creation for checking for dirty state
上级
b61ae53c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
55 addition
and
44 deletion
+55
-44
src/vs/workbench/electron-browser/workbench.ts
src/vs/workbench/electron-browser/workbench.ts
+3
-3
src/vs/workbench/services/configuration/node/configurationEditingService.ts
...ervices/configuration/node/configurationEditingService.ts
+22
-24
src/vs/workbench/services/configuration/test/node/configurationEditingService.test.ts
...nfiguration/test/node/configurationEditingService.test.ts
+30
-17
未找到文件。
src/vs/workbench/electron-browser/workbench.ts
浏览文件 @
0d096fed
...
...
@@ -389,6 +389,9 @@ export class Workbench implements IPartService {
// History
serviceCollection
.
set
(
IHistoryService
,
this
.
instantiationService
.
createInstance
(
HistoryService
));
// Text File Service
serviceCollection
.
set
(
ITextFileService
,
this
.
instantiationService
.
createInstance
(
TextFileService
));
// Configuration Editing
serviceCollection
.
set
(
IConfigurationEditingService
,
this
.
instantiationService
.
createInstance
(
ConfigurationEditingService
));
...
...
@@ -403,9 +406,6 @@ export class Workbench implements IPartService {
this
.
toShutdown
.
push
(
this
.
quickOpen
);
serviceCollection
.
set
(
IQuickOpenService
,
this
.
quickOpen
);
// Text File Service
serviceCollection
.
set
(
ITextFileService
,
this
.
instantiationService
.
createInstance
(
TextFileService
));
// Contributed services
const
contributedServices
=
getServices
();
for
(
let
contributedService
of
contributedServices
)
{
...
...
src/vs/workbench/services/configuration/node/configurationEditingService.ts
浏览文件 @
0d096fed
...
...
@@ -12,11 +12,11 @@ import * as json from 'vs/base/common/json';
import
*
as
encoding
from
'
vs/base/node/encoding
'
;
import
strings
=
require
(
'
vs/base/common/strings
'
);
import
{
getConfigurationKeys
}
from
'
vs/platform/configuration/common/model
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
setProperty
}
from
'
vs/base/common/jsonEdit
'
;
import
{
applyEdits
}
from
'
vs/base/common/jsonFormatter
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
WORKSPACE_CONFIG_DEFAULT_PATH
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
...
...
@@ -47,7 +47,7 @@ export class ConfigurationEditingService implements IConfigurationEditingService
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
,
@
IFileService
private
fileService
:
IFileService
,
@
I
WorkbenchEditorService
private
editorService
:
IWorkbenchEditor
Service
@
I
TextFileService
private
textFileService
:
ITextFile
Service
)
{
}
...
...
@@ -160,33 +160,31 @@ export class ConfigurationEditingService implements IConfigurationEditingService
// Target cannot be dirty
const
resource
=
operation
.
target
;
return
this
.
editorService
.
createInput
({
resource
}).
then
(
typedInput
=>
{
if
(
typedInput
.
isDirty
())
{
return
{
error
:
ConfigurationEditingErrorCode
.
ERROR_CONFIGURATION_FILE_DIRTY
};
}
if
(
this
.
textFileService
.
isDirty
(
resource
))
{
return
TPromise
.
as
({
error
:
ConfigurationEditingErrorCode
.
ERROR_CONFIGURATION_FILE_DIRTY
});
}
return
this
.
fileService
.
existsFile
(
resource
).
then
(
exists
=>
{
if
(
!
exists
)
{
return
{
exists
};
}
return
this
.
fileService
.
existsFile
(
resource
).
then
(
exists
=>
{
if
(
!
exists
)
{
return
{
exists
};
}
return
this
.
fileService
.
resolveContent
(
resource
,
{
acceptTextOnly
:
true
,
encoding
:
encoding
.
UTF8
}).
then
(
content
=>
{
return
this
.
fileService
.
resolveContent
(
resource
,
{
acceptTextOnly
:
true
,
encoding
:
encoding
.
UTF8
}).
then
(
content
=>
{
// If we write to a workspace standalone file and replace the entire contents (no key provided)
// we can return here because any parse errors can safely be ignored since all contents are replaced
if
(
operation
.
isWorkspaceStandalone
&&
!
operation
.
key
)
{
return
{
exists
,
contents
:
content
.
value
};
}
// If we write to a workspace standalone file and replace the entire contents (no key provided)
// we can return here because any parse errors can safely be ignored since all contents are replaced
if
(
operation
.
isWorkspaceStandalone
&&
!
operation
.
key
)
{
return
{
exists
,
contents
:
content
.
value
};
}
// Target cannot contain JSON errors
const
parseErrors
=
[];
json
.
parse
(
content
.
value
,
parseErrors
);
if
(
parseErrors
.
length
>
0
)
{
return
{
error
:
ConfigurationEditingErrorCode
.
ERROR_INVALID_CONFIGURATION
};
}
// Target cannot contain JSON errors
const
parseErrors
=
[];
json
.
parse
(
content
.
value
,
parseErrors
);
if
(
parseErrors
.
length
>
0
)
{
return
{
error
:
ConfigurationEditingErrorCode
.
ERROR_INVALID_CONFIGURATION
};
}
return
{
exists
,
contents
:
content
.
value
};
});
return
{
exists
,
contents
:
content
.
value
};
});
});
}
...
...
src/vs/workbench/services/configuration/test/node/configurationEditingService.test.ts
浏览文件 @
0d096fed
...
...
@@ -13,10 +13,10 @@ import * as json from 'vs/base/common/json';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
ParsedArgs
,
parseArgs
}
from
'
vs/platform/environment/node/argv
'
;
import
{
WorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
WorkspaceContextService
,
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
EnvironmentService
}
from
'
vs/platform/environment/node/environmentService
'
;
import
extfs
=
require
(
'
vs/base/node/extfs
'
);
import
{
TestEventService
,
TestEditor
Service
}
from
'
vs/test/utils/servicesTestUtils
'
;
import
{
TestEventService
,
workbenchInstantiationService
,
TestTextFile
Service
}
from
'
vs/test/utils/servicesTestUtils
'
;
import
uuid
=
require
(
'
vs/base/common/uuid
'
);
import
{
IConfigurationRegistry
,
Extensions
as
ConfigurationExtensions
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
WorkspaceConfigurationService
}
from
'
vs/workbench/services/configuration/node/configurationService
'
;
...
...
@@ -25,7 +25,14 @@ import utils = require('vs/workbench/services/files/test/node/utils');
import
{
FileService
}
from
'
vs/workbench/services/files/node/fileService
'
;
import
{
ConfigurationEditingService
,
WORKSPACE_STANDALONE_CONFIGURATIONS
}
from
'
vs/workbench/services/configuration/node/configurationEditingService
'
;
import
{
ConfigurationTarget
,
IConfigurationEditingError
,
ConfigurationEditingErrorCode
}
from
'
vs/workbench/services/configuration/common/configurationEditing
'
;
import
{
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
class
SettingsTestEnvironmentService
extends
EnvironmentService
{
...
...
@@ -36,19 +43,25 @@ class SettingsTestEnvironmentService extends EnvironmentService {
get
appSettingsPath
():
string
{
return
this
.
customAppSettingsHome
;
}
}
class
TestWorkbenchEditorService
extends
TestEditorService
{
constructor
(
private
dirty
:
boolean
)
{
super
();
class
TestDirtyTextFileService
extends
TestTextFileService
{
constructor
(
private
dirty
:
boolean
,
@
ILifecycleService
lifecycleService
:
ILifecycleService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
,
@
IEditorGroupService
editorGroupService
:
IEditorGroupService
,
@
IFileService
fileService
:
IFileService
,
@
IUntitledEditorService
untitledEditorService
:
IUntitledEditorService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
)
{
super
(
lifecycleService
,
contextService
,
configurationService
,
telemetryService
,
editorService
,
editorGroupService
,
fileService
,
untitledEditorService
,
instantiationService
);
}
public
createInput
(
input
:
IResourceInput
):
TPromise
<
any
>
{
return
TPromise
.
as
({
getName
:
()
=>
'
name
'
,
getDescription
:
()
=>
'
description
'
,
isDirty
:
()
=>
this
.
dirty
,
matches
:
()
=>
false
});
public
isDirty
(
resource
?:
URI
):
boolean
{
return
this
.
dirty
;
}
}
...
...
@@ -70,14 +83,14 @@ suite('WorkspaceConfigurationEditingService - Node', () => {
const
workspaceContextService
=
new
WorkspaceContextService
(
noWorkspace
?
null
:
{
resource
:
URI
.
file
(
workspaceDir
)
});
const
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
globalSettingsFile
);
const
configurationService
=
new
WorkspaceConfigurationService
(
workspaceContextService
,
new
TestEventService
(),
environmentService
);
const
editorService
=
new
TestWorkbenchEditorService
(
dirty
);
const
textFileService
=
workbenchInstantiationService
().
createInstance
(
TestDirtyTextFileService
,
dirty
);
const
events
=
new
utils
.
TestEventService
();
const
fileService
=
new
FileService
(
noWorkspace
?
null
:
workspaceDir
,
{
disableWatcher
:
true
},
events
);
return
configurationService
.
initialize
().
then
(()
=>
{
return
{
configurationEditingService
:
new
ConfigurationEditingService
(
configurationService
,
workspaceContextService
,
environmentService
,
fileService
,
editor
Service
),
configurationService
:
configurationService
configurationEditingService
:
new
ConfigurationEditingService
(
configurationService
,
workspaceContextService
,
environmentService
,
fileService
,
textFile
Service
),
configurationService
};
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录