Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
822a45f6
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 搜索 >>
提交
822a45f6
编写于
12月 21, 2020
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add outline target and adjust sorting, filtering for document symbols outline accordingly
上级
cece1a4f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
46 addition
and
71 deletion
+46
-71
src/vs/workbench/browser/parts/editor/breadcrumbsModel.ts
src/vs/workbench/browser/parts/editor/breadcrumbsModel.ts
+2
-2
src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts
src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts
+2
-47
src/vs/workbench/contrib/codeEditor/browser/outline/documentSymbolsOutline.ts
...trib/codeEditor/browser/outline/documentSymbolsOutline.ts
+29
-15
src/vs/workbench/contrib/codeEditor/browser/quickaccess/gotoSymbolQuickAccess.ts
...b/codeEditor/browser/quickaccess/gotoSymbolQuickAccess.ts
+2
-2
src/vs/workbench/services/outline/browser/outline.ts
src/vs/workbench/services/outline/browser/outline.ts
+8
-2
src/vs/workbench/services/outline/browser/outlineService.ts
src/vs/workbench/services/outline/browser/outlineService.ts
+3
-3
未找到文件。
src/vs/workbench/browser/parts/editor/breadcrumbsModel.ts
浏览文件 @
822a45f6
...
...
@@ -15,7 +15,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import
{
BreadcrumbsConfig
}
from
'
vs/workbench/browser/parts/editor/breadcrumbs
'
;
import
{
FileKind
}
from
'
vs/platform/files/common/files
'
;
import
{
withNullAsUndefined
}
from
'
vs/base/common/types
'
;
import
{
IOutline
,
IOutlineService
}
from
'
vs/workbench/services/outline/browser/outline
'
;
import
{
IOutline
,
IOutlineService
,
OutlineTarget
}
from
'
vs/workbench/services/outline/browser/outline
'
;
import
{
IEditorPane
}
from
'
vs/workbench/common/editor
'
;
export
class
FileElement
{
...
...
@@ -154,7 +154,7 @@ export class BreadcrumbsModel {
this
.
_outlineDisposables
.
clear
();
this
.
_outlineDisposables
.
add
(
toDisposable
(()
=>
newCts
.
dispose
(
true
)));
this
.
_outlineService
.
createOutline
(
editor
,
newCts
.
token
).
then
(
outline
=>
{
this
.
_outlineService
.
createOutline
(
editor
,
OutlineTarget
.
Breadcrumbs
,
newCts
.
token
).
then
(
outline
=>
{
if
(
newCts
.
token
.
isCancellationRequested
)
{
// cancelled: dispose new outline and reset
outline
?.
dispose
();
...
...
src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts
浏览文件 @
822a45f6
...
...
@@ -23,11 +23,9 @@ import { ResourceLabels, IResourceLabel, DEFAULT_LABELS_CONTAINER } from 'vs/wor
import
{
BreadcrumbsConfig
}
from
'
vs/workbench/browser/parts/editor/breadcrumbs
'
;
import
{
OutlineElement2
,
FileElement
}
from
'
vs/workbench/browser/parts/editor/breadcrumbsModel
'
;
import
{
IAsyncDataSource
,
ITreeRenderer
,
ITreeNode
,
ITreeFilter
,
TreeVisibility
,
ITreeSorter
}
from
'
vs/base/browser/ui/tree/tree
'
;
import
{
OutlineItemComparator
,
OutlineNavigationLabelProvider
,
OutlineFilter
}
from
'
vs/editor/contrib/documentSymbols/outlineTree
'
;
import
{
IIdentityProvider
,
IListVirtualDelegate
,
IKeyboardNavigationLabelProvider
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
IFileIconTheme
,
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IListAccessibilityProvider
}
from
'
vs/base/browser/ui/list/listWidget
'
;
// import { IModeService } from 'vs/editor/common/services/modeService';
import
{
localize
}
from
'
vs/nls
'
;
import
{
IOutline
}
from
'
vs/workbench/services/outline/browser/outline
'
;
import
{
IEditorOptions
}
from
'
vs/platform/editor/common/editor
'
;
...
...
@@ -452,22 +450,6 @@ export class BreadcrumbsFilePicker extends BreadcrumbsPicker {
export
class
BreadcrumbsOutlinePicker
extends
BreadcrumbsPicker
{
protected
readonly
_symbolSortOrder
:
BreadcrumbsConfig
<
'
position
'
|
'
name
'
|
'
type
'
>
;
protected
_outlineComparator
:
OutlineItemComparator
;
constructor
(
parent
:
HTMLElement
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IThemeService
themeService
:
IThemeService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
// @IModeService private readonly _modeService: IModeService,
@
ITelemetryService
telemetryService
:
ITelemetryService
,
)
{
super
(
parent
,
instantiationService
,
themeService
,
configurationService
,
telemetryService
);
this
.
_symbolSortOrder
=
BreadcrumbsConfig
.
SymbolSortOrder
.
bindTo
(
this
.
_configurationService
);
this
.
_outlineComparator
=
new
OutlineItemComparator
();
}
protected
_createTree
(
container
:
HTMLElement
,
input
:
OutlineElement2
)
{
const
{
config
}
=
input
.
outline
;
...
...
@@ -480,35 +462,20 @@ export class BreadcrumbsOutlinePicker extends BreadcrumbsPicker {
config
.
renderers
,
config
.
treeDataSource
,
{
...
config
.
options
,
identityProvider
:
config
.
identityProvider
,
collapseByDefault
:
true
,
expandOnlyOnTwistieClick
:
true
,
multipleSelectionSupport
:
false
,
sorter
:
this
.
_outlineComparator
,
identityProvider
:
config
.
identityProvider
,
keyboardNavigationLabelProvider
:
new
OutlineNavigationLabelProvider
(),
accessibilityProvider
:
config
.
options
.
accessibilityProvider
,
filter
:
this
.
_instantiationService
.
createInstance
(
OutlineFilter
,
'
breadcrumbs
'
)
}
);
}
dispose
():
void
{
this
.
_symbolSortOrder
.
dispose
();
super
.
dispose
();
}
protected
_setInput
(
input
:
OutlineElement2
):
Promise
<
void
>
{
const
tree
=
this
.
_tree
as
WorkbenchDataTree
<
IOutline
<
any
>
,
any
,
FuzzyScore
>
;
// todo@jrieken
// const overrideConfiguration = {
// resource: model.uri,
// overrideIdentifier: this._modeService.getModeIdByFilepathOrFirstLine(model.uri)
// };
// this._outlineComparator.type = this._getOutlineItemCompareType(overrideConfiguration);
tree
.
setInput
(
input
.
outline
);
if
(
input
.
element
!==
input
.
outline
)
{
tree
.
reveal
(
input
.
element
,
0.5
);
...
...
@@ -529,18 +496,6 @@ export class BreadcrumbsOutlinePicker extends BreadcrumbsPicker {
await
outline
.
reveal
(
element
,
options
,
sideBySide
);
return
true
;
}
// private _getOutlineItemCompareType(overrideConfiguration?: IConfigurationOverrides): OutlineSortOrder {
// switch (this._symbolSortOrder.getValue(overrideConfiguration)) {
// case 'name':
// return OutlineSortOrder.ByName;
// case 'type':
// return OutlineSortOrder.ByKind;
// case 'position':
// default:
// return OutlineSortOrder.ByPosition;
// }
// }
}
//#endregion
src/vs/workbench/contrib/codeEditor/browser/outline/documentSymbolsOutline.ts
浏览文件 @
822a45f6
...
...
@@ -5,12 +5,12 @@
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
Disposable
,
DisposableStore
,
IDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IOutline
,
IOutlineCreator
,
IOutlineService
,
OutlineTreeConfiguration
}
from
'
vs/workbench/services/outline/browser/outline
'
;
import
{
IOutline
,
IOutlineCreator
,
IOutlineService
,
OutlineT
arget
,
OutlineT
reeConfiguration
}
from
'
vs/workbench/services/outline/browser/outline
'
;
import
{
IWorkbenchContributionsRegistry
,
Extensions
as
WorkbenchExtensions
}
from
'
vs/workbench/common/contributions
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
LifecyclePhase
}
from
'
vs/workbench/services/lifecycle/common/lifecycle
'
;
import
{
IEditorPane
}
from
'
vs/workbench/common/editor
'
;
import
{
OutlineAccessibilityProvider
,
OutlineElementRenderer
,
OutlineFilter
,
OutlineGroupRenderer
,
OutlineIdentityProvider
,
Outline
NavigationLabelProvi
der
,
OutlineVirtualDelegate
}
from
'
vs/editor/contrib/documentSymbols/outlineTree
'
;
import
{
OutlineAccessibilityProvider
,
OutlineElementRenderer
,
OutlineFilter
,
OutlineGroupRenderer
,
OutlineIdentityProvider
,
Outline
ItemComparator
,
OutlineNavigationLabelProvider
,
OutlineSortOr
der
,
OutlineVirtualDelegate
}
from
'
vs/editor/contrib/documentSymbols/outlineTree
'
;
import
{
ICodeEditor
,
isCodeEditor
,
isDiffEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
OutlineGroup
,
OutlineElement
,
OutlineModel
,
TreeElement
}
from
'
vs/editor/contrib/documentSymbols/outlineModel
'
;
import
{
DocumentSymbolProviderRegistry
}
from
'
vs/editor/common/modes
'
;
...
...
@@ -29,7 +29,6 @@ import { Range } from 'vs/editor/common/core/range';
import
{
IEditorOptions
,
TextEditorSelectionRevealType
}
from
'
vs/platform/editor/common/editor
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
type
DocumentSymbolItem
=
OutlineGroup
|
OutlineElement
;
class
DocumentSymbolsOutline
implements
IOutline
<
DocumentSymbolItem
>
{
...
...
@@ -50,19 +49,17 @@ class DocumentSymbolsOutline implements IOutline<DocumentSymbolItem> {
constructor
(
private
readonly
_editor
:
ICodeEditor
,
target
:
OutlineTarget
,
@
ICodeEditorService
private
readonly
_codeEditorService
:
ICodeEditorService
,
@
IConfigurationService
private
readonly
_configurationService
:
IConfigurationService
,
@
ITextResourceConfigurationService
private
readonly
_textResourceConfigurationService
:
ITextResourceConfigurationService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
)
{
const
sorter
=
new
OutlineItemComparator
();
this
.
config
=
new
OutlineTreeConfiguration
(
{
getBreadcrumbElements
:
()
=>
<
DocumentSymbolItem
[]
>
this
.
_outlineElementChain
.
filter
(
element
=>
!
(
element
instanceof
OutlineModel
))
},
{
getQuickPickElements
:
()
=>
{
throw
new
Error
(
'
not implemented
'
);
}
},
{
getBreadcrumbElements
:
()
=>
<
DocumentSymbolItem
[]
>
this
.
_outlineElementChain
.
filter
(
element
=>
!
(
element
instanceof
OutlineModel
))
},
{
getQuickPickElements
:
()
=>
{
throw
new
Error
(
'
not implemented
'
);
}
},
{
getChildren
:
(
parent
)
=>
{
if
(
parent
instanceof
OutlineElement
||
parent
instanceof
OutlineGroup
)
{
...
...
@@ -81,14 +78,31 @@ class DocumentSymbolsOutline implements IOutline<DocumentSymbolItem> {
collapseByDefault
:
true
,
expandOnlyOnTwistieClick
:
true
,
multipleSelectionSupport
:
false
,
// sorter: this._outlineComparator,
identityProvider
:
new
OutlineIdentityProvider
(),
keyboardNavigationLabelProvider
:
new
OutlineNavigationLabelProvider
(),
accessibilityProvider
:
new
OutlineAccessibilityProvider
(
''
),
filter
:
instantiationService
.
createInstance
(
OutlineFilter
,
'
breadcrumbs
'
)
accessibilityProvider
:
new
OutlineAccessibilityProvider
(
target
===
OutlineTarget
.
Breadcrumbs
?
'
breadcrumbs
'
:
'
outline
'
),
filter
:
instantiationService
.
createInstance
(
OutlineFilter
,
target
===
OutlineTarget
.
Breadcrumbs
?
'
breadcrumbs
'
:
'
outline
'
),
sorter
}
);
// special sorting for breadcrumbs
if
(
target
===
OutlineTarget
.
Breadcrumbs
)
{
const
updateSort
=
()
=>
{
const
uri
=
this
.
_outlineModel
?.
uri
;
const
value
=
_textResourceConfigurationService
.
getValue
(
uri
,
`breadcrumbs.symbolSortOrder`
);
if
(
value
===
'
name
'
)
{
sorter
.
type
=
OutlineSortOrder
.
ByName
;
}
else
if
(
value
===
'
type
'
)
{
sorter
.
type
=
OutlineSortOrder
.
ByKind
;
}
else
{
sorter
.
type
=
OutlineSortOrder
.
ByPosition
;
}
};
this
.
_disposables
.
add
(
_textResourceConfigurationService
.
onDidChangeConfiguration
(()
=>
updateSort
()));
updateSort
();
}
// update as language, model, providers changes
this
.
_disposables
.
add
(
DocumentSymbolProviderRegistry
.
onDidChange
(
_
=>
this
.
_updateOutline
()));
this
.
_disposables
.
add
(
this
.
_editor
.
onDidChangeModel
(
_
=>
this
.
_updateOutline
()));
...
...
@@ -333,7 +347,7 @@ class DocumentSymbolsOutlineCreator implements IOutlineCreator<IEditorPane, Docu
return
isCodeEditor
(
ctrl
)
||
isDiffEditor
(
ctrl
);
}
async
createOutline
(
pane
:
IEditorPane
,
token
:
CancellationToken
):
Promise
<
IOutline
<
DocumentSymbolItem
>
|
undefined
>
{
async
createOutline
(
pane
:
IEditorPane
,
t
arget
:
OutlineTarget
,
t
oken
:
CancellationToken
):
Promise
<
IOutline
<
DocumentSymbolItem
>
|
undefined
>
{
const
control
=
pane
.
getControl
();
let
editor
:
ICodeEditor
|
undefined
;
if
(
isCodeEditor
(
control
))
{
...
...
@@ -344,7 +358,7 @@ class DocumentSymbolsOutlineCreator implements IOutlineCreator<IEditorPane, Docu
if
(
!
editor
)
{
return
undefined
;
}
return
this
.
_instantiationService
.
createInstance
(
DocumentSymbolsOutline
,
editor
);
return
this
.
_instantiationService
.
createInstance
(
DocumentSymbolsOutline
,
editor
,
target
);
}
}
...
...
src/vs/workbench/contrib/codeEditor/browser/quickaccess/gotoSymbolQuickAccess.ts
浏览文件 @
822a45f6
...
...
@@ -26,7 +26,7 @@ import { onUnexpectedError } from 'vs/base/common/errors';
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
IQuickAccessTextEditorContext
}
from
'
vs/editor/contrib/quickAccess/editorNavigationQuickAccess
'
;
import
{
IOutlineService
}
from
'
vs/workbench/services/outline/browser/outline
'
;
import
{
IOutlineService
,
OutlineTarget
}
from
'
vs/workbench/services/outline/browser/outline
'
;
import
{
isCompositeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
export
class
GotoSymbolQuickAccessProvider
extends
AbstractGotoSymbolQuickAccessProvider
{
...
...
@@ -138,7 +138,7 @@ export class GotoSymbolQuickAccessProvider extends AbstractGotoSymbolQuickAccess
picker
.
busy
=
true
;
this
.
outlineService
.
createOutline
(
pane
,
cts
.
token
).
then
(
outline
=>
{
this
.
outlineService
.
createOutline
(
pane
,
OutlineTarget
.
QuickPick
,
cts
.
token
).
then
(
outline
=>
{
if
(
!
outline
)
{
return
;
...
...
src/vs/workbench/services/outline/browser/outline.ts
浏览文件 @
822a45f6
...
...
@@ -17,17 +17,23 @@ import { IEditorPane } from 'vs/workbench/common/editor';
export
const
IOutlineService
=
createDecorator
<
IOutlineService
>
(
'
IOutlineService
'
);
export
const
enum
OutlineTarget
{
OutlinePane
,
Breadcrumbs
,
QuickPick
}
export
interface
IOutlineService
{
_serviceBrand
:
undefined
;
onDidChange
:
Event
<
void
>
;
canCreateOutline
(
editor
:
IEditorPane
):
boolean
;
createOutline
(
editor
:
IEditorPane
,
token
:
CancellationToken
):
Promise
<
IOutline
<
any
>
|
undefined
>
;
createOutline
(
editor
:
IEditorPane
,
t
arget
:
OutlineTarget
,
t
oken
:
CancellationToken
):
Promise
<
IOutline
<
any
>
|
undefined
>
;
registerOutlineCreator
(
creator
:
IOutlineCreator
<
any
,
any
>
):
IDisposable
;
}
export
interface
IOutlineCreator
<
P
extends
IEditorPane
,
E
>
{
matches
(
candidate
:
IEditorPane
):
candidate
is
P
;
createOutline
(
editor
:
P
,
token
:
CancellationToken
):
Promise
<
IOutline
<
E
>
|
undefined
>
;
createOutline
(
editor
:
P
,
t
arget
:
OutlineTarget
,
t
oken
:
CancellationToken
):
Promise
<
IOutline
<
E
>
|
undefined
>
;
}
export
interface
IBreadcrumbsDataSource
<
E
>
{
...
...
src/vs/workbench/services/outline/browser/outlineService.ts
浏览文件 @
822a45f6
...
...
@@ -8,7 +8,7 @@ import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import
{
LinkedList
}
from
'
vs/base/common/linkedList
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
IEditorPane
}
from
'
vs/workbench/common/editor
'
;
import
{
IOutline
,
IOutlineCreator
,
IOutlineService
}
from
'
vs/workbench/services/outline/browser/outline
'
;
import
{
IOutline
,
IOutlineCreator
,
IOutlineService
,
OutlineTarget
}
from
'
vs/workbench/services/outline/browser/outline
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
class
OutlineService
implements
IOutlineService
{
...
...
@@ -29,10 +29,10 @@ class OutlineService implements IOutlineService {
return
false
;
}
async
createOutline
(
pane
:
IEditorPane
,
token
:
CancellationToken
):
Promise
<
IOutline
<
any
>
|
undefined
>
{
async
createOutline
(
pane
:
IEditorPane
,
t
arget
:
OutlineTarget
,
t
oken
:
CancellationToken
):
Promise
<
IOutline
<
any
>
|
undefined
>
{
for
(
let
factory
of
this
.
_factories
)
{
if
(
factory
.
matches
(
pane
))
{
return
await
factory
.
createOutline
(
pane
,
token
);
return
await
factory
.
createOutline
(
pane
,
t
arget
,
t
oken
);
}
}
return
undefined
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录