Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0a1d595a
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,发现更多精彩内容 >>
提交
0a1d595a
编写于
5月 24, 2019
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use CommonExtensionService for the web
上级
c053e698
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
86 addition
and
78 deletion
+86
-78
src/vs/workbench/browser/web.simpleservices.ts
src/vs/workbench/browser/web.simpleservices.ts
+3
-12
src/vs/workbench/services/extensions/browser/extensionService.ts
...workbench/services/extensions/browser/extensionService.ts
+51
-33
src/vs/workbench/services/extensions/common/abstractExtensionService.ts
...ch/services/extensions/common/abstractExtensionService.ts
+32
-33
未找到文件。
src/vs/workbench/browser/web.simpleservices.ts
浏览文件 @
0a1d595a
...
...
@@ -20,7 +20,6 @@ import { IExtensionHostDebugParams, IDebugParams } from 'vs/platform/environment
import
{
IExtensionGalleryService
,
IQueryOptions
,
IGalleryExtension
,
InstallOperation
,
StatisticType
,
ITranslation
,
IGalleryExtensionVersion
,
IExtensionIdentifier
,
IReportedExtension
,
IExtensionManagementService
,
ILocalExtension
,
IGalleryMetadata
,
IExtensionTipsService
,
ExtensionRecommendationReason
,
IExtensionRecommendation
,
IExtensionEnablementService
,
EnablementState
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
import
{
IPager
}
from
'
vs/base/common/paging
'
;
import
{
IExtensionManifest
,
ExtensionType
,
ExtensionIdentifier
,
IExtension
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
NullExtensionService
,
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
IURLHandler
,
IURLService
}
from
'
vs/platform/url/common/url
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
...
...
@@ -365,10 +364,10 @@ export class SimpleExtensionEnablementService implements IExtensionEnablementSer
readonly
onEnablementChanged
=
Event
.
None
;
readonly
allUserExtensionsDisabled
=
tru
e
;
readonly
allUserExtensionsDisabled
=
fals
e
;
getEnablementState
(
extension
:
IExtension
):
EnablementState
{
return
EnablementState
.
Dis
abled
;
return
EnablementState
.
En
abled
;
}
canChangeEnablement
(
extension
:
IExtension
):
boolean
{
...
...
@@ -380,7 +379,7 @@ export class SimpleExtensionEnablementService implements IExtensionEnablementSer
}
isEnabled
(
extension
:
IExtension
):
boolean
{
return
fals
e
;
return
tru
e
;
}
}
...
...
@@ -484,14 +483,6 @@ registerSingleton(IExtensionManagementService, SimpleExtensionManagementService)
//#endregion
//#region Extensions
export
class
SimpleExtensionService
extends
NullExtensionService
{
}
registerSingleton
(
IExtensionService
,
SimpleExtensionService
);
//#endregion
//#region Extension URL Handler
export
const
IExtensionUrlHandler
=
createDecorator
<
IExtensionUrlHandler
>
(
'
inactiveExtensionUrlHandler
'
);
...
...
src/vs/workbench/services/extensions/browser/extensionService.ts
浏览文件 @
0a1d595a
...
...
@@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
nls
from
'
vs/nls
'
;
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
import
{
IExtensionEnablementService
,
IExtensionManagementService
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
...
...
@@ -10,33 +11,23 @@ import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteA
import
{
IRemoteAuthorityResolverService
}
from
'
vs/platform/remote/common/remoteAuthorityResolver
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IWindowService
}
from
'
vs/platform/windows/common/windows
'
;
import
{
IExtensionService
,
IExtensionHostStarter
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IProductService
}
from
'
vs/platform/product/common/product
'
;
import
{
AbstractExtensionService
,
IExtensionScanner
}
from
'
vs/workbench/services/extensions/common/abstractExtensionService
'
;
import
{
CommonExtensionService
}
from
'
vs/workbench/services/extensions/common/abstractExtensionService
'
;
import
{
browserWebSocketFactory
}
from
'
vs/platform/remote/browser/browserWebSocketFactory
'
;
import
{
Translations
,
ILog
}
from
'
vs/workbench/services/extensions/common/extensionPoints
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
IMessagePassingProtocol
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
ExtensionHostProcessManager
}
from
'
vs/workbench/services/extensions/common/extensionHostProcessManager
'
;
import
{
RemoteExtensionHostClient
,
IInitDataProvider
}
from
'
vs/workbench/services/extensions/common/remoteExtensionHostClient
'
;
import
{
IRemoteAgentEnvironment
}
from
'
vs/platform/remote/common/remoteAgentEnvironment
'
;
import
{
INotificationService
,
Severity
}
from
'
vs/platform/notification/common/notification
'
;
class
NullExtensionScanner
implements
IExtensionScanner
{
readonly
scannedExtensions
:
Promise
<
IExtensionDescription
[]
>
=
Promise
.
resolve
([]);
readonly
translationConfig
:
Promise
<
Translations
>
;
export
class
ExtensionService
extends
CommonExtensionService
implements
IExtensionService
{
public
async
scanSingleExtension
(
path
:
string
,
isBuiltin
:
boolean
,
log
:
ILog
):
Promise
<
IExtensionDescription
|
null
>
{
return
null
;
}
public
async
startScanningExtensions
(
log
:
ILog
):
Promise
<
void
>
{
}
}
private
_remoteExtensionsEnvironmentData
:
IRemoteAgentEnvironment
|
null
;
export
class
ExtensionService
extends
AbstractExtensionService
implements
IExtensionService
{
constructor
(
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
INotificationService
notificationService
:
INotificationService
,
...
...
@@ -53,8 +44,6 @@ export class ExtensionService extends AbstractExtensionService implements IExten
@
IProductService
productService
:
IProductService
)
{
super
(
new
NullExtensionScanner
(),
browserWebSocketFactory
,
instantiationService
,
notificationService
,
environmentService
,
...
...
@@ -69,25 +58,55 @@ export class ExtensionService extends AbstractExtensionService implements IExten
fileService
,
productService
,
);
}
protected
_createLocalExtHostProcessWorker
(
autoStart
:
boolean
,
extensions
:
Promise
<
IExtensionDescription
[]
>
):
IExtensionHostStarter
{
return
new
class
implements
IExtensionHostStarter
{
onExit
=
Event
.
None
;
start
():
Promise
<
IMessagePassingProtocol
>
|
null
{
return
new
Promise
<
IMessagePassingProtocol
>
((
c
,
e
)
=>
{
this
.
_remoteExtensionsEnvironmentData
=
null
;
this
.
_initialize
();
}
private
_createProvider
(
remoteAuthority
:
string
):
IInitDataProvider
{
return
{
remoteAuthority
:
remoteAuthority
,
getInitData
:
()
=>
{
return
this
.
whenInstalledExtensionsRegistered
().
then
(()
=>
{
return
this
.
_remoteExtensionsEnvironmentData
!
;
});
}
getInspectPort
():
number
|
undefined
{
throw
new
Error
(
'
Method not implemented.
'
);
}
dispose
():
void
{
throw
new
Error
(
'
Method not implemented.
'
);
}
};
}
protected
_createExtensionHosts
(
isInitialStart
:
boolean
,
initialActivationEvents
:
string
[]):
ExtensionHostProcessManager
[]
{
const
result
:
ExtensionHostProcessManager
[]
=
[];
const
remoteAgentConnection
=
this
.
_remoteAgentService
.
getConnection
()
!
;
const
remoteExtHostProcessWorker
=
this
.
_instantiationService
.
createInstance
(
RemoteExtensionHostClient
,
this
.
getExtensions
(),
this
.
_createProvider
(
remoteAgentConnection
.
remoteAuthority
),
browserWebSocketFactory
);
const
remoteExtHostProcessManager
=
this
.
_instantiationService
.
createInstance
(
ExtensionHostProcessManager
,
false
,
remoteExtHostProcessWorker
,
remoteAgentConnection
.
remoteAuthority
,
initialActivationEvents
);
result
.
push
(
remoteExtHostProcessManager
);
return
result
;
}
protected
async
_scanAndHandleExtensions
():
Promise
<
void
>
{
// fetch the remote environment
const
remoteEnv
=
(
await
this
.
_remoteAgentService
.
getEnvironment
())
!
;
// enable or disable proposed API per extension
this
.
_checkEnableProposedApi
(
remoteEnv
.
extensions
);
// remove disabled extensions
remoteEnv
.
extensions
=
remoteEnv
.
extensions
.
filter
(
extension
=>
this
.
_isEnabled
(
extension
));
// save for remote extension's init data
this
.
_remoteExtensionsEnvironmentData
=
remoteEnv
;
// this._handleExtensionPoints((<IExtensionDescription[]>[]).concat(remoteEnv.extensions).concat(localExtensions));
const
result
=
this
.
_registry
.
deltaExtensions
(
remoteEnv
.
extensions
,
[]);
if
(
result
.
removedDueToLooping
.
length
>
0
)
{
this
.
_logOrShowMessage
(
Severity
.
Error
,
nls
.
localize
(
'
looping
'
,
"
The following extensions contain dependency loops and have been disabled: {0}
"
,
result
.
removedDueToLooping
.
map
(
e
=>
`'
${
e
.
identifier
.
value
}
'`
).
join
(
'
,
'
)));
}
this
.
_doHandleExtensionPoints
(
this
.
_registry
.
getAllExtensionDescriptions
());
}
public
_onExtensionHostExit
(
code
:
number
):
void
{
// Expected development extension termination: When the extension host goes down we also shutdown the window
if
(
!
this
.
_isExtensionDevTestFromCli
)
{
...
...
@@ -103,4 +122,3 @@ export class ExtensionService extends AbstractExtensionService implements IExten
}
registerSingleton
(
IExtensionService
,
ExtensionService
);
src/vs/workbench/services/extensions/common/abstractExtensionService.ts
浏览文件 @
0a1d595a
...
...
@@ -138,27 +138,14 @@ export abstract class CommonExtensionService extends Disposable implements IExte
const
devOpts
=
parseExtensionDevOptions
(
this
.
_environmentService
);
this
.
_isExtensionDevHost
=
devOpts
.
isExtensionDevHost
;
this
.
_isExtensionDevTestFromCli
=
devOpts
.
isExtensionDevTestFromCli
;
this
.
_startDelayed
(
this
.
_lifecycleService
);
}
private
_startDelayed
(
lifecycleService
:
ILifecycleService
):
void
{
// delay extension host creation and extension scanning
// until the workbench is running. we cannot defer the
// extension host more (LifecyclePhase.Restored) because
// some editors require the extension host to restore
// and this would result in a deadlock
// see https://github.com/Microsoft/vscode/issues/41322
lifecycleService
.
when
(
LifecyclePhase
.
Ready
).
then
(()
=>
{
// reschedule to ensure this runs after restoring viewlets, panels, and editors
runWhenIdle
(
async
()
=>
{
perf
.
mark
(
'
willLoadExtensions
'
);
this
.
_startExtensionHostProcess
(
true
,
[]);
this
.
whenInstalledExtensionsRegistered
().
then
(()
=>
perf
.
mark
(
'
didLoadExtensions
'
));
await
this
.
_scanAndHandleExtensions
();
this
.
_releaseBarrier
();
},
50
/*max delay*/
);
});
protected
async
_initialize
():
Promise
<
void
>
{
perf
.
mark
(
'
willLoadExtensions
'
);
this
.
_startExtensionHostProcess
(
true
,
[]);
this
.
whenInstalledExtensionsRegistered
().
then
(()
=>
perf
.
mark
(
'
didLoadExtensions
'
));
await
this
.
_scanAndHandleExtensions
();
this
.
_releaseBarrier
();
}
private
_releaseBarrier
():
void
{
...
...
@@ -192,28 +179,28 @@ export abstract class CommonExtensionService extends Disposable implements IExte
const
processManagers
=
this
.
_createExtensionHosts
(
isInitialStart
,
initialActivationEvents
);
processManagers
.
forEach
((
processManager
)
=>
{
processManager
.
onDidExit
(([
code
,
signal
])
=>
this
.
_onExtensionHostCrashOrExit
(
code
,
signal
,
processManager
.
isLoc
al
));
processManager
.
onDidExit
(([
code
,
signal
])
=>
this
.
_onExtensionHostCrashOrExit
(
processManager
,
code
,
sign
al
));
processManager
.
onDidChangeResponsiveState
((
responsiveState
)
=>
{
this
.
_onDidChangeResponsiveChange
.
fire
({
isResponsive
:
responsiveState
===
ResponsiveState
.
Responsive
});
});
this
.
_extensionHostProcessManagers
.
push
(
processManager
);
});
}
private
_onExtensionHostCrashOrExit
(
code
:
number
,
signal
:
string
|
null
,
showNotification
:
boolean
):
void
{
private
_onExtensionHostCrashOrExit
(
extensionHost
:
ExtensionHostProcessManager
,
code
:
number
,
signal
:
string
|
null
):
void
{
// Unexpected termination
if
(
!
this
.
_isExtensionDevHost
)
{
this
.
_onExtensionHostCrashed
(
code
,
signal
,
showNotification
);
this
.
_onExtensionHostCrashed
(
extensionHost
,
code
,
signal
);
return
;
}
this
.
_onExtensionHostExit
(
code
);
}
private
_onExtensionHostCrashed
(
code
:
number
,
signal
:
string
|
null
,
showNotification
:
boolean
):
void
{
private
_onExtensionHostCrashed
(
extensionHost
:
ExtensionHostProcessManager
,
code
:
number
,
signal
:
string
|
null
):
void
{
console
.
error
(
'
Extension host terminated unexpectedly. Code:
'
,
code
,
'
Signal:
'
,
signal
);
this
.
_stopExtensionHostProcess
();
if
(
showNotification
)
{
if
(
extensionHost
.
isLocal
)
{
if
(
code
===
55
)
{
this
.
_notificationService
.
prompt
(
Severity
.
Error
,
...
...
@@ -351,9 +338,6 @@ export abstract class CommonExtensionService extends Disposable implements IExte
}
public
getInspectPort
():
number
{
if
(
this
.
_extensionHostProcessManagers
.
length
>
0
)
{
return
this
.
_extensionHostProcessManagers
[
0
].
getInspectPort
();
}
return
0
;
}
...
...
@@ -533,7 +517,7 @@ export abstract class CommonExtensionService extends Disposable implements IExte
export
abstract
class
AbstractExtensionService
extends
CommonExtensionService
implements
IExtensionService
{
private
_remoteExtensionsEnvironmentData
:
Map
<
string
,
IRemoteAgentEnvironment
>
;
private
readonly
_remoteExtensionsEnvironmentData
:
Map
<
string
,
IRemoteAgentEnvironment
>
;
protected
readonly
_extensionHostLogsLocation
:
URI
;
private
readonly
_extensionScanner
:
IExtensionScanner
;
...
...
@@ -608,6 +592,19 @@ export abstract class AbstractExtensionService extends CommonExtensionService im
this
.
_handleDeltaExtensions
(
new
DeltaExtensionsQueueItem
([],
[
event
.
identifier
.
id
]));
}
}));
// delay extension host creation and extension scanning
// until the workbench is running. we cannot defer the
// extension host more (LifecyclePhase.Restored) because
// some editors require the extension host to restore
// and this would result in a deadlock
// see https://github.com/Microsoft/vscode/issues/41322
this
.
_lifecycleService
.
when
(
LifecyclePhase
.
Ready
).
then
(()
=>
{
// reschedule to ensure this runs after restoring viewlets, panels, and editors
runWhenIdle
(
async
()
=>
{
this
.
_initialize
();
},
50
/*max delay*/
);
});
}
//#region deltaExtensions
...
...
@@ -918,11 +915,6 @@ export abstract class AbstractExtensionService extends CommonExtensionService im
// fetch the remote environment
const
remoteEnv
=
(
await
this
.
_remoteAgentService
.
getEnvironment
())
!
;
// revive URIs
remoteEnv
.
extensions
.
forEach
((
extension
)
=>
{
(
<
any
>
extension
).
extensionLocation
=
URI
.
revive
(
extension
.
extensionLocation
);
});
// enable or disable proposed API per extension
this
.
_checkEnableProposedApi
(
remoteEnv
.
extensions
);
...
...
@@ -965,6 +957,13 @@ export abstract class AbstractExtensionService extends CommonExtensionService im
this
.
_doHandleExtensionPoints
(
this
.
_registry
.
getAllExtensionDescriptions
());
}
public
getInspectPort
():
number
{
if
(
this
.
_extensionHostProcessManagers
.
length
>
0
)
{
return
this
.
_extensionHostProcessManagers
[
0
].
getInspectPort
();
}
return
0
;
}
public
abstract
_onExtensionHostExit
(
code
:
number
):
void
;
protected
abstract
_createLocalExtHostProcessWorker
(
autoStart
:
boolean
,
extensions
:
Promise
<
IExtensionDescription
[]
>
):
IExtensionHostStarter
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录