Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
f8da5375
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,发现更多精彩内容 >>
提交
f8da5375
编写于
9月 13, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #58592
上级
9c882c7c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
45 addition
and
38 deletion
+45
-38
src/vs/workbench/parts/quickopen/browser/gotoSymbolHandler.ts
...vs/workbench/parts/quickopen/browser/gotoSymbolHandler.ts
+45
-38
未找到文件。
src/vs/workbench/parts/quickopen/browser/gotoSymbolHandler.ts
浏览文件 @
f8da5375
...
...
@@ -19,7 +19,7 @@ import { IModelDecorationsChangeAccessor, OverviewRulerLane, IModelDeltaDecorati
import
{
IQuickOpenService
}
from
'
vs/platform/quickOpen/common/quickOpen
'
;
import
{
ITextEditorOptions
}
from
'
vs/platform/editor/common/editor
'
;
import
{
getDocumentSymbols
}
from
'
vs/editor/contrib/quickOpen/quickOpen
'
;
import
{
DocumentSymbolProviderRegistry
,
DocumentSymbol
,
symbolKindToCssClass
}
from
'
vs/editor/common/modes
'
;
import
{
DocumentSymbolProviderRegistry
,
DocumentSymbol
,
symbolKindToCssClass
,
SymbolKind
}
from
'
vs/editor/common/modes
'
;
import
{
IRange
}
from
'
vs/editor/common/core/range
'
;
import
{
themeColorFromId
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
overviewRulerRangeHighlight
}
from
'
vs/editor/common/view/editorColorRegistry
'
;
...
...
@@ -32,26 +32,33 @@ import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cance
export
const
GOTO_SYMBOL_PREFIX
=
'
@
'
;
export
const
SCOPE_PREFIX
=
'
:
'
;
const
NLS_SYMBOL_CACHE
:
{
[
type
:
string
]:
string
}
=
{
'
method
'
:
nls
.
localize
(
'
method
'
,
"
methods ({0})
"
),
'
function
'
:
nls
.
localize
(
'
function
'
,
"
functions ({0})
"
),
'
constructor
'
:
nls
.
localize
(
'
_constructor
'
,
"
constructors ({0})
"
),
'
variable
'
:
nls
.
localize
(
'
variable
'
,
"
variables ({0})
"
),
'
class
'
:
nls
.
localize
(
'
class
'
,
"
classes ({0})
"
),
'
interface
'
:
nls
.
localize
(
'
interface
'
,
"
interfaces ({0})
"
),
'
namespace
'
:
nls
.
localize
(
'
namespace
'
,
"
namespaces ({0})
"
),
'
package
'
:
nls
.
localize
(
'
package
'
,
"
packages ({0})
"
),
'
module
'
:
nls
.
localize
(
'
modules
'
,
"
modules ({0})
"
),
'
property
'
:
nls
.
localize
(
'
property
'
,
"
properties ({0})
"
),
'
enum
'
:
nls
.
localize
(
'
enum
'
,
"
enumerations ({0})
"
),
'
string
'
:
nls
.
localize
(
'
string
'
,
"
strings ({0})
"
),
'
rule
'
:
nls
.
localize
(
'
rule
'
,
"
rules ({0})
"
),
'
file
'
:
nls
.
localize
(
'
file
'
,
"
files ({0})
"
),
'
array
'
:
nls
.
localize
(
'
array
'
,
"
arrays ({0})
"
),
'
number
'
:
nls
.
localize
(
'
number
'
,
"
numbers ({0})
"
),
'
boolean
'
:
nls
.
localize
(
'
boolean
'
,
"
booleans ({0})
"
),
'
object
'
:
nls
.
localize
(
'
object
'
,
"
objects ({0})
"
),
'
key
'
:
nls
.
localize
(
'
key
'
,
"
keys ({0})
"
)
const
FALLBACK_NLS_SYMBOL_KIND
=
nls
.
localize
(
'
property
'
,
"
properties ({0})
"
);
const
NLS_SYMBOL_KIND_CACHE
:
{
[
type
:
number
]:
string
}
=
{
[
SymbolKind
.
Method
]:
nls
.
localize
(
'
method
'
,
"
methods ({0})
"
),
[
SymbolKind
.
Function
]:
nls
.
localize
(
'
function
'
,
"
functions ({0})
"
),
[
SymbolKind
.
Constructor
]:
nls
.
localize
(
'
_constructor
'
,
"
constructors ({0})
"
),
[
SymbolKind
.
Variable
]:
nls
.
localize
(
'
variable
'
,
"
variables ({0})
"
),
[
SymbolKind
.
Class
]:
nls
.
localize
(
'
class
'
,
"
classes ({0})
"
),
[
SymbolKind
.
Struct
]:
nls
.
localize
(
'
struct
'
,
"
structs ({0})
"
),
[
SymbolKind
.
Event
]:
nls
.
localize
(
'
event
'
,
"
events ({0})
"
),
[
SymbolKind
.
Operator
]:
nls
.
localize
(
'
operator
'
,
"
operators ({0})
"
),
[
SymbolKind
.
Interface
]:
nls
.
localize
(
'
interface
'
,
"
interfaces ({0})
"
),
[
SymbolKind
.
Namespace
]:
nls
.
localize
(
'
namespace
'
,
"
namespaces ({0})
"
),
[
SymbolKind
.
Package
]:
nls
.
localize
(
'
package
'
,
"
packages ({0})
"
),
[
SymbolKind
.
TypeParameter
]:
nls
.
localize
(
'
typeParameter
'
,
"
type parameters ({0})
"
),
[
SymbolKind
.
Module
]:
nls
.
localize
(
'
modules
'
,
"
modules ({0})
"
),
[
SymbolKind
.
Property
]:
nls
.
localize
(
'
property
'
,
"
properties ({0})
"
),
[
SymbolKind
.
Enum
]:
nls
.
localize
(
'
enum
'
,
"
enumerations ({0})
"
),
[
SymbolKind
.
EnumMember
]:
nls
.
localize
(
'
enumMember
'
,
"
enumeration members ({0})
"
),
[
SymbolKind
.
String
]:
nls
.
localize
(
'
string
'
,
"
strings ({0})
"
),
[
SymbolKind
.
File
]:
nls
.
localize
(
'
file
'
,
"
files ({0})
"
),
[
SymbolKind
.
Array
]:
nls
.
localize
(
'
array
'
,
"
arrays ({0})
"
),
[
SymbolKind
.
Number
]:
nls
.
localize
(
'
number
'
,
"
numbers ({0})
"
),
[
SymbolKind
.
Boolean
]:
nls
.
localize
(
'
boolean
'
,
"
booleans ({0})
"
),
[
SymbolKind
.
Object
]:
nls
.
localize
(
'
object
'
,
"
objects ({0})
"
),
[
SymbolKind
.
Key
]:
nls
.
localize
(
'
key
'
,
"
keys ({0})
"
),
[
SymbolKind
.
Field
]:
nls
.
localize
(
'
field
'
,
"
fields ({0})
"
),
[
SymbolKind
.
Constant
]:
nls
.
localize
(
'
constant
'
,
"
constants ({0})
"
)
};
export
class
GotoSymbolAction
extends
QuickOpenAction
{
...
...
@@ -112,7 +119,7 @@ class OutlineModel extends QuickOpenModel {
// Mark all type groups
const
visibleResults
=
<
SymbolEntry
[]
>
this
.
getEntries
(
true
);
if
(
visibleResults
.
length
>
0
&&
searchValue
.
indexOf
(
SCOPE_PREFIX
)
===
0
)
{
let
currentType
:
string
=
null
;
let
currentType
:
SymbolKind
=
null
;
let
currentResult
:
SymbolEntry
=
null
;
let
typeCounter
=
0
;
...
...
@@ -120,14 +127,14 @@ class OutlineModel extends QuickOpenModel {
const
result
=
visibleResults
[
i
];
// Found new type
if
(
currentType
!==
result
.
get
Type
())
{
if
(
currentType
!==
result
.
get
Kind
())
{
// Update previous result with count
if
(
currentResult
)
{
currentResult
.
setGroupLabel
(
this
.
renderGroupLabel
(
currentType
,
typeCounter
));
}
currentType
=
result
.
get
Type
();
currentType
=
result
.
get
Kind
();
currentResult
=
result
;
typeCounter
=
1
;
...
...
@@ -194,9 +201,9 @@ class OutlineModel extends QuickOpenModel {
searchValue
=
searchValue
.
substr
(
SCOPE_PREFIX
.
length
);
// Sort by type first if scoped search
const
elementAType
=
elementA
.
getType
()
;
const
elementBType
=
elementB
.
getType
()
;
let
r
=
elementAType
.
localeCompare
(
elementBType
);
const
elementAType
Label
=
NLS_SYMBOL_KIND_CACHE
[
elementA
.
getKind
()]
||
FALLBACK_NLS_SYMBOL_KIND
;
const
elementBType
Label
=
NLS_SYMBOL_KIND_CACHE
[
elementB
.
getKind
()]
||
FALLBACK_NLS_SYMBOL_KIND
;
let
r
=
elementAType
Label
.
localeCompare
(
elementBTypeLabel
);
if
(
r
!==
0
)
{
return
r
;
}
...
...
@@ -220,13 +227,13 @@ class OutlineModel extends QuickOpenModel {
return
elementARange
.
startLineNumber
-
elementBRange
.
startLineNumber
;
}
private
renderGroupLabel
(
type
:
string
,
count
:
number
):
string
{
const
pattern
=
NLS_SYMBOL
_CACHE
[
type
];
if
(
pattern
)
{
return
strings
.
format
(
pattern
,
count
)
;
private
renderGroupLabel
(
type
:
SymbolKind
,
count
:
number
):
string
{
let
pattern
=
NLS_SYMBOL_KIND
_CACHE
[
type
];
if
(
!
pattern
)
{
pattern
=
FALLBACK_NLS_SYMBOL_KIND
;
}
return
type
;
return
strings
.
format
(
pattern
,
count
)
;
}
}
...
...
@@ -234,19 +241,19 @@ class SymbolEntry extends EditorQuickOpenEntryGroup {
private
editorService
:
IEditorService
;
private
index
:
number
;
private
name
:
string
;
private
type
:
string
;
private
kind
:
SymbolKind
;
private
icon
:
string
;
private
description
:
string
;
private
range
:
IRange
;
private
revealRange
:
IRange
;
private
handler
:
GotoSymbolHandler
;
constructor
(
index
:
number
,
name
:
string
,
type
:
string
,
description
:
string
,
icon
:
string
,
range
:
IRange
,
revealRange
:
IRange
,
highlights
:
IHighlight
[],
editorService
:
IEditorService
,
handler
:
GotoSymbolHandler
)
{
constructor
(
index
:
number
,
name
:
string
,
kind
:
SymbolKind
,
description
:
string
,
icon
:
string
,
range
:
IRange
,
revealRange
:
IRange
,
highlights
:
IHighlight
[],
editorService
:
IEditorService
,
handler
:
GotoSymbolHandler
)
{
super
();
this
.
index
=
index
;
this
.
name
=
name
;
this
.
type
=
type
;
this
.
kind
=
kind
;
this
.
icon
=
icon
;
this
.
description
=
description
;
this
.
range
=
range
;
...
...
@@ -276,8 +283,8 @@ class SymbolEntry extends EditorQuickOpenEntryGroup {
return
this
.
description
;
}
get
Type
():
string
{
return
this
.
type
;
get
Kind
():
SymbolKind
{
return
this
.
kind
;
}
getRange
():
IRange
{
...
...
@@ -470,7 +477,7 @@ export class GotoSymbolHandler extends QuickOpenHandler {
// Add
results
.
push
(
new
SymbolEntry
(
i
,
label
,
icon
,
description
,
`symbol-icon
${
icon
}
`
,
label
,
element
.
kind
,
description
,
`symbol-icon
${
icon
}
`
,
element
.
range
,
element
.
selectionRange
,
null
,
this
.
editorService
,
this
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录