Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
bfd40c5a
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,发现更多精彩内容 >>
提交
bfd40c5a
编写于
11月 12, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add internal interfaces and actions for go to declaration, #62483
上级
8e55669b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
78 addition
and
1 deletion
+78
-1
src/vs/editor/browser/widget/codeEditorWidget.ts
src/vs/editor/browser/widget/codeEditorWidget.ts
+5
-0
src/vs/editor/common/editorContextKeys.ts
src/vs/editor/common/editorContextKeys.ts
+1
-0
src/vs/editor/common/modes.ts
src/vs/editor/common/modes.ts
+17
-0
src/vs/editor/contrib/goToDefinition/goToDefinition.ts
src/vs/editor/contrib/goToDefinition/goToDefinition.ts
+8
-1
src/vs/editor/contrib/goToDefinition/goToDefinitionCommands.ts
...s/editor/contrib/goToDefinition/goToDefinitionCommands.ts
+35
-0
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+12
-0
未找到文件。
src/vs/editor/browser/widget/codeEditorWidget.ts
浏览文件 @
bfd40c5a
...
...
@@ -1639,6 +1639,7 @@ export class EditorModeContext extends Disposable {
private
_hasCodeActionsProvider
:
IContextKey
<
boolean
>
;
private
_hasCodeLensProvider
:
IContextKey
<
boolean
>
;
private
_hasDefinitionProvider
:
IContextKey
<
boolean
>
;
private
_hasDeclarationProvider
:
IContextKey
<
boolean
>
;
private
_hasImplementationProvider
:
IContextKey
<
boolean
>
;
private
_hasTypeDefinitionProvider
:
IContextKey
<
boolean
>
;
private
_hasHoverProvider
:
IContextKey
<
boolean
>
;
...
...
@@ -1663,6 +1664,7 @@ export class EditorModeContext extends Disposable {
this
.
_hasCodeActionsProvider
=
EditorContextKeys
.
hasCodeActionsProvider
.
bindTo
(
contextKeyService
);
this
.
_hasCodeLensProvider
=
EditorContextKeys
.
hasCodeLensProvider
.
bindTo
(
contextKeyService
);
this
.
_hasDefinitionProvider
=
EditorContextKeys
.
hasDefinitionProvider
.
bindTo
(
contextKeyService
);
this
.
_hasDeclarationProvider
=
EditorContextKeys
.
hasDeclarationProvider
.
bindTo
(
contextKeyService
);
this
.
_hasImplementationProvider
=
EditorContextKeys
.
hasImplementationProvider
.
bindTo
(
contextKeyService
);
this
.
_hasTypeDefinitionProvider
=
EditorContextKeys
.
hasTypeDefinitionProvider
.
bindTo
(
contextKeyService
);
this
.
_hasHoverProvider
=
EditorContextKeys
.
hasHoverProvider
.
bindTo
(
contextKeyService
);
...
...
@@ -1686,6 +1688,7 @@ export class EditorModeContext extends Disposable {
this
.
_register
(
modes
.
CodeActionProviderRegistry
.
onDidChange
(
update
));
this
.
_register
(
modes
.
CodeLensProviderRegistry
.
onDidChange
(
update
));
this
.
_register
(
modes
.
DefinitionProviderRegistry
.
onDidChange
(
update
));
this
.
_register
(
modes
.
DeclarationProviderRegistry
.
onDidChange
(
update
));
this
.
_register
(
modes
.
ImplementationProviderRegistry
.
onDidChange
(
update
));
this
.
_register
(
modes
.
TypeDefinitionProviderRegistry
.
onDidChange
(
update
));
this
.
_register
(
modes
.
HoverProviderRegistry
.
onDidChange
(
update
));
...
...
@@ -1710,6 +1713,7 @@ export class EditorModeContext extends Disposable {
this
.
_hasCodeActionsProvider
.
reset
();
this
.
_hasCodeLensProvider
.
reset
();
this
.
_hasDefinitionProvider
.
reset
();
this
.
_hasDeclarationProvider
.
reset
();
this
.
_hasImplementationProvider
.
reset
();
this
.
_hasTypeDefinitionProvider
.
reset
();
this
.
_hasHoverProvider
.
reset
();
...
...
@@ -1734,6 +1738,7 @@ export class EditorModeContext extends Disposable {
this
.
_hasCodeActionsProvider
.
set
(
modes
.
CodeActionProviderRegistry
.
has
(
model
));
this
.
_hasCodeLensProvider
.
set
(
modes
.
CodeLensProviderRegistry
.
has
(
model
));
this
.
_hasDefinitionProvider
.
set
(
modes
.
DefinitionProviderRegistry
.
has
(
model
));
this
.
_hasDeclarationProvider
.
set
(
modes
.
DeclarationProviderRegistry
.
has
(
model
));
this
.
_hasImplementationProvider
.
set
(
modes
.
ImplementationProviderRegistry
.
has
(
model
));
this
.
_hasTypeDefinitionProvider
.
set
(
modes
.
TypeDefinitionProviderRegistry
.
has
(
model
));
this
.
_hasHoverProvider
.
set
(
modes
.
HoverProviderRegistry
.
has
(
model
));
...
...
src/vs/editor/common/editorContextKeys.ts
浏览文件 @
bfd40c5a
...
...
@@ -38,6 +38,7 @@ export namespace EditorContextKeys {
export
const
hasCodeActionsProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasCodeActionsProvider
'
,
false
);
export
const
hasCodeLensProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasCodeLensProvider
'
,
false
);
export
const
hasDefinitionProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasDefinitionProvider
'
,
false
);
export
const
hasDeclarationProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasDeclarationProvider
'
,
false
);
export
const
hasImplementationProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasImplementationProvider
'
,
false
);
export
const
hasTypeDefinitionProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasTypeDefinitionProvider
'
,
false
);
export
const
hasHoverProvider
=
new
RawContextKey
<
boolean
>
(
'
editorHasHoverProvider
'
,
false
);
...
...
src/vs/editor/common/modes.ts
浏览文件 @
bfd40c5a
...
...
@@ -747,6 +747,18 @@ export interface DefinitionProvider {
provideDefinition
(
model
:
model
.
ITextModel
,
position
:
Position
,
token
:
CancellationToken
):
ProviderResult
<
Definition
|
DefinitionLink
[]
>
;
}
/**
* The definition provider interface defines the contract between extensions and
* the [go to definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition)
* and peek definition features.
*/
export
interface
DeclarationProvider
{
/**
* Provide the declaration of the symbol at the given position and document.
*/
provideDeclaration
(
model
:
model
.
ITextModel
,
position
:
Position
,
token
:
CancellationToken
):
ProviderResult
<
Definition
|
DefinitionLink
[]
>
;
}
/**
* The implementation provider interface defines the contract between extensions and
* the go to implementation feature.
...
...
@@ -1275,6 +1287,11 @@ export const DocumentHighlightProviderRegistry = new LanguageFeatureRegistry<Doc
*/
export
const
DefinitionProviderRegistry
=
new
LanguageFeatureRegistry
<
DefinitionProvider
>
();
/**
* @internal
*/
export
const
DeclarationProviderRegistry
=
new
LanguageFeatureRegistry
<
DeclarationProvider
>
();
/**
* @internal
*/
...
...
src/vs/editor/contrib/goToDefinition/goToDefinition.ts
浏览文件 @
bfd40c5a
...
...
@@ -9,7 +9,7 @@ import { onUnexpectedExternalError } from 'vs/base/common/errors';
import
{
registerDefaultLanguageCommand
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
DefinitionLink
,
DefinitionProviderRegistry
,
ImplementationProviderRegistry
,
TypeDefinitionProviderRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
DefinitionLink
,
DefinitionProviderRegistry
,
ImplementationProviderRegistry
,
TypeDefinitionProviderRegistry
,
DeclarationProviderRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
LanguageFeatureRegistry
}
from
'
vs/editor/common/modes/languageFeatureRegistry
'
;
...
...
@@ -40,6 +40,12 @@ export function getDefinitionsAtPosition(model: ITextModel, position: Position,
});
}
export
function
getDeclarationsAtPosition
(
model
:
ITextModel
,
position
:
Position
,
token
:
CancellationToken
):
Thenable
<
DefinitionLink
[]
>
{
return
getDefinitions
(
model
,
position
,
DeclarationProviderRegistry
,
(
provider
,
model
,
position
)
=>
{
return
provider
.
provideDeclaration
(
model
,
position
,
token
);
});
}
export
function
getImplementationsAtPosition
(
model
:
ITextModel
,
position
:
Position
,
token
:
CancellationToken
):
Thenable
<
DefinitionLink
[]
>
{
return
getDefinitions
(
model
,
position
,
ImplementationProviderRegistry
,
(
provider
,
model
,
position
)
=>
{
return
provider
.
provideImplementation
(
model
,
position
,
token
);
...
...
@@ -53,5 +59,6 @@ export function getTypeDefinitionsAtPosition(model: ITextModel, position: Positi
}
registerDefaultLanguageCommand
(
'
_executeDefinitionProvider
'
,
(
model
,
position
)
=>
getDefinitionsAtPosition
(
model
,
position
,
CancellationToken
.
None
));
registerDefaultLanguageCommand
(
'
_executeDeclarationProvider
'
,
(
model
,
position
)
=>
getDeclarationsAtPosition
(
model
,
position
,
CancellationToken
.
None
));
registerDefaultLanguageCommand
(
'
_executeImplementationProvider
'
,
(
model
,
position
)
=>
getImplementationsAtPosition
(
model
,
position
,
CancellationToken
.
None
));
registerDefaultLanguageCommand
(
'
_executeTypeDefinitionProvider
'
,
(
model
,
position
)
=>
getTypeDefinitionsAtPosition
(
model
,
position
,
CancellationToken
.
None
));
src/vs/editor/contrib/goToDefinition/goToDefinitionCommands.ts
浏览文件 @
bfd40c5a
...
...
@@ -249,6 +249,41 @@ export class PeekDefinitionAction extends DefinitionAction {
}
}
export
class
GoToDeclarationAction
extends
DefinitionAction
{
public
static
readonly
ID
=
'
editor.action.goToDeclaration
'
;
constructor
()
{
super
(
new
DefinitionActionConfig
(),
{
id
:
GoToDeclarationAction
.
ID
,
label
:
nls
.
localize
(
'
actions.goToDeclaration.label
'
,
"
Go to Declaration
"
),
alias
:
'
Go to Declaration
'
,
precondition
:
ContextKeyExpr
.
and
(
EditorContextKeys
.
hasDeclarationProvider
,
EditorContextKeys
.
isInEmbeddedEditor
.
toNegated
()),
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
editorTextFocus
,
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
F12
,
weight
:
KeybindingWeight
.
EditorContrib
},
menuOpts
:
{
group
:
'
navigation
'
,
order
:
1.3
}
});
}
protected
_getNoResultFoundMessage
(
info
?:
IWordAtPosition
):
string
{
return
info
&&
info
.
word
?
nls
.
localize
(
'
decl.noResultWord
'
,
"
No declaration found for '{0}'
"
,
info
.
word
)
:
nls
.
localize
(
'
decl.generic.noResults
'
,
"
No declaration found
"
);
}
protected
_getMetaTitle
(
model
:
ReferencesModel
):
string
{
return
model
.
references
.
length
>
1
&&
nls
.
localize
(
'
decl.meta.title
'
,
"
– {0} declarations
"
,
model
.
references
.
length
);
}
}
export
class
ImplementationAction
extends
DefinitionAction
{
protected
_getDeclarationsAtPosition
(
model
:
ITextModel
,
position
:
corePosition
.
Position
,
token
:
CancellationToken
):
Thenable
<
DefinitionLink
[]
>
{
return
getImplementationsAtPosition
(
model
,
position
,
token
);
...
...
src/vs/monaco.d.ts
浏览文件 @
bfd40c5a
...
...
@@ -5058,6 +5058,18 @@ declare namespace monaco.languages {
provideDefinition
(
model
:
editor
.
ITextModel
,
position
:
Position
,
token
:
CancellationToken
):
ProviderResult
<
Definition
|
DefinitionLink
[]
>
;
}
/**
* The definition provider interface defines the contract between extensions and
* the [go to definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition)
* and peek definition features.
*/
export
interface
DeclarationProvider
{
/**
* Provide the declaration of the symbol at the given position and document.
*/
provideDeclaration
(
model
:
editor
.
ITextModel
,
position
:
Position
,
token
:
CancellationToken
):
ProviderResult
<
Definition
|
DefinitionLink
[]
>
;
}
/**
* The implementation provider interface defines the contract between extensions and
* the go to implementation feature.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录