Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
6bd9a98c
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,发现更多精彩内容 >>
提交
6bd9a98c
编写于
2月 04, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
setting 'extensions.showTips' with bells and whistles, nicer eventing in config service
上级
c169d6b0
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
70 addition
and
16 deletion
+70
-16
src/vs/platform/configuration/common/configuration.ts
src/vs/platform/configuration/common/configuration.ts
+7
-1
src/vs/platform/configuration/common/configurationService.ts
src/vs/platform/configuration/common/configurationService.ts
+9
-0
src/vs/workbench/parts/extensions/electron-browser/extensionTipsService.ts
...parts/extensions/electron-browser/extensionTipsService.ts
+28
-14
src/vs/workbench/parts/extensions/electron-browser/extensions.contribution.ts
...ts/extensions/electron-browser/extensions.contribution.ts
+16
-1
src/vs/workbench/parts/extensions/electron-browser/extensionsWidgets.ts
...ch/parts/extensions/electron-browser/extensionsWidgets.ts
+6
-0
src/vs/workbench/test/browser/servicesTestUtils.ts
src/vs/workbench/test/browser/servicesTestUtils.ts
+4
-0
未找到文件。
src/vs/platform/configuration/common/configuration.ts
浏览文件 @
6bd9a98c
...
...
@@ -5,6 +5,7 @@
import
{
createDecorator
,
ServiceIdentifier
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IEventEmitter
}
from
'
vs/base/common/eventEmitter
'
;
import
Event
from
'
vs/base/common/event
'
;
import
winjs
=
require
(
'
vs/base/common/winjs.base
'
);
export
var
IConfigurationService
=
createDecorator
<
IConfigurationService
>
(
'
configurationService
'
);
...
...
@@ -21,7 +22,12 @@ export interface IConfigurationService extends IEventEmitter {
/**
* Returns iff the workspace has configuration or not.
*/
hasWorkspaceConfiguration
():
boolean
;
hasWorkspaceConfiguration
():
boolean
;
/**
* Event that fires when the configuration changes.
*/
onDidUpdateConfiguration
:
Event
<
{
config
:
any
}
>
}
export
class
ConfigurationServiceEventTypes
{
...
...
src/vs/platform/configuration/common/configurationService.ts
浏览文件 @
6bd9a98c
...
...
@@ -19,6 +19,7 @@ import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import
Files
=
require
(
'
vs/platform/files/common/files
'
);
import
{
IConfigurationRegistry
,
Extensions
}
from
'
./configurationRegistry
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
Event
,
{
fromEventEmitter
}
from
'
vs/base/common/event
'
;
// ---- service abstract implementation
...
...
@@ -43,6 +44,8 @@ interface ILoadConfigResult {
export
abstract
class
ConfigurationService
extends
eventEmitter
.
EventEmitter
implements
IConfigurationService
,
lifecycle
.
IDisposable
{
public
serviceId
=
IConfigurationService
;
public
onDidUpdateConfiguration
:
Event
<
{
config
:
any
}
>
;
protected
contextService
:
IWorkspaceContextService
;
protected
eventService
:
IEventService
;
protected
workspaceSettingsRootFolder
:
string
;
...
...
@@ -67,6 +70,8 @@ export abstract class ConfigurationService extends eventEmitter.EventEmitter imp
unbind
();
subscription
.
dispose
();
}
this
.
onDidUpdateConfiguration
=
fromEventEmitter
(
this
,
ConfigurationServiceEventTypes
.
UPDATED
);
}
protected
abstract
resolveContents
(
resource
:
uri
[]):
winjs
.
TPromise
<
IContent
[]
>
;
...
...
@@ -229,6 +234,10 @@ export class NullConfigurationService extends eventEmitter.EventEmitter implemen
public
hasWorkspaceConfiguration
():
boolean
{
return
false
;
}
public
onDidUpdateConfiguration
()
{
return
{
dispose
()
{
}
};
}
}
export
var
nullService
=
new
NullConfigurationService
();
src/vs/workbench/parts/extensions/electron-browser/extensionTipsService.ts
浏览文件 @
6bd9a98c
...
...
@@ -75,7 +75,7 @@ export class ExtensionTipsService implements IExtensionTipsService {
private
_onDidChangeTips
:
Emitter
<
IExtension
[]
>
=
new
Emitter
<
IExtension
[]
>
();
private
_tips
:
{
[
id
:
string
]:
ExtensionTip
}
=
Object
.
create
(
null
);
private
_
toDispos
e
:
IDisposable
[]
=
[];
private
_
disposeOnUpdat
e
:
IDisposable
[]
=
[];
private
_availableExtensions
:
Promise
<
ExtensionMap
>
;
private
_extensionData
:
Promise
<
ExtensionData
>
;
...
...
@@ -83,18 +83,13 @@ export class ExtensionTipsService implements IExtensionTipsService {
@
IExtensionsService
private
_extensionService
:
IExtensionsService
,
@
IGalleryService
private
_galleryService
:
IGalleryService
,
@
IModelService
private
_modelService
:
IModelService
,
@
IConfigurationService
configurationService
:
IConfigurationService
@
IConfigurationService
private
_
configurationService
:
IConfigurationService
)
{
configurationService
.
loadConfiguration
(
'
extensions
'
).
then
(
value
=>
{
if
(
value
&&
value
.
experimentalSuggestions
===
true
)
{
this
.
_init
();
}
},
onUnexpectedError
);
this
.
_updateState
();
}
dispose
()
{
this
.
_
toDispose
=
disposeAll
(
this
.
_toDispos
e
);
this
.
_
disposeOnUpdate
=
disposeAll
(
this
.
_disposeOnUpdat
e
);
}
get
onDidChangeTips
():
Event
<
IExtension
[]
>
{
...
...
@@ -107,7 +102,26 @@ export class ExtensionTipsService implements IExtensionTipsService {
return
tips
.
map
(
tip
=>
tip
.
extension
);
}
private
_init
()
{
// --- internals
private
_updateState
():
void
{
// check with configuration service and then GO
this
.
_disposeOnUpdate
=
disposeAll
(
this
.
_disposeOnUpdate
);
this
.
_tips
=
Object
.
create
(
null
);
this
.
_onDidChangeTips
.
fire
(
this
.
tips
);
this
.
_configurationService
.
loadConfiguration
(
'
extensions
'
).
then
(
value
=>
{
if
(
value
&&
value
.
showTips
===
true
)
{
this
.
_init
();
}
},
onUnexpectedError
);
// listen for config changes
this
.
_configurationService
.
onDidUpdateConfiguration
(
this
.
_updateState
,
this
,
this
.
_disposeOnUpdate
);
}
private
_init
():
void
{
if
(
!
this
.
_galleryService
.
isEnabled
())
{
return
;
...
...
@@ -122,7 +136,7 @@ export class ExtensionTipsService implements IExtensionTipsService {
this
.
_availableExtensions
=
this
.
_getAvailableExtensions
();
// don't suggest what got installed
this
.
_
toDispos
e
.
push
(
this
.
_extensionService
.
onDidInstallExtension
(
ext
=>
{
this
.
_
disposeOnUpdat
e
.
push
(
this
.
_extensionService
.
onDidInstallExtension
(
ext
=>
{
const
id
=
`
${
ext
.
publisher
}
.
${
ext
.
name
}
`
;
let
change
=
false
;
if
(
delete
this
.
_tips
[
id
])
{
...
...
@@ -139,16 +153,16 @@ export class ExtensionTipsService implements IExtensionTipsService {
// such that files you type have bigger impact on the suggest
// order than those you only look at
const
modelListener
:
{
[
uri
:
string
]:
IDisposable
}
=
Object
.
create
(
null
);
this
.
_
toDispos
e
.
push
({
dispose
()
{
disposeAll
(
values
(
modelListener
))
}
});
this
.
_
disposeOnUpdat
e
.
push
({
dispose
()
{
disposeAll
(
values
(
modelListener
))
}
});
this
.
_
toDispos
e
.
push
(
this
.
_modelService
.
onModelAdded
(
model
=>
{
this
.
_
disposeOnUpdat
e
.
push
(
this
.
_modelService
.
onModelAdded
(
model
=>
{
const
uri
=
model
.
getAssociatedResource
();
this
.
_suggestByResource
(
uri
,
ExtensionTipReasons
.
FileOpened
);
modelListener
[
uri
.
toString
()]
=
model
.
addListener2
(
EventType
.
ModelContentChanged2
,
()
=>
this
.
_suggestByResource
(
uri
,
ExtensionTipReasons
.
FileEdited
));
}));
this
.
_
toDispos
e
.
push
(
this
.
_modelService
.
onModelRemoved
(
model
=>
{
this
.
_
disposeOnUpdat
e
.
push
(
this
.
_modelService
.
onModelRemoved
(
model
=>
{
const
subscription
=
modelListener
[
model
.
getAssociatedResource
().
toString
()];
if
(
subscription
)
{
subscription
.
dispose
();
...
...
src/vs/workbench/parts/extensions/electron-browser/extensions.contribution.ts
浏览文件 @
6bd9a98c
...
...
@@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
nls
=
require
(
'
vs/nls
'
);
import
platform
=
require
(
'
vs/platform/platform
'
);
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
statusbar
=
require
(
'
vs/workbench/browser/parts/statusbar/statusbar
'
);
...
...
@@ -11,6 +12,7 @@ import { IGalleryService } from 'vs/workbench/parts/extensions/common/extensions
import
{
GalleryService
}
from
'
vs/workbench/parts/extensions/node/vsoGalleryService
'
;
import
{
IWorkbenchContributionsRegistry
,
Extensions
as
WorkbenchExtensions
}
from
'
vs/workbench/common/contributions
'
;
import
{
ExtensionsWorkbenchExtension
}
from
'
vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchExtension
'
;
import
ConfigurationRegistry
=
require
(
'
vs/platform/configuration/common/configurationRegistry
'
);
// Register Gallery Service
registerSingleton
(
IGalleryService
,
GalleryService
);
...
...
@@ -32,4 +34,17 @@ registerSingleton(IGalleryService, GalleryService);
ExtensionTipsStatusbarItem
,
statusbar
.
StatusbarAlignment
.
LEFT
,
9
/* Low Priority */
));
\ No newline at end of file
));
(
<
ConfigurationRegistry
.
IConfigurationRegistry
>
platform
.
Registry
.
as
(
ConfigurationRegistry
.
Extensions
.
Configuration
)).
registerConfiguration
({
id
:
'
extensions
'
,
type
:
'
object
'
,
properties
:
{
'
extensions.showTips
'
:
{
type
:
'
boolean
'
,
default
:
false
,
description
:
nls
.
localize
(
'
extConfig
'
,
"
Suggest extensions based on changed and open files.
"
),
}
}
});
src/vs/workbench/parts/extensions/electron-browser/extensionsWidgets.ts
浏览文件 @
6bd9a98c
...
...
@@ -97,6 +97,12 @@ export class ExtensionTipsStatusbarItem implements statusbar.IStatusbarItem {
)
{
this
.
_extensionTipsService
.
onDidChangeTips
(
tips
=>
{
if
(
tips
.
length
===
0
)
{
dom
.
removeClass
(
this
.
_domNode
,
'
active
'
);
return
;
}
// check for new tips
let
hasNewTips
=
false
;
for
(
let
tip
of
tips
)
{
...
...
src/vs/workbench/test/browser/servicesTestUtils.ts
浏览文件 @
6bd9a98c
...
...
@@ -514,4 +514,8 @@ export class TestConfigurationService extends EventEmitter.EventEmitter implemen
public
hasWorkspaceConfiguration
():
boolean
{
return
false
;
}
public
onDidUpdateConfiguration
()
{
return
{
dispose
()
{
}
};
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录