Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
旅途_2012
vscode
提交
ff683d9f
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,发现更多精彩内容 >>
提交
ff683d9f
编写于
4月 11, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
have IHostUtils
上级
4423de89
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
34 addition
and
18 deletion
+34
-18
src/vs/workbench/api/node/extHostExtensionService.ts
src/vs/workbench/api/node/extHostExtensionService.ts
+14
-10
src/vs/workbench/services/extensions/node/extensionHostMain.ts
...s/workbench/services/extensions/node/extensionHostMain.ts
+7
-7
src/vs/workbench/services/extensions/node/extensionHostProcess.ts
...orkbench/services/extensions/node/extensionHostProcess.ts
+13
-1
未找到文件。
src/vs/workbench/api/node/extHostExtensionService.ts
浏览文件 @
ff683d9f
...
...
@@ -10,7 +10,6 @@ import { Barrier } from 'vs/base/common/async';
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
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
...
...
@@ -30,7 +29,6 @@ import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensio
import
{
IWorkspace
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
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
'
;
import
{
ExtensionMemento
}
from
'
vs/workbench/api/common/extHostMemento
'
;
...
...
@@ -40,11 +38,17 @@ interface ITestRunner {
run
(
testsRoot
:
string
,
clb
:
(
error
:
Error
,
failures
?:
number
)
=>
void
):
void
;
}
export
interface
IHostUtils
{
exit
(
code
?:
number
):
void
;
exists
(
path
:
string
):
Promise
<
boolean
>
;
realpath
(
path
:
string
):
Promise
<
string
>
;
}
export
class
ExtHostExtensionService
implements
ExtHostExtensionServiceShape
{
private
static
readonly
WORKSPACE_CONTAINS_TIMEOUT
=
7000
;
private
readonly
_
nativeExit
:
(
code
?:
number
)
=>
void
;
private
readonly
_
hostUtils
:
IHostUtils
;
private
readonly
_initData
:
IInitData
;
private
readonly
_extHostContext
:
IMainContext
;
private
readonly
_extHostWorkspace
:
ExtHostWorkspace
;
...
...
@@ -70,7 +74,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
private
_started
:
boolean
;
constructor
(
nativeExit
:
(
code
?:
number
)
=>
void
,
hostUtils
:
IHostUtils
,
initData
:
IInitData
,
extHostContext
:
IMainContext
,
extHostWorkspace
:
ExtHostWorkspace
,
...
...
@@ -80,7 +84,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
schemeTransformer
:
ISchemeTransformer
|
null
,
outputChannelName
:
string
)
{
this
.
_
nativeExit
=
nativeExit
;
this
.
_
hostUtils
=
hostUtils
;
this
.
_initData
=
initData
;
this
.
_extHostContext
=
extHostContext
;
this
.
_extHostWorkspace
=
extHostWorkspace
;
...
...
@@ -230,7 +234,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
if
(
!
ext
.
main
)
{
return
undefined
;
}
return
realpath
(
ext
.
extensionLocation
.
fsPath
).
then
(
value
=>
tree
.
set
(
URI
.
file
(
value
).
fsPath
,
ext
));
return
this
.
_hostUtils
.
realpath
(
ext
.
extensionLocation
.
fsPath
).
then
(
value
=>
tree
.
set
(
URI
.
file
(
value
).
fsPath
,
ext
));
});
this
.
_extensionPathIndex
=
Promise
.
all
(
extensions
).
then
(()
=>
tree
);
}
...
...
@@ -451,7 +455,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
// find exact path
for
(
const
{
uri
}
of
workspace
.
folders
)
{
if
(
await
pf
s
.
exists
(
path
.
join
(
URI
.
revive
(
uri
).
fsPath
,
fileName
)))
{
if
(
await
this
.
_hostUtil
s
.
exists
(
path
.
join
(
URI
.
revive
(
uri
).
fsPath
,
fileName
)))
{
// the file was found
return
(
this
.
_activateById
(
extensionId
,
new
ExtensionActivatedByEvent
(
true
,
`workspaceContains:
${
fileName
}
`
))
...
...
@@ -561,7 +565,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
return
;
}
this
.
_
nativeE
xit
(
code
);
this
.
_
hostUtils
.
e
xit
(
code
);
},
500
);
}
...
...
@@ -645,12 +649,12 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
if
(
!
extensionDescription
)
{
return
;
}
const
realpathValue
=
await
realpath
(
extensionDescription
.
extensionLocation
.
fsPath
);
const
realpathValue
=
await
this
.
_hostUtils
.
realpath
(
extensionDescription
.
extensionLocation
.
fsPath
);
trie
.
delete
(
URI
.
file
(
realpathValue
).
fsPath
);
}));
await
Promise
.
all
(
toAdd
.
map
(
async
(
extensionDescription
)
=>
{
const
realpathValue
=
await
realpath
(
extensionDescription
.
extensionLocation
.
fsPath
);
const
realpathValue
=
await
this
.
_hostUtils
.
realpath
(
extensionDescription
.
extensionLocation
.
fsPath
);
trie
.
set
(
URI
.
file
(
realpathValue
).
fsPath
,
extensionDescription
);
}));
...
...
src/vs/workbench/services/extensions/node/extensionHostMain.ts
浏览文件 @
ff683d9f
...
...
@@ -12,7 +12,7 @@ import { IURITransformer } from 'vs/base/common/uriIpc';
import
{
IMessagePassingProtocol
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
IInitData
,
MainContext
,
MainThreadConsoleShape
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
ExtHostConfiguration
}
from
'
vs/workbench/api/common/extHostConfiguration
'
;
import
{
ExtHostExtensionService
}
from
'
vs/workbench/api/node/extHostExtensionService
'
;
import
{
ExtHostExtensionService
,
IHostUtils
}
from
'
vs/workbench/api/node/extHostExtensionService
'
;
import
{
ExtHostLogService
}
from
'
vs/workbench/api/common/extHostLogService
'
;
import
{
ExtHostWorkspace
}
from
'
vs/workbench/api/common/extHostWorkspace
'
;
import
{
RPCProtocol
}
from
'
vs/workbench/services/extensions/common/rpcProtocol
'
;
...
...
@@ -40,7 +40,7 @@ export interface ILogServiceFn {
export
class
ExtensionHostMain
{
private
_isTerminating
:
boolean
;
private
readonly
_
exitFn
:
IExitFn
;
private
readonly
_
hostUtils
:
IHostUtils
;
private
readonly
_extensionService
:
ExtHostExtensionService
;
private
readonly
_extHostLogService
:
ExtHostLogService
;
private
disposables
:
IDisposable
[]
=
[];
...
...
@@ -50,15 +50,15 @@ export class ExtensionHostMain {
constructor
(
protocol
:
IMessagePassingProtocol
,
initData
:
IInitData
,
exitFn
:
IExitFn
,
hostUtils
:
IHostUtils
,
consolePatchFn
:
IConsolePatchFn
,
logServiceFn
:
ILogServiceFn
,
uriTransformer
:
IURITransformer
|
null
,
schemeTransformer
:
ISchemeTransformer
|
null
,
outputChannelName
:
string
outputChannelName
:
string
,
)
{
this
.
_isTerminating
=
false
;
this
.
_
exitFn
=
exitFn
;
this
.
_
hostUtils
=
hostUtils
;
const
rpcProtocol
=
new
RPCProtocol
(
protocol
,
null
,
uriTransformer
);
// ensure URIs are transformed and revived
...
...
@@ -79,7 +79,7 @@ export class ExtensionHostMain {
const
extHostConfiguraiton
=
new
ExtHostConfiguration
(
rpcProtocol
.
getProxy
(
MainContext
.
MainThreadConfiguration
),
extHostWorkspace
);
this
.
_extensionService
=
new
ExtHostExtensionService
(
exitFn
,
hostUtils
,
initData
,
rpcProtocol
,
extHostWorkspace
,
...
...
@@ -141,7 +141,7 @@ export class ExtensionHostMain {
// Give extensions 1 second to wrap up any async dispose, then exit in at most 4 seconds
setTimeout
(()
=>
{
Promise
.
race
([
timeout
(
4000
),
extensionsDeactivated
]).
finally
(()
=>
this
.
_
exitFn
());
Promise
.
race
([
timeout
(
4000
),
extensionsDeactivated
]).
finally
(()
=>
this
.
_
hostUtils
.
exit
());
},
1000
);
}
...
...
src/vs/workbench/services/extensions/node/extensionHostProcess.ts
浏览文件 @
ff683d9f
...
...
@@ -20,6 +20,9 @@ import { createSpdLogService } from 'vs/platform/log/node/spdlogService';
import
{
ExtensionHostLogFileName
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
ISchemeTransformer
}
from
'
vs/workbench/api/common/extHostLanguageFeatures
'
;
import
{
IURITransformer
}
from
'
vs/base/common/uriIpc
'
;
import
{
exists
}
from
'
vs/base/node/pfs
'
;
import
{
realpath
}
from
'
vs/base/node/extpath
'
;
import
{
IHostUtils
}
from
'
vs/workbench/api/node/extHostExtensionService
'
;
// With Electron 2.x and node.js 8.x the "natives" module
// can cause a native crash (see https://github.com/nodejs/node/issues/19891 and
...
...
@@ -270,10 +273,19 @@ createExtHostProtocol().then(protocol => {
const
schemeTransformer
:
ISchemeTransformer
|
null
=
null
;
const
outputChannelName
=
nls
.
localize
(
'
extension host Log
'
,
"
Extension Host
"
);
// host abstraction
const
hostUtils
=
new
class
NodeHost
implements
IHostUtils
{
exit
(
code
:
number
)
{
nativeExit
(
code
);
}
exists
(
path
:
string
)
{
return
exists
(
path
);
}
realpath
(
path
:
string
)
{
return
realpath
(
path
);
}
};
const
extensionHostMain
=
new
ExtensionHostMain
(
renderer
.
protocol
,
initData
,
nativeExit
,
hostUtils
,
patchPatchedConsole
,
createLogService
,
uriTransformer
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录