Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
2eb78b54
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,发现更多精彩内容 >>
提交
2eb78b54
编写于
9月 19, 2018
作者:
R
Ramya Achutha Rao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Extension Search Experiments
上级
dbdbbe52
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
114 addition
and
5 deletion
+114
-5
src/vs/workbench/parts/experiments/node/experimentService.ts
src/vs/workbench/parts/experiments/node/experimentService.ts
+5
-1
src/vs/workbench/parts/experiments/test/node/experimentService.test.ts
...nch/parts/experiments/test/node/experimentService.test.ts
+11
-1
src/vs/workbench/parts/extensions/electron-browser/extensionsViews.ts
...ench/parts/extensions/electron-browser/extensionsViews.ts
+26
-2
src/vs/workbench/parts/extensions/test/electron-browser/extensionsViews.test.ts
.../extensions/test/electron-browser/extensionsViews.test.ts
+72
-1
未找到文件。
src/vs/workbench/parts/experiments/node/experimentService.ts
浏览文件 @
2eb78b54
...
...
@@ -70,7 +70,8 @@ interface IExperimentAction {
export
enum
ExperimentActionType
{
Custom
=
'
Custom
'
,
Prompt
=
'
Prompt
'
,
AddToRecommendations
=
'
AddToRecommendations
'
AddToRecommendations
=
'
AddToRecommendations
'
,
ExtensionSearchResults
=
'
ExtensionSearchResults
'
}
export
interface
IExperimentActionPromptProperties
{
...
...
@@ -231,6 +232,9 @@ export class ExperimentService extends Disposable implements IExperimentService
}
});
}
if
(
!
processedExperiment
.
action
.
properties
)
{
processedExperiment
.
action
.
properties
=
{};
}
}
this
.
_experiments
.
push
(
processedExperiment
);
...
...
src/vs/workbench/parts/experiments/test/node/experimentService.test.ts
浏览文件 @
2eb78b54
...
...
@@ -592,6 +592,13 @@ suite('Experiment Service', () => {
properties
:
customProperties
}
},
{
id
:
'
custom-experiment-no-properties
'
,
enabled
:
true
,
action
:
{
type
:
'
Custom
'
}
},
{
id
:
'
prompt-with-no-commands
'
,
enabled
:
true
,
...
...
@@ -622,9 +629,12 @@ suite('Experiment Service', () => {
testObject
=
instantiationService
.
createInstance
(
TestExperimentService
);
const
custom
=
testObject
.
getExperimentsByType
(
ExperimentActionType
.
Custom
).
then
(
result
=>
{
assert
.
equal
(
result
.
length
,
2
);
assert
.
equal
(
result
.
length
,
3
);
assert
.
equal
(
result
[
0
].
id
,
'
simple-experiment
'
);
assert
.
equal
(
result
[
1
].
id
,
'
custom-experiment
'
);
assert
.
equal
(
result
[
1
].
action
.
properties
,
customProperties
);
assert
.
equal
(
result
[
2
].
id
,
'
custom-experiment-no-properties
'
);
assert
.
equal
(
!!
result
[
2
].
action
.
properties
,
true
);
});
const
prompt
=
testObject
.
getExperimentsByType
(
ExperimentActionType
.
Prompt
).
then
(
result
=>
{
assert
.
equal
(
result
.
length
,
2
);
...
...
src/vs/workbench/parts/extensions/electron-browser/extensionsViews.ts
浏览文件 @
2eb78b54
...
...
@@ -39,7 +39,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
import
{
ViewletPanel
,
IViewletPanelOptions
}
from
'
vs/workbench/browser/parts/views/panelViewlet
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
distinct
}
from
'
vs/base/common/arrays
'
;
import
{
IExperimentService
}
from
'
vs/workbench/parts/experiments/node/experimentService
'
;
import
{
IExperimentService
,
IExperiment
,
ExperimentActionType
}
from
'
vs/workbench/parts/experiments/node/experimentService
'
;
export
class
ExtensionsListView
extends
ViewletPanel
{
...
...
@@ -48,6 +48,7 @@ export class ExtensionsListView extends ViewletPanel {
private
badge
:
CountBadge
;
protected
badgeContainer
:
HTMLElement
;
private
list
:
WorkbenchPagedList
<
IExtension
>
;
private
searchExperiments
:
IExperiment
[]
=
[];
constructor
(
private
options
:
IViewletViewOptions
,
...
...
@@ -67,6 +68,7 @@ export class ExtensionsListView extends ViewletPanel {
@
IExperimentService
private
experimentService
:
IExperimentService
)
{
super
({
...(
options
as
IViewletPanelOptions
),
ariaHeaderLabel
:
options
.
title
},
keybindingService
,
contextMenuService
,
configurationService
);
this
.
experimentService
.
getExperimentsByType
(
ExperimentActionType
.
ExtensionSearchResults
).
then
(
result
=>
this
.
searchExperiments
=
result
);
}
protected
renderHeader
(
container
:
HTMLElement
):
void
{
...
...
@@ -361,7 +363,29 @@ export class ExtensionsListView extends ViewletPanel {
options
.
source
=
'
viewlet
'
;
}
return
this
.
extensionsWorkbenchService
.
queryGallery
(
options
).
then
(
pager
=>
new
PagedModel
(
pager
));
const
pager
=
await
this
.
extensionsWorkbenchService
.
queryGallery
(
options
);
this
.
searchExperiments
.
forEach
(
experiment
=>
{
if
(
text
&&
text
.
toLowerCase
()
===
experiment
.
action
.
properties
[
'
searchText
'
]
&&
Array
.
isArray
(
experiment
.
action
.
properties
[
'
preferredResults
'
]))
{
const
preferredResults
:
string
[]
=
experiment
.
action
.
properties
[
'
preferredResults
'
];
let
positionToUpdate
=
0
;
for
(
let
i
=
0
;
i
<
preferredResults
.
length
;
i
++
)
{
for
(
let
j
=
positionToUpdate
;
j
<
pager
.
firstPage
.
length
;
j
++
)
{
if
(
pager
.
firstPage
[
j
].
id
===
preferredResults
[
i
])
{
if
(
positionToUpdate
!==
j
)
{
const
preferredExtension
=
pager
.
firstPage
.
splice
(
j
,
1
)[
0
];
pager
.
firstPage
.
splice
(
positionToUpdate
,
0
,
preferredExtension
);
positionToUpdate
++
;
}
break
;
}
}
}
}
});
return
new
PagedModel
(
pager
);
}
private
sortExtensions
(
extensions
:
IExtension
[],
options
:
IQueryOptions
):
IExtension
[]
{
...
...
src/vs/workbench/parts/extensions/test/electron-browser/extensionsViews.test.ts
浏览文件 @
2eb78b54
...
...
@@ -38,7 +38,7 @@ import { URI } from 'vs/base/common/uri';
import
{
SingleServerExtensionManagementServerService
}
from
'
vs/workbench/services/extensions/node/extensionManagementServerService
'
;
import
{
TestConfigurationService
}
from
'
vs/platform/configuration/test/common/testConfigurationService
'
;
import
{
SinonStub
}
from
'
sinon
'
;
import
{
IExperimentService
,
ExperimentService
}
from
'
vs/workbench/parts/experiments/node/experimentService
'
;
import
{
IExperimentService
,
ExperimentService
,
ExperimentState
,
ExperimentActionType
}
from
'
vs/workbench/parts/experiments/node/experimentService
'
;
suite
(
'
ExtensionsListView Tests
'
,
()
=>
{
...
...
@@ -118,6 +118,7 @@ suite('ExtensionsListView Tests', () => {
instantiationService
.
stubPromise
(
IExtensionManagementService
,
'
getInstalled
'
,
[
localEnabledTheme
,
localEnabledLanguage
,
localRandom
,
localDisabledTheme
,
localDisabledLanguage
,
builtInTheme
,
builtInBasic
]);
instantiationService
.
stubPromise
(
IExtensionManagementService
,
'
getExtensionsReport
'
,
[]);
instantiationService
.
stubPromise
(
IExtensionGalleryService
,
'
query
'
,
aPage
());
instantiationService
.
stubPromise
(
IExperimentService
,
'
getExperimentsByType
'
,
[]);
instantiationService
.
stub
(
IExtensionService
,
{
getExtensions
:
()
=>
{
...
...
@@ -373,6 +374,76 @@ suite('ExtensionsListView Tests', () => {
});
});
test
(
'
Test search
'
,
()
=>
{
const
searchText
=
'
search-me
'
;
const
results
=
[
fileBasedRecommendationA
,
workspaceRecommendationA
,
otherRecommendationA
,
workspaceRecommendationB
];
const
queryTarget
=
<
SinonStub
>
instantiationService
.
stubPromise
(
IExtensionGalleryService
,
'
query
'
,
aPage
(...
results
));
return
testableView
.
show
(
'
search-me
'
).
then
(
result
=>
{
const
options
:
IQueryOptions
=
queryTarget
.
args
[
0
][
0
];
assert
.
ok
(
queryTarget
.
calledOnce
);
assert
.
equal
(
options
.
text
,
searchText
);
assert
.
equal
(
result
.
length
,
results
.
length
);
for
(
let
i
=
0
;
i
<
results
.
length
;
i
++
)
{
assert
.
equal
(
result
.
get
(
i
).
id
,
results
[
i
].
identifier
.
id
);
}
});
});
test
(
'
Test preferred search experiment
'
,
()
=>
{
const
searchText
=
'
search-me
'
;
const
realResults
=
[
fileBasedRecommendationA
,
workspaceRecommendationA
,
otherRecommendationA
,
workspaceRecommendationB
];
const
preferredResults
=
[
workspaceRecommendationA
,
workspaceRecommendationB
,
fileBasedRecommendationA
,
otherRecommendationA
];
const
queryTarget
=
<
SinonStub
>
instantiationService
.
stubPromise
(
IExtensionGalleryService
,
'
query
'
,
aPage
(...
realResults
));
const
experimentTarget
=
<
SinonStub
>
instantiationService
.
stubPromise
(
IExperimentService
,
'
getExperimentsByType
'
,
[{
id
:
'
someId
'
,
enabled
:
true
,
state
:
ExperimentState
.
Run
,
action
:
{
type
:
ExperimentActionType
.
ExtensionSearchResults
,
properties
:
{
searchText
:
'
search-me
'
,
preferredResults
:
[
workspaceRecommendationA
.
identifier
.
id
,
'
something-that-wasnt-in-first-page
'
,
workspaceRecommendationB
.
identifier
.
id
]
}
}
}]);
testableView
.
dispose
();
testableView
=
instantiationService
.
createInstance
(
ExtensionsListView
,
{});
return
testableView
.
show
(
'
search-me
'
).
then
(
result
=>
{
const
options
:
IQueryOptions
=
queryTarget
.
args
[
0
][
0
];
assert
.
ok
(
experimentTarget
.
calledOnce
);
assert
.
ok
(
queryTarget
.
calledOnce
);
assert
.
equal
(
options
.
text
,
searchText
);
assert
.
equal
(
result
.
length
,
preferredResults
.
length
);
for
(
let
i
=
0
;
i
<
preferredResults
.
length
;
i
++
)
{
assert
.
equal
(
result
.
get
(
i
).
id
,
preferredResults
[
i
].
identifier
.
id
);
}
});
});
function
aLocalExtension
(
name
:
string
=
'
someext
'
,
manifest
:
any
=
{},
properties
:
any
=
{},
type
:
LocalExtensionType
=
LocalExtensionType
.
User
):
ILocalExtension
{
const
localExtension
=
<
ILocalExtension
>
Object
.
create
({
manifest
:
{}
});
assign
(
localExtension
,
{
type
,
manifest
:
{},
location
:
URI
.
file
(
`pub.
${
name
}
`
)
},
properties
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录