Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
792fea6c
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,发现更多精彩内容 >>
提交
792fea6c
编写于
5月 18, 2018
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleaning up ts symbol provider
上级
dea67d94
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
29 addition
and
25 deletion
+29
-25
extensions/typescript-language-features/src/features/documentSymbolProvider.ts
...-language-features/src/features/documentSymbolProvider.ts
+29
-25
未找到文件。
extensions/typescript-language-features/src/features/documentSymbolProvider.ts
浏览文件 @
792fea6c
...
...
@@ -10,22 +10,25 @@ import * as PConst from '../protocol.const';
import
{
ITypeScriptServiceClient
}
from
'
../typescriptService
'
;
import
*
as
typeConverters
from
'
../utils/typeConverters
'
;
const
outlineTypeTable
:
{
[
kind
:
string
]:
SymbolKind
}
=
Object
.
create
(
null
);
outlineTypeTable
[
PConst
.
Kind
.
module
]
=
SymbolKind
.
Module
;
outlineTypeTable
[
PConst
.
Kind
.
class
]
=
SymbolKind
.
Class
;
outlineTypeTable
[
PConst
.
Kind
.
enum
]
=
SymbolKind
.
Enum
;
outlineTypeTable
[
PConst
.
Kind
.
interface
]
=
SymbolKind
.
Interface
;
outlineTypeTable
[
PConst
.
Kind
.
memberFunction
]
=
SymbolKind
.
Method
;
outlineTypeTable
[
PConst
.
Kind
.
memberVariable
]
=
SymbolKind
.
Property
;
outlineTypeTable
[
PConst
.
Kind
.
memberGetAccessor
]
=
SymbolKind
.
Property
;
outlineTypeTable
[
PConst
.
Kind
.
memberSetAccessor
]
=
SymbolKind
.
Property
;
outlineTypeTable
[
PConst
.
Kind
.
variable
]
=
SymbolKind
.
Variable
;
outlineTypeTable
[
PConst
.
Kind
.
const
]
=
SymbolKind
.
Variable
;
outlineTypeTable
[
PConst
.
Kind
.
localVariable
]
=
SymbolKind
.
Variable
;
outlineTypeTable
[
PConst
.
Kind
.
variable
]
=
SymbolKind
.
Variable
;
outlineTypeTable
[
PConst
.
Kind
.
function
]
=
SymbolKind
.
Function
;
outlineTypeTable
[
PConst
.
Kind
.
localFunction
]
=
SymbolKind
.
Function
;
const
getSymbolKind
=
(
kind
:
string
):
SymbolKind
=>
{
switch
(
kind
)
{
case
PConst
.
Kind
.
module
:
return
SymbolKind
.
Module
;
case
PConst
.
Kind
.
class
:
return
SymbolKind
.
Class
;
case
PConst
.
Kind
.
enum
:
return
SymbolKind
.
Enum
;
case
PConst
.
Kind
.
interface
:
return
SymbolKind
.
Interface
;
case
PConst
.
Kind
.
memberFunction
:
return
SymbolKind
.
Method
;
case
PConst
.
Kind
.
memberVariable
:
return
SymbolKind
.
Property
;
case
PConst
.
Kind
.
memberGetAccessor
:
return
SymbolKind
.
Property
;
case
PConst
.
Kind
.
memberSetAccessor
:
return
SymbolKind
.
Property
;
case
PConst
.
Kind
.
variable
:
return
SymbolKind
.
Variable
;
case
PConst
.
Kind
.
const
:
return
SymbolKind
.
Variable
;
case
PConst
.
Kind
.
localVariable
:
return
SymbolKind
.
Variable
;
case
PConst
.
Kind
.
variable
:
return
SymbolKind
.
Variable
;
case
PConst
.
Kind
.
function
:
return
SymbolKind
.
Function
;
case
PConst
.
Kind
.
localFunction
:
return
SymbolKind
.
Function
;
}
return
SymbolKind
.
Variable
;
};
export
default
class
TypeScriptDocumentSymbolProvider
implements
DocumentSymbolProvider
{
public
constructor
(
...
...
@@ -45,9 +48,9 @@ export default class TypeScriptDocumentSymbolProvider implements DocumentSymbolP
const
response
=
await
this
.
client
.
execute
(
'
navtree
'
,
args
,
token
);
if
(
response
.
body
)
{
// The root represents the file. Ignore this when showing in the UI
le
t
tree
=
response
.
body
;
cons
t
tree
=
response
.
body
;
if
(
tree
.
childItems
)
{
le
t
result
=
new
Array
<
Hierarchy
<
SymbolInformation2
>>
();
cons
t
result
=
new
Array
<
Hierarchy
<
SymbolInformation2
>>
();
tree
.
childItems
.
forEach
(
item
=>
TypeScriptDocumentSymbolProvider
.
convertNavTree
(
resource
.
uri
,
result
,
item
));
return
result
;
}
...
...
@@ -55,8 +58,8 @@ export default class TypeScriptDocumentSymbolProvider implements DocumentSymbolP
}
else
{
const
response
=
await
this
.
client
.
execute
(
'
navbar
'
,
args
,
token
);
if
(
response
.
body
)
{
le
t
result
=
new
Array
<
SymbolInformation
>
();
le
t
foldingMap
:
ObjectMap
<
SymbolInformation
>
=
Object
.
create
(
null
);
cons
t
result
=
new
Array
<
SymbolInformation
>
();
cons
t
foldingMap
:
ObjectMap
<
SymbolInformation
>
=
Object
.
create
(
null
);
response
.
body
.
forEach
(
item
=>
TypeScriptDocumentSymbolProvider
.
convertNavBar
(
resource
.
uri
,
0
,
foldingMap
,
result
as
SymbolInformation
[],
item
));
return
result
;
}
...
...
@@ -68,11 +71,11 @@ export default class TypeScriptDocumentSymbolProvider implements DocumentSymbolP
}
private
static
convertNavBar
(
resource
:
Uri
,
indent
:
number
,
foldingMap
:
ObjectMap
<
SymbolInformation
>
,
bucket
:
SymbolInformation
[],
item
:
Proto
.
NavigationBarItem
,
containerLabel
?:
string
):
void
{
le
t
realIndent
=
indent
+
item
.
indent
;
le
t
key
=
`
${
realIndent
}
|
${
item
.
text
}
`
;
cons
t
realIndent
=
indent
+
item
.
indent
;
cons
t
key
=
`
${
realIndent
}
|
${
item
.
text
}
`
;
if
(
realIndent
!==
0
&&
!
foldingMap
[
key
]
&&
TypeScriptDocumentSymbolProvider
.
shouldInclueEntry
(
item
.
text
))
{
le
t
result
=
new
SymbolInformation
(
item
.
text
,
outlineTypeTable
[
item
.
kind
as
string
]
||
SymbolKind
.
Variable
,
cons
t
result
=
new
SymbolInformation
(
item
.
text
,
getSymbolKind
(
item
.
kind
)
,
containerLabel
?
containerLabel
:
''
,
typeConverters
.
Location
.
fromTextSpan
(
resource
,
item
.
spans
[
0
]));
foldingMap
[
key
]
=
result
;
...
...
@@ -89,10 +92,11 @@ export default class TypeScriptDocumentSymbolProvider implements DocumentSymbolP
if
(
!
TypeScriptDocumentSymbolProvider
.
shouldInclueEntry
(
item
.
text
))
{
return
;
}
const
symbolInfo
=
new
SymbolInformation2
(
item
.
text
,
''
,
// todo@joh detail
outlineTypeTable
[
item
.
kind
as
string
]
||
SymbolKind
.
Variable
,
getSymbolKind
(
item
.
kind
)
,
typeConverters
.
Range
.
fromTextSpan
(
item
.
spans
[
0
]),
typeConverters
.
Location
.
fromTextSpan
(
resource
,
item
.
spans
[
0
]),
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录