Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8835c06e
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,发现更多精彩内容 >>
提交
8835c06e
编写于
5月 17, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
editor - move some workbench specific commands to workbench
上级
a323b399
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
83 addition
and
83 deletion
+83
-83
src/vs/editor/contrib/referenceSearch/referenceSearch.ts
src/vs/editor/contrib/referenceSearch/referenceSearch.ts
+3
-80
src/vs/workbench/parts/codeEditor/electron-browser/workbenchReferenceSearch.ts
...s/codeEditor/electron-browser/workbenchReferenceSearch.ts
+80
-3
未找到文件。
src/vs/editor/contrib/referenceSearch/referenceSearch.ts
浏览文件 @
8835c06e
...
...
@@ -6,14 +6,10 @@
import
*
as
nls
from
'
vs/nls
'
;
import
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IEditorService
}
from
'
vs/platform/editor/common/editor
'
;
import
{
CommandsRegistry
,
ICommandHandler
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IContextKeyService
,
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
Position
,
IPosition
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Position
}
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
'
;
...
...
@@ -24,12 +20,12 @@ 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
,
isCodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ICodeEditor
}
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
'
;
const
defaultReferenceSearchOptions
:
RequestOptions
=
{
export
const
defaultReferenceSearchOptions
:
RequestOptions
=
{
getMetaTitle
(
model
)
{
return
model
.
references
.
length
>
1
&&
nls
.
localize
(
'
meta.titleReference
'
,
"
– {0} references
"
,
model
.
references
.
length
);
}
...
...
@@ -94,79 +90,6 @@ 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
'
);
}
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
:
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
},
]
}
});
function
closeActiveReferenceSearch
(
accessor
:
ServicesAccessor
,
args
:
any
)
{
withController
(
accessor
,
controller
=>
controller
.
closeWidget
());
}
...
...
src/vs/workbench/parts/codeEditor/electron-browser/workbenchReferenceSearch.ts
浏览文件 @
8835c06e
...
...
@@ -4,19 +4,27 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
IEditorService
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IInstantiationService
,
optional
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
,
optional
,
ServicesAccessor
}
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
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ICodeEditor
,
isCodeEditor
}
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
{
IEditorService
}
from
'
vs/platform/editor/common/editor
'
;
export
class
WorkbenchReferencesController
extends
ReferencesController
{
...
...
@@ -51,3 +59,72 @@ 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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录