Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a6885b48
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,发现更多精彩内容 >>
提交
a6885b48
编写于
7月 19, 2018
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use toDisposable in more places in workbench and platform
上级
ad7cbfda
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
53 addition
and
69 deletion
+53
-69
src/vs/platform/commands/common/commands.ts
src/vs/platform/commands/common/commands.ts
+6
-8
src/vs/platform/theme/common/themeService.ts
src/vs/platform/theme/common/themeService.ts
+5
-7
src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts
...vs/workbench/api/electron-browser/mainThreadFileSystem.ts
+4
-6
src/vs/workbench/api/node/extHostFileSystem.ts
src/vs/workbench/api/node/extHostFileSystem.ts
+8
-10
src/vs/workbench/api/node/extHostSearch.ts
src/vs/workbench/api/node/extHostSearch.ts
+5
-6
src/vs/workbench/parts/outline/electron-browser/outlinePanel.ts
.../workbench/parts/outline/electron-browser/outlinePanel.ts
+2
-4
src/vs/workbench/parts/snippets/electron-browser/snippetsService.ts
...kbench/parts/snippets/electron-browser/snippetsService.ts
+6
-8
src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts
...rkbench/parts/tasks/electron-browser/task.contribution.ts
+4
-6
src/vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughPart.ts
...s/welcome/walkThrough/electron-browser/walkThroughPart.ts
+2
-2
src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts
...est/electron-browser/configurationResolverService.test.ts
+2
-1
src/vs/workbench/services/search/node/searchService.ts
src/vs/workbench/services/search/node/searchService.ts
+9
-11
未找到文件。
src/vs/platform/commands/common/commands.ts
浏览文件 @
a6885b48
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
TypeConstraint
,
validateConstraints
}
from
'
vs/base/common/types
'
;
import
{
ServicesAccessor
,
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
...
...
@@ -91,14 +91,12 @@ export const CommandsRegistry: ICommandRegistry = new class implements ICommandR
let
removeFn
=
commands
.
unshift
(
idOrCommand
);
return
{
dispose
:
()
=>
{
removeFn
();
if
(
this
.
_commands
.
get
(
id
).
isEmpty
())
{
this
.
_commands
.
delete
(
id
);
}
return
toDisposable
(()
=>
{
removeFn
();
if
(
this
.
_commands
.
get
(
id
).
isEmpty
())
{
this
.
_commands
.
delete
(
id
);
}
};
}
)
;
}
getCommand
(
id
:
string
):
ICommand
{
...
...
src/vs/platform/theme/common/themeService.ts
浏览文件 @
a6885b48
...
...
@@ -6,7 +6,7 @@
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
platform
from
'
vs/platform/registry/common/platform
'
;
import
{
ColorIdentifier
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
...
...
@@ -111,12 +111,10 @@ class ThemingRegistry implements IThemingRegistry {
public
onThemeChange
(
participant
:
IThemingParticipant
):
IDisposable
{
this
.
themingParticipants
.
push
(
participant
);
this
.
onThemingParticipantAddedEmitter
.
fire
(
participant
);
return
{
dispose
:
()
=>
{
const
idx
=
this
.
themingParticipants
.
indexOf
(
participant
);
this
.
themingParticipants
.
splice
(
idx
,
1
);
}
};
return
toDisposable
(()
=>
{
const
idx
=
this
.
themingParticipants
.
indexOf
(
participant
);
this
.
themingParticipants
.
splice
(
idx
,
1
);
});
}
public
get
onThemingParticipantAdded
():
Event
<
IThemingParticipant
>
{
...
...
src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts
浏览文件 @
a6885b48
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
FileWriteOptions
,
FileSystemProviderCapabilities
,
IFileChange
,
IFileService
,
IFileSystemProvider
,
IStat
,
IWatchOptions
,
FileType
,
FileOverwriteOptions
,
FileDeleteOptions
}
from
'
vs/platform/files/common/files
'
;
...
...
@@ -71,11 +71,9 @@ class RemoteFileSystemProvider implements IFileSystemProvider {
watch
(
resource
:
URI
,
opts
:
IWatchOptions
)
{
const
session
=
Math
.
random
();
this
.
_proxy
.
$watch
(
this
.
_handle
,
session
,
resource
,
opts
);
return
{
dispose
:
()
=>
{
this
.
_proxy
.
$unwatch
(
this
.
_handle
,
session
);
}
};
return
toDisposable
(()
=>
{
this
.
_proxy
.
$unwatch
(
this
.
_handle
,
session
);
});
}
$onFileSystemChange
(
changes
:
IFileChangeDto
[]):
void
{
...
...
src/vs/workbench/api/node/extHostFileSystem.ts
浏览文件 @
a6885b48
...
...
@@ -9,7 +9,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import
{
MainContext
,
IMainContext
,
ExtHostFileSystemShape
,
MainThreadFileSystemShape
,
IFileChangeDto
}
from
'
./extHost.protocol
'
;
import
*
as
vscode
from
'
vscode
'
;
import
*
as
files
from
'
vs/platform/files/common/files
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
{
values
}
from
'
vs/base/common/map
'
;
import
{
Range
,
FileChangeType
}
from
'
vs/workbench/api/node/extHostTypes
'
;
...
...
@@ -132,15 +132,13 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
this
.
_proxy
.
$onFileSystemChange
(
handle
,
mapped
);
});
return
{
dispose
:
()
=>
{
subscription
.
dispose
();
this
.
_linkProvider
.
delete
(
scheme
);
this
.
_usedSchemes
.
delete
(
scheme
);
this
.
_fsProvider
.
delete
(
handle
);
this
.
_proxy
.
$unregisterProvider
(
handle
);
}
};
return
toDisposable
(()
=>
{
subscription
.
dispose
();
this
.
_linkProvider
.
delete
(
scheme
);
this
.
_usedSchemes
.
delete
(
scheme
);
this
.
_fsProvider
.
delete
(
handle
);
this
.
_proxy
.
$unregisterProvider
(
handle
);
});
}
private
static
_asIStat
(
stat
:
vscode
.
FileStat
):
files
.
IStat
{
...
...
src/vs/workbench/api/node/extHostSearch.ts
浏览文件 @
a6885b48
...
...
@@ -15,6 +15,7 @@ import * as extfs from 'vs/base/node/extfs';
import
{
IFileMatch
,
IFolderQuery
,
IPatternInfo
,
IRawSearchQuery
,
ISearchCompleteStats
,
ISearchQuery
}
from
'
vs/platform/search/common/search
'
;
import
*
as
vscode
from
'
vscode
'
;
import
{
ExtHostSearchShape
,
IMainContext
,
MainContext
,
MainThreadSearchShape
}
from
'
./extHost.protocol
'
;
import
{
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
export
interface
ISchemeTransformer
{
transformOutgoing
(
scheme
:
string
):
string
;
...
...
@@ -44,12 +45,10 @@ export class ExtHostSearch implements ExtHostSearchShape {
const
handle
=
this
.
_handlePool
++
;
this
.
_searchProvider
.
set
(
handle
,
provider
);
this
.
_proxy
.
$registerSearchProvider
(
handle
,
this
.
_transformScheme
(
scheme
));
return
{
dispose
:
()
=>
{
this
.
_searchProvider
.
delete
(
handle
);
this
.
_proxy
.
$unregisterProvider
(
handle
);
}
};
return
toDisposable
(()
=>
{
this
.
_searchProvider
.
delete
(
handle
);
this
.
_proxy
.
$unregisterProvider
(
handle
);
});
}
$provideFileSearchResults
(
handle
:
number
,
session
:
number
,
rawQuery
:
IRawSearchQuery
):
TPromise
<
ISearchCompleteStats
>
{
...
...
src/vs/workbench/parts/outline/electron-browser/outlinePanel.ts
浏览文件 @
a6885b48
...
...
@@ -18,7 +18,7 @@ import { onUnexpectedError, isPromiseCanceledError } from 'vs/base/common/errors
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
defaultGenerator
}
from
'
vs/base/common/idGenerator
'
;
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
dispose
,
IDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
LRUCache
}
from
'
vs/base/common/map
'
;
import
{
escape
}
from
'
vs/base/common/strings
'
;
import
URI
from
'
vs/base/common/uri
'
;
...
...
@@ -567,9 +567,7 @@ export class OutlinePanel extends ViewletPanel {
}
this
.
_editorDisposables
.
push
(
this
.
_input
.
onDidChange
(
onInputValueChanged
));
this
.
_editorDisposables
.
push
({
dispose
:
()
=>
this
.
_contextKeyFiltered
.
reset
()
});
this
.
_editorDisposables
.
push
(
toDisposable
(()
=>
this
.
_contextKeyFiltered
.
reset
()));
// feature: reveal outline selection in editor
// on change -> reveal/select defining range
...
...
src/vs/workbench/parts/snippets/electron-browser/snippetsService.ts
浏览文件 @
a6885b48
...
...
@@ -7,7 +7,7 @@
import
{
basename
,
extname
,
join
}
from
'
path
'
;
import
{
MarkdownString
}
from
'
vs/base/common/htmlContent
'
;
import
{
IJSONSchema
}
from
'
vs/base/common/jsonSchema
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
dispose
,
IDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
values
}
from
'
vs/base/common/map
'
;
import
*
as
resources
from
'
vs/base/common/resources
'
;
import
{
compare
,
endsWith
,
isFalsyOrWhitespace
}
from
'
vs/base/common/strings
'
;
...
...
@@ -253,14 +253,12 @@ class SnippetsService implements ISnippetsService {
}
});
},
(
error
:
string
)
=>
this
.
_logService
.
error
(
error
));
this
.
_disposables
.
push
({
dispose
:
()
=>
{
if
(
watcher
)
{
watcher
.
removeAllListeners
();
watcher
.
close
();
}
this
.
_disposables
.
push
(
toDisposable
(()
=>
{
if
(
watcher
)
{
watcher
.
removeAllListeners
();
watcher
.
close
();
}
});
})
)
;
}).
then
(
undefined
,
err
=>
{
this
.
_logService
.
error
(
'
Failed to load user snippets
'
,
err
);
...
...
src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts
浏览文件 @
a6885b48
...
...
@@ -17,7 +17,7 @@ import URI from 'vs/base/common/uri';
import
{
IStringDictionary
}
from
'
vs/base/common/collections
'
;
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
*
as
Dom
from
'
vs/base/browser/dom
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
*
as
Types
from
'
vs/base/common/types
'
;
import
{
KeyMod
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
...
...
@@ -253,11 +253,9 @@ class BuildStatusBarItem extends Themable implements IStatusbarItem {
this
.
updateStyles
();
return
{
dispose
:
()
=>
{
callOnDispose
=
dispose
(
callOnDispose
);
}
};
return
toDisposable
(()
=>
{
callOnDispose
=
dispose
(
callOnDispose
);
});
}
private
ignoreEvent
(
event
:
TaskEvent
):
boolean
{
...
...
src/vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughPart.ts
浏览文件 @
a6885b48
...
...
@@ -10,7 +10,7 @@ import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableEle
import
{
ScrollbarVisibility
}
from
'
vs/base/common/scrollable
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
EditorOptions
,
IEditorMemento
}
from
'
vs/workbench/common/editor
'
;
import
{
BaseEditor
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
...
...
@@ -117,7 +117,7 @@ export class WalkThroughPart extends BaseEditor {
private
addEventListener
<
E
extends
HTMLElement
>
(
element
:
E
,
type
:
string
,
listener
:
EventListenerOrEventListenerObject
,
useCapture
?:
boolean
):
IDisposable
;
private
addEventListener
<
E
extends
HTMLElement
>
(
element
:
E
,
type
:
string
,
listener
:
EventListenerOrEventListenerObject
,
useCapture
?:
boolean
):
IDisposable
{
element
.
addEventListener
(
type
,
listener
,
useCapture
);
return
{
dispose
:
()
=>
{
element
.
removeEventListener
(
type
,
listener
,
useCapture
);
}
}
;
return
toDisposable
(()
=>
{
element
.
removeEventListener
(
type
,
listener
,
useCapture
);
})
;
}
private
registerFocusHandlers
()
{
...
...
src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts
浏览文件 @
a6885b48
...
...
@@ -14,6 +14,7 @@ import { ConfigurationResolverService } from 'vs/workbench/services/configuratio
import
{
IWorkspaceFolder
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
TestEnvironmentService
,
TestEditorService
,
TestContextService
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
TestConfigurationService
}
from
'
vs/platform/configuration/test/common/testConfigurationService
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
suite
(
'
Configuration Resolver Service
'
,
()
=>
{
let
configurationResolverService
:
IConfigurationResolverService
;
...
...
@@ -391,7 +392,7 @@ class MockCommandService implements ICommandService {
public
_serviceBrand
:
any
;
public
callCount
=
0
;
onWillExecuteCommand
=
()
=>
({
dispose
:
()
=>
{
}
})
;
onWillExecuteCommand
=
()
=>
Disposable
.
None
;
public
executeCommand
(
commandId
:
string
,
...
args
:
any
[]):
TPromise
<
any
>
{
this
.
callCount
++
;
...
...
src/vs/workbench/services/search/node/searchService.ts
浏览文件 @
a6885b48
...
...
@@ -19,7 +19,7 @@ import { IRawSearch, ISerializedSearchComplete, ISerializedSearchProgressItem, I
import
{
ISearchChannel
,
SearchChannelClient
}
from
'
./searchIpc
'
;
import
{
IEnvironmentService
,
IDebugParams
}
from
'
vs/platform/environment/common/environment
'
;
import
{
ResourceMap
}
from
'
vs/base/common/map
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
...
...
@@ -55,18 +55,16 @@ export class SearchService implements ISearchService {
this
.
searchProviders
.
push
(
provider
);
}
return
{
dispose
:
()
=>
{
if
(
scheme
===
'
file
'
)
{
this
.
fileSearchProvider
=
null
;
}
else
{
const
idx
=
this
.
searchProviders
.
indexOf
(
provider
);
if
(
idx
>=
0
)
{
this
.
searchProviders
.
splice
(
idx
,
1
);
}
return
toDisposable
(()
=>
{
if
(
scheme
===
'
file
'
)
{
this
.
fileSearchProvider
=
null
;
}
else
{
const
idx
=
this
.
searchProviders
.
indexOf
(
provider
);
if
(
idx
>=
0
)
{
this
.
searchProviders
.
splice
(
idx
,
1
);
}
}
};
}
)
;
}
public
extendQuery
(
query
:
ISearchQuery
):
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录