Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
3db1eb51
V
vscode
项目概览
掘金者说
/
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,发现更多精彩内容 >>
提交
3db1eb51
编写于
7月 09, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - adopt action2 for help actions
上级
43184b2b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
150 addition
and
129 deletion
+150
-129
src/vs/workbench/browser/actions/helpActions.ts
src/vs/workbench/browser/actions/helpActions.ts
+150
-129
未找到文件。
src/vs/workbench/browser/actions/helpActions.ts
浏览文件 @
3db1eb51
...
...
@@ -3,224 +3,248 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
product
from
'
vs/platform/product/common/product
'
;
import
{
isMacintosh
,
isLinux
,
language
}
from
'
vs/base/common/platform
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
IWorkbenchActionRegistry
,
Extensions
}
from
'
vs/workbench/common/actions
'
;
import
{
SyncActionDescriptor
,
MenuRegistry
,
MenuId
}
from
'
vs/platform/actions/common/actions
'
;
import
{
MenuId
,
Action2
,
registerAction2
,
MenuRegistry
}
from
'
vs/platform/actions/common/actions
'
;
import
{
KeyChord
,
KeyMod
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
IProductService
}
from
'
vs/platform/product/common/productService
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
class
KeybindingsReferenceAction
extends
Action
{
const
helpCategory
=
nls
.
localize
(
'
help
'
,
"
Help
"
);
class
KeybindingsReferenceAction
extends
Action2
{
static
readonly
ID
=
'
workbench.action.keybindingsReference
'
;
static
readonly
LABEL
=
nls
.
localize
(
'
keybindingsReference
'
,
"
Keyboard Shortcuts Reference
"
);
static
readonly
AVAILABLE
=
!!
(
isLinux
?
product
.
keyboardShortcutsUrlLinux
:
isMacintosh
?
product
.
keyboardShortcutsUrlMac
:
product
.
keyboardShortcutsUrlWin
);
constructor
(
id
:
string
,
label
:
string
,
@
IOpenerService
private
readonly
openerService
:
IOpenerService
,
@
IProductService
private
readonly
productService
:
IProductService
)
{
super
(
id
,
label
);
constructor
()
{
super
({
id
:
KeybindingsReferenceAction
.
ID
,
title
:
{
value
:
nls
.
localize
(
'
keybindingsReference
'
,
"
Keyboard Shortcuts Reference
"
),
original
:
'
Help: Keyboard Shortcuts Reference
'
},
category
:
helpCategory
,
f1
:
true
,
keybinding
:
{
weight
:
KeybindingWeight
.
WorkbenchContrib
,
when
:
null
,
primary
:
KeyChord
(
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_K
,
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_R
)
}
});
}
async
run
():
Promise
<
void
>
{
const
url
=
isLinux
?
this
.
productService
.
keyboardShortcutsUrlLinux
:
isMacintosh
?
this
.
productService
.
keyboardShortcutsUrlMac
:
this
.
productService
.
keyboardShortcutsUrlWin
;
run
(
accessor
:
ServicesAccessor
):
void
{
const
productService
=
accessor
.
get
(
IProductService
);
const
openerService
=
accessor
.
get
(
IOpenerService
);
const
url
=
isLinux
?
productService
.
keyboardShortcutsUrlLinux
:
isMacintosh
?
productService
.
keyboardShortcutsUrlMac
:
productService
.
keyboardShortcutsUrlWin
;
if
(
url
)
{
this
.
openerService
.
open
(
URI
.
parse
(
url
));
openerService
.
open
(
URI
.
parse
(
url
));
}
}
}
class
OpenDocumentationUrlAction
extends
Action
{
class
OpenDocumentationUrlAction
extends
Action
2
{
static
readonly
ID
=
'
workbench.action.openDocumentationUrl
'
;
static
readonly
LABEL
=
nls
.
localize
(
'
openDocumentationUrl
'
,
"
Documentation
"
);
static
readonly
AVAILABLE
=
!!
product
.
documentationUrl
;
constructor
(
id
:
string
,
label
:
string
,
@
IOpenerService
private
readonly
openerService
:
IOpenerService
,
@
IProductService
private
readonly
productService
:
IProductService
)
{
super
(
id
,
label
);
constructor
(
)
{
super
({
id
:
OpenDocumentationUrlAction
.
ID
,
title
:
{
value
:
nls
.
localize
(
'
openDocumentationUrl
'
,
"
Documentation
"
),
original
:
'
Help: Documentation
'
}
,
category
:
helpCategory
,
f1
:
true
}
);
}
async
run
():
Promise
<
void
>
{
if
(
this
.
productService
.
documentationUrl
)
{
this
.
openerService
.
open
(
URI
.
parse
(
this
.
productService
.
documentationUrl
));
run
(
accessor
:
ServicesAccessor
):
void
{
const
productService
=
accessor
.
get
(
IProductService
);
const
openerService
=
accessor
.
get
(
IOpenerService
);
if
(
productService
.
documentationUrl
)
{
openerService
.
open
(
URI
.
parse
(
productService
.
documentationUrl
));
}
}
}
class
OpenIntroductoryVideosUrlAction
extends
Action
{
class
OpenIntroductoryVideosUrlAction
extends
Action
2
{
static
readonly
ID
=
'
workbench.action.openIntroductoryVideosUrl
'
;
static
readonly
LABEL
=
nls
.
localize
(
'
openIntroductoryVideosUrl
'
,
"
Introductory Videos
"
);
static
readonly
AVAILABLE
=
!!
product
.
introductoryVideosUrl
;
constructor
(
id
:
string
,
label
:
string
,
@
IOpenerService
private
readonly
openerService
:
IOpenerService
,
@
IProductService
private
readonly
productService
:
IProductService
)
{
super
(
id
,
label
);
constructor
(
)
{
super
({
id
:
OpenIntroductoryVideosUrlAction
.
ID
,
title
:
{
value
:
nls
.
localize
(
'
openIntroductoryVideosUrl
'
,
"
Introductory Videos
"
),
original
:
'
Help: Introductory Videos
'
}
,
category
:
helpCategory
,
f1
:
true
}
);
}
async
run
():
Promise
<
void
>
{
if
(
this
.
productService
.
introductoryVideosUrl
)
{
this
.
openerService
.
open
(
URI
.
parse
(
this
.
productService
.
introductoryVideosUrl
));
run
(
accessor
:
ServicesAccessor
):
void
{
const
productService
=
accessor
.
get
(
IProductService
);
const
openerService
=
accessor
.
get
(
IOpenerService
);
if
(
productService
.
introductoryVideosUrl
)
{
openerService
.
open
(
URI
.
parse
(
productService
.
introductoryVideosUrl
));
}
}
}
class
OpenTipsAndTricksUrlAction
extends
Action
{
class
OpenTipsAndTricksUrlAction
extends
Action
2
{
static
readonly
ID
=
'
workbench.action.openTipsAndTricksUrl
'
;
static
readonly
LABEL
=
nls
.
localize
(
'
openTipsAndTricksUrl
'
,
"
Tips and Tricks
"
);
static
readonly
AVAILABLE
=
!!
product
.
tipsAndTricksUrl
;
constructor
(
id
:
string
,
label
:
string
,
@
IOpenerService
private
readonly
openerService
:
IOpenerService
,
@
IProductService
private
readonly
productService
:
IProductService
)
{
super
(
id
,
label
);
constructor
(
)
{
super
({
id
:
OpenTipsAndTricksUrlAction
.
ID
,
title
:
{
value
:
nls
.
localize
(
'
openTipsAndTricksUrl
'
,
"
Tips and Tricks
"
),
original
:
'
Help: Tips and Tricks
'
}
,
category
:
helpCategory
,
f1
:
true
}
);
}
async
run
():
Promise
<
void
>
{
if
(
this
.
productService
.
tipsAndTricksUrl
)
{
this
.
openerService
.
open
(
URI
.
parse
(
this
.
productService
.
tipsAndTricksUrl
));
run
(
accessor
:
ServicesAccessor
):
void
{
const
productService
=
accessor
.
get
(
IProductService
);
const
openerService
=
accessor
.
get
(
IOpenerService
);
if
(
productService
.
tipsAndTricksUrl
)
{
openerService
.
open
(
URI
.
parse
(
productService
.
tipsAndTricksUrl
));
}
}
}
class
OpenNewsletterSignupUrlAction
extends
Action
{
class
OpenNewsletterSignupUrlAction
extends
Action
2
{
static
readonly
ID
=
'
workbench.action.openNewsletterSignupUrl
'
;
static
readonly
LABEL
=
nls
.
localize
(
'
newsletterSignup
'
,
"
Signup for the VS Code Newsletter
"
);
static
readonly
AVAILABLE
=
!!
product
.
newsletterSignupUrl
;
constructor
(
id
:
string
,
label
:
string
,
@
IOpenerService
private
readonly
openerService
:
IOpenerService
,
@
ITelemetryService
private
readonly
telemetryService
:
ITelemetryService
,
@
IProductService
private
readonly
productService
:
IProductService
)
{
super
(
id
,
label
);
constructor
()
{
super
({
id
:
OpenNewsletterSignupUrlAction
.
ID
,
title
:
{
value
:
nls
.
localize
(
'
newsletterSignup
'
,
"
Signup for the VS Code Newsletter
"
),
original
:
'
Help: Signup for the VS Code Newsletter
'
},
category
:
helpCategory
,
f1
:
true
});
}
async
run
():
Promise
<
void
>
{
const
info
=
await
this
.
telemetryService
.
getTelemetryInfo
();
async
run
(
accessor
:
ServicesAccessor
):
Promise
<
void
>
{
const
productService
=
accessor
.
get
(
IProductService
);
const
openerService
=
accessor
.
get
(
IOpenerService
);
const
telemetryService
=
accessor
.
get
(
ITelemetryService
);
this
.
openerService
.
open
(
URI
.
parse
(
`
${
this
.
productService
.
newsletterSignupUrl
}
?machineId=
${
encodeURIComponent
(
info
.
machineId
)}
`
));
const
info
=
await
telemetryService
.
getTelemetryInfo
();
openerService
.
open
(
URI
.
parse
(
`
${
productService
.
newsletterSignupUrl
}
?machineId=
${
encodeURIComponent
(
info
.
machineId
)}
`
));
}
}
class
OpenTwitterUrlAction
extends
Action
{
class
OpenTwitterUrlAction
extends
Action
2
{
static
readonly
ID
=
'
workbench.action.openTwitterUrl
'
;
static
readonly
LABEL
=
nls
.
localize
(
'
openTwitterUrl
'
,
"
Join Us on Twitter
"
);
static
readonly
AVAILABLE
=
!!
product
.
twitterUrl
;
constructor
(
id
:
string
,
label
:
string
,
@
IOpenerService
private
readonly
openerService
:
IOpenerService
,
@
IProductService
private
readonly
productService
:
IProductService
)
{
super
(
id
,
label
);
constructor
(
)
{
super
({
id
:
OpenTwitterUrlAction
.
ID
,
title
:
{
value
:
nls
.
localize
(
'
openTwitterUrl
'
,
"
Join Us on Twitter
"
),
original
:
'
Help: Join Us on Twitter
'
}
,
category
:
helpCategory
,
f1
:
true
}
);
}
async
run
():
Promise
<
void
>
{
if
(
this
.
productService
.
twitterUrl
)
{
this
.
openerService
.
open
(
URI
.
parse
(
this
.
productService
.
twitterUrl
));
run
(
accessor
:
ServicesAccessor
):
void
{
const
productService
=
accessor
.
get
(
IProductService
);
const
openerService
=
accessor
.
get
(
IOpenerService
);
if
(
productService
.
twitterUrl
)
{
openerService
.
open
(
URI
.
parse
(
productService
.
twitterUrl
));
}
}
}
class
OpenRequestFeatureUrlAction
extends
Action
{
class
OpenRequestFeatureUrlAction
extends
Action
2
{
static
readonly
ID
=
'
workbench.action.openRequestFeatureUrl
'
;
static
readonly
LABEL
=
nls
.
localize
(
'
openUserVoiceUrl
'
,
"
Search Feature Requests
"
);
static
readonly
AVAILABLE
=
!!
product
.
requestFeatureUrl
;
constructor
(
id
:
string
,
label
:
string
,
@
IOpenerService
private
readonly
openerService
:
IOpenerService
,
@
IProductService
private
readonly
productService
:
IProductService
)
{
super
(
id
,
label
);
constructor
(
)
{
super
({
id
:
OpenRequestFeatureUrlAction
.
ID
,
title
:
{
value
:
nls
.
localize
(
'
openUserVoiceUrl
'
,
"
Search Feature Requests
"
),
original
:
'
Help: Search Feature Requests
'
}
,
category
:
helpCategory
,
f1
:
true
}
);
}
async
run
():
Promise
<
void
>
{
if
(
this
.
productService
.
requestFeatureUrl
)
{
this
.
openerService
.
open
(
URI
.
parse
(
this
.
productService
.
requestFeatureUrl
));
run
(
accessor
:
ServicesAccessor
):
void
{
const
productService
=
accessor
.
get
(
IProductService
);
const
openerService
=
accessor
.
get
(
IOpenerService
);
if
(
productService
.
requestFeatureUrl
)
{
openerService
.
open
(
URI
.
parse
(
productService
.
requestFeatureUrl
));
}
}
}
class
OpenLicenseUrlAction
extends
Action
{
class
OpenLicenseUrlAction
extends
Action
2
{
static
readonly
ID
=
'
workbench.action.openLicenseUrl
'
;
static
readonly
LABEL
=
nls
.
localize
(
'
openLicenseUrl
'
,
"
View License
"
);
static
readonly
AVAILABLE
=
!!
product
.
licenseUrl
;
constructor
(
id
:
string
,
label
:
string
,
@
IOpenerService
private
readonly
openerService
:
IOpenerService
,
@
IProductService
private
readonly
productService
:
IProductService
)
{
super
(
id
,
label
);
constructor
(
)
{
super
({
id
:
OpenLicenseUrlAction
.
ID
,
title
:
{
value
:
nls
.
localize
(
'
openLicenseUrl
'
,
"
View License
"
),
original
:
'
Help: View License
'
}
,
category
:
helpCategory
,
f1
:
true
}
);
}
async
run
():
Promise
<
void
>
{
if
(
this
.
productService
.
licenseUrl
)
{
run
(
accessor
:
ServicesAccessor
):
void
{
const
productService
=
accessor
.
get
(
IProductService
);
const
openerService
=
accessor
.
get
(
IOpenerService
);
if
(
productService
.
licenseUrl
)
{
if
(
language
)
{
const
queryArgChar
=
this
.
productService
.
licenseUrl
.
indexOf
(
'
?
'
)
>
0
?
'
&
'
:
'
?
'
;
this
.
openerService
.
open
(
URI
.
parse
(
`
${
this
.
productService
.
licenseUrl
}${
queryArgChar
}
lang=
${
language
}
`
));
const
queryArgChar
=
productService
.
licenseUrl
.
indexOf
(
'
?
'
)
>
0
?
'
&
'
:
'
?
'
;
openerService
.
open
(
URI
.
parse
(
`
${
productService
.
licenseUrl
}${
queryArgChar
}
lang=
${
language
}
`
));
}
else
{
this
.
openerService
.
open
(
URI
.
parse
(
this
.
productService
.
licenseUrl
));
openerService
.
open
(
URI
.
parse
(
productService
.
licenseUrl
));
}
}
}
}
class
OpenPrivacyStatementUrlAction
extends
Action
{
class
OpenPrivacyStatementUrlAction
extends
Action
2
{
static
readonly
ID
=
'
workbench.action.openPrivacyStatementUrl
'
;
static
readonly
LABEL
=
nls
.
localize
(
'
openPrivacyStatement
'
,
"
Privacy Statement
"
);
static
readonly
AVAILABE
=
!!
product
.
privacyStatementUrl
;
constructor
(
id
:
string
,
label
:
string
,
@
IOpenerService
private
readonly
openerService
:
IOpenerService
,
@
IProductService
private
readonly
productService
:
IProductService
)
{
super
(
id
,
label
);
constructor
(
)
{
super
({
id
:
OpenPrivacyStatementUrlAction
.
ID
,
title
:
{
value
:
nls
.
localize
(
'
openPrivacyStatement
'
,
"
Privacy Statement
"
),
original
:
'
Help: Privacy Statement
'
}
,
category
:
helpCategory
,
f1
:
true
}
);
}
async
run
():
Promise
<
void
>
{
if
(
this
.
productService
.
privacyStatementUrl
)
{
run
(
accessor
:
ServicesAccessor
):
void
{
const
productService
=
accessor
.
get
(
IProductService
);
const
openerService
=
accessor
.
get
(
IOpenerService
);
if
(
productService
.
privacyStatementUrl
)
{
if
(
language
)
{
const
queryArgChar
=
this
.
productService
.
privacyStatementUrl
.
indexOf
(
'
?
'
)
>
0
?
'
&
'
:
'
?
'
;
this
.
openerService
.
open
(
URI
.
parse
(
`
${
this
.
productService
.
privacyStatementUrl
}${
queryArgChar
}
lang=
${
language
}
`
));
const
queryArgChar
=
productService
.
privacyStatementUrl
.
indexOf
(
'
?
'
)
>
0
?
'
&
'
:
'
?
'
;
openerService
.
open
(
URI
.
parse
(
`
${
productService
.
privacyStatementUrl
}${
queryArgChar
}
lang=
${
language
}
`
));
}
else
{
this
.
openerService
.
open
(
URI
.
parse
(
this
.
productService
.
privacyStatementUrl
));
openerService
.
open
(
URI
.
parse
(
productService
.
privacyStatementUrl
));
}
}
}
...
...
@@ -228,43 +252,40 @@ class OpenPrivacyStatementUrlAction extends Action {
// --- Actions Registration
const
registry
=
Registry
.
as
<
IWorkbenchActionRegistry
>
(
Extensions
.
WorkbenchActions
);
const
helpCategory
=
nls
.
localize
(
'
help
'
,
"
Help
"
);
if
(
KeybindingsReferenceAction
.
AVAILABLE
)
{
regist
ry
.
registerWorkbenchAction
(
SyncActionDescriptor
.
from
(
KeybindingsReferenceAction
,
{
primary
:
KeyChord
(
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_K
,
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_R
)
}),
'
Help: Keyboard Shortcuts Reference
'
,
helpCategory
);
regist
erAction2
(
KeybindingsReferenceAction
);
}
if
(
OpenDocumentationUrlAction
.
AVAILABLE
)
{
regist
ry
.
registerWorkbenchAction
(
SyncActionDescriptor
.
from
(
OpenDocumentationUrlAction
),
'
Help: Documentation
'
,
helpCategory
);
regist
erAction2
(
OpenDocumentationUrlAction
);
}
if
(
OpenIntroductoryVideosUrlAction
.
AVAILABLE
)
{
regist
ry
.
registerWorkbenchAction
(
SyncActionDescriptor
.
from
(
OpenIntroductoryVideosUrlAction
),
'
Help: Introductory Videos
'
,
helpCategory
);
regist
erAction2
(
OpenIntroductoryVideosUrlAction
);
}
if
(
OpenTipsAndTricksUrlAction
.
AVAILABLE
)
{
regist
ry
.
registerWorkbenchAction
(
SyncActionDescriptor
.
from
(
OpenTipsAndTricksUrlAction
),
'
Help: Tips and Tricks
'
,
helpCategory
);
regist
erAction2
(
OpenTipsAndTricksUrlAction
);
}
if
(
OpenNewsletterSignupUrlAction
.
AVAILABLE
)
{
regist
ry
.
registerWorkbenchAction
(
SyncActionDescriptor
.
from
(
OpenNewsletterSignupUrlAction
),
'
Help: Tips and Tricks
'
,
helpCategory
);
regist
erAction2
(
OpenNewsletterSignupUrlAction
);
}
if
(
OpenTwitterUrlAction
.
AVAILABLE
)
{
regist
ry
.
registerWorkbenchAction
(
SyncActionDescriptor
.
from
(
OpenTwitterUrlAction
),
'
Help: Join Us on Twitter
'
,
helpCategory
);
regist
erAction2
(
OpenTwitterUrlAction
);
}
if
(
OpenRequestFeatureUrlAction
.
AVAILABLE
)
{
regist
ry
.
registerWorkbenchAction
(
SyncActionDescriptor
.
from
(
OpenRequestFeatureUrlAction
),
'
Help: Search Feature Requests
'
,
helpCategory
);
regist
erAction2
(
OpenRequestFeatureUrlAction
);
}
if
(
OpenLicenseUrlAction
.
AVAILABLE
)
{
regist
ry
.
registerWorkbenchAction
(
SyncActionDescriptor
.
from
(
OpenLicenseUrlAction
),
'
Help: View License
'
,
helpCategory
);
regist
erAction2
(
OpenLicenseUrlAction
);
}
if
(
OpenPrivacyStatementUrlAction
.
AVAILABE
)
{
regist
ry
.
registerWorkbenchAction
(
SyncActionDescriptor
.
from
(
OpenPrivacyStatementUrlAction
),
'
Help: Privacy Statement
'
,
helpCategory
);
regist
erAction2
(
OpenPrivacyStatementUrlAction
);
}
// --- Menu Registration
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录