Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
daacf5c9
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,发现更多精彩内容 >>
提交
daacf5c9
编写于
6月 11, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move find/show references command back to editor
上级
c65cd725
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
76 addition
and
82 deletion
+76
-82
src/vs/editor/contrib/referenceSearch/referenceSearch.ts
src/vs/editor/contrib/referenceSearch/referenceSearch.ts
+74
-2
src/vs/workbench/parts/codeEditor/electron-browser/workbenchReferenceSearch.ts
...s/codeEditor/electron-browser/workbenchReferenceSearch.ts
+2
-80
未找到文件。
src/vs/editor/contrib/referenceSearch/referenceSearch.ts
浏览文件 @
daacf5c9
...
...
@@ -9,10 +9,11 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IContextKeyService
,
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Position
,
IPosition
}
from
'
vs/editor/common/core/position
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
registerEditorAction
,
ServicesAccessor
,
EditorAction
,
registerEditorContribution
,
registerDefaultLanguageCommand
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
Location
,
ReferenceProviderRegistry
}
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
'
;
...
...
@@ -20,10 +21,13 @@ import { asWinJsPromise } from 'vs/base/common/async';
import
{
onUnexpectedExternalError
}
from
'
vs/base/common/errors
'
;
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
import
{
EmbeddedCodeEditorWidget
}
from
'
vs/editor/browser/widget/embeddedCodeEditorWidget
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ICodeEditor
,
isCodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
IListService
}
from
'
vs/platform/list/browser/listService
'
;
import
{
ctxReferenceWidgetSearchTreeFocused
}
from
'
vs/editor/contrib/referenceSearch/referencesWidget
'
;
import
{
CommandsRegistry
,
ICommandHandler
}
from
'
vs/platform/commands/common/commands
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
export
const
defaultReferenceSearchOptions
:
RequestOptions
=
{
getMetaTitle
(
model
)
{
...
...
@@ -90,6 +94,74 @@ registerEditorContribution(ReferenceController);
registerEditorAction
(
ReferenceAction
);
let
findReferencesCommand
:
ICommandHandler
=
(
accessor
:
ServicesAccessor
,
resource
:
URI
,
position
:
IPosition
)
=>
{
if
(
!
(
resource
instanceof
URI
))
{
throw
new
Error
(
'
illegal argument, uri
'
);
}
if
(
!
position
)
{
throw
new
Error
(
'
illegal argument, position
'
);
}
const
codeEditorService
=
accessor
.
get
(
ICodeEditorService
);
return
codeEditorService
.
openCodeEditor
({
resource
},
codeEditorService
.
getFocusedCodeEditor
()).
then
(
control
=>
{
if
(
!
isCodeEditor
(
control
))
{
return
undefined
;
}
let
controller
=
ReferencesController
.
get
(
control
);
if
(
!
controller
)
{
return
undefined
;
}
let
references
=
provideReferences
(
control
.
getModel
(),
Position
.
lift
(
position
)).
then
(
references
=>
new
ReferencesModel
(
references
));
let
range
=
new
Range
(
position
.
lineNumber
,
position
.
column
,
position
.
lineNumber
,
position
.
column
);
return
TPromise
.
as
(
controller
.
toggleWidget
(
range
,
references
,
defaultReferenceSearchOptions
));
});
};
let
showReferencesCommand
:
ICommandHandler
=
(
accessor
:
ServicesAccessor
,
resource
:
URI
,
position
:
IPosition
,
references
:
Location
[])
=>
{
if
(
!
(
resource
instanceof
URI
))
{
throw
new
Error
(
'
illegal argument, uri expected
'
);
}
const
codeEditorService
=
accessor
.
get
(
ICodeEditorService
);
return
codeEditorService
.
openCodeEditor
({
resource
},
codeEditorService
.
getFocusedCodeEditor
()).
then
(
control
=>
{
if
(
!
isCodeEditor
(
control
))
{
return
undefined
;
}
let
controller
=
ReferencesController
.
get
(
control
);
if
(
!
controller
)
{
return
undefined
;
}
return
TPromise
.
as
(
controller
.
toggleWidget
(
new
Range
(
position
.
lineNumber
,
position
.
column
,
position
.
lineNumber
,
position
.
column
),
TPromise
.
as
(
new
ReferencesModel
(
references
)),
defaultReferenceSearchOptions
)).
then
(()
=>
true
);
});
};
// register commands
CommandsRegistry
.
registerCommand
({
id
:
'
editor.action.findReferences
'
,
handler
:
findReferencesCommand
});
CommandsRegistry
.
registerCommand
({
id
:
'
editor.action.showReferences
'
,
handler
:
showReferencesCommand
,
description
:
{
description
:
'
Show references at a position in a file
'
,
args
:
[
{
name
:
'
uri
'
,
description
:
'
The text document in which to show references
'
,
constraint
:
URI
},
{
name
:
'
position
'
,
description
:
'
The position at which to show
'
,
constraint
:
Position
.
isIPosition
},
{
name
:
'
locations
'
,
description
:
'
An array of locations.
'
,
constraint
:
Array
},
]
}
});
function
closeActiveReferenceSearch
(
accessor
:
ServicesAccessor
,
args
:
any
)
{
withController
(
accessor
,
controller
=>
controller
.
closeWidget
());
}
...
...
src/vs/workbench/parts/codeEditor/electron-browser/workbenchReferenceSearch.ts
浏览文件 @
daacf5c9
...
...
@@ -4,28 +4,19 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
IInstantiationService
,
optional
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
,
optional
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
ICodeEditor
,
isCodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
registerEditorContribution
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
ITextModelService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
ReferencesController
}
from
'
vs/editor/contrib/referenceSearch/referencesController
'
;
import
{
CommandsRegistry
,
ICommandHandler
}
from
'
vs/platform/commands/common/commands
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ReferencesModel
}
from
'
vs/editor/contrib/referenceSearch/referencesModel
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Position
,
IPosition
}
from
'
vs/editor/common/core/position
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
Location
}
from
'
vs/editor/common/modes
'
;
import
{
provideReferences
,
defaultReferenceSearchOptions
}
from
'
vs/editor/contrib/referenceSearch/referenceSearch
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
export
class
WorkbenchReferencesController
extends
ReferencesController
{
...
...
@@ -60,72 +51,3 @@ export class WorkbenchReferencesController extends ReferencesController {
}
registerEditorContribution
(
WorkbenchReferencesController
);
let
findReferencesCommand
:
ICommandHandler
=
(
accessor
:
ServicesAccessor
,
resource
:
URI
,
position
:
IPosition
)
=>
{
if
(
!
(
resource
instanceof
URI
))
{
throw
new
Error
(
'
illegal argument, uri
'
);
}
if
(
!
position
)
{
throw
new
Error
(
'
illegal argument, position
'
);
}
return
accessor
.
get
(
IEditorService
).
openEditor
({
resource
}).
then
(
editor
=>
{
let
control
=
editor
.
getControl
();
if
(
!
isCodeEditor
(
control
))
{
return
undefined
;
}
let
controller
=
ReferencesController
.
get
(
control
);
if
(
!
controller
)
{
return
undefined
;
}
let
references
=
provideReferences
(
control
.
getModel
(),
Position
.
lift
(
position
)).
then
(
references
=>
new
ReferencesModel
(
references
));
let
range
=
new
Range
(
position
.
lineNumber
,
position
.
column
,
position
.
lineNumber
,
position
.
column
);
return
TPromise
.
as
(
controller
.
toggleWidget
(
range
,
references
,
defaultReferenceSearchOptions
));
});
};
let
showReferencesCommand
:
ICommandHandler
=
(
accessor
:
ServicesAccessor
,
resource
:
URI
,
position
:
IPosition
,
references
:
Location
[])
=>
{
if
(
!
(
resource
instanceof
URI
))
{
throw
new
Error
(
'
illegal argument, uri expected
'
);
}
return
accessor
.
get
(
IEditorService
).
openEditor
({
resource
}).
then
(
editor
=>
{
let
control
=
editor
.
getControl
();
if
(
!
isCodeEditor
(
control
))
{
return
undefined
;
}
let
controller
=
ReferencesController
.
get
(
control
);
if
(
!
controller
)
{
return
undefined
;
}
return
TPromise
.
as
(
controller
.
toggleWidget
(
new
Range
(
position
.
lineNumber
,
position
.
column
,
position
.
lineNumber
,
position
.
column
),
TPromise
.
as
(
new
ReferencesModel
(
references
)),
defaultReferenceSearchOptions
)).
then
(()
=>
true
);
});
};
// register commands
CommandsRegistry
.
registerCommand
({
id
:
'
editor.action.findReferences
'
,
handler
:
findReferencesCommand
});
CommandsRegistry
.
registerCommand
({
id
:
'
editor.action.showReferences
'
,
handler
:
showReferencesCommand
,
description
:
{
description
:
'
Show references at a position in a file
'
,
args
:
[
{
name
:
'
uri
'
,
description
:
'
The text document in which to show references
'
,
constraint
:
URI
},
{
name
:
'
position
'
,
description
:
'
The position at which to show
'
,
constraint
:
Position
.
isIPosition
},
{
name
:
'
locations
'
,
description
:
'
An array of locations.
'
,
constraint
:
Array
},
]
}
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录