Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
59d26e22
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
提交
59d26e22
编写于
10月 01, 2018
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Running extensions editor: Convert workbench editor actions to commands
fixes #59346
上级
f74a50e3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
125 addition
and
89 deletion
+125
-89
src/vs/workbench/parts/extensions/electron-browser/extensions.contribution.ts
...ts/extensions/electron-browser/extensions.contribution.ts
+79
-2
src/vs/workbench/parts/extensions/electron-browser/media/runtimeExtensionsEditor.css
...nsions/electron-browser/media/runtimeExtensionsEditor.css
+1
-37
src/vs/workbench/parts/extensions/electron-browser/runtimeExtensionsEditor.ts
...ts/extensions/electron-browser/runtimeExtensionsEditor.ts
+45
-50
未找到文件。
src/vs/workbench/parts/extensions/electron-browser/extensions.contribution.ts
浏览文件 @
59d26e22
...
...
@@ -38,10 +38,12 @@ import { areSameExtensions } from 'vs/platform/extensionManagement/common/extens
import
{
GalleryExtensionsHandler
,
ExtensionsHandler
}
from
'
vs/workbench/parts/extensions/browser/extensionsQuickOpen
'
;
import
{
EditorDescriptor
,
IEditorRegistry
,
Extensions
as
EditorExtensions
}
from
'
vs/workbench/browser/editor
'
;
import
{
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
RuntimeExtensionsEditor
,
ShowRuntimeExtensionsAction
,
IExtensionHostProfileService
}
from
'
vs/workbench/parts/extensions/electron-browser/runtimeExtensionsEditor
'
;
import
{
EditorInput
,
IEditorInputFactory
,
IEditorInputFactoryRegistry
,
Extensions
as
EditorInputExtensions
}
from
'
vs/workbench/common/editor
'
;
import
{
RuntimeExtensionsEditor
,
ShowRuntimeExtensionsAction
,
IExtensionHostProfileService
,
DebugExtensionHostAction
,
StartExtensionHostProfileAction
,
StopExtensionHostProfileAction
,
CONTEXT_PROFILE_SESSION_STATE
,
SaveExtensionHostProfileAction
,
CONTEXT_EXTENSION_HOST_PROFILE_RECORDED
}
from
'
vs/workbench/parts/extensions/electron-browser/runtimeExtensionsEditor
'
;
import
{
EditorInput
,
IEditorInputFactory
,
IEditorInputFactoryRegistry
,
Extensions
as
EditorInputExtensions
,
ActiveEditorContext
}
from
'
vs/workbench/common/editor
'
;
import
{
ExtensionHostProfileService
}
from
'
vs/workbench/parts/extensions/electron-browser/extensionProfileService
'
;
import
{
RuntimeExtensionsInput
}
from
'
vs/workbench/services/extensions/electron-browser/runtimeExtensionsInput
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
// Singletons
registerSingleton
(
IExtensionsWorkbenchService
,
ExtensionsWorkbenchService
);
...
...
@@ -258,6 +260,26 @@ CommandsRegistry.registerCommand('extension.open', (accessor: ServicesAccessor,
});
});
CommandsRegistry
.
registerCommand
(
DebugExtensionHostAction
.
ID
,
(
accessor
:
ServicesAccessor
)
=>
{
const
instantationService
=
accessor
.
get
(
IInstantiationService
);
instantationService
.
createInstance
(
DebugExtensionHostAction
).
run
();
});
CommandsRegistry
.
registerCommand
(
StartExtensionHostProfileAction
.
ID
,
(
accessor
:
ServicesAccessor
)
=>
{
const
instantationService
=
accessor
.
get
(
IInstantiationService
);
instantationService
.
createInstance
(
StartExtensionHostProfileAction
,
StartExtensionHostProfileAction
.
ID
,
StartExtensionHostProfileAction
.
LABEL
).
run
();
});
CommandsRegistry
.
registerCommand
(
StopExtensionHostProfileAction
.
ID
,
(
accessor
:
ServicesAccessor
)
=>
{
const
instantationService
=
accessor
.
get
(
IInstantiationService
);
instantationService
.
createInstance
(
StopExtensionHostProfileAction
,
StopExtensionHostProfileAction
.
ID
,
StopExtensionHostProfileAction
.
LABEL
).
run
();
});
CommandsRegistry
.
registerCommand
(
SaveExtensionHostProfileAction
.
ID
,
(
accessor
:
ServicesAccessor
)
=>
{
const
instantationService
=
accessor
.
get
(
IInstantiationService
);
instantationService
.
createInstance
(
SaveExtensionHostProfileAction
,
SaveExtensionHostProfileAction
.
ID
,
SaveExtensionHostProfileAction
.
LABEL
).
run
();
});
// File menu registration
MenuRegistry
.
appendMenuItem
(
MenuId
.
MenubarPreferencesMenu
,
{
...
...
@@ -288,3 +310,58 @@ MenuRegistry.appendMenuItem(MenuId.MenubarViewMenu, {
},
order
:
5
});
// Running extensions
MenuRegistry
.
appendMenuItem
(
MenuId
.
EditorTitle
,
{
command
:
{
id
:
DebugExtensionHostAction
.
ID
,
title
:
DebugExtensionHostAction
.
LABEL
,
iconLocation
:
{
dark
:
URI
.
parse
(
require
.
toUrl
(
`vs/workbench/parts/extensions/electron-browser/media/start-inverse.svg`
)),
light
:
URI
.
parse
(
require
.
toUrl
(
`vs/workbench/parts/extensions/electron-browser/media/start.svg`
)),
}
},
group
:
'
navigation
'
,
when
:
ActiveEditorContext
.
isEqualTo
(
RuntimeExtensionsEditor
.
ID
)
});
MenuRegistry
.
appendMenuItem
(
MenuId
.
EditorTitle
,
{
command
:
{
id
:
StartExtensionHostProfileAction
.
ID
,
title
:
StartExtensionHostProfileAction
.
LABEL
,
iconLocation
:
{
dark
:
URI
.
parse
(
require
.
toUrl
(
`vs/workbench/parts/extensions/electron-browser/media/profile-start-inverse.svg`
)),
light
:
URI
.
parse
(
require
.
toUrl
(
`vs/workbench/parts/extensions/electron-browser/media/profile-start.svg`
)),
}
},
group
:
'
navigation
'
,
when
:
ContextKeyExpr
.
and
(
ActiveEditorContext
.
isEqualTo
(
RuntimeExtensionsEditor
.
ID
),
CONTEXT_PROFILE_SESSION_STATE
.
notEqualsTo
(
'
running
'
))
});
MenuRegistry
.
appendMenuItem
(
MenuId
.
EditorTitle
,
{
command
:
{
id
:
StopExtensionHostProfileAction
.
ID
,
title
:
StopExtensionHostProfileAction
.
LABEL
,
iconLocation
:
{
dark
:
URI
.
parse
(
require
.
toUrl
(
`vs/workbench/parts/extensions/electron-browser/media/profile-stop-inverse.svg`
)),
light
:
URI
.
parse
(
require
.
toUrl
(
`vs/workbench/parts/extensions/electron-browser/media/profile-stop.svg`
)),
}
},
group
:
'
navigation
'
,
when
:
ContextKeyExpr
.
and
(
ActiveEditorContext
.
isEqualTo
(
RuntimeExtensionsEditor
.
ID
),
CONTEXT_PROFILE_SESSION_STATE
.
isEqualTo
(
'
running
'
))
});
MenuRegistry
.
appendMenuItem
(
MenuId
.
EditorTitle
,
{
command
:
{
id
:
SaveExtensionHostProfileAction
.
ID
,
title
:
SaveExtensionHostProfileAction
.
LABEL
,
iconLocation
:
{
dark
:
URI
.
parse
(
require
.
toUrl
(
`vs/workbench/parts/extensions/electron-browser/media/save-inverse.svg`
)),
light
:
URI
.
parse
(
require
.
toUrl
(
`vs/workbench/parts/extensions/electron-browser/media/save.svg`
)),
},
precondition
:
CONTEXT_EXTENSION_HOST_PROFILE_RECORDED
},
group
:
'
navigation
'
,
when
:
ContextKeyExpr
.
and
(
ActiveEditorContext
.
isEqualTo
(
RuntimeExtensionsEditor
.
ID
))
});
src/vs/workbench/parts/extensions/electron-browser/media/runtimeExtensionsEditor.css
浏览文件 @
59d26e22
...
...
@@ -53,42 +53,6 @@
padding
:
10px
14px
10px
0
;
}
.monaco-action-bar
.debug-extension-host
{
background
:
url('start.svg')
center
center
no-repeat
;
}
.vs-dark
.monaco-action-bar
.debug-extension-host
,
.hc-black
.monaco-action-bar
.debug-extension-host
{
background
:
url('start-inverse.svg')
center
center
no-repeat
;
}
.monaco-action-bar
.extension-host-profile-start
{
background
:
url('profile-start.svg')
center
center
no-repeat
;
}
.monaco-action-bar
.extension-host-profile-stop
{
background
:
url('profile-stop.svg')
center
center
no-repeat
;
}
.vs-dark
.monaco-action-bar
.extension-host-profile-start
,
.hc-black
.monaco-action-bar
.extension-host-profile-start
{
background
:
url('profile-start-inverse.svg')
center
center
no-repeat
;
}
.vs-dark
.monaco-action-bar
.extension-host-profile-stop
,
.hc-black
.monaco-action-bar
.extension-host-profile-stop
{
background
:
url('profile-stop-inverse.svg')
center
center
no-repeat
;
animation
:
fade
1000ms
infinite
;
}
.monaco-action-bar
.save-extension-host-profile
{
background
:
url('save.svg')
center
center
no-repeat
;
}
.vs-dark
.monaco-action-bar
.save-extension-host-profile
,
.hc-black
.monaco-action-bar
.save-extension-host-profile
{
background
:
url('save-inverse.svg')
center
center
no-repeat
;
}
.runtime-extensions-editor
.monaco-action-bar
{
padding-top
:
21px
;
flex-shrink
:
0
;
...
...
@@ -114,4 +78,4 @@
from
{
opacity
:
1.0
;
}
50
%
{
opacity
:
0.5
;
}
to
{
opacity
:
1.0
;
}
}
\ No newline at end of file
}
src/vs/workbench/parts/extensions/electron-browser/runtimeExtensionsEditor.ts
浏览文件 @
59d26e22
...
...
@@ -40,10 +40,13 @@ import { RuntimeExtensionsInput } from 'vs/workbench/services/extensions/electro
import
{
IDebugService
}
from
'
vs/workbench/parts/debug/common/debug
'
;
import
{
IDialogService
}
from
'
vs/platform/dialogs/common/dialogs
'
;
import
{
randomPort
}
from
'
vs/base/node/ports
'
;
import
{
IContextKeyService
,
RawContextKey
,
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
export
const
IExtensionHostProfileService
=
createDecorator
<
IExtensionHostProfileService
>
(
'
extensionHostProfileService
'
);
export
const
CONTEXT_PROFILE_SESSION_STATE
=
new
RawContextKey
<
string
>
(
'
profileSessionState
'
,
'
none
'
);
export
const
CONTEXT_EXTENSION_HOST_PROFILE_RECORDED
=
new
RawContextKey
<
boolean
>
(
'
extensionHostProfileRecorded
'
,
false
);
export
const
enum
ProfileSessionState
{
export
enum
ProfileSessionState
{
None
=
0
,
Starting
=
1
,
Running
=
2
,
...
...
@@ -89,7 +92,7 @@ interface IRuntimeExtension {
export
class
RuntimeExtensionsEditor
extends
BaseEditor
{
static
readonly
ID
:
string
=
'
workbench.editor.runtimeExtensions
'
;
public
static
readonly
ID
:
string
=
'
workbench.editor.runtimeExtensions
'
;
private
_list
:
WorkbenchList
<
IRuntimeExtension
>
;
private
_profileInfo
:
IExtensionHostProfile
;
...
...
@@ -97,10 +100,13 @@ export class RuntimeExtensionsEditor extends BaseEditor {
private
_elements
:
IRuntimeExtension
[];
private
_extensionsDescriptions
:
IExtensionDescription
[];
private
_updateSoon
:
RunOnceScheduler
;
private
_profileSessionState
:
IContextKey
<
string
>
;
private
_extensionsHostRecoded
:
IContextKey
<
boolean
>
;
constructor
(
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
IThemeService
themeService
:
IThemeService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IExtensionsWorkbenchService
private
readonly
_extensionsWorkbenchService
:
IExtensionsWorkbenchService
,
@
IExtensionService
private
readonly
_extensionService
:
IExtensionService
,
@
INotificationService
private
readonly
_notificationService
:
INotificationService
,
...
...
@@ -114,14 +120,23 @@ export class RuntimeExtensionsEditor extends BaseEditor {
this
.
_profileInfo
=
this
.
_extensionHostProfileService
.
lastProfile
;
this
.
_register
(
this
.
_extensionHostProfileService
.
onDidChangeLastProfile
(()
=>
{
this
.
_profileInfo
=
this
.
_extensionHostProfileService
.
lastProfile
;
this
.
_extensionsHostRecoded
.
set
(
!!
this
.
_profileInfo
);
this
.
_updateExtensions
();
}));
this
.
_extensionHostProfileService
.
onDidChangeState
(()
=>
{
const
state
=
this
.
_extensionHostProfileService
.
state
;
this
.
_profileSessionState
.
set
(
ProfileSessionState
[
state
].
toLowerCase
());
});
this
.
_elements
=
null
;
this
.
_extensionsDescriptions
=
[];
this
.
_updateExtensions
();
this
.
_profileSessionState
=
CONTEXT_PROFILE_SESSION_STATE
.
bindTo
(
contextKeyService
);
this
.
_extensionsHostRecoded
=
CONTEXT_EXTENSION_HOST_PROFILE_RECORDED
.
bindTo
(
contextKeyService
);
this
.
_updateSoon
=
this
.
_register
(
new
RunOnceScheduler
(()
=>
this
.
_updateExtensions
(),
200
));
this
.
_extensionService
.
getExtensions
().
then
((
extensions
)
=>
{
...
...
@@ -401,7 +416,13 @@ export class RuntimeExtensionsEditor extends BaseEditor {
actions
.
forEach
((
a
:
DisableForWorkspaceAction
|
DisableGloballyAction
)
=>
a
.
extension
=
e
.
element
.
marketplaceInfo
);
actions
.
push
(
new
Separator
());
}
actions
.
push
(
this
.
extensionHostProfileAction
,
this
.
saveExtensionHostProfileAction
);
const
state
=
this
.
_extensionHostProfileService
.
state
;
if
(
state
===
ProfileSessionState
.
Running
)
{
actions
.
push
(
this
.
_instantiationService
.
createInstance
(
StopExtensionHostProfileAction
,
StopExtensionHostProfileAction
.
ID
,
StopExtensionHostProfileAction
.
LABEL
));
}
else
{
actions
.
push
(
this
.
_instantiationService
.
createInstance
(
StartExtensionHostProfileAction
,
StartExtensionHostProfileAction
.
ID
,
StartExtensionHostProfileAction
.
LABEL
));
}
actions
.
push
(
this
.
saveExtensionHostProfileAction
);
this
.
_contextMenuService
.
showContextMenu
({
getAnchor
:
()
=>
e
.
anchor
,
...
...
@@ -410,24 +431,6 @@ export class RuntimeExtensionsEditor extends BaseEditor {
});
}
public
getActions
():
IAction
[]
{
return
[
this
.
debugExtensionHostAction
,
this
.
saveExtensionHostProfileAction
,
this
.
extensionHostProfileAction
];
}
@
memoize
private
get
debugExtensionHostAction
():
IAction
{
return
this
.
_instantiationService
.
createInstance
(
DebugExtensionHostAction
);
}
@
memoize
private
get
extensionHostProfileAction
():
IAction
{
return
this
.
_instantiationService
.
createInstance
(
ExtensionHostProfileAction
,
ExtensionHostProfileAction
.
ID
,
ExtensionHostProfileAction
.
LABEL_START
);
}
@
memoize
private
get
saveExtensionHostProfileAction
():
IAction
{
return
this
.
_instantiationService
.
createInstance
(
SaveExtensionHostProfileAction
,
SaveExtensionHostProfileAction
.
ID
,
SaveExtensionHostProfileAction
.
LABEL
);
...
...
@@ -493,7 +496,7 @@ class ReportExtensionIssueAction extends Action {
}
}
class
DebugExtensionHostAction
extends
Action
{
export
class
DebugExtensionHostAction
extends
Action
{
static
readonly
ID
=
'
workbench.extensions.action.debugExtensionHost
'
;
static
LABEL
=
nls
.
localize
(
'
debugExtensionHost
'
,
"
Start Debugging Extension Host
"
);
static
CSS_CLASS
=
'
debug-extension-host
'
;
...
...
@@ -532,48 +535,41 @@ class DebugExtensionHostAction extends Action {
}
}
class
ExtensionHostProfileAction
extends
Action
{
export
class
Start
ExtensionHostProfileAction
extends
Action
{
static
readonly
ID
=
'
workbench.extensions.action.extensionHostProfile
'
;
static
LABEL_START
=
nls
.
localize
(
'
extensionHostProfileStart
'
,
"
Start Extension Host Profile
"
);
static
LABEL_STOP
=
nls
.
localize
(
'
extensionHostProfileStop
'
,
"
Stop Extension Host Profile
"
);
static
STOP_CSS_CLASS
=
'
extension-host-profile-stop
'
;
static
START_CSS_CLASS
=
'
extension-host-profile-start
'
;
static
LABEL
=
nls
.
localize
(
'
extensionHostProfileStart
'
,
"
Start Extension Host Profile
"
);
constructor
(
id
:
string
=
ExtensionHostProfileAction
.
ID
,
label
:
string
=
ExtensionHostProfileAction
.
LABEL_START
,
id
:
string
=
StartExtensionHostProfileAction
.
ID
,
label
:
string
=
StartExtensionHostProfileAction
.
LABEL
,
@
IExtensionHostProfileService
private
readonly
_extensionHostProfileService
:
IExtensionHostProfileService
,
)
{
super
(
id
,
label
,
ExtensionHostProfileAction
.
START_CSS_CLASS
);
super
(
id
,
label
);
}
this
.
_extensionHostProfileService
.
onDidChangeState
(()
=>
this
.
_update
());
run
():
TPromise
<
any
>
{
this
.
_extensionHostProfileService
.
startProfiling
();
return
TPromise
.
as
(
null
);
}
}
private
_update
():
void
{
const
state
=
this
.
_extensionHostProfileService
.
state
;
export
class
StopExtensionHostProfileAction
extends
Action
{
static
readonly
ID
=
'
workbench.extensions.action.stopExtensionHostProfile
'
;
static
LABEL
=
nls
.
localize
(
'
stopExtensionHostProfileStart
'
,
"
Stop Extension Host Profile
"
);
if
(
state
===
ProfileSessionState
.
Running
)
{
this
.
class
=
ExtensionHostProfileAction
.
STOP_CSS_CLASS
;
this
.
label
=
ExtensionHostProfileAction
.
LABEL_STOP
;
}
else
{
this
.
class
=
ExtensionHostProfileAction
.
START_CSS_CLASS
;
this
.
label
=
ExtensionHostProfileAction
.
LABEL_START
;
}
constructor
(
id
:
string
=
StartExtensionHostProfileAction
.
ID
,
label
:
string
=
StartExtensionHostProfileAction
.
LABEL
,
@
IExtensionHostProfileService
private
readonly
_extensionHostProfileService
:
IExtensionHostProfileService
,
)
{
super
(
id
,
label
);
}
run
():
TPromise
<
any
>
{
const
state
=
this
.
_extensionHostProfileService
.
state
;
if
(
state
===
ProfileSessionState
.
Running
)
{
this
.
_extensionHostProfileService
.
stopProfiling
();
}
else
if
(
state
===
ProfileSessionState
.
None
)
{
this
.
_extensionHostProfileService
.
startProfiling
();
}
this
.
_extensionHostProfileService
.
stopProfiling
();
return
TPromise
.
as
(
null
);
}
}
class
SaveExtensionHostProfileAction
extends
Action
{
export
class
SaveExtensionHostProfileAction
extends
Action
{
static
LABEL
=
nls
.
localize
(
'
saveExtensionHostProfile
'
,
"
Save Extension Host Profile
"
);
static
readonly
ID
=
'
workbench.extensions.action.saveExtensionHostProfile
'
;
...
...
@@ -584,8 +580,7 @@ class SaveExtensionHostProfileAction extends Action {
@
IEnvironmentService
private
readonly
_environmentService
:
IEnvironmentService
,
@
IExtensionHostProfileService
private
readonly
_extensionHostProfileService
:
IExtensionHostProfileService
,
)
{
super
(
id
,
label
,
'
save-extension-host-profile
'
,
false
);
this
.
enabled
=
(
this
.
_extensionHostProfileService
.
lastProfile
!==
null
);
super
(
id
,
label
,
undefined
,
false
);
this
.
_extensionHostProfileService
.
onDidChangeLastProfile
(()
=>
{
this
.
enabled
=
(
this
.
_extensionHostProfileService
.
lastProfile
!==
null
);
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录