Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
1711f6e2
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,发现更多精彩内容 >>
提交
1711f6e2
编写于
11月 05, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
run peek references when running go to definition on the only definition, fixes #73081
上级
63b032ad
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
84 addition
and
66 deletion
+84
-66
src/vs/editor/contrib/gotoSymbol/goToCommands.ts
src/vs/editor/contrib/gotoSymbol/goToCommands.ts
+83
-65
src/vs/editor/contrib/gotoSymbol/referencesModel.ts
src/vs/editor/contrib/gotoSymbol/referencesModel.ts
+1
-1
未找到文件。
src/vs/editor/contrib/gotoSymbol/goToCommands.ts
浏览文件 @
1711f6e2
...
...
@@ -8,7 +8,7 @@ import { createCancelablePromise, raceCancellation } from 'vs/base/common/async'
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
KeyChord
,
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
{
isWeb
}
from
'
vs/base/common/platform
'
;
import
{
ICodeEditor
,
isCodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ICodeEditor
,
isCodeEditor
,
IActiveCodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
EditorAction
,
IActionOptions
,
registerEditorAction
,
ServicesAccessor
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
*
as
corePosition
from
'
vs/editor/common/core/position
'
;
...
...
@@ -35,9 +35,9 @@ import { isStandalone } from 'vs/base/browser/browser';
import
{
URI
}
from
'
vs/base/common/uri
'
;
export
interface
SymbolNavigationActionConfig
{
openToSide
:
boolean
;
// = false
openInPeek
:
boolean
;
// = false
muteMessage
:
boolean
;
// = true
openToSide
:
boolean
;
openInPeek
:
boolean
;
muteMessage
:
boolean
;
}
abstract
class
SymbolNavigationAction
extends
EditorAction
{
...
...
@@ -69,8 +69,10 @@ abstract class SymbolNavigationAction extends EditorAction {
return
;
}
const
referenceUnderCusor
=
references
.
referenceAt
(
model
.
uri
,
pos
);
alert
(
references
.
ariaMessage
);
const
referenceCount
=
references
.
references
.
length
;
const
altAction
=
references
.
referenceAt
(
model
.
uri
,
pos
)
&&
editor
.
getAction
(
this
.
_getAlternativeCommand
());
if
(
referenceCount
===
0
)
{
// no result -> show message
...
...
@@ -78,12 +80,12 @@ abstract class SymbolNavigationAction extends EditorAction {
const
info
=
model
.
getWordAtPosition
(
pos
);
MessageController
.
get
(
editor
).
showMessage
(
this
.
_getNoResultFoundMessage
(
info
),
pos
);
}
}
else
if
(
referenceCount
===
1
&&
referenceUnderCusor
)
{
//
only the position at which we are -> adjust selection
return
this
.
_openReference
(
editor
,
editorService
,
referenceUnderCusor
,
false
).
then
(()
=>
undefined
);
}
else
if
(
referenceCount
===
1
&&
altAction
)
{
//
already at the only result, run alternative
altAction
.
run
(
);
}
else
{
//
handle multile results
//
normal results handling
return
this
.
_onResult
(
editorService
,
symbolNavService
,
editor
,
references
);
}
...
...
@@ -104,20 +106,16 @@ abstract class SymbolNavigationAction extends EditorAction {
protected
abstract
_getMetaTitle
(
model
:
ReferencesModel
):
string
;
pr
ivate
async
_onResult
(
editorService
:
ICodeEditorService
,
symbolNavService
:
ISymbolNavigationService
,
editor
:
ICodeEditor
,
model
:
ReferencesModel
):
Promise
<
void
>
{
pr
otected
abstract
_getAlternativeCommand
():
string
;
const
msg
=
model
.
getAriaMessage
();
alert
(
msg
);
private
async
_onResult
(
editorService
:
ICodeEditorService
,
symbolNavService
:
ISymbolNavigationService
,
editor
:
IActiveCodeEditor
,
model
:
ReferencesModel
):
Promise
<
void
>
{
const
gotoLocation
=
editor
.
getOption
(
EditorOption
.
gotoLocation
);
if
(
this
.
_configuration
.
openInPeek
||
(
gotoLocation
.
multiple
===
'
peek
'
&&
model
.
references
.
length
>
1
))
{
this
.
_openInPeek
(
editorService
,
editor
,
model
);
}
else
if
(
editor
.
hasModel
())
{
const
next
=
model
.
firstReference
();
if
(
!
next
)
{
return
;
}
}
else
{
const
next
=
model
.
firstReference
()
!
;
const
targetEditor
=
await
this
.
_openReference
(
editor
,
editorService
,
next
,
this
.
_configuration
.
openToSide
);
if
(
targetEditor
&&
model
.
references
.
length
>
1
&&
gotoLocation
.
multiple
===
'
gotoAndPeek
'
)
{
this
.
_openInPeek
(
editorService
,
targetEditor
,
model
);
...
...
@@ -188,6 +186,10 @@ export class DefinitionAction extends SymbolNavigationAction {
protected
_getMetaTitle
(
model
:
ReferencesModel
):
string
{
return
model
.
references
.
length
>
1
?
nls
.
localize
(
'
meta.title
'
,
"
– {0} definitions
"
,
model
.
references
.
length
)
:
''
;
}
protected
_getAlternativeCommand
():
string
{
return
'
editor.action.referenceSearch.trigger
'
;
}
}
const
goToDefinitionKb
=
isWeb
&&
!
isStandalone
...
...
@@ -307,6 +309,10 @@ class DeclarationAction extends SymbolNavigationAction {
protected
_getMetaTitle
(
model
:
ReferencesModel
):
string
{
return
model
.
references
.
length
>
1
?
nls
.
localize
(
'
decl.meta.title
'
,
"
– {0} declarations
"
,
model
.
references
.
length
)
:
''
;
}
protected
_getAlternativeCommand
():
string
{
return
'
editor.action.referenceSearch.trigger
'
;
}
}
registerEditorAction
(
class
GoToDeclarationAction
extends
DeclarationAction
{
...
...
@@ -367,28 +373,32 @@ registerEditorAction(class PeekDeclarationAction extends DeclarationAction {
//#endregion
//#region ---
IMPLEMENTA
TION
//#region ---
TYPE DEFINI
TION
class
Implementa
tionAction
extends
SymbolNavigationAction
{
class
TypeDefini
tionAction
extends
SymbolNavigationAction
{
protected
async
_getLocationModel
(
model
:
ITextModel
,
position
:
corePosition
.
Position
,
token
:
CancellationToken
):
Promise
<
ReferencesModel
>
{
return
new
ReferencesModel
(
await
get
Implementa
tionsAtPosition
(
model
,
position
,
token
));
return
new
ReferencesModel
(
await
get
TypeDefini
tionsAtPosition
(
model
,
position
,
token
));
}
protected
_getNoResultFoundMessage
(
info
:
IWordAtPosition
|
null
):
string
{
return
info
&&
info
.
word
?
nls
.
localize
(
'
goTo
Implementation.noResultWord
'
,
"
No implementa
tion found for '{0}'
"
,
info
.
word
)
:
nls
.
localize
(
'
goTo
Implementation.generic.noResults
'
,
"
No implementa
tion found
"
);
?
nls
.
localize
(
'
goTo
TypeDefinition.noResultWord
'
,
"
No type defini
tion found for '{0}'
"
,
info
.
word
)
:
nls
.
localize
(
'
goTo
TypeDefinition.generic.noResults
'
,
"
No type defini
tion found
"
);
}
protected
_getMetaTitle
(
model
:
ReferencesModel
):
string
{
return
model
.
references
.
length
>
1
?
nls
.
localize
(
'
meta.implementations.title
'
,
"
– {0} implementations
"
,
model
.
references
.
length
)
:
''
;
return
model
.
references
.
length
>
1
?
nls
.
localize
(
'
meta.typeDefinitions.title
'
,
"
– {0} type definitions
"
,
model
.
references
.
length
)
:
''
;
}
protected
_getAlternativeCommand
():
string
{
return
'
editor.action.referenceSearch.trigger
'
;
}
}
registerEditorAction
(
class
GoTo
ImplementationAction
extends
Implementa
tionAction
{
registerEditorAction
(
class
GoTo
TypeDefinitionAction
extends
TypeDefini
tionAction
{
public
static
readonly
ID
=
'
editor.action.goTo
Implementa
tion
'
;
public
static
readonly
ID
=
'
editor.action.goTo
TypeDefini
tion
'
;
constructor
()
{
super
({
...
...
@@ -396,29 +406,34 @@ registerEditorAction(class GoToImplementationAction extends ImplementationAction
openInPeek
:
false
,
muteMessage
:
false
},
{
id
:
GoTo
Implementa
tionAction
.
ID
,
label
:
nls
.
localize
(
'
actions.goTo
Implementation.label
'
,
"
Go to Implementa
tion
"
),
alias
:
'
Go to
Implementa
tion
'
,
id
:
GoTo
TypeDefini
tionAction
.
ID
,
label
:
nls
.
localize
(
'
actions.goTo
TypeDefinition.label
'
,
"
Go to Type Defini
tion
"
),
alias
:
'
Go to
Type Defini
tion
'
,
precondition
:
ContextKeyExpr
.
and
(
EditorContextKeys
.
has
Implementa
tionProvider
,
EditorContextKeys
.
has
TypeDefini
tionProvider
,
EditorContextKeys
.
isInEmbeddedEditor
.
toNegated
()),
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
editorTextFocus
,
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
F12
,
primary
:
0
,
weight
:
KeybindingWeight
.
EditorContrib
},
menuOpts
:
{
group
:
'
navigation
'
,
order
:
1.4
},
menubarOpts
:
{
menuId
:
MenuId
.
MenubarGoMenu
,
group
:
'
4_symbol_nav
'
,
order
:
4
,
title
:
nls
.
localize
({
key
:
'
miGotoImplementation
'
,
comment
:
[
'
&& denotes a mnemonic
'
]
},
"
Go to &&Implementation
"
)
order
:
3
,
title
:
nls
.
localize
({
key
:
'
miGotoTypeDefinition
'
,
comment
:
[
'
&& denotes a mnemonic
'
]
},
"
Go to &&Type Definition
"
)
}
});
}
});
registerEditorAction
(
class
Peek
ImplementationAction
extends
Implementa
tionAction
{
registerEditorAction
(
class
Peek
TypeDefinitionAction
extends
TypeDefini
tionAction
{
public
static
readonly
ID
=
'
editor.action.peek
Implementa
tion
'
;
public
static
readonly
ID
=
'
editor.action.peek
TypeDefini
tion
'
;
constructor
()
{
super
({
...
...
@@ -426,15 +441,15 @@ registerEditorAction(class PeekImplementationAction extends ImplementationAction
openInPeek
:
true
,
muteMessage
:
false
},
{
id
:
Peek
Implementa
tionAction
.
ID
,
label
:
nls
.
localize
(
'
actions.peek
Implementation.label
'
,
"
Peek Implementa
tion
"
),
alias
:
'
Peek
Implementa
tion
'
,
id
:
Peek
TypeDefini
tionAction
.
ID
,
label
:
nls
.
localize
(
'
actions.peek
TypeDefinition.label
'
,
"
Peek Type Defini
tion
"
),
alias
:
'
Peek
Type Defini
tion
'
,
precondition
:
ContextKeyExpr
.
and
(
EditorContextKeys
.
has
Implementa
tionProvider
,
EditorContextKeys
.
has
TypeDefini
tionProvider
,
EditorContextKeys
.
isInEmbeddedEditor
.
toNegated
()),
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
editorTextFocus
,
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Shift
|
KeyCode
.
F12
,
primary
:
0
,
weight
:
KeybindingWeight
.
EditorContrib
}
});
...
...
@@ -443,28 +458,32 @@ registerEditorAction(class PeekImplementationAction extends ImplementationAction
//#endregion
//#region ---
TYPE DEFINI
TION
//#region ---
IMPLEMENTA
TION
class
TypeDefini
tionAction
extends
SymbolNavigationAction
{
class
Implementa
tionAction
extends
SymbolNavigationAction
{
protected
async
_getLocationModel
(
model
:
ITextModel
,
position
:
corePosition
.
Position
,
token
:
CancellationToken
):
Promise
<
ReferencesModel
>
{
return
new
ReferencesModel
(
await
get
TypeDefini
tionsAtPosition
(
model
,
position
,
token
));
return
new
ReferencesModel
(
await
get
Implementa
tionsAtPosition
(
model
,
position
,
token
));
}
protected
_getNoResultFoundMessage
(
info
:
IWordAtPosition
|
null
):
string
{
return
info
&&
info
.
word
?
nls
.
localize
(
'
goTo
TypeDefinition.noResultWord
'
,
"
No type defini
tion found for '{0}'
"
,
info
.
word
)
:
nls
.
localize
(
'
goTo
TypeDefinition.generic.noResults
'
,
"
No type defini
tion found
"
);
?
nls
.
localize
(
'
goTo
Implementation.noResultWord
'
,
"
No implementa
tion found for '{0}'
"
,
info
.
word
)
:
nls
.
localize
(
'
goTo
Implementation.generic.noResults
'
,
"
No implementa
tion found
"
);
}
protected
_getMetaTitle
(
model
:
ReferencesModel
):
string
{
return
model
.
references
.
length
>
1
?
nls
.
localize
(
'
meta.typeDefinitions.title
'
,
"
– {0} type definitions
"
,
model
.
references
.
length
)
:
''
;
return
model
.
references
.
length
>
1
?
nls
.
localize
(
'
meta.implementations.title
'
,
"
– {0} implementations
"
,
model
.
references
.
length
)
:
''
;
}
protected
_getAlternativeCommand
():
string
{
return
''
;
}
}
registerEditorAction
(
class
GoTo
TypeDefinitionAction
extends
TypeDefini
tionAction
{
registerEditorAction
(
class
GoTo
ImplementationAction
extends
Implementa
tionAction
{
public
static
readonly
ID
=
'
editor.action.goTo
TypeDefini
tion
'
;
public
static
readonly
ID
=
'
editor.action.goTo
Implementa
tion
'
;
constructor
()
{
super
({
...
...
@@ -472,34 +491,29 @@ registerEditorAction(class GoToTypeDefinitionAction extends TypeDefinitionAction
openInPeek
:
false
,
muteMessage
:
false
},
{
id
:
GoTo
TypeDefini
tionAction
.
ID
,
label
:
nls
.
localize
(
'
actions.goTo
TypeDefinition.label
'
,
"
Go to Type Defini
tion
"
),
alias
:
'
Go to
Type Defini
tion
'
,
id
:
GoTo
Implementa
tionAction
.
ID
,
label
:
nls
.
localize
(
'
actions.goTo
Implementation.label
'
,
"
Go to Implementa
tion
"
),
alias
:
'
Go to
Implementa
tion
'
,
precondition
:
ContextKeyExpr
.
and
(
EditorContextKeys
.
has
TypeDefini
tionProvider
,
EditorContextKeys
.
has
Implementa
tionProvider
,
EditorContextKeys
.
isInEmbeddedEditor
.
toNegated
()),
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
editorTextFocus
,
primary
:
0
,
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
F12
,
weight
:
KeybindingWeight
.
EditorContrib
},
menuOpts
:
{
group
:
'
navigation
'
,
order
:
1.4
},
menubarOpts
:
{
menuId
:
MenuId
.
MenubarGoMenu
,
group
:
'
4_symbol_nav
'
,
order
:
3
,
title
:
nls
.
localize
({
key
:
'
miGotoTypeDefinition
'
,
comment
:
[
'
&& denotes a mnemonic
'
]
},
"
Go to &&Type Definition
"
)
order
:
4
,
title
:
nls
.
localize
({
key
:
'
miGotoImplementation
'
,
comment
:
[
'
&& denotes a mnemonic
'
]
},
"
Go to &&Implementation
"
)
}
});
}
});
registerEditorAction
(
class
Peek
TypeDefinitionAction
extends
TypeDefini
tionAction
{
registerEditorAction
(
class
Peek
ImplementationAction
extends
Implementa
tionAction
{
public
static
readonly
ID
=
'
editor.action.peek
TypeDefini
tion
'
;
public
static
readonly
ID
=
'
editor.action.peek
Implementa
tion
'
;
constructor
()
{
super
({
...
...
@@ -507,15 +521,15 @@ registerEditorAction(class PeekTypeDefinitionAction extends TypeDefinitionAction
openInPeek
:
true
,
muteMessage
:
false
},
{
id
:
Peek
TypeDefini
tionAction
.
ID
,
label
:
nls
.
localize
(
'
actions.peek
TypeDefinition.label
'
,
"
Peek Type Defini
tion
"
),
alias
:
'
Peek
Type Defini
tion
'
,
id
:
Peek
Implementa
tionAction
.
ID
,
label
:
nls
.
localize
(
'
actions.peek
Implementation.label
'
,
"
Peek Implementa
tion
"
),
alias
:
'
Peek
Implementa
tion
'
,
precondition
:
ContextKeyExpr
.
and
(
EditorContextKeys
.
has
TypeDefini
tionProvider
,
EditorContextKeys
.
has
Implementa
tionProvider
,
EditorContextKeys
.
isInEmbeddedEditor
.
toNegated
()),
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
editorTextFocus
,
primary
:
0
,
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Shift
|
KeyCode
.
F12
,
weight
:
KeybindingWeight
.
EditorContrib
}
});
...
...
@@ -543,6 +557,10 @@ class ReferencesAction extends SymbolNavigationAction {
?
nls
.
localize
(
'
meta.titleReference
'
,
"
– {0} references
"
,
model
.
references
.
length
)
:
''
;
}
protected
_getAlternativeCommand
():
string
{
return
''
;
}
}
registerEditorAction
(
class
GoToReferencesAction
extends
ReferencesAction
{
...
...
@@ -596,7 +614,7 @@ registerEditorAction(class PeekReferencesAction extends ReferencesAction {
//#endregion
//#region ---
-
REFERENCE search special commands
//#region --- REFERENCE search special commands
const
defaultReferenceSearchOptions
:
RequestOptions
=
{
getMetaTitle
(
model
)
{
...
...
src/vs/editor/contrib/gotoSymbol/referencesModel.ts
浏览文件 @
1711f6e2
...
...
@@ -192,7 +192,7 @@ export class ReferencesModel implements IDisposable {
return
this
.
groups
.
length
===
0
;
}
get
A
riaMessage
():
string
{
get
a
riaMessage
():
string
{
if
(
this
.
isEmpty
)
{
return
localize
(
'
aria.result.0
'
,
"
No results found
"
);
}
else
if
(
this
.
references
.
length
===
1
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录