Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
de5800af
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,体验更适合开发者的 AI 搜索 >>
提交
de5800af
编写于
8月 02, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wire up WorkspaceSymbolProvider
上级
e62cfe97
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
77 addition
and
15 deletion
+77
-15
src/vs/vscode.d.ts
src/vs/vscode.d.ts
+30
-4
src/vs/workbench/api/node/extHostLanguageFeatures.ts
src/vs/workbench/api/node/extHostLanguageFeatures.ts
+27
-2
src/vs/workbench/api/node/extHostTypeConverters.ts
src/vs/workbench/api/node/extHostTypeConverters.ts
+6
-6
src/vs/workbench/api/node/extHostTypes.ts
src/vs/workbench/api/node/extHostTypes.ts
+13
-2
src/vs/workbench/parts/search/browser/openSymbolHandler.ts
src/vs/workbench/parts/search/browser/openSymbolHandler.ts
+1
-1
未找到文件。
src/vs/vscode.d.ts
浏览文件 @
de5800af
...
...
@@ -1737,6 +1737,16 @@ declare namespace vscode {
*/
location
:
Location
;
/**
* Creates a new symbol information object.
*
* @param name The name of the symbol.
* @param kind The kind of the symbol.
* @param containerName The name of the symbol containing the symbol.
* @param location The the location of the symbol.
*/
constructor
(
name
:
string
,
kind
:
SymbolKind
,
containerName
:
string
,
location
:
Location
);
/**
* Creates a new symbol information object.
*
...
...
@@ -1774,7 +1784,9 @@ declare namespace vscode {
/**
* Project-wide search for a symbol matching the given query string. It is up to the provider
* how to search given the query string, like substring, indexOf etc.
* how to search given the query string, like substring, indexOf etc. To improve performance implementors can
* skip the [location](#SymbolInformation.location) of symbols and implement `resolveWorkspaceSymbol` to do that
* later.
*
* @param query A non-empty query string.
* @param token A cancellation token.
...
...
@@ -1782,6 +1794,20 @@ declare namespace vscode {
* signaled by returning `undefined`, `null`, or an empty array.
*/
provideWorkspaceSymbols
(
query
:
string
,
token
:
CancellationToken
):
SymbolInformation
[]
|
Thenable
<
SymbolInformation
[]
>
;
/**
* Given a symbol fill in its [location](#SymbolInformation.location). This method is called whenever a symbol
* is selected in the UI. Providers can implement this method and return incomplete symbols from
* [`provideWorkspaceSymbols`](#WorkspaceSymbolProvider.provideWorkspaceSymbols) which often helps to improve
* performance.
*
* @param symbol The symbol that is to be resolved. Guaranteed to be an instance of an object returned from an
* earlier call to `provideWorkspaceSymbols`.
* @param token A cancellation token.
* @return The resolved symbol or a thenable that resolves to that. When no result is returned,
* the given `symbol` is used.
*/
resolveWorkspaceSymbol
?:
(
symbol
:
SymbolInformation
,
token
:
CancellationToken
)
=>
SymbolInformation
|
Thenable
<
SymbolInformation
>
;
}
/**
...
...
@@ -3710,9 +3736,9 @@ declare namespace vscode {
/**
* Register a workspace symbol provider.
*
* Multiple providers can be registered
for a language. In that case providers are asked in
*
parallel and the results are merged. A failing provider (rejected promise or exception) will
*
not cause
a failure of the whole operation.
* Multiple providers can be registered
. In that case providers are asked in parallel and
*
the results are merged. A failing provider (rejected promise or exception) will not cause
* a failure of the whole operation.
*
* @param provider A workspace symbol provider.
* @return A [disposable](#Disposable) that unregisters this provider when being disposed.
...
...
src/vs/workbench/api/node/extHostLanguageFeatures.ts
浏览文件 @
de5800af
...
...
@@ -394,24 +394,49 @@ class OnTypeFormattingAdapter {
}
}
interface
MyWorkspaceSymbol
extends
IWorkspaceSymbol
{
idx
:
number
;
}
class
NavigateTypeAdapter
implements
IWorkspaceSymbolProvider
{
private
_provider
:
vscode
.
WorkspaceSymbolProvider
;
private
_cache
:
vscode
.
SymbolInformation
[];
constructor
(
provider
:
vscode
.
WorkspaceSymbolProvider
)
{
this
.
_provider
=
provider
;
}
provideWorkspaceSymbols
(
search
:
string
):
TPromise
<
IWorkspaceSymbol
[]
>
{
this
.
_cache
=
[];
return
asWinJsPromise
(
token
=>
this
.
_provider
.
provideWorkspaceSymbols
(
search
,
token
)).
then
(
value
=>
{
if
(
Array
.
isArray
(
value
))
{
return
value
.
map
(
TypeConverters
.
fromSymbolInformation
);
this
.
_cache
=
value
;
return
value
.
map
((
item
,
idx
)
=>
{
const
result
=
<
MyWorkspaceSymbol
>
TypeConverters
.
fromSymbolInformation
(
item
);
result
.
idx
=
idx
;
return
result
;
});
}
});
}
resolveWorkspaceSymbol
(
item
:
IWorkspaceSymbol
):
TPromise
<
IWorkspaceSymbol
>
{
return
TPromise
.
as
(
item
);
if
(
typeof
this
.
_provider
.
resolveWorkspaceSymbol
!==
'
function
'
)
{
return
;
}
const
idx
=
(
<
MyWorkspaceSymbol
>
item
).
idx
;
if
(
typeof
idx
!==
'
number
'
)
{
return
;
}
return
asWinJsPromise
(
token
=>
this
.
_provider
.
resolveWorkspaceSymbol
(
this
.
_cache
[
idx
],
token
)).
then
(
value
=>
{
return
value
&&
TypeConverters
.
fromSymbolInformation
(
value
);
});
}
}
...
...
src/vs/workbench/api/node/extHostTypeConverters.ts
浏览文件 @
de5800af
...
...
@@ -194,18 +194,18 @@ export function fromSymbolInformation(info: vscode.SymbolInformation): IWorkspac
return
<
IWorkspaceSymbol
>
{
name
:
info
.
name
,
type
:
types
.
SymbolKind
[
info
.
kind
||
types
.
SymbolKind
.
Property
].
toLowerCase
(),
range
:
fromRange
(
info
.
location
.
range
)
,
r
esource
:
info
.
location
.
uri
,
containerName
:
info
.
containerName
containerName
:
info
.
containerName
,
r
ange
:
info
.
location
&&
fromRange
(
info
.
location
.
range
)
,
resource
:
info
.
location
&&
info
.
location
.
uri
,
};
}
export
function
toSymbolInformation
(
bearing
:
IWorkspaceSymbol
):
types
.
SymbolInformation
{
return
new
types
.
SymbolInformation
(
bearing
.
name
,
types
.
SymbolKind
[
bearing
.
type
.
charAt
(
0
).
toUpperCase
()
+
bearing
.
type
.
substr
(
1
)],
toRange
(
bearing
.
range
)
,
bearing
.
resource
,
bearing
.
containerName
);
bearing
.
containerName
,
new
types
.
Location
(
bearing
.
resource
,
toRange
(
bearing
.
range
))
);
}
...
...
src/vs/workbench/api/node/extHostTypes.ts
浏览文件 @
de5800af
...
...
@@ -628,11 +628,22 @@ export class SymbolInformation {
kind
:
SymbolKind
;
containerName
:
string
;
constructor
(
name
:
string
,
kind
:
SymbolKind
,
range
:
Range
,
uri
?:
URI
,
containerName
?:
string
)
{
constructor
(
name
:
string
,
kind
:
SymbolKind
,
containerName
:
string
,
location
:
Location
);
constructor
(
name
:
string
,
kind
:
SymbolKind
,
range
:
Range
,
uri
?:
URI
,
containerName
?:
string
);
constructor
(
name
:
string
,
kind
:
SymbolKind
,
rangeOrContainer
:
string
|
Range
,
locationOrUri
?:
Location
|
URI
,
containerName
?:
string
)
{
this
.
name
=
name
;
this
.
kind
=
kind
;
this
.
location
=
new
Location
(
uri
,
range
);
this
.
containerName
=
containerName
;
if
(
typeof
rangeOrContainer
===
'
string
'
)
{
this
.
containerName
=
rangeOrContainer
;
}
if
(
locationOrUri
instanceof
Location
)
{
this
.
location
=
locationOrUri
;
}
else
if
(
locationOrUri
instanceof
URI
&&
rangeOrContainer
instanceof
Range
)
{
this
.
location
=
new
Location
(
locationOrUri
,
rangeOrContainer
);
}
}
toJSON
():
any
{
...
...
src/vs/workbench/parts/search/browser/openSymbolHandler.ts
浏览文件 @
de5800af
...
...
@@ -47,7 +47,7 @@ class SymbolEntry extends EditorQuickOpenEntry {
public
getDescription
():
string
{
let
result
=
this
.
_bearing
.
containerName
;
if
(
!
result
)
{
if
(
!
result
&&
this
.
_bearing
.
resource
)
{
result
=
labels
.
getPathLabel
(
this
.
_bearing
.
resource
,
this
.
_contextService
);
}
return
result
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录