Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ae03a05c
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,发现更多精彩内容 >>
提交
ae03a05c
编写于
11月 04, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move commands to references controller
上级
05b1d4b7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
142 addition
and
155 deletion
+142
-155
src/vs/editor/contrib/referenceSearch/peekViewWidget.ts
src/vs/editor/contrib/referenceSearch/peekViewWidget.ts
+21
-1
src/vs/editor/contrib/referenceSearch/referenceSearch.ts
src/vs/editor/contrib/referenceSearch/referenceSearch.ts
+7
-138
src/vs/editor/contrib/referenceSearch/referencesController.ts
...vs/editor/contrib/referenceSearch/referencesController.ts
+114
-16
未找到文件。
src/vs/editor/contrib/referenceSearch/peekViewWidget.ts
浏览文件 @
ae03a05c
...
...
@@ -17,11 +17,13 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
import
{
EmbeddedCodeEditorWidget
}
from
'
vs/editor/browser/widget/embeddedCodeEditorWidget
'
;
import
{
IOptions
,
IStyles
,
ZoneWidget
}
from
'
vs/editor/contrib/zoneWidget/zoneWidget
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
{
ContextKeyExpr
,
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ContextKeyExpr
,
RawContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ServicesAccessor
,
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
registerEditorContribution
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
IEditorContribution
}
from
'
vs/editor/common/editorCommon
'
;
export
const
IPeekViewService
=
createDecorator
<
IPeekViewService
>
(
'
IPeekViewService
'
);
...
...
@@ -57,6 +59,24 @@ export namespace PeekContext {
export
const
notInPeekEditor
:
ContextKeyExpr
=
inPeekEditor
.
toNegated
();
}
class
PeekContextController
implements
IEditorContribution
{
static
readonly
ID
=
'
editor.contrib.referenceController
'
;
constructor
(
editor
:
ICodeEditor
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
)
{
if
(
editor
instanceof
EmbeddedCodeEditorWidget
)
{
PeekContext
.
inPeekEditor
.
bindTo
(
contextKeyService
);
}
}
dispose
():
void
{
}
}
registerEditorContribution
(
PeekContextController
.
ID
,
PeekContextController
);
export
function
getOuterEditor
(
accessor
:
ServicesAccessor
):
ICodeEditor
|
null
{
let
editor
=
accessor
.
get
(
ICodeEditorService
).
getFocusedCodeEditor
();
if
(
editor
instanceof
EmbeddedCodeEditorWidget
)
{
...
...
src/vs/editor/contrib/referenceSearch/referenceSearch.ts
浏览文件 @
ae03a05c
...
...
@@ -4,54 +4,26 @@
*--------------------------------------------------------------------------------------------*/
import
*
as
nls
from
'
vs/nls
'
;
import
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
{
IContextKeyService
,
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
KeybindingsRegistry
,
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
Position
,
IPosition
}
from
'
vs/editor/common/core/position
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
ServicesAccessor
,
registerEditorContribution
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
ServicesAccessor
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
Location
}
from
'
vs/editor/common/modes
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
PeekContext
,
getOuterEditor
}
from
'
./peekViewWidget
'
;
import
{
ReferencesController
,
RequestOptions
,
ctxReferenceSearchVisible
}
from
'
./referencesController
'
;
import
{
ReferencesModel
,
OneReference
}
from
'
./referencesModel
'
;
import
{
ReferencesController
,
RequestOptions
}
from
'
./referencesController
'
;
import
{
ReferencesModel
}
from
'
./referencesModel
'
;
import
{
createCancelablePromise
}
from
'
vs/base/common/async
'
;
import
{
EmbeddedCodeEditorWidget
}
from
'
vs/editor/browser/widget/embeddedCodeEditorWidget
'
;
import
{
ICodeEditor
,
isCodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IListService
}
from
'
vs/platform/list/browser/listService
'
;
import
{
ctxReferenceWidgetSearchTreeFocused
}
from
'
vs/editor/contrib/referenceSearch/referencesWidget
'
;
import
{
isCodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
CommandsRegistry
,
ICommandHandler
}
from
'
vs/platform/commands/common/commands
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
getReferencesAtPosition
}
from
'
vs/editor/contrib/goToDefinition/goToDefinition
'
;
export
const
defaultReferenceSearchOptions
:
RequestOptions
=
{
const
defaultReferenceSearchOptions
:
RequestOptions
=
{
getMetaTitle
(
model
)
{
return
model
.
references
.
length
>
1
?
nls
.
localize
(
'
meta.titleReference
'
,
"
– {0} references
"
,
model
.
references
.
length
)
:
''
;
}
};
class
ReferenceController
implements
editorCommon
.
IEditorContribution
{
public
static
readonly
ID
=
'
editor.contrib.referenceController
'
;
constructor
(
editor
:
ICodeEditor
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
)
{
if
(
editor
instanceof
EmbeddedCodeEditorWidget
)
{
PeekContext
.
inPeekEditor
.
bindTo
(
contextKeyService
);
}
}
public
dispose
():
void
{
}
}
registerEditorContribution
(
ReferenceController
.
ID
,
ReferenceController
);
let
findReferencesCommand
:
ICommandHandler
=
(
accessor
:
ServicesAccessor
,
resource
:
URI
,
position
:
IPosition
)
=>
{
const
findReferencesCommand
:
ICommandHandler
=
(
accessor
:
ServicesAccessor
,
resource
:
URI
,
position
:
IPosition
)
=>
{
if
(
!
(
resource
instanceof
URI
))
{
throw
new
Error
(
'
illegal argument, uri
'
);
}
...
...
@@ -76,7 +48,7 @@ let findReferencesCommand: ICommandHandler = (accessor: ServicesAccessor, resour
});
};
le
t
showReferencesCommand
:
ICommandHandler
=
(
accessor
:
ServicesAccessor
,
resource
:
URI
,
position
:
IPosition
,
references
:
Location
[])
=>
{
cons
t
showReferencesCommand
:
ICommandHandler
=
(
accessor
:
ServicesAccessor
,
resource
:
URI
,
position
:
IPosition
,
references
:
Location
[])
=>
{
if
(
!
(
resource
instanceof
URI
))
{
throw
new
Error
(
'
illegal argument, uri expected
'
);
}
...
...
@@ -124,106 +96,3 @@ CommandsRegistry.registerCommand({
}
});
function
closeActiveReferenceSearch
(
accessor
:
ServicesAccessor
)
{
withController
(
accessor
,
controller
=>
controller
.
closeWidget
());
}
function
openReferenceToSide
(
accessor
:
ServicesAccessor
)
{
const
listService
=
accessor
.
get
(
IListService
);
const
focus
=
listService
.
lastFocusedList
&&
listService
.
lastFocusedList
.
getFocus
();
if
(
focus
instanceof
OneReference
)
{
withController
(
accessor
,
controller
=>
controller
.
openReference
(
focus
,
true
));
}
}
function
withController
(
accessor
:
ServicesAccessor
,
fn
:
(
controller
:
ReferencesController
)
=>
void
):
void
{
const
outerEditor
=
getOuterEditor
(
accessor
);
if
(
!
outerEditor
)
{
return
;
}
let
controller
=
ReferencesController
.
get
(
outerEditor
);
if
(
!
controller
)
{
return
;
}
fn
(
controller
);
}
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
goToNextReference
'
,
weight
:
KeybindingWeight
.
WorkbenchContrib
+
50
,
primary
:
KeyCode
.
F4
,
when
:
ctxReferenceSearchVisible
,
handler
(
accessor
)
{
withController
(
accessor
,
controller
=>
{
controller
.
goToNextOrPreviousReference
(
true
);
});
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
goToNextReferenceFromEmbeddedEditor
'
,
weight
:
KeybindingWeight
.
EditorContrib
+
50
,
primary
:
KeyCode
.
F4
,
when
:
PeekContext
.
inPeekEditor
,
handler
(
accessor
)
{
withController
(
accessor
,
controller
=>
{
controller
.
goToNextOrPreviousReference
(
true
);
});
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
goToPreviousReference
'
,
weight
:
KeybindingWeight
.
WorkbenchContrib
+
50
,
primary
:
KeyMod
.
Shift
|
KeyCode
.
F4
,
when
:
ctxReferenceSearchVisible
,
handler
(
accessor
)
{
withController
(
accessor
,
controller
=>
{
controller
.
goToNextOrPreviousReference
(
false
);
});
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
goToPreviousReferenceFromEmbeddedEditor
'
,
weight
:
KeybindingWeight
.
EditorContrib
+
50
,
primary
:
KeyMod
.
Shift
|
KeyCode
.
F4
,
when
:
PeekContext
.
inPeekEditor
,
handler
(
accessor
)
{
withController
(
accessor
,
controller
=>
{
controller
.
goToNextOrPreviousReference
(
false
);
});
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
closeReferenceSearch
'
,
weight
:
KeybindingWeight
.
WorkbenchContrib
+
50
,
primary
:
KeyCode
.
Escape
,
secondary
:
[
KeyMod
.
Shift
|
KeyCode
.
Escape
],
when
:
ContextKeyExpr
.
and
(
ctxReferenceSearchVisible
,
ContextKeyExpr
.
not
(
'
config.editor.stablePeek
'
)),
handler
:
closeActiveReferenceSearch
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
closeReferenceSearchEditor
'
,
weight
:
KeybindingWeight
.
EditorContrib
-
101
,
primary
:
KeyCode
.
Escape
,
secondary
:
[
KeyMod
.
Shift
|
KeyCode
.
Escape
],
when
:
ContextKeyExpr
.
and
(
PeekContext
.
inPeekEditor
,
ContextKeyExpr
.
not
(
'
config.editor.stablePeek
'
)),
handler
:
closeActiveReferenceSearch
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
openReferenceToSide
'
,
weight
:
KeybindingWeight
.
EditorContrib
,
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
Enter
,
mac
:
{
primary
:
KeyMod
.
WinCtrl
|
KeyCode
.
Enter
},
when
:
ContextKeyExpr
.
and
(
ctxReferenceSearchVisible
,
ctxReferenceWidgetSearchTreeFocused
),
handler
:
openReferenceToSide
});
src/vs/editor/contrib/referenceSearch/referencesController.ts
浏览文件 @
ae03a05c
...
...
@@ -7,19 +7,23 @@ import * as nls from 'vs/nls';
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
dispose
,
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IContextKey
,
IContextKeyService
,
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IInstantiationService
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IContextKey
,
IContextKeyService
,
RawContextKey
,
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ReferencesModel
}
from
'
./referencesModel
'
;
import
{
ReferenceWidget
,
LayoutData
}
from
'
./referencesWidget
'
;
import
{
ReferencesModel
,
OneReference
}
from
'
./referencesModel
'
;
import
{
ReferenceWidget
,
LayoutData
,
ctxReferenceWidgetSearchTreeFocused
}
from
'
./referencesWidget
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Location
}
from
'
vs/editor/common/modes
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
CancelablePromise
}
from
'
vs/base/common/async
'
;
import
{
getOuterEditor
,
PeekContext
}
from
'
vs/editor/contrib/referenceSearch/peekViewWidget
'
;
import
{
IListService
}
from
'
vs/platform/list/browser/listService
'
;
import
{
KeybindingsRegistry
,
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
export
const
ctxReferenceSearchVisible
=
new
RawContextKey
<
boolean
>
(
'
referenceSearchVisible
'
,
false
);
...
...
@@ -33,7 +37,7 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
static
readonly
ID
=
'
editor.contrib.referencesController
'
;
private
readonly
_disposables
=
new
DisposableStore
();
private
readonly
_editor
:
ICodeEditor
;
private
_widget
?:
ReferenceWidget
;
private
_model
?:
ReferencesModel
;
private
_requestIdPool
=
0
;
...
...
@@ -47,7 +51,7 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
constructor
(
private
readonly
_defaultTreeKeyboardSupport
:
boolean
,
editor
:
ICodeEditor
,
private
readonly
_
editor
:
ICodeEditor
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
ICodeEditorService
private
readonly
_editorService
:
ICodeEditorService
,
@
INotificationService
private
readonly
_notificationService
:
INotificationService
,
...
...
@@ -55,21 +59,17 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
@
IStorageService
private
readonly
_storageService
:
IStorageService
,
@
IConfigurationService
private
readonly
_configurationService
:
IConfigurationService
,
)
{
this
.
_editor
=
editor
;
this
.
_referenceSearchVisible
=
ctxReferenceSearchVisible
.
bindTo
(
contextKeyService
);
}
dispose
():
void
{
this
.
_referenceSearchVisible
.
reset
();
dispose
(
this
.
_disposables
);
if
(
this
.
_widget
)
{
dispose
(
this
.
_widget
);
this
.
_widget
=
undefined
;
}
if
(
this
.
_model
)
{
dispose
(
this
.
_model
);
this
.
_model
=
undefined
;
}
this
.
_disposables
.
dispose
();
dispose
(
this
.
_widget
);
dispose
(
this
.
_model
);
this
.
_widget
=
undefined
;
this
.
_model
=
undefined
;
}
toggleWidget
(
range
:
Range
,
modelPromise
:
CancelablePromise
<
ReferencesModel
>
,
options
:
RequestOptions
):
void
{
...
...
@@ -260,3 +260,101 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
},
this
.
_editor
,
sideBySide
);
}
}
function
withController
(
accessor
:
ServicesAccessor
,
fn
:
(
controller
:
ReferencesController
)
=>
void
):
void
{
const
outerEditor
=
getOuterEditor
(
accessor
);
if
(
!
outerEditor
)
{
return
;
}
let
controller
=
ReferencesController
.
get
(
outerEditor
);
if
(
controller
)
{
fn
(
controller
);
}
}
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
goToNextReference
'
,
weight
:
KeybindingWeight
.
WorkbenchContrib
+
50
,
primary
:
KeyCode
.
F4
,
when
:
ctxReferenceSearchVisible
,
handler
(
accessor
)
{
withController
(
accessor
,
controller
=>
{
controller
.
goToNextOrPreviousReference
(
true
);
});
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
goToNextReferenceFromEmbeddedEditor
'
,
weight
:
KeybindingWeight
.
EditorContrib
+
50
,
primary
:
KeyCode
.
F4
,
when
:
PeekContext
.
inPeekEditor
,
handler
(
accessor
)
{
withController
(
accessor
,
controller
=>
{
controller
.
goToNextOrPreviousReference
(
true
);
});
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
goToPreviousReference
'
,
weight
:
KeybindingWeight
.
WorkbenchContrib
+
50
,
primary
:
KeyMod
.
Shift
|
KeyCode
.
F4
,
when
:
ctxReferenceSearchVisible
,
handler
(
accessor
)
{
withController
(
accessor
,
controller
=>
{
controller
.
goToNextOrPreviousReference
(
false
);
});
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
goToPreviousReferenceFromEmbeddedEditor
'
,
weight
:
KeybindingWeight
.
EditorContrib
+
50
,
primary
:
KeyMod
.
Shift
|
KeyCode
.
F4
,
when
:
PeekContext
.
inPeekEditor
,
handler
(
accessor
)
{
withController
(
accessor
,
controller
=>
{
controller
.
goToNextOrPreviousReference
(
false
);
});
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
closeReferenceSearch
'
,
weight
:
KeybindingWeight
.
WorkbenchContrib
+
50
,
primary
:
KeyCode
.
Escape
,
secondary
:
[
KeyMod
.
Shift
|
KeyCode
.
Escape
],
when
:
ContextKeyExpr
.
and
(
ctxReferenceSearchVisible
,
ContextKeyExpr
.
not
(
'
config.editor.stablePeek
'
)),
handler
(
accessor
:
ServicesAccessor
)
{
withController
(
accessor
,
controller
=>
controller
.
closeWidget
());
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
closeReferenceSearchEditor
'
,
weight
:
KeybindingWeight
.
EditorContrib
-
101
,
primary
:
KeyCode
.
Escape
,
secondary
:
[
KeyMod
.
Shift
|
KeyCode
.
Escape
],
when
:
ContextKeyExpr
.
and
(
PeekContext
.
inPeekEditor
,
ContextKeyExpr
.
not
(
'
config.editor.stablePeek
'
)),
handler
(
accessor
:
ServicesAccessor
)
{
withController
(
accessor
,
controller
=>
controller
.
closeWidget
());
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
openReferenceToSide
'
,
weight
:
KeybindingWeight
.
EditorContrib
,
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
Enter
,
mac
:
{
primary
:
KeyMod
.
WinCtrl
|
KeyCode
.
Enter
},
when
:
ContextKeyExpr
.
and
(
ctxReferenceSearchVisible
,
ctxReferenceWidgetSearchTreeFocused
),
handler
(
accessor
:
ServicesAccessor
)
{
const
listService
=
accessor
.
get
(
IListService
);
const
focus
=
listService
.
lastFocusedList
&&
listService
.
lastFocusedList
.
getFocus
();
if
(
focus
instanceof
OneReference
)
{
withController
(
accessor
,
controller
=>
controller
.
openReference
(
focus
,
true
));
}
}
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录