Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
55c48a96
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
未验证
提交
55c48a96
编写于
7月 12, 2019
作者:
M
Matt Bierner
提交者:
GitHub
7月 12, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #77153 from mjbvz/extensions-idisposable-refactoring
Avoid using untracked IDisposables in workbench/contrib/extensions
上级
0041b0f1
42780334
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
32 addition
and
70 deletion
+32
-70
src/vs/workbench/contrib/extensions/electron-browser/extensionProfileService.ts
...ib/extensions/electron-browser/extensionProfileService.ts
+4
-7
src/vs/workbench/contrib/extensions/electron-browser/extensionTipsService.ts
...ntrib/extensions/electron-browser/extensionTipsService.ts
+2
-7
src/vs/workbench/contrib/extensions/electron-browser/extensionsViewlet.ts
.../contrib/extensions/electron-browser/extensionsViewlet.ts
+17
-37
src/vs/workbench/contrib/extensions/electron-browser/extensionsWidgets.ts
.../contrib/extensions/electron-browser/extensionsWidgets.ts
+9
-19
未找到文件。
src/vs/workbench/contrib/extensions/electron-browser/extensionProfileService.ts
浏览文件 @
55c48a96
...
...
@@ -7,7 +7,7 @@ import * as nls from 'vs/nls';
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IInstantiationService
,
ServiceIdentifier
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IExtensionHostProfile
,
ProfileSession
,
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
Disposable
,
IDisposable
,
to
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
,
toDisposable
,
Mutable
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
StatusbarAlignment
,
IStatusbarService
,
IStatusbarEntryAccessor
,
IStatusbarEntry
}
from
'
vs/platform/statusbar/common/statusbar
'
;
import
{
IExtensionHostProfileService
,
ProfileSessionState
}
from
'
vs/workbench/contrib/extensions/electron-browser/runtimeExtensionsEditor
'
;
...
...
@@ -37,7 +37,7 @@ export class ExtensionHostProfileService extends Disposable implements IExtensio
private
_state
:
ProfileSessionState
;
private
profilingStatusBarIndicator
:
IStatusbarEntryAccessor
|
undefined
;
private
profilingStatusBarIndicatorLabelUpdater
:
IDisposable
|
undefined
;
private
readonly
profilingStatusBarIndicatorLabelUpdater
=
this
.
_register
(
new
MutableDisposable
())
;
public
get
state
()
{
return
this
.
_state
;
}
public
get
lastProfile
()
{
return
this
.
_profile
;
}
...
...
@@ -77,10 +77,7 @@ export class ExtensionHostProfileService extends Disposable implements IExtensio
}
private
updateProfilingStatusBarIndicator
(
visible
:
boolean
):
void
{
if
(
this
.
profilingStatusBarIndicatorLabelUpdater
)
{
this
.
profilingStatusBarIndicatorLabelUpdater
.
dispose
();
this
.
profilingStatusBarIndicatorLabelUpdater
=
undefined
;
}
this
.
profilingStatusBarIndicatorLabelUpdater
.
clear
();
if
(
visible
)
{
const
indicator
:
IStatusbarEntry
=
{
...
...
@@ -95,7 +92,7 @@ export class ExtensionHostProfileService extends Disposable implements IExtensio
this
.
profilingStatusBarIndicator
.
update
({
...
indicator
,
text
:
nls
.
localize
(
'
profilingExtensionHostTime
'
,
"
$(sync~spin) Profiling Extension Host ({0} sec)
"
,
Math
.
round
((
new
Date
().
getTime
()
-
timeStarted
)
/
1000
)),
});
}
},
1000
);
this
.
profilingStatusBarIndicatorLabelUpdater
=
toDisposable
(()
=>
clearInterval
(
handle
));
this
.
profilingStatusBarIndicatorLabelUpdater
.
value
=
toDisposable
(()
=>
clearInterval
(
handle
));
if
(
!
this
.
profilingStatusBarIndicator
)
{
this
.
profilingStatusBarIndicator
=
this
.
_statusbarService
.
addEntry
(
indicator
,
'
status.profiler
'
,
nls
.
localize
(
'
status.profiler
'
,
"
Extension Profiler
"
),
StatusbarAlignment
.
RIGHT
);
...
...
src/vs/workbench/contrib/extensions/electron-browser/extensionTipsService.ts
浏览文件 @
55c48a96
...
...
@@ -6,7 +6,7 @@
import
{
localize
}
from
'
vs/nls
'
;
import
{
join
}
from
'
vs/base/common/path
'
;
import
{
forEach
}
from
'
vs/base/common/collections
'
;
import
{
IDisposable
,
dispose
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
match
}
from
'
vs/base/common/glob
'
;
import
*
as
json
from
'
vs/base/common/json
'
;
import
{
...
...
@@ -82,7 +82,6 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
private
_globallyIgnoredRecommendations
:
string
[]
=
[];
private
_workspaceIgnoredRecommendations
:
string
[]
=
[];
private
_extensionsRecommendationsUrl
:
string
;
private
_disposables
:
IDisposable
[]
=
[];
public
loadWorkspaceConfigPromise
:
Promise
<
void
>
;
private
proactiveRecommendationsFetched
:
boolean
=
false
;
...
...
@@ -134,7 +133,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
this
.
loadWorkspaceConfigPromise
=
this
.
getWorkspaceRecommendations
().
then
(()
=>
{
this
.
promptWorkspaceRecommendations
();
this
.
_
modelService
.
onModelAdded
(
this
.
promptFiletypeBasedRecommendations
,
this
,
this
.
_disposables
);
this
.
_
register
(
this
.
_modelService
.
onModelAdded
(
this
.
promptFiletypeBasedRecommendations
,
this
)
);
this
.
_modelService
.
getModels
().
forEach
(
model
=>
this
.
promptFiletypeBasedRecommendations
(
model
));
});
...
...
@@ -1034,8 +1033,4 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
private
isExtensionAllowedToBeRecommended
(
id
:
string
):
boolean
{
return
this
.
_allIgnoredRecommendations
.
indexOf
(
id
.
toLowerCase
())
===
-
1
;
}
dispose
()
{
this
.
_disposables
=
dispose
(
this
.
_disposables
);
}
}
src/vs/workbench/contrib/extensions/electron-browser/extensionsViewlet.ts
浏览文件 @
55c48a96
...
...
@@ -8,7 +8,7 @@ import { localize } from 'vs/nls';
import
{
timeout
,
Delayer
}
from
'
vs/base/common/async
'
;
import
{
isPromiseCanceledError
}
from
'
vs/base/common/errors
'
;
import
{
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
{
IDisposable
,
dispos
e
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
,
MutableDisposabl
e
}
from
'
vs/base/common/lifecycle
'
;
import
{
Event
as
EventOf
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IAction
}
from
'
vs/base/common/actions
'
;
import
{
Separator
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
...
...
@@ -339,7 +339,6 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
private
extensionsBox
:
HTMLElement
;
private
primaryActions
:
IAction
[];
private
secondaryActions
:
IAction
[]
|
null
;
private
disposables
:
IDisposable
[]
=
[];
private
readonly
searchViewletState
:
MementoObject
;
constructor
(
...
...
@@ -374,14 +373,14 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
this
.
recommendedExtensionsContextKey
=
RecommendedExtensionsContext
.
bindTo
(
contextKeyService
);
this
.
defaultRecommendedExtensionsContextKey
=
DefaultRecommendedExtensionsContext
.
bindTo
(
contextKeyService
);
this
.
defaultRecommendedExtensionsContextKey
.
set
(
!
this
.
configurationService
.
getValue
<
boolean
>
(
ShowRecommendationsOnlyOnDemandKey
));
this
.
disposables
.
push
(
this
.
viewletService
.
onDidViewletOpen
(
this
.
onViewletOpen
,
this
,
this
.
disposable
s
));
this
.
_register
(
this
.
viewletService
.
onDidViewletOpen
(
this
.
onViewletOpen
,
thi
s
));
this
.
searchViewletState
=
this
.
getMemento
(
StorageScope
.
WORKSPACE
);
this
.
extensionManagementService
.
getInstalled
(
ExtensionType
.
User
).
then
(
result
=>
{
this
.
hasInstalledExtensionsContextKey
.
set
(
result
.
length
>
0
);
});
this
.
configurationService
.
onDidChangeConfiguration
(
e
=>
{
this
.
_register
(
this
.
configurationService
.
onDidChangeConfiguration
(
e
=>
{
if
(
e
.
affectsConfiguration
(
AutoUpdateConfigurationKey
))
{
this
.
secondaryActions
=
null
;
this
.
updateTitleArea
();
...
...
@@ -389,7 +388,7 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
if
(
e
.
affectedKeys
.
indexOf
(
ShowRecommendationsOnlyOnDemandKey
)
>
-
1
)
{
this
.
defaultRecommendedExtensionsContextKey
.
set
(
!
this
.
configurationService
.
getValue
<
boolean
>
(
ShowRecommendationsOnlyOnDemandKey
));
}
},
this
,
this
.
disposables
);
},
this
)
);
}
create
(
parent
:
HTMLElement
):
void
{
...
...
@@ -401,7 +400,7 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
const
placeholder
=
localize
(
'
searchExtensions
'
,
"
Search Extensions in Marketplace
"
);
const
searchValue
=
this
.
searchViewletState
[
'
query.value
'
]
?
this
.
searchViewletState
[
'
query.value
'
]
:
''
;
this
.
searchBox
=
this
.
instantiationService
.
createInstance
(
SuggestEnabledInput
,
`
${
VIEWLET_ID
}
.searchbox`
,
header
,
{
this
.
searchBox
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
SuggestEnabledInput
,
`
${
VIEWLET_ID
}
.searchbox`
,
header
,
{
triggerCharacters
:
[
'
@
'
],
sortKey
:
(
item
:
string
)
=>
{
if
(
item
.
indexOf
(
'
:
'
)
===
-
1
)
{
return
'
a
'
;
}
...
...
@@ -410,24 +409,22 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
else
{
return
'
d
'
;
}
},
provideResults
:
(
query
:
string
)
=>
Query
.
suggestions
(
query
)
},
placeholder
,
'
extensions:searchinput
'
,
{
placeholderText
:
placeholder
,
value
:
searchValue
});
},
placeholder
,
'
extensions:searchinput
'
,
{
placeholderText
:
placeholder
,
value
:
searchValue
})
)
;
if
(
this
.
searchBox
.
getValue
())
{
this
.
triggerSearch
();
}
this
.
disposables
.
push
(
attachSuggestEnabledInputBoxStyler
(
this
.
searchBox
,
this
.
themeService
));
this
.
disposables
.
push
(
this
.
searchBox
);
this
.
_register
(
attachSuggestEnabledInputBoxStyler
(
this
.
searchBox
,
this
.
themeService
));
const
_searchChange
=
new
Emitter
<
string
>
();
this
.
onSearchChange
=
_searchChange
.
event
;
this
.
searchBox
.
onInputDidChange
(()
=>
{
this
.
_register
(
this
.
searchBox
.
onInputDidChange
(()
=>
{
this
.
triggerSearch
();
_searchChange
.
fire
(
this
.
searchBox
.
getValue
());
},
this
,
this
.
disposables
);
},
this
)
);
this
.
searchBox
.
onShouldFocusResults
(()
=>
this
.
focusListView
(),
this
,
this
.
disposables
);
this
.
_register
(
this
.
searchBox
.
onShouldFocusResults
(()
=>
this
.
focusListView
(),
this
)
);
this
.
_register
(
this
.
onDidChangeVisibility
(
visible
=>
{
if
(
visible
)
{
...
...
@@ -614,52 +611,39 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
this
.
notificationService
.
error
(
err
);
}
dispose
():
void
{
this
.
disposables
=
dispose
(
this
.
disposables
);
super
.
dispose
();
}
}
export
class
StatusUpdater
implements
IWorkbenchContribution
{
export
class
StatusUpdater
extends
Disposable
implements
IWorkbenchContribution
{
private
disposables
:
IDisposable
[];
private
badgeHandle
:
IDisposable
;
private
readonly
badgeHandle
=
this
.
_register
(
new
MutableDisposable
());
constructor
(
@
IActivityService
private
readonly
activityService
:
IActivityService
,
@
IExtensionsWorkbenchService
private
readonly
extensionsWorkbenchService
:
IExtensionsWorkbenchService
,
@
IExtensionEnablementService
private
readonly
extensionEnablementService
:
IExtensionEnablementService
)
{
extensionsWorkbenchService
.
onChange
(
this
.
onServiceChange
,
this
,
this
.
disposables
);
super
();
this
.
_register
(
extensionsWorkbenchService
.
onChange
(
this
.
onServiceChange
,
this
));
}
private
onServiceChange
():
void
{
dispose
(
this
.
badgeHandle
);
this
.
badgeHandle
.
clear
();
if
(
this
.
extensionsWorkbenchService
.
local
.
some
(
e
=>
e
.
state
===
ExtensionState
.
Installing
))
{
this
.
badgeHandle
=
this
.
activityService
.
showActivity
(
VIEWLET_ID
,
new
ProgressBadge
(()
=>
localize
(
'
extensions
'
,
"
Extensions
"
)),
'
extensions-badge progress-badge
'
);
this
.
badgeHandle
.
value
=
this
.
activityService
.
showActivity
(
VIEWLET_ID
,
new
ProgressBadge
(()
=>
localize
(
'
extensions
'
,
"
Extensions
"
)),
'
extensions-badge progress-badge
'
);
return
;
}
const
outdated
=
this
.
extensionsWorkbenchService
.
outdated
.
reduce
((
r
,
e
)
=>
r
+
(
this
.
extensionEnablementService
.
isEnabled
(
e
.
local
!
)
?
1
:
0
),
0
);
if
(
outdated
>
0
)
{
const
badge
=
new
NumberBadge
(
outdated
,
n
=>
localize
(
'
outdatedExtensions
'
,
'
{0} Outdated Extensions
'
,
n
));
this
.
badgeHandle
=
this
.
activityService
.
showActivity
(
VIEWLET_ID
,
badge
,
'
extensions-badge count-badge
'
);
this
.
badgeHandle
.
value
=
this
.
activityService
.
showActivity
(
VIEWLET_ID
,
badge
,
'
extensions-badge count-badge
'
);
}
}
dispose
():
void
{
this
.
disposables
=
dispose
(
this
.
disposables
);
dispose
(
this
.
badgeHandle
);
}
}
export
class
MaliciousExtensionChecker
implements
IWorkbenchContribution
{
private
disposables
:
IDisposable
[];
constructor
(
@
IExtensionManagementService
private
readonly
extensionsManagementService
:
IExtensionManagementService
,
@
IWindowService
private
readonly
windowService
:
IWindowService
,
...
...
@@ -704,8 +688,4 @@ export class MaliciousExtensionChecker implements IWorkbenchContribution {
}).
then
(()
=>
undefined
);
},
err
=>
this
.
logService
.
error
(
err
));
}
dispose
():
void
{
this
.
disposables
=
dispose
(
this
.
disposables
);
}
}
src/vs/workbench/contrib/extensions/electron-browser/extensionsWidgets.ts
浏览文件 @
55c48a96
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
'
vs/css!./media/extensionsWidgets
'
;
import
{
Disposable
,
IDisposable
,
dispose
,
to
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
,
toDisposable
,
DisposableStore
,
Mutable
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IExtension
,
IExtensionsWorkbenchService
,
IExtensionContainer
,
ExtensionState
}
from
'
../common/extensions
'
;
import
{
append
,
$
,
addClass
}
from
'
vs/base/browser/dom
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
...
...
@@ -196,7 +196,7 @@ export class TooltipWidget extends ExtensionWidget {
export
class
RecommendationWidget
extends
ExtensionWidget
{
private
element
?:
HTMLElement
;
private
disposables
:
IDisposable
[]
=
[]
;
private
readonly
disposables
=
this
.
_register
(
new
DisposableStore
())
;
private
_tooltip
:
string
;
get
tooltip
():
string
{
return
this
.
_tooltip
;
}
...
...
@@ -227,7 +227,7 @@ export class RecommendationWidget extends ExtensionWidget {
this
.
parent
.
removeChild
(
this
.
element
);
}
this
.
element
=
undefined
;
this
.
disposables
=
dispose
(
this
.
disposables
);
this
.
disposables
.
clear
(
);
}
render
():
void
{
...
...
@@ -256,8 +256,7 @@ export class RecommendationWidget extends ExtensionWidget {
export
class
RemoteBadgeWidget
extends
ExtensionWidget
{
private
remoteBadge
:
RemoteBadge
|
null
;
private
disposables
:
IDisposable
[]
=
[];
private
readonly
remoteBadge
=
this
.
_register
(
new
MutableDisposable
<
RemoteBadge
>
());
private
element
:
HTMLElement
;
...
...
@@ -274,12 +273,10 @@ export class RemoteBadgeWidget extends ExtensionWidget {
}
private
clear
():
void
{
if
(
this
.
remoteBadge
)
{
this
.
element
.
removeChild
(
this
.
remoteBadge
.
element
);
this
.
remoteBadge
.
dispose
();
if
(
this
.
remoteBadge
.
value
)
{
this
.
element
.
removeChild
(
this
.
remoteBadge
.
value
.
element
);
}
this
.
remoteBadge
=
null
;
this
.
disposables
=
dispose
(
this
.
disposables
);
this
.
remoteBadge
.
clear
();
}
render
():
void
{
...
...
@@ -288,17 +285,10 @@ export class RemoteBadgeWidget extends ExtensionWidget {
return
;
}
if
(
this
.
extension
.
server
===
this
.
extensionManagementServerService
.
remoteExtensionManagementServer
)
{
this
.
remoteBadge
=
this
.
instantiationService
.
createInstance
(
RemoteBadge
,
this
.
tooltip
);
append
(
this
.
element
,
this
.
remoteBadge
.
element
);
this
.
remoteBadge
.
value
=
this
.
instantiationService
.
createInstance
(
RemoteBadge
,
this
.
tooltip
);
append
(
this
.
element
,
this
.
remoteBadge
.
value
.
element
);
}
}
dispose
():
void
{
if
(
this
.
remoteBadge
)
{
this
.
remoteBadge
.
dispose
();
}
super
.
dispose
();
}
}
class
RemoteBadge
extends
Disposable
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录