Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b0cf4b24
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,发现更多精彩内容 >>
提交
b0cf4b24
编写于
6月 07, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
referenceSearch - use DisposableStore over IDisposable[]
上级
29b13ead
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
26 addition
and
27 deletion
+26
-27
src/vs/editor/contrib/referenceSearch/referencesController.ts
...vs/editor/contrib/referenceSearch/referencesController.ts
+7
-7
src/vs/editor/contrib/referenceSearch/referencesModel.ts
src/vs/editor/contrib/referenceSearch/referencesModel.ts
+5
-6
src/vs/editor/contrib/referenceSearch/referencesWidget.ts
src/vs/editor/contrib/referenceSearch/referencesWidget.ts
+14
-14
未找到文件。
src/vs/editor/contrib/referenceSearch/referencesController.ts
浏览文件 @
b0cf4b24
...
...
@@ -5,7 +5,7 @@
import
*
as
nls
from
'
vs/nls
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
IDisposable
,
dispos
e
}
from
'
vs/base/common/lifecycle
'
;
import
{
dispose
,
DisposableStor
e
}
from
'
vs/base/common/lifecycle
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IContextKey
,
IContextKeyService
,
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
...
...
@@ -32,11 +32,11 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
private
static
readonly
ID
=
'
editor.contrib.referencesController
'
;
private
readonly
_disposables
=
new
DisposableStore
();
private
readonly
_editor
:
ICodeEditor
;
private
_widget
:
ReferenceWidget
|
null
;
private
_model
:
ReferencesModel
|
null
;
private
_requestIdPool
=
0
;
private
_disposables
:
IDisposable
[]
=
[];
private
_ignoreModelChangeEvent
=
false
;
private
readonly
_referenceSearchVisible
:
IContextKey
<
boolean
>
;
...
...
@@ -91,8 +91,8 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
this
.
_referenceSearchVisible
.
set
(
true
);
// close the widget on model/mode changes
this
.
_disposables
.
push
(
this
.
_editor
.
onDidChangeModelLanguage
(()
=>
{
this
.
closeWidget
();
}));
this
.
_disposables
.
push
(
this
.
_editor
.
onDidChangeModel
(()
=>
{
this
.
_disposables
.
add
(
this
.
_editor
.
onDidChangeModelLanguage
(()
=>
{
this
.
closeWidget
();
}));
this
.
_disposables
.
add
(
this
.
_editor
.
onDidChangeModel
(()
=>
{
if
(
!
this
.
_ignoreModelChangeEvent
)
{
this
.
closeWidget
();
}
...
...
@@ -103,7 +103,7 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
this
.
_widget
.
setTitle
(
nls
.
localize
(
'
labelLoading
'
,
"
Loading...
"
));
this
.
_widget
.
show
(
range
);
this
.
_disposables
.
push
(
this
.
_widget
.
onDidClose
(()
=>
{
this
.
_disposables
.
add
(
this
.
_widget
.
onDidClose
(()
=>
{
modelPromise
.
cancel
();
if
(
this
.
_widget
)
{
this
.
_storageService
.
store
(
storageKey
,
JSON
.
stringify
(
this
.
_widget
.
layoutData
),
StorageScope
.
GLOBAL
);
...
...
@@ -112,7 +112,7 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
this
.
closeWidget
();
}));
this
.
_disposables
.
push
(
this
.
_widget
.
onDidSelectReference
(
event
=>
{
this
.
_disposables
.
add
(
this
.
_widget
.
onDidSelectReference
(
event
=>
{
let
{
element
,
kind
}
=
event
;
switch
(
kind
)
{
case
'
open
'
:
...
...
@@ -205,7 +205,7 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
this
.
_widget
=
null
;
}
this
.
_referenceSearchVisible
.
reset
();
this
.
_disposables
=
dispose
(
this
.
_disposables
);
this
.
_disposables
.
clear
(
);
if
(
this
.
_model
)
{
dispose
(
this
.
_model
);
this
.
_model
=
null
;
...
...
src/vs/editor/contrib/referenceSearch/referencesModel.ts
浏览文件 @
b0cf4b24
...
...
@@ -6,7 +6,7 @@
import
{
localize
}
from
'
vs/nls
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
basename
}
from
'
vs/base/common/resources
'
;
import
{
IDisposable
,
dispose
,
IReference
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
,
IReference
,
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
defaultGenerator
}
from
'
vs/base/common/idGenerator
'
;
...
...
@@ -166,7 +166,7 @@ export class FileReferences implements IDisposable {
export
class
ReferencesModel
implements
IDisposable
{
private
readonly
_disposables
:
IDisposable
[]
;
private
readonly
_disposables
=
new
DisposableStore
()
;
readonly
groups
:
FileReferences
[]
=
[];
readonly
references
:
OneReference
[]
=
[];
...
...
@@ -174,7 +174,7 @@ export class ReferencesModel implements IDisposable {
readonly
onDidChangeReferenceRange
:
Event
<
OneReference
>
=
this
.
_onDidChangeReferenceRange
.
event
;
constructor
(
references
:
LocationLink
[])
{
this
.
_disposables
=
[];
// grouping and sorting
const
[
providersFirst
]
=
references
;
references
.
sort
(
ReferencesModel
.
_compareReferences
);
...
...
@@ -192,7 +192,7 @@ export class ReferencesModel implements IDisposable {
||
!
Range
.
equalsRange
(
ref
.
range
,
current
.
children
[
current
.
children
.
length
-
1
].
range
))
{
let
oneRef
=
new
OneReference
(
current
,
ref
.
targetSelectionRange
||
ref
.
range
,
providersFirst
===
ref
);
this
.
_disposables
.
push
(
oneRef
.
onRefChanged
((
e
)
=>
this
.
_onDidChangeReferenceRange
.
fire
(
e
)));
this
.
_disposables
.
add
(
oneRef
.
onRefChanged
((
e
)
=>
this
.
_onDidChangeReferenceRange
.
fire
(
e
)));
this
.
references
.
push
(
oneRef
);
current
.
children
.
push
(
oneRef
);
}
...
...
@@ -282,9 +282,8 @@ export class ReferencesModel implements IDisposable {
dispose
():
void
{
dispose
(
this
.
groups
);
dispose
(
this
.
_disposables
);
this
.
_disposables
.
dispose
(
);
this
.
groups
.
length
=
0
;
this
.
_disposables
.
length
=
0
;
}
private
static
_compareReferences
(
a
:
Location
,
b
:
Location
):
number
{
...
...
src/vs/editor/contrib/referenceSearch/referencesWidget.ts
浏览文件 @
b0cf4b24
...
...
@@ -8,7 +8,7 @@ import { IMouseEvent } from 'vs/base/browser/mouseEvent';
import
{
Orientation
}
from
'
vs/base/browser/ui/sash/sash
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
dispose
,
IDisposable
,
IReference
}
from
'
vs/base/common/lifecycle
'
;
import
{
dispose
,
IDisposable
,
IReference
,
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
basenameOrAuthority
,
dirname
}
from
'
vs/base/common/resources
'
;
import
'
vs/css!./media/referencesWidget
'
;
...
...
@@ -47,17 +47,17 @@ class DecorationsManager implements IDisposable {
private
_decorations
=
new
Map
<
string
,
OneReference
>
();
private
_decorationIgnoreSet
=
new
Set
<
string
>
();
private
_callOnDispose
:
IDisposable
[]
=
[]
;
private
_callOnModelChange
:
IDisposable
[]
=
[]
;
private
_callOnDispose
=
new
DisposableStore
()
;
private
_callOnModelChange
=
new
DisposableStore
()
;
constructor
(
private
_editor
:
ICodeEditor
,
private
_model
:
ReferencesModel
)
{
this
.
_callOnDispose
.
push
(
this
.
_editor
.
onDidChangeModel
(()
=>
this
.
_onModelChanged
()));
this
.
_callOnDispose
.
add
(
this
.
_editor
.
onDidChangeModel
(()
=>
this
.
_onModelChanged
()));
this
.
_onModelChanged
();
}
public
dispose
():
void
{
this
.
_callOnModelChange
=
dispose
(
this
.
_callOnModelChange
);
this
.
_callOnDispose
=
dispose
(
this
.
_callOnDispose
);
this
.
_callOnModelChange
.
dispose
(
);
this
.
_callOnDispose
.
dispose
(
);
this
.
removeDecorations
();
}
...
...
@@ -78,7 +78,7 @@ class DecorationsManager implements IDisposable {
if
(
!
this
.
_editor
.
hasModel
())
{
return
;
}
this
.
_callOnModelChange
.
push
(
this
.
_editor
.
getModel
().
onDidChangeDecorations
((
event
)
=>
this
.
_onDecorationChanged
()));
this
.
_callOnModelChange
.
add
(
this
.
_editor
.
getModel
().
onDidChangeDecorations
((
event
)
=>
this
.
_onDecorationChanged
()));
const
newDecorations
:
IModelDeltaDecoration
[]
=
[];
const
newDecorationsActualIndex
:
number
[]
=
[];
...
...
@@ -194,8 +194,8 @@ export class ReferenceWidget extends PeekViewWidget {
private
_model
:
ReferencesModel
|
undefined
;
private
_decorationsManager
:
DecorationsManager
;
private
_disposeOnNewModel
:
IDisposable
[]
=
[]
;
private
_callOnDispose
:
IDisposable
[]
=
[]
;
private
_disposeOnNewModel
=
new
DisposableStore
()
;
private
_callOnDispose
=
new
DisposableStore
()
;
private
_onDidSelectReference
=
new
Emitter
<
SelectionEvent
>
();
private
_tree
:
WorkbenchAsyncDataTree
<
ReferencesModel
|
FileReferences
,
TreeElement
,
FuzzyScore
>
;
...
...
@@ -222,14 +222,14 @@ export class ReferenceWidget extends PeekViewWidget {
super
(
editor
,
{
showFrame
:
false
,
showArrow
:
true
,
isResizeable
:
true
,
isAccessible
:
true
});
this
.
_applyTheme
(
themeService
.
getTheme
());
this
.
_callOnDispose
.
push
(
themeService
.
onThemeChange
(
this
.
_applyTheme
.
bind
(
this
)));
this
.
_callOnDispose
.
add
(
themeService
.
onThemeChange
(
this
.
_applyTheme
.
bind
(
this
)));
this
.
_peekViewService
.
addExclusiveWidget
(
editor
,
this
);
this
.
create
();
}
dispose
():
void
{
this
.
setModel
(
undefined
);
this
.
_callOnDispose
=
dispose
(
this
.
_callOnDispose
);
this
.
_callOnDispose
.
dispose
(
);
dispose
(
this
.
_preview
);
dispose
(
this
.
_previewNotAvailableMessage
);
dispose
(
this
.
_tree
);
...
...
@@ -446,13 +446,13 @@ export class ReferenceWidget extends PeekViewWidget {
dom
.
hide
(
this
.
_messageContainer
);
this
.
_decorationsManager
=
new
DecorationsManager
(
this
.
_preview
,
this
.
_model
);
this
.
_disposeOnNewModel
.
push
(
this
.
_decorationsManager
);
this
.
_disposeOnNewModel
.
add
(
this
.
_decorationsManager
);
// listen on model changes
this
.
_disposeOnNewModel
.
push
(
this
.
_model
.
onDidChangeReferenceRange
(
reference
=>
this
.
_tree
.
rerender
(
reference
)));
this
.
_disposeOnNewModel
.
add
(
this
.
_model
.
onDidChangeReferenceRange
(
reference
=>
this
.
_tree
.
rerender
(
reference
)));
// listen on editor
this
.
_disposeOnNewModel
.
push
(
this
.
_preview
.
onMouseDown
(
e
=>
{
this
.
_disposeOnNewModel
.
add
(
this
.
_preview
.
onMouseDown
(
e
=>
{
const
{
event
,
target
}
=
e
;
if
(
event
.
detail
!==
2
)
{
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录