Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d296132a
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,体验更适合开发者的 AI 搜索 >>
提交
d296132a
编写于
4月 04, 2019
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove hash service and make createSHA as browser util
上级
844716ab
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
45 addition
and
69 deletion
+45
-69
src/vs/base/browser/hash.ts
src/vs/base/browser/hash.ts
+15
-0
src/vs/base/test/browser/hash.test.ts
src/vs/base/test/browser/hash.test.ts
+16
-0
src/vs/workbench/electron-browser/main.ts
src/vs/workbench/electron-browser/main.ts
+3
-9
src/vs/workbench/services/configuration/browser/configuration.ts
...workbench/services/configuration/browser/configuration.ts
+3
-5
src/vs/workbench/services/configuration/browser/configurationService.ts
...ch/services/configuration/browser/configurationService.ts
+1
-3
src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts
...test/electron-browser/configurationEditingService.test.ts
+1
-2
src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts
...ration/test/electron-browser/configurationService.test.ts
+6
-7
src/vs/workbench/services/hash/common/hashService.ts
src/vs/workbench/services/hash/common/hashService.ts
+0
-33
src/vs/workbench/test/workbenchTestServices.ts
src/vs/workbench/test/workbenchTestServices.ts
+0
-10
未找到文件。
src/vs/
workbench/services/hash/node/hashService
.ts
→
src/vs/
base/browser/hash
.ts
浏览文件 @
d296132a
...
...
@@ -3,14 +3,13 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
createHash
}
from
'
crypto
'
;
import
{
IHashService
}
from
'
vs/workbench/services/hash/common/hashService
'
;
export
class
HashService
implements
IHashService
{
_serviceBrand
:
any
;
createSHA1
(
content
:
string
):
Promise
<
string
>
{
return
Promise
.
resolve
(
createHash
(
'
sha1
'
).
update
(
content
).
digest
(
'
hex
'
));
export
function
createSHA1
(
content
:
string
):
Thenable
<
string
>
{
if
(
typeof
require
!==
'
undefined
'
)
{
const
_crypto
:
typeof
crypto
=
require
.
__$__nodeRequire
(
'
crypto
'
);
return
Promise
.
resolve
(
_crypto
[
'
createHash
'
](
'
sha1
'
).
update
(
content
).
digest
(
'
hex
'
));
}
}
return
crypto
.
subtle
.
digest
(
'
SHA-1
'
,
new
TextEncoder
().
encode
(
content
)).
then
(
buffer
=>
{
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest#Converting_a_digest_to_a_hex_string
return
Array
.
prototype
.
map
.
call
(
new
Uint8Array
(
buffer
),
(
value
:
number
)
=>
`00
${
value
.
toString
(
16
)}
`
.
slice
(
-
2
)).
join
(
''
);
});
}
\ No newline at end of file
src/vs/
workbench/services/hash/test/hashService
.test.ts
→
src/vs/
base/test/browser/hash
.test.ts
浏览文件 @
d296132a
...
...
@@ -2,19 +2,15 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
assert
from
'
assert
'
;
import
{
HashService
}
from
'
vs/workbench/services/hash/common/hashService
'
;
suite
(
'
Hash Service
'
,
()
=>
{
import
{
createSHA1
}
from
'
vs/base/browser/hash
'
;
suite
(
'
Hash
'
,
()
=>
{
test
(
'
computeSHA1Hash
'
,
async
()
=>
{
const
service
=
new
HashService
();
assert
.
equal
(
await
service
.
createSHA1
(
''
),
'
da39a3ee5e6b4b0d3255bfef95601890afd80709
'
);
assert
.
equal
(
await
service
.
createSHA1
(
'
hello world
'
),
'
2aae6c35c94fcfb415dbe95f408b9ce91ee846ed
'
);
assert
.
equal
(
await
service
.
createSHA1
(
'
da39a3ee5e6b4b0d3255bfef95601890afd80709
'
),
'
10a34637ad661d98ba3344717656fcc76209c2f8
'
);
assert
.
equal
(
await
service
.
createSHA1
(
'
2aae6c35c94fcfb415dbe95f408b9ce91ee846ed
'
),
'
d6b0d82cea4269b51572b8fab43adcee9fc3cf9a
'
);
assert
.
equal
(
await
service
.
createSHA1
(
'
öäü_?ß()<>ÖÄÜ
'
),
'
b64beaeff9e317b0193c8e40a2431b210388eba9
'
);
assert
.
equal
(
await
createSHA1
(
''
),
'
da39a3ee5e6b4b0d3255bfef95601890afd80709
'
);
assert
.
equal
(
await
createSHA1
(
'
hello world
'
),
'
2aae6c35c94fcfb415dbe95f408b9ce91ee846ed
'
);
assert
.
equal
(
await
createSHA1
(
'
da39a3ee5e6b4b0d3255bfef95601890afd80709
'
),
'
10a34637ad661d98ba3344717656fcc76209c2f8
'
);
assert
.
equal
(
await
createSHA1
(
'
2aae6c35c94fcfb415dbe95f408b9ce91ee846ed
'
),
'
d6b0d82cea4269b51572b8fab43adcee9fc3cf9a
'
);
assert
.
equal
(
await
createSHA1
(
'
öäü_?ß()<>ÖÄÜ
'
),
'
b64beaeff9e317b0193c8e40a2431b210388eba9
'
);
});
});
\ No newline at end of file
src/vs/workbench/electron-browser/main.ts
浏览文件 @
d296132a
...
...
@@ -50,8 +50,6 @@ import { IChannel } from 'vs/base/parts/ipc/common/ipc';
import
{
REMOTE_FILE_SYSTEM_CHANNEL_NAME
,
RemoteExtensionsFileSystemProvider
}
from
'
vs/platform/remote/common/remoteAgentFileSystemChannel
'
;
import
{
REMOTE_HOST_SCHEME
}
from
'
vs/platform/remote/common/remoteHosts
'
;
import
{
DefaultConfigurationExportHelper
}
from
'
vs/workbench/services/configuration/node/configurationExportHelper
'
;
import
{
HashService
}
from
'
vs/workbench/services/hash/node/hashService
'
;
import
{
IHashService
}
from
'
vs/workbench/services/hash/common/hashService
'
;
import
{
ConfigurationCache
}
from
'
vs/workbench/services/configuration/node/configurationCache
'
;
import
{
ConfigurationFileService
}
from
'
vs/workbench/services/configuration/node/configurationFileService
'
;
...
...
@@ -206,12 +204,8 @@ class CodeRendererMain extends Disposable {
fileService
.
registerProvider
(
REMOTE_HOST_SCHEME
,
remoteFileSystemProvider
);
}
// Hash Service
const
hashService
=
new
HashService
();
serviceCollection
.
set
(
IHashService
,
hashService
);
return
this
.
resolveWorkspaceInitializationPayload
(
environmentService
).
then
(
payload
=>
Promise
.
all
([
this
.
createWorkspaceService
(
payload
,
environmentService
,
hashService
,
remoteAgentService
,
logService
).
then
(
service
=>
{
this
.
createWorkspaceService
(
payload
,
environmentService
,
remoteAgentService
,
logService
).
then
(
service
=>
{
// Workspace
serviceCollection
.
set
(
IWorkspaceContextService
,
service
);
...
...
@@ -302,8 +296,8 @@ class CodeRendererMain extends Disposable {
},
error
=>
onUnexpectedError
(
error
));
}
private
createWorkspaceService
(
payload
:
IWorkspaceInitializationPayload
,
environmentService
:
IEnvironmentService
,
hashService
:
IHashService
,
remoteAgentService
:
IRemoteAgentService
,
logService
:
ILogService
):
Promise
<
WorkspaceService
>
{
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
URI
.
file
(
environmentService
.
appSettingsPath
),
remoteAuthority
:
this
.
configuration
.
remoteAuthority
,
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
ConfigurationFileService
(),
hashService
,
remoteAgentService
);
private
createWorkspaceService
(
payload
:
IWorkspaceInitializationPayload
,
environmentService
:
IEnvironmentService
,
remoteAgentService
:
IRemoteAgentService
,
logService
:
ILogService
):
Promise
<
WorkspaceService
>
{
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
URI
.
file
(
environmentService
.
appSettingsPath
),
remoteAuthority
:
this
.
configuration
.
remoteAuthority
,
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
ConfigurationFileService
(),
remoteAgentService
);
return
workspaceService
.
initialize
(
payload
).
then
(()
=>
workspaceService
,
error
=>
{
onUnexpectedError
(
error
);
...
...
src/vs/workbench/services/configuration/browser/configuration.ts
浏览文件 @
d296132a
...
...
@@ -21,7 +21,7 @@ import { extname, join } from 'vs/base/common/path';
import
{
equals
}
from
'
vs/base/common/objects
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
IConfigurationModel
,
compare
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IHashService
}
from
'
vs/workbench/services/hash/common/hashService
'
;
import
{
createSHA1
}
from
'
vs/base/browser/hash
'
;
export
class
LocalUserConfiguration
extends
Disposable
{
...
...
@@ -789,11 +789,10 @@ class CachedFolderConfiguration extends Disposable implements IFolderConfigurati
constructor
(
folder
:
URI
,
configFolderRelativePath
:
string
,
hashService
:
IHashService
,
private
readonly
configurationCache
:
IConfigurationCache
)
{
super
();
this
.
key
=
hashService
.
createSHA1
(
join
(
folder
.
path
,
configFolderRelativePath
)).
then
(
key
=>
(
<
ConfigurationKey
>
{
type
:
'
folder
'
,
key
}));
this
.
key
=
createSHA1
(
join
(
folder
.
path
,
configFolderRelativePath
)).
then
(
key
=>
(
<
ConfigurationKey
>
{
type
:
'
folder
'
,
key
}));
this
.
configurationModel
=
new
ConfigurationModel
();
}
...
...
@@ -841,7 +840,6 @@ export class FolderConfiguration extends Disposable implements IFolderConfigurat
readonly
workspaceFolder
:
IWorkspaceFolder
,
configFolderRelativePath
:
string
,
private
readonly
workbenchState
:
WorkbenchState
,
hashService
:
IHashService
,
configurationFileService
:
IConfigurationFileService
,
configurationCache
:
IConfigurationCache
,
fileService
?:
IFileService
...
...
@@ -849,7 +847,7 @@ export class FolderConfiguration extends Disposable implements IFolderConfigurat
super
();
this
.
configurationFolder
=
resources
.
joinPath
(
workspaceFolder
.
uri
,
configFolderRelativePath
);
this
.
cachedFolderConfiguration
=
new
CachedFolderConfiguration
(
workspaceFolder
.
uri
,
configFolderRelativePath
,
hashService
,
configurationCache
);
this
.
cachedFolderConfiguration
=
new
CachedFolderConfiguration
(
workspaceFolder
.
uri
,
configFolderRelativePath
,
configurationCache
);
this
.
folderConfiguration
=
this
.
cachedFolderConfiguration
;
if
(
fileService
)
{
this
.
folderConfiguration
=
new
FileServiceBasedFolderConfiguration
(
this
.
configurationFolder
,
this
.
workbenchState
,
fileService
);
...
...
src/vs/workbench/services/configuration/browser/configurationService.ts
浏览文件 @
d296132a
...
...
@@ -31,7 +31,6 @@ import { isEqual, dirname } from 'vs/base/common/resources';
import
{
mark
}
from
'
vs/base/common/performance
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
IRemoteAgentService
}
from
'
vs/workbench/services/remote/common/remoteAgentService
'
;
import
{
IHashService
}
from
'
vs/workbench/services/hash/common/hashService
'
;
export
class
WorkspaceService
extends
Disposable
implements
IConfigurationService
,
IWorkspaceContextService
{
...
...
@@ -68,7 +67,6 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
constructor
(
{
userSettingsResource
,
remoteAuthority
,
configurationCache
}:
{
userSettingsResource
?:
URI
,
remoteAuthority
?:
string
,
configurationCache
:
IConfigurationCache
},
private
readonly
configurationFileService
:
IConfigurationFileService
,
private
readonly
hashService
:
IHashService
,
private
readonly
remoteAgentService
:
IRemoteAgentService
,
)
{
super
();
...
...
@@ -631,7 +629,7 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
return
Promise
.
all
([...
folders
.
map
(
folder
=>
{
let
folderConfiguration
=
this
.
cachedFolderConfigs
.
get
(
folder
.
uri
);
if
(
!
folderConfiguration
)
{
folderConfiguration
=
new
FolderConfiguration
(
folder
,
FOLDER_CONFIG_FOLDER_NAME
,
this
.
getWorkbenchState
(),
this
.
hashService
,
this
.
configurationFileService
,
this
.
configurationCache
,
this
.
fileService
);
folderConfiguration
=
new
FolderConfiguration
(
folder
,
FOLDER_CONFIG_FOLDER_NAME
,
this
.
getWorkbenchState
(),
this
.
configurationFileService
,
this
.
configurationCache
,
this
.
fileService
);
this
.
_register
(
folderConfiguration
.
onDidChange
(()
=>
this
.
onWorkspaceFolderConfigurationChanged
(
folder
)));
this
.
cachedFolderConfigs
.
set
(
folder
.
uri
,
this
.
_register
(
folderConfiguration
));
}
...
...
src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts
浏览文件 @
d296132a
...
...
@@ -39,7 +39,6 @@ import { NullLogService } from 'vs/platform/log/common/log';
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
DiskFileSystemProvider
}
from
'
vs/workbench/services/files2/node/diskFileSystemProvider
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
HashService
}
from
'
vs/workbench/services/hash/node/hashService
'
;
import
{
ConfigurationCache
}
from
'
vs/workbench/services/configuration/node/configurationCache
'
;
import
{
ConfigurationFileService
}
from
'
vs/workbench/services/configuration/node/configurationFileService
'
;
...
...
@@ -107,7 +106,7 @@ suite('ConfigurationEditingService', () => {
instantiationService
.
stub
(
IEnvironmentService
,
environmentService
);
const
remoteAgentService
=
instantiationService
.
createInstance
(
RemoteAgentService
,
{});
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
URI
.
file
(
environmentService
.
appSettingsPath
),
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
ConfigurationFileService
(),
new
HashService
(),
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
URI
.
file
(
environmentService
.
appSettingsPath
),
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
ConfigurationFileService
(),
remoteAgentService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
return
workspaceService
.
initialize
(
noWorkspace
?
{
id
:
''
}
:
{
folder
:
URI
.
file
(
workspaceDir
),
id
:
createHash
(
'
md5
'
).
update
(
URI
.
file
(
workspaceDir
).
toString
()).
digest
(
'
hex
'
)
}).
then
(()
=>
{
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
...
...
src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts
浏览文件 @
d296132a
...
...
@@ -41,7 +41,6 @@ import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteA
import
{
FileService2
}
from
'
vs/workbench/services/files2/common/fileService2
'
;
import
{
NullLogService
}
from
'
vs/platform/log/common/log
'
;
import
{
DiskFileSystemProvider
}
from
'
vs/workbench/services/files2/node/diskFileSystemProvider
'
;
import
{
HashService
}
from
'
vs/workbench/services/hash/node/hashService
'
;
import
{
ConfigurationCache
}
from
'
vs/workbench/services/configuration/node/configurationCache
'
;
import
{
ConfigurationFileService
}
from
'
vs/workbench/services/configuration/node/configurationFileService
'
;
...
...
@@ -102,7 +101,7 @@ suite('WorkspaceContextService - Folder', () => {
workspaceResource
=
folderDir
;
const
globalSettingsFile
=
path
.
join
(
parentDir
,
'
settings.json
'
);
const
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
globalSettingsFile
);
workspaceContextService
=
new
WorkspaceService
({
userSettingsResource
:
URI
.
file
(
environmentService
.
appSettingsPath
),
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
ConfigurationFileService
(),
new
HashService
(),
new
RemoteAgentService
(
<
IWindowConfiguration
>
{},
environmentService
,
new
RemoteAuthorityResolverService
()));
workspaceContextService
=
new
WorkspaceService
({
userSettingsResource
:
URI
.
file
(
environmentService
.
appSettingsPath
),
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
ConfigurationFileService
(),
new
RemoteAgentService
(
<
IWindowConfiguration
>
{},
environmentService
,
new
RemoteAuthorityResolverService
()));
return
(
<
WorkspaceService
>
workspaceContextService
).
initialize
(
convertToWorkspacePayload
(
URI
.
file
(
folderDir
)));
});
});
...
...
@@ -164,7 +163,7 @@ suite('WorkspaceContextService - Workspace', () => {
const
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
path
.
join
(
parentDir
,
'
settings.json
'
));
const
remoteAgentService
=
instantiationService
.
createInstance
(
RemoteAgentService
,
{});
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
URI
.
file
(
environmentService
.
appSettingsPath
),
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
ConfigurationFileService
(),
new
HashService
(),
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
URI
.
file
(
environmentService
.
appSettingsPath
),
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
ConfigurationFileService
(),
remoteAgentService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
...
...
@@ -220,7 +219,7 @@ suite('WorkspaceContextService - Workspace Editing', () => {
const
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
path
.
join
(
parentDir
,
'
settings.json
'
));
const
remoteAgentService
=
instantiationService
.
createInstance
(
RemoteAgentService
,
{});
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
URI
.
file
(
environmentService
.
appSettingsPath
),
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
ConfigurationFileService
(),
new
HashService
(),
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
URI
.
file
(
environmentService
.
appSettingsPath
),
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
ConfigurationFileService
(),
remoteAgentService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
...
...
@@ -486,7 +485,7 @@ suite('WorkspaceService - Initialization', () => {
const
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
globalSettingsFile
);
const
remoteAgentService
=
instantiationService
.
createInstance
(
RemoteAgentService
,
{});
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
URI
.
file
(
environmentService
.
appSettingsPath
),
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
ConfigurationFileService
(),
new
HashService
(),
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
URI
.
file
(
environmentService
.
appSettingsPath
),
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
ConfigurationFileService
(),
remoteAgentService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
instantiationService
.
stub
(
IEnvironmentService
,
environmentService
);
...
...
@@ -750,7 +749,7 @@ suite('WorkspaceConfigurationService - Folder', () => {
const
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
globalSettingsFile
);
const
remoteAgentService
=
instantiationService
.
createInstance
(
RemoteAgentService
,
{});
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
URI
.
file
(
environmentService
.
appSettingsPath
),
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
ConfigurationFileService
(),
new
HashService
(),
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
URI
.
file
(
environmentService
.
appSettingsPath
),
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
ConfigurationFileService
(),
remoteAgentService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
instantiationService
.
stub
(
IEnvironmentService
,
environmentService
);
...
...
@@ -1047,7 +1046,7 @@ suite('WorkspaceConfigurationService-Multiroot', () => {
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
path
.
join
(
parentDir
,
'
settings.json
'
));
const
remoteAgentService
=
instantiationService
.
createInstance
(
RemoteAgentService
,
{});
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
URI
.
file
(
environmentService
.
appSettingsPath
),
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
ConfigurationFileService
(),
new
HashService
(),
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
URI
.
file
(
environmentService
.
appSettingsPath
),
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
ConfigurationFileService
(),
remoteAgentService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
...
...
src/vs/workbench/services/hash/common/hashService.ts
已删除
100644 → 0
浏览文件 @
844716ab
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
VSBuffer
}
from
'
vs/base/common/buffer
'
;
export
const
IHashService
=
createDecorator
<
IHashService
>
(
'
hashService
'
);
export
interface
IHashService
{
_serviceBrand
:
any
;
/**
* Produce a SHA1 hash of the provided content.
*/
createSHA1
(
content
:
string
):
Thenable
<
string
>
;
}
export
class
HashService
implements
IHashService
{
_serviceBrand
:
any
;
createSHA1
(
content
:
string
):
Thenable
<
string
>
{
return
crypto
.
subtle
.
digest
(
'
SHA-1
'
,
VSBuffer
.
fromString
(
content
).
buffer
).
then
(
buffer
=>
{
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest#Converting_a_digest_to_a_hex_string
return
Array
.
prototype
.
map
.
call
(
new
Uint8Array
(
buffer
),
(
value
:
number
)
=>
`00
${
value
.
toString
(
16
)}
`
.
slice
(
-
2
)).
join
(
''
);
});
}
}
registerSingleton
(
IHashService
,
HashService
,
true
);
\ No newline at end of file
src/vs/workbench/test/workbenchTestServices.ts
浏览文件 @
d296132a
...
...
@@ -48,7 +48,6 @@ import { IRecentlyOpened, IRecent } from 'vs/platform/history/common/history';
import
{
ITextResourceConfigurationService
,
ITextResourcePropertiesService
}
from
'
vs/editor/common/services/resourceConfiguration
'
;
import
{
IPosition
,
Position
as
EditorPosition
}
from
'
vs/editor/common/core/position
'
;
import
{
IMenuService
,
MenuId
,
IMenu
,
ISerializableCommandAction
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IHashService
}
from
'
vs/workbench/services/hash/common/hashService
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
MockContextKeyService
,
MockKeybindingService
}
from
'
vs/platform/keybinding/test/common/mockKeybindingService
'
;
import
{
ITextBufferFactory
,
DefaultEndOfLine
,
EndOfLinePreference
,
IModelDecorationOptions
,
ITextModel
}
from
'
vs/editor/common/model
'
;
...
...
@@ -309,7 +308,6 @@ export function workbenchInstantiationService(): IInstantiationService {
instantiationService
.
stub
(
ITextFileService
,
<
ITextFileService
>
instantiationService
.
createInstance
(
TestTextFileService
));
instantiationService
.
stub
(
ITextModelService
,
<
ITextModelService
>
instantiationService
.
createInstance
(
TextModelResolverService
));
instantiationService
.
stub
(
IThemeService
,
new
TestThemeService
());
instantiationService
.
stub
(
IHashService
,
new
TestHashService
());
instantiationService
.
stub
(
ILogService
,
new
TestLogService
());
instantiationService
.
stub
(
IEditorGroupsService
,
new
TestEditorGroupsService
([
new
TestEditorGroup
(
0
)]));
instantiationService
.
stub
(
ILabelService
,
<
ILabelService
>
instantiationService
.
createInstance
(
LabelService
));
...
...
@@ -1555,14 +1553,6 @@ export class TestTextResourcePropertiesService implements ITextResourcePropertie
}
export
class
TestHashService
implements
IHashService
{
_serviceBrand
:
any
;
createSHA1
(
content
:
string
):
Thenable
<
string
>
{
return
Promise
.
resolve
(
content
);
}
}
export
class
TestSharedProcessService
implements
ISharedProcessService
{
_serviceBrand
:
ServiceIdentifier
<
any
>
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录