Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
旅途_2012
vscode
提交
86fee5f4
V
vscode
项目概览
旅途_2012
/
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,发现更多精彩内容 >>
提交
86fee5f4
编写于
4月 11, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move out extHostStorage and extHostMemento
上级
7a1f2e07
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
141 addition
and
121 deletion
+141
-121
src/vs/workbench/api/common/extHostMemento.ts
src/vs/workbench/api/common/extHostMemento.ts
+59
-0
src/vs/workbench/api/node/extHostExtensionService.ts
src/vs/workbench/api/node/extHostExtensionService.ts
+7
-121
src/vs/workbench/api/node/extHostStoragePaths.ts
src/vs/workbench/api/node/extHostStoragePaths.ts
+75
-0
未找到文件。
src/vs/workbench/api/common/extHostMemento.ts
0 → 100644
浏览文件 @
86fee5f4
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IExtensionMemento
}
from
'
vs/workbench/api/common/extHostExtensionActivator
'
;
import
{
ExtHostStorage
}
from
'
vs/workbench/api/common/extHostStorage
'
;
export
class
ExtensionMemento
implements
IExtensionMemento
{
private
readonly
_id
:
string
;
private
readonly
_shared
:
boolean
;
private
readonly
_storage
:
ExtHostStorage
;
private
readonly
_init
:
Promise
<
ExtensionMemento
>
;
private
_value
:
{
[
n
:
string
]:
any
;
};
private
readonly
_storageListener
:
IDisposable
;
constructor
(
id
:
string
,
global
:
boolean
,
storage
:
ExtHostStorage
)
{
this
.
_id
=
id
;
this
.
_shared
=
global
;
this
.
_storage
=
storage
;
this
.
_init
=
this
.
_storage
.
getValue
(
this
.
_shared
,
this
.
_id
,
Object
.
create
(
null
)).
then
(
value
=>
{
this
.
_value
=
value
;
return
this
;
});
this
.
_storageListener
=
this
.
_storage
.
onDidChangeStorage
(
e
=>
{
if
(
e
.
shared
===
this
.
_shared
&&
e
.
key
===
this
.
_id
)
{
this
.
_value
=
e
.
value
;
}
});
}
get
whenReady
():
Promise
<
ExtensionMemento
>
{
return
this
.
_init
;
}
get
<
T
>
(
key
:
string
,
defaultValue
:
T
):
T
{
let
value
=
this
.
_value
[
key
];
if
(
typeof
value
===
'
undefined
'
)
{
value
=
defaultValue
;
}
return
value
;
}
update
(
key
:
string
,
value
:
any
):
Promise
<
boolean
>
{
this
.
_value
[
key
]
=
value
;
return
this
.
_storage
.
setValue
(
this
.
_shared
,
this
.
_id
,
this
.
_value
)
.
then
(()
=>
true
);
}
dispose
():
void
{
this
.
_storageListener
.
dispose
();
}
}
src/vs/workbench/api/node/extHostExtensionService.ts
浏览文件 @
86fee5f4
...
...
@@ -7,15 +7,15 @@ import * as nls from 'vs/nls';
import
*
as
path
from
'
vs/base/common/path
'
;
import
{
originalFSPath
}
from
'
vs/base/common/resources
'
;
import
{
Barrier
}
from
'
vs/base/common/async
'
;
import
{
IDisposable
,
dispose
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
dispose
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
TernarySearchTree
}
from
'
vs/base/common/map
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
*
as
pfs
from
'
vs/base/node/pfs
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
createApiFactory
,
IExtensionApiFactory
,
NodeModuleRequireInterceptor
,
VSCodeNodeModuleFactory
,
KeytarNodeModuleFactory
,
OpenNodeModuleFactory
}
from
'
vs/workbench/api/node/extHost.api.impl
'
;
import
{
ExtHostExtensionServiceShape
,
IEnvironment
,
IInitData
,
IMainContext
,
MainContext
,
MainThreadExtensionServiceShape
,
MainThreadTelemetryShape
,
MainThreadWorkspaceShape
,
IStaticWorkspaceData
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
ExtHostExtensionServiceShape
,
IEnvironment
,
IInitData
,
IMainContext
,
MainContext
,
MainThreadExtensionServiceShape
,
MainThreadTelemetryShape
,
MainThreadWorkspaceShape
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
ExtHostConfiguration
}
from
'
vs/workbench/api/common/extHostConfiguration
'
;
import
{
ActivatedExtension
,
EmptyExtension
,
ExtensionActivatedByAPI
,
ExtensionActivatedByEvent
,
ExtensionActivationReason
,
ExtensionActivationTimes
,
ExtensionActivationTimesBuilder
,
ExtensionsActivator
,
IExtensionAPI
,
IExtensionContext
,
IExtensionM
emento
,
IExtensionM
odule
,
HostExtension
}
from
'
vs/workbench/api/common/extHostExtensionActivator
'
;
import
{
ActivatedExtension
,
EmptyExtension
,
ExtensionActivatedByAPI
,
ExtensionActivatedByEvent
,
ExtensionActivationReason
,
ExtensionActivationTimes
,
ExtensionActivationTimesBuilder
,
ExtensionsActivator
,
IExtensionAPI
,
IExtensionContext
,
IExtensionModule
,
HostExtension
}
from
'
vs/workbench/api/common/extHostExtensionActivator
'
;
import
{
ExtHostLogService
}
from
'
vs/workbench/api/common/extHostLogService
'
;
import
{
ExtHostStorage
}
from
'
vs/workbench/api/common/extHostStorage
'
;
import
{
ExtHostWorkspace
}
from
'
vs/workbench/api/common/extHostWorkspace
'
;
...
...
@@ -33,122 +33,8 @@ import { withNullAsUndefined } from 'vs/base/common/types';
import
{
realpath
}
from
'
vs/base/node/extpath
'
;
import
{
VSBuffer
}
from
'
vs/base/common/buffer
'
;
import
{
ISchemeTransformer
}
from
'
vs/workbench/api/common/extHostLanguageFeatures
'
;
class
ExtensionMemento
implements
IExtensionMemento
{
private
readonly
_id
:
string
;
private
readonly
_shared
:
boolean
;
private
readonly
_storage
:
ExtHostStorage
;
private
readonly
_init
:
Promise
<
ExtensionMemento
>
;
private
_value
:
{
[
n
:
string
]:
any
;
};
private
readonly
_storageListener
:
IDisposable
;
constructor
(
id
:
string
,
global
:
boolean
,
storage
:
ExtHostStorage
)
{
this
.
_id
=
id
;
this
.
_shared
=
global
;
this
.
_storage
=
storage
;
this
.
_init
=
this
.
_storage
.
getValue
(
this
.
_shared
,
this
.
_id
,
Object
.
create
(
null
)).
then
(
value
=>
{
this
.
_value
=
value
;
return
this
;
});
this
.
_storageListener
=
this
.
_storage
.
onDidChangeStorage
(
e
=>
{
if
(
e
.
shared
===
this
.
_shared
&&
e
.
key
===
this
.
_id
)
{
this
.
_value
=
e
.
value
;
}
});
}
get
whenReady
():
Promise
<
ExtensionMemento
>
{
return
this
.
_init
;
}
get
<
T
>
(
key
:
string
,
defaultValue
:
T
):
T
{
let
value
=
this
.
_value
[
key
];
if
(
typeof
value
===
'
undefined
'
)
{
value
=
defaultValue
;
}
return
value
;
}
update
(
key
:
string
,
value
:
any
):
Promise
<
boolean
>
{
this
.
_value
[
key
]
=
value
;
return
this
.
_storage
.
setValue
(
this
.
_shared
,
this
.
_id
,
this
.
_value
)
.
then
(()
=>
true
);
}
dispose
():
void
{
this
.
_storageListener
.
dispose
();
}
}
class
ExtensionStoragePath
{
private
readonly
_workspace
?:
IStaticWorkspaceData
;
private
readonly
_environment
:
IEnvironment
;
private
readonly
_ready
:
Promise
<
string
|
undefined
>
;
private
_value
?:
string
;
constructor
(
workspace
:
IStaticWorkspaceData
|
undefined
,
environment
:
IEnvironment
)
{
this
.
_workspace
=
workspace
;
this
.
_environment
=
environment
;
this
.
_ready
=
this
.
_getOrCreateWorkspaceStoragePath
().
then
(
value
=>
this
.
_value
=
value
);
}
get
whenReady
():
Promise
<
any
>
{
return
this
.
_ready
;
}
workspaceValue
(
extension
:
IExtensionDescription
):
string
|
undefined
{
if
(
this
.
_value
)
{
return
path
.
join
(
this
.
_value
,
extension
.
identifier
.
value
);
}
return
undefined
;
}
globalValue
(
extension
:
IExtensionDescription
):
string
{
return
path
.
join
(
this
.
_environment
.
globalStorageHome
.
fsPath
,
extension
.
identifier
.
value
.
toLowerCase
());
}
private
async
_getOrCreateWorkspaceStoragePath
():
Promise
<
string
|
undefined
>
{
if
(
!
this
.
_workspace
)
{
return
Promise
.
resolve
(
undefined
);
}
if
(
!
this
.
_environment
.
appSettingsHome
)
{
return
undefined
;
}
const
storageName
=
this
.
_workspace
.
id
;
const
storagePath
=
path
.
join
(
this
.
_environment
.
appSettingsHome
.
fsPath
,
'
workspaceStorage
'
,
storageName
);
const
exists
=
await
pfs
.
dirExists
(
storagePath
);
if
(
exists
)
{
return
storagePath
;
}
try
{
await
pfs
.
mkdirp
(
storagePath
);
await
pfs
.
writeFile
(
path
.
join
(
storagePath
,
'
meta.json
'
),
JSON
.
stringify
({
id
:
this
.
_workspace
.
id
,
configuration
:
this
.
_workspace
.
configuration
&&
URI
.
revive
(
this
.
_workspace
.
configuration
).
toString
(),
name
:
this
.
_workspace
.
name
},
undefined
,
2
)
);
return
storagePath
;
}
catch
(
e
)
{
console
.
error
(
e
);
return
undefined
;
}
}
}
import
{
ExtensionMemento
}
from
'
vs/workbench/api/common/extHostMemento
'
;
import
{
ExtensionStoragePaths
}
from
'
vs/workbench/api/node/extHostStoragePaths
'
;
interface
ITestRunner
{
run
(
testsRoot
:
string
,
clb
:
(
error
:
Error
,
failures
?:
number
)
=>
void
):
void
;
...
...
@@ -174,7 +60,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
private
readonly
_readyToRunExtensions
:
Barrier
;
private
readonly
_registry
:
ExtensionDescriptionRegistry
;
private
readonly
_storage
:
ExtHostStorage
;
private
readonly
_storagePath
:
ExtensionStoragePath
;
private
readonly
_storagePath
:
ExtensionStoragePath
s
;
private
readonly
_activator
:
ExtensionsActivator
;
private
_extensionPathIndex
:
Promise
<
TernarySearchTree
<
IExtensionDescription
>>
|
null
;
private
readonly
_extensionApiFactory
:
IExtensionApiFactory
;
...
...
@@ -210,7 +96,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
this
.
_readyToRunExtensions
=
new
Barrier
();
this
.
_registry
=
new
ExtensionDescriptionRegistry
(
initData
.
extensions
);
this
.
_storage
=
new
ExtHostStorage
(
this
.
_extHostContext
);
this
.
_storagePath
=
new
ExtensionStoragePath
(
withNullAsUndefined
(
initData
.
workspace
),
initData
.
environment
);
this
.
_storagePath
=
new
ExtensionStoragePath
s
(
withNullAsUndefined
(
initData
.
workspace
),
initData
.
environment
);
const
hostExtensions
=
new
Set
<
string
>
();
initData
.
hostExtensions
.
forEach
((
extensionId
)
=>
hostExtensions
.
add
(
ExtensionIdentifier
.
toKey
(
extensionId
)));
...
...
src/vs/workbench/api/node/extHostStoragePaths.ts
0 → 100644
浏览文件 @
86fee5f4
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
path
from
'
vs/base/common/path
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
*
as
pfs
from
'
vs/base/node/pfs
'
;
import
{
IEnvironment
,
IStaticWorkspaceData
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
export
class
ExtensionStoragePaths
{
private
readonly
_workspace
?:
IStaticWorkspaceData
;
private
readonly
_environment
:
IEnvironment
;
private
readonly
_ready
:
Promise
<
string
|
undefined
>
;
private
_value
?:
string
;
constructor
(
workspace
:
IStaticWorkspaceData
|
undefined
,
environment
:
IEnvironment
)
{
this
.
_workspace
=
workspace
;
this
.
_environment
=
environment
;
this
.
_ready
=
this
.
_getOrCreateWorkspaceStoragePath
().
then
(
value
=>
this
.
_value
=
value
);
}
get
whenReady
():
Promise
<
any
>
{
return
this
.
_ready
;
}
workspaceValue
(
extension
:
IExtensionDescription
):
string
|
undefined
{
if
(
this
.
_value
)
{
return
path
.
join
(
this
.
_value
,
extension
.
identifier
.
value
);
}
return
undefined
;
}
globalValue
(
extension
:
IExtensionDescription
):
string
{
return
path
.
join
(
this
.
_environment
.
globalStorageHome
.
fsPath
,
extension
.
identifier
.
value
.
toLowerCase
());
}
private
async
_getOrCreateWorkspaceStoragePath
():
Promise
<
string
|
undefined
>
{
if
(
!
this
.
_workspace
)
{
return
Promise
.
resolve
(
undefined
);
}
if
(
!
this
.
_environment
.
appSettingsHome
)
{
return
undefined
;
}
const
storageName
=
this
.
_workspace
.
id
;
const
storagePath
=
path
.
join
(
this
.
_environment
.
appSettingsHome
.
fsPath
,
'
workspaceStorage
'
,
storageName
);
const
exists
=
await
pfs
.
dirExists
(
storagePath
);
if
(
exists
)
{
return
storagePath
;
}
try
{
await
pfs
.
mkdirp
(
storagePath
);
await
pfs
.
writeFile
(
path
.
join
(
storagePath
,
'
meta.json
'
),
JSON
.
stringify
({
id
:
this
.
_workspace
.
id
,
configuration
:
this
.
_workspace
.
configuration
&&
URI
.
revive
(
this
.
_workspace
.
configuration
).
toString
(),
name
:
this
.
_workspace
.
name
},
undefined
,
2
)
);
return
storagePath
;
}
catch
(
e
)
{
console
.
error
(
e
);
return
undefined
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录