Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
48bef528
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
48bef528
编写于
3月 31, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
improve query interface
上级
bb273906
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
12 deletion
+31
-12
src/vs/base/common/objects.ts
src/vs/base/common/objects.ts
+5
-0
src/vs/workbench/parts/extensions/common/extensions.ts
src/vs/workbench/parts/extensions/common/extensions.ts
+12
-1
src/vs/workbench/parts/extensions/common/vsoGalleryService.ts
...vs/workbench/parts/extensions/common/vsoGalleryService.ts
+11
-8
src/vs/workbench/parts/extensions/electron-browser/extensionsQuickOpen.ts
.../parts/extensions/electron-browser/extensionsQuickOpen.ts
+3
-3
未找到文件。
src/vs/base/common/objects.ts
浏览文件 @
48bef528
...
...
@@ -303,4 +303,9 @@ export function safeStringify(obj: any): string {
}
return
value
;
});
}
export
function
getOrDefault
<
T
,
R
>
(
obj
:
T
,
fn
:
(
obj
:
T
)
=>
R
,
defaultValue
:
R
=
null
):
R
{
const
result
=
fn
(
obj
);
return
typeof
result
===
'
undefined
'
?
defaultValue
:
result
;
}
\ No newline at end of file
src/vs/workbench/parts/extensions/common/extensions.ts
浏览文件 @
48bef528
...
...
@@ -45,10 +45,21 @@ export interface IExtension extends IExtensionManifest {
export
const
IExtensionsService
=
createDecorator
<
IExtensionsService
>
(
'
extensionsService
'
);
export
const
IGalleryService
=
createDecorator
<
IGalleryService
>
(
'
galleryService
'
);
export
interface
IQueryOptions
{
text
?:
string
;
pageNumber
?:
number
;
pageSize
?:
number
;
}
export
interface
IQueryResult
{
extensions
:
IExtension
[];
total
:
number
;
}
export
interface
IGalleryService
{
serviceId
:
ServiceIdentifier
<
any
>
;
isEnabled
():
boolean
;
query
(
text
?:
string
):
TPromise
<
{
extensions
:
IExtension
[];
total
:
number
;
}
>
;
query
(
options
?:
IQueryOptions
):
TPromise
<
IQueryResult
>
;
}
export
interface
IExtensionsService
{
...
...
src/vs/workbench/parts/extensions/common/vsoGalleryService.ts
浏览文件 @
48bef528
...
...
@@ -4,9 +4,9 @@
*--------------------------------------------------------------------------------------------*/
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IGalleryService
,
I
Extension
,
IGalleryVersion
}
from
'
vs/workbench/parts/extensions/common/extensions
'
;
import
{
IGalleryService
,
I
GalleryVersion
,
IQueryOptions
,
IQueryResult
}
from
'
vs/workbench/parts/extensions/common/extensions
'
;
import
{
IXHRResponse
}
from
'
vs/base/common/http
'
;
import
{
assign
}
from
'
vs/base/common/objects
'
;
import
{
assign
,
getOrDefault
}
from
'
vs/base/common/objects
'
;
import
{
IRequestService
}
from
'
vs/platform/request/common/request
'
;
import
{
IWorkspaceContextService
}
from
'
vs/workbench/services/workspace/common/contextService
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
...
...
@@ -47,8 +47,6 @@ function getInstallCount(statistics: IGalleryExtensionStatistics[]): number {
return
result
?
result
.
value
:
0
;
}
// const FIVE_MINUTES = 1000 * 60 * 5;
export
class
GalleryService
implements
IGalleryService
{
serviceId
=
IGalleryService
;
...
...
@@ -74,12 +72,12 @@ export class GalleryService implements IGalleryService {
return
!!
this
.
extensionsGalleryUrl
;
}
query
(
text
:
string
=
''
):
TPromise
<
{
extensions
:
IExtension
[];
total
:
number
;
}
>
{
query
(
options
:
IQueryOptions
=
{}):
TPromise
<
IQueryResult
>
{
if
(
!
this
.
isEnabled
())
{
return
TPromise
.
wrapError
(
new
Error
(
'
No extension gallery service configured.
'
));
}
return
this
.
queryGallery
(
text
)
return
this
.
queryGallery
(
options
)
.
then
(
r
=>
JSON
.
parse
(
r
.
responseText
).
results
[
0
])
.
then
<
{
galleryExtensions
:
IGalleryExtension
[];
total
:
number
;
}
>
(
r
=>
{
const
galleryExtensions
=
r
.
extensions
;
...
...
@@ -122,14 +120,19 @@ export class GalleryService implements IGalleryService {
});
}
private
queryGallery
(
text
:
string
):
TPromise
<
IXHRResponse
>
{
private
queryGallery
(
options
:
IQueryOptions
):
TPromise
<
IXHRResponse
>
{
const
text
=
getOrDefault
(
options
,
o
=>
o
.
text
,
''
);
const
pageNumber
=
getOrDefault
(
options
,
o
=>
o
.
pageNumber
,
1
);
const
pageSize
=
getOrDefault
(
options
,
o
=>
o
.
pageNumber
,
10
);
const
data
=
JSON
.
stringify
({
filters
:
[{
criteria
:[
{
filterType
:
8
,
value
:
'
Microsoft.VisualStudio.Code
'
},
{
filterType
:
10
,
value
:
text
}
],
pageSize
:
10
pageNumber
,
pageSize
}],
flags
:
0x1
|
0x4
|
0x80
|
0x100
});
...
...
src/vs/workbench/parts/extensions/electron-browser/extensionsQuickOpen.ts
浏览文件 @
48bef528
...
...
@@ -437,9 +437,9 @@ export class GalleryExtensionsHandler extends QuickOpenHandler {
return
nls
.
localize
(
'
galleryExtensionsHandlerAriaLabel
'
,
"
Type to narrow down the list of extensions from the gallery
"
);
}
getResults
(
inpu
t
:
string
):
TPromise
<
IModel
<
IExtensionEntry
>>
{
return
this
.
delayer
.
trigger
(()
=>
TPromise
.
join
<
any
>
([
this
.
galleryService
.
query
(
input
),
this
.
extensionsService
.
getInstalled
()]))
.
then
(
result
=>
this
.
instantiationService
.
createInstance
(
GalleryExtensionsModel
,
inpu
t
,
result
[
0
].
extensions
,
result
[
1
]));
getResults
(
tex
t
:
string
):
TPromise
<
IModel
<
IExtensionEntry
>>
{
return
this
.
delayer
.
trigger
(()
=>
TPromise
.
join
<
any
>
([
this
.
galleryService
.
query
(
{
text
}
),
this
.
extensionsService
.
getInstalled
()]))
.
then
(
result
=>
this
.
instantiationService
.
createInstance
(
GalleryExtensionsModel
,
tex
t
,
result
[
0
].
extensions
,
result
[
1
]));
}
getEmptyLabel
(
input
:
string
):
string
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录