Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
6ea319fa
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,发现更多精彩内容 >>
提交
6ea319fa
编写于
11月 25, 2015
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move the logic of getOutlineEntries into one place
上级
1ef99fc7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
75 addition
and
43 deletion
+75
-43
src/vs/editor/contrib/quickOpen/common/quickOpen.ts
src/vs/editor/contrib/quickOpen/common/quickOpen.ts
+61
-2
src/vs/workbench/api/common/languageFeatures.ts
src/vs/workbench/api/common/languageFeatures.ts
+4
-4
src/vs/workbench/parts/quickopen/browser/gotoSymbolHandler.ts
...vs/workbench/parts/quickopen/browser/gotoSymbolHandler.ts
+3
-30
src/vs/workbench/test/common/api/languageFeatures.test.ts
src/vs/workbench/test/common/api/languageFeatures.test.ts
+7
-7
未找到文件。
src/vs/editor/contrib/quickOpen/common/quickOpen.ts
浏览文件 @
6ea319fa
...
@@ -5,14 +5,73 @@
...
@@ -5,14 +5,73 @@
'
use strict
'
;
'
use strict
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IOutlineEntry
,
IOutlineSupport
}
from
'
vs/editor/common/modes
'
;
import
{
IOutlineEntry
,
IOutlineSupport
}
from
'
vs/editor/common/modes
'
;
import
LanguageFeatureRegistry
from
'
vs/editor/common/modes/languageFeatureRegistry
'
;
import
LanguageFeatureRegistry
from
'
vs/editor/common/modes/languageFeatureRegistry
'
;
const
QuickOut
ineRegistry
=
new
LanguageFeatureRegistry
<
IOutlineSupport
>
(
'
outlineSupport
'
);
const
Outl
ineRegistry
=
new
LanguageFeatureRegistry
<
IOutlineSupport
>
(
'
outlineSupport
'
);
export
{
export
{
OutlineRegistry
,
IOutlineEntry
,
IOutlineEntry
,
IOutlineSupport
IOutlineSupport
}
}
export
default
QuickOutineRegistry
;
export
function
getOutlineEntries
(
model
:
IModel
):
TPromise
<
{
entries
:
IOutlineEntry
[],
outlineGroupLabel
:
{
[
n
:
string
]:
string
;}
}
>
{
\ No newline at end of file
let
resource
=
model
.
getAssociatedResource
();
let
groupLabels
:
{
[
n
:
string
]:
string
}
=
Object
.
create
(
null
);
let
entries
:
IOutlineEntry
[]
=
[];
let
promises
=
OutlineRegistry
.
all
(
<
IModel
>
model
).
map
(
support
=>
{
if
(
support
.
outlineGroupLabel
)
{
for
(
var
key
in
support
.
outlineGroupLabel
)
{
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
support
.
outlineGroupLabel
,
key
))
{
groupLabels
[
key
]
=
support
.
outlineGroupLabel
[
key
];
}
}
}
return
support
.
getOutline
(
resource
).
then
(
result
=>
{
if
(
Array
.
isArray
(
result
))
{
entries
.
push
(...
result
);
}
},
err
=>
{
onUnexpectedError
(
err
);
});
});
return
TPromise
.
join
(
promises
).
then
(()
=>
{
let
flatEntries
:
IOutlineEntry
[]
=
[];
flatten
(
flatEntries
,
entries
,
''
);
flatEntries
.
sort
(
compareEntriesUsingStart
);
return
{
entries
:
flatEntries
,
outlineGroupLabel
:
groupLabels
}
});
}
function
compareEntriesUsingStart
(
a
:
IOutlineEntry
,
b
:
IOutlineEntry
):
number
{
return
Range
.
compareRangesUsingStarts
(
a
.
range
,
b
.
range
);
}
function
flatten
(
bucket
:
IOutlineEntry
[],
entries
:
IOutlineEntry
[],
overrideContainerLabel
:
string
):
void
{
for
(
let
entry
of
entries
)
{
bucket
.
push
({
type
:
entry
.
type
,
range
:
entry
.
range
,
label
:
entry
.
label
,
icon
:
entry
.
icon
,
containerLabel
:
entry
.
containerLabel
||
overrideContainerLabel
});
if
(
entry
.
children
)
{
flatten
(
bucket
,
entry
.
children
,
entry
.
label
);
}
}
}
src/vs/workbench/api/common/languageFeatures.ts
浏览文件 @
6ea319fa
...
@@ -27,7 +27,7 @@ import ExtraInfoRegistry from 'vs/editor/contrib/hover/common/hover';
...
@@ -27,7 +27,7 @@ import ExtraInfoRegistry from 'vs/editor/contrib/hover/common/hover';
import
DocumentHighlighterRegistry
from
'
vs/editor/contrib/wordHighlighter/common/wordHighlighter
'
;
import
DocumentHighlighterRegistry
from
'
vs/editor/contrib/wordHighlighter/common/wordHighlighter
'
;
import
ReferenceSearchRegistry
from
'
vs/editor/contrib/referenceSearch/common/referenceSearch
'
;
import
ReferenceSearchRegistry
from
'
vs/editor/contrib/referenceSearch/common/referenceSearch
'
;
import
QuickFixRegistry
from
'
vs/editor/contrib/quickFix/common/quickFix
'
;
import
QuickFixRegistry
from
'
vs/editor/contrib/quickFix/common/quickFix
'
;
import
QuickOutlineRegistry
,
{
IOutlineEntry
,
IOutlineSupport
}
from
'
vs/editor/contrib/quickOpen/common/quickOpen
'
;
import
{
OutlineRegistry
,
IOutlineEntry
,
IOutlineSupport
}
from
'
vs/editor/contrib/quickOpen/common/quickOpen
'
;
import
LanguageFeatureRegistry
from
'
vs/editor/common/modes/languageFeatureRegistry
'
;
import
LanguageFeatureRegistry
from
'
vs/editor/common/modes/languageFeatureRegistry
'
;
import
{
NavigateTypesSupportRegistry
,
INavigateTypesSupport
,
ITypeBearing
}
from
'
vs/workbench/parts/search/common/search
'
import
{
NavigateTypesSupportRegistry
,
INavigateTypesSupport
,
ITypeBearing
}
from
'
vs/workbench/parts/search/common/search
'
import
{
RenameRegistry
}
from
'
vs/editor/contrib/rename/common/rename
'
;
import
{
RenameRegistry
}
from
'
vs/editor/contrib/rename/common/rename
'
;
...
@@ -544,7 +544,7 @@ export class ExtensionHostDocumentSymbols extends AbstractExtensionHostFeature<v
...
@@ -544,7 +544,7 @@ export class ExtensionHostDocumentSymbols extends AbstractExtensionHostFeature<v
export
class
MainThreadDocumentSymbols
extends
AbstractMainThreadFeature
<
IOutlineSupport
>
implements
IOutlineSupport
{
export
class
MainThreadDocumentSymbols
extends
AbstractMainThreadFeature
<
IOutlineSupport
>
implements
IOutlineSupport
{
constructor
(
@
IThreadService
threadService
:
IThreadService
)
{
constructor
(
@
IThreadService
threadService
:
IThreadService
)
{
super
(
'
vscode.executeDocumentSymbolProvider
'
,
Quick
OutlineRegistry
,
threadService
);
super
(
'
vscode.executeDocumentSymbolProvider
'
,
OutlineRegistry
,
threadService
);
}
}
getOutline
(
resource
:
URI
):
TPromise
<
IOutlineEntry
[]
>
{
getOutline
(
resource
:
URI
):
TPromise
<
IOutlineEntry
[]
>
{
...
@@ -1262,7 +1262,7 @@ export namespace LanguageFeatures {
...
@@ -1262,7 +1262,7 @@ export namespace LanguageFeatures {
threadService
.
getRemotable
(
MainThreadReferenceSearch
);
threadService
.
getRemotable
(
MainThreadReferenceSearch
);
threadService
.
getRemotable
(
MainThreadCodeActions
);
threadService
.
getRemotable
(
MainThreadCodeActions
);
threadService
.
getRemotable
(
MainThreadCodeLens
);
threadService
.
getRemotable
(
MainThreadCodeLens
);
threadService
.
getRemotable
(
MainThreadDocumentSymbols
);
//
threadService.getRemotable(MainThreadDocumentSymbols);
threadService
.
getRemotable
(
MainThreadWorkspaceSymbols
);
threadService
.
getRemotable
(
MainThreadWorkspaceSymbols
);
threadService
.
getRemotable
(
MainThreadRename
);
threadService
.
getRemotable
(
MainThreadRename
);
threadService
.
getRemotable
(
MainThreadFormatDocument
);
threadService
.
getRemotable
(
MainThreadFormatDocument
);
...
@@ -1280,7 +1280,7 @@ export namespace LanguageFeatures {
...
@@ -1280,7 +1280,7 @@ export namespace LanguageFeatures {
referenceSearch
:
new
ExtensionHostReferenceSearch
(
threadService
),
referenceSearch
:
new
ExtensionHostReferenceSearch
(
threadService
),
codeActions
:
new
ExtensionHostCodeActions
(
threadService
),
codeActions
:
new
ExtensionHostCodeActions
(
threadService
),
codeLens
:
threadService
.
getRemotable
(
ExtensionHostCodeLens
),
codeLens
:
threadService
.
getRemotable
(
ExtensionHostCodeLens
),
documentSymbols
:
new
ExtensionHostDocumentSymbols
(
threadService
),
//
documentSymbols: new ExtensionHostDocumentSymbols(threadService),
workspaceSymbols
:
new
ExtensionHostWorkspaceSymbols
(
threadService
),
workspaceSymbols
:
new
ExtensionHostWorkspaceSymbols
(
threadService
),
rename
:
new
ExtensionHostRename
(
threadService
),
rename
:
new
ExtensionHostRename
(
threadService
),
formatDocument
:
new
ExtHostFormatDocument
(
threadService
),
formatDocument
:
new
ExtHostFormatDocument
(
threadService
),
...
...
src/vs/workbench/parts/quickopen/browser/gotoSymbolHandler.ts
浏览文件 @
6ea319fa
...
@@ -31,7 +31,7 @@ import {IQuickOpenService} from 'vs/workbench/services/quickopen/browser/quickOp
...
@@ -31,7 +31,7 @@ import {IQuickOpenService} from 'vs/workbench/services/quickopen/browser/quickOp
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
KeyMod
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
KeyMod
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
QuickOpenRegistry
from
'
vs/editor/contrib/quickOpen/common/quickOpen
'
;
import
{
OutlineRegistry
,
getOutlineEntries
}
from
'
vs/editor/contrib/quickOpen/common/quickOpen
'
;
const
ACTION_ID
=
'
workbench.action.gotoSymbol
'
;
const
ACTION_ID
=
'
workbench.action.gotoSymbol
'
;
const
ACTION_LABEL
=
nls
.
localize
(
'
gotoSymbol
'
,
"
Go to Symbol...
"
);
const
ACTION_LABEL
=
nls
.
localize
(
'
gotoSymbol
'
,
"
Go to Symbol...
"
);
...
@@ -432,7 +432,7 @@ export class GotoSymbolHandler extends QuickOpenHandler {
...
@@ -432,7 +432,7 @@ export class GotoSymbolHandler extends QuickOpenHandler {
if
(
model
&&
types
.
isFunction
((
<
ITokenizedModel
>
model
).
getMode
))
{
if
(
model
&&
types
.
isFunction
((
<
ITokenizedModel
>
model
).
getMode
))
{
canRun
=
QuickOpen
Registry
.
has
(
<
IModel
>
model
);
canRun
=
Outline
Registry
.
has
(
<
IModel
>
model
);
}
}
}
}
...
@@ -527,34 +527,7 @@ export class GotoSymbolHandler extends QuickOpenHandler {
...
@@ -527,34 +527,7 @@ export class GotoSymbolHandler extends QuickOpenHandler {
return
TPromise
.
as
(
this
.
outlineToModelCache
[
modelId
]);
return
TPromise
.
as
(
this
.
outlineToModelCache
[
modelId
]);
}
}
let
groupLabels
:
{
[
n
:
string
]:
string
}
=
Object
.
create
(
null
);
return
getOutlineEntries
(
<
IModel
>
model
).
then
(
outline
=>
{
let
entries
:
IOutlineEntry
[]
=
[];
let
resource
=
(
<
IModel
>
model
).
getAssociatedResource
();
let
promises
=
QuickOpenRegistry
.
all
(
<
IModel
>
model
).
map
(
support
=>
{
if
(
support
.
outlineGroupLabel
)
{
for
(
var
key
in
support
.
outlineGroupLabel
)
{
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
support
.
outlineGroupLabel
,
key
))
{
groupLabels
[
key
]
=
support
.
outlineGroupLabel
[
key
];
}
}
}
return
support
.
getOutline
(
resource
).
then
(
result
=>
{
if
(
Array
.
isArray
(
result
))
{
entries
.
push
(...
result
);
}
},
err
=>
{
errors
.
onUnexpectedError
(
err
);
});
});
return
TPromise
.
join
(
promises
).
then
(()
=>
{
let
outline
=
{
entries
,
outlineGroupLabel
:
groupLabels
};
let
model
=
new
OutlineModel
(
outline
,
this
.
toQuickOpenEntries
(
outline
));
let
model
=
new
OutlineModel
(
outline
,
this
.
toQuickOpenEntries
(
outline
));
...
...
src/vs/workbench/test/common/api/languageFeatures.test.ts
浏览文件 @
6ea319fa
...
@@ -18,7 +18,7 @@ import * as LF from 'vs/workbench/api/common/languageFeatures';
...
@@ -18,7 +18,7 @@ import * as LF from 'vs/workbench/api/common/languageFeatures';
import
{
PluginHostCommands
,
MainThreadCommands
}
from
'
vs/workbench/api/common/pluginHostCommands
'
;
import
{
PluginHostCommands
,
MainThreadCommands
}
from
'
vs/workbench/api/common/pluginHostCommands
'
;
import
{
PluginHostModelService
}
from
'
vs/workbench/api/common/pluginHostDocuments
'
;
import
{
PluginHostModelService
}
from
'
vs/workbench/api/common/pluginHostDocuments
'
;
import
{
SyncDescriptor0
}
from
'
vs/platform/instantiation/common/descriptors
'
;
import
{
SyncDescriptor0
}
from
'
vs/platform/instantiation/common/descriptors
'
;
import
QuickOutlineRegistry
from
'
vs/editor/contrib/quickOpen/common/quickOpen
'
;
import
{
OutlineRegistry
}
from
'
vs/editor/contrib/quickOpen/common/quickOpen
'
;
import
{
LanguageSelector
,
ModelLike
}
from
'
vs/editor/common/modes/languageSelector
'
;
import
{
LanguageSelector
,
ModelLike
}
from
'
vs/editor/common/modes/languageSelector
'
;
class
ThreadService
extends
NullThreadService
{
class
ThreadService
extends
NullThreadService
{
...
@@ -85,17 +85,17 @@ suite('ExtHostLanguageFeatures', function() {
...
@@ -85,17 +85,17 @@ suite('ExtHostLanguageFeatures', function() {
// register
// register
assert
.
equal
(
Quick
OutlineRegistry
.
all
(
model
).
length
,
0
);
assert
.
equal
(
OutlineRegistry
.
all
(
model
).
length
,
0
);
let
disposable
=
extHost
.
register
(
'
far
'
,
{
let
disposable
=
extHost
.
register
(
'
far
'
,
{
provideDocumentSymbols
()
{
provideDocumentSymbols
()
{
return
[];
return
[];
}
}
});
});
assert
.
equal
(
Quick
OutlineRegistry
.
all
(
model
).
length
,
1
);
assert
.
equal
(
OutlineRegistry
.
all
(
model
).
length
,
1
);
// deregister
// deregister
disposable
.
dispose
();
disposable
.
dispose
();
assert
.
equal
(
Quick
OutlineRegistry
.
all
(
model
).
length
,
0
);
assert
.
equal
(
OutlineRegistry
.
all
(
model
).
length
,
0
);
// all extension host provider appear as one
// all extension host provider appear as one
disposable
=
extHost
.
register
(
'
far
'
,
{
disposable
=
extHost
.
register
(
'
far
'
,
{
...
@@ -108,12 +108,12 @@ suite('ExtHostLanguageFeatures', function() {
...
@@ -108,12 +108,12 @@ suite('ExtHostLanguageFeatures', function() {
return
[];
return
[];
}
}
});
});
assert
.
equal
(
Quick
OutlineRegistry
.
all
(
model
).
length
,
1
);
assert
.
equal
(
OutlineRegistry
.
all
(
model
).
length
,
1
);
disposable
.
dispose
();
disposable
.
dispose
();
assert
.
equal
(
Quick
OutlineRegistry
.
all
(
model
).
length
,
1
);
assert
.
equal
(
OutlineRegistry
.
all
(
model
).
length
,
1
);
disposable2
.
dispose
();
disposable2
.
dispose
();
assert
.
equal
(
Quick
OutlineRegistry
.
all
(
model
).
length
,
0
);
assert
.
equal
(
OutlineRegistry
.
all
(
model
).
length
,
0
);
});
});
test
(
'
DocumentSymbols, evil provider
'
,
function
(
done
)
{
test
(
'
DocumentSymbols, evil provider
'
,
function
(
done
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录