Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7cbf2790
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,发现更多精彩内容 >>
提交
7cbf2790
编写于
5月 02, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6040 from Microsoft/joh/zonedebt
Joh/zonedebt
上级
f09f1f5a
54e21006
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
239 addition
and
232 deletion
+239
-232
src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts
...editor/contrib/referenceSearch/browser/referenceSearch.ts
+59
-55
src/vs/editor/contrib/referenceSearch/browser/referenceSearchWidget.ts
.../contrib/referenceSearch/browser/referenceSearchWidget.ts
+139
-137
src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts
src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts
+39
-36
src/vs/editor/contrib/zoneWidget/browser/zoneWidget.ts
src/vs/editor/contrib/zoneWidget/browser/zoneWidget.ts
+2
-4
未找到文件。
src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts
浏览文件 @
7cbf2790
...
@@ -28,7 +28,7 @@ import {CommonEditorRegistry, ContextKey, EditorActionDescriptor} from 'vs/edito
...
@@ -28,7 +28,7 @@ import {CommonEditorRegistry, ContextKey, EditorActionDescriptor} from 'vs/edito
import
{
IReference
,
ReferenceSearchRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
IReference
,
ReferenceSearchRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
EditorBrowserRegistry
}
from
'
vs/editor/browser/editorBrowserExtensions
'
;
import
{
EditorBrowserRegistry
}
from
'
vs/editor/browser/editorBrowserExtensions
'
;
import
{
Events
,
IPeekViewService
,
getOuterEditor
}
from
'
vs/editor/contrib/zoneWidget/browser/peekViewWidget
'
;
import
{
IPeekViewService
,
getOuterEditor
}
from
'
vs/editor/contrib/zoneWidget/browser/peekViewWidget
'
;
import
{
findReferences
}
from
'
../common/referenceSearch
'
;
import
{
findReferences
}
from
'
../common/referenceSearch
'
;
import
{
EventType
,
ReferencesModel
}
from
'
./referenceSearchModel
'
;
import
{
EventType
,
ReferencesModel
}
from
'
./referenceSearchModel
'
;
import
{
ReferenceWidget
}
from
'
./referenceSearchWidget
'
;
import
{
ReferenceWidget
}
from
'
./referenceSearchWidget
'
;
...
@@ -37,12 +37,12 @@ export class FindReferencesController implements editorCommon.IEditorContributio
...
@@ -37,12 +37,12 @@ export class FindReferencesController implements editorCommon.IEditorContributio
public
static
ID
=
'
editor.contrib.findReferencesController
'
;
public
static
ID
=
'
editor.contrib.findReferencesController
'
;
private
editor
:
ICodeEditor
;
private
_
editor
:
ICodeEditor
;
private
widget
:
ReferenceWidget
;
private
_
widget
:
ReferenceWidget
;
private
requestIdPool
:
number
;
private
_
requestIdPool
:
number
;
private
callOnClear
:
Function
[];
private
_
callOnClear
:
Function
[];
private
model
:
ReferencesModel
;
private
_
model
:
ReferencesModel
;
private
modelRevealing
:
boolean
;
private
_
modelRevealing
:
boolean
;
private
editorService
:
IEditorService
;
private
editorService
:
IEditorService
;
private
telemetryService
:
ITelemetryService
;
private
telemetryService
:
ITelemetryService
;
...
@@ -68,8 +68,8 @@ export class FindReferencesController implements editorCommon.IEditorContributio
...
@@ -68,8 +68,8 @@ export class FindReferencesController implements editorCommon.IEditorContributio
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
,
@
optional
(
IPeekViewService
)
peekViewService
:
IPeekViewService
@
optional
(
IPeekViewService
)
peekViewService
:
IPeekViewService
)
{
)
{
this
.
requestIdPool
=
0
;
this
.
_
requestIdPool
=
0
;
this
.
callOnClear
=
[];
this
.
_
callOnClear
=
[];
this
.
editorService
=
editorService
;
this
.
editorService
=
editorService
;
this
.
telemetryService
=
telemetryService
;
this
.
telemetryService
=
telemetryService
;
this
.
messageService
=
messageService
;
this
.
messageService
=
messageService
;
...
@@ -77,8 +77,8 @@ export class FindReferencesController implements editorCommon.IEditorContributio
...
@@ -77,8 +77,8 @@ export class FindReferencesController implements editorCommon.IEditorContributio
this
.
peekViewService
=
peekViewService
;
this
.
peekViewService
=
peekViewService
;
this
.
contextService
=
contextService
;
this
.
contextService
=
contextService
;
this
.
keybindingService
=
keybindingService
;
this
.
keybindingService
=
keybindingService
;
this
.
modelRevealing
=
false
;
this
.
_
modelRevealing
=
false
;
this
.
editor
=
editor
;
this
.
_
editor
=
editor
;
this
.
_referenceSearchVisible
=
keybindingService
.
createKey
(
CONTEXT_REFERENCE_SEARCH_VISIBLE
,
false
);
this
.
_referenceSearchVisible
=
keybindingService
.
createKey
(
CONTEXT_REFERENCE_SEARCH_VISIBLE
,
false
);
}
}
...
@@ -87,11 +87,11 @@ export class FindReferencesController implements editorCommon.IEditorContributio
...
@@ -87,11 +87,11 @@ export class FindReferencesController implements editorCommon.IEditorContributio
}
}
public
dispose
():
void
{
public
dispose
():
void
{
if
(
this
.
widget
)
{
if
(
this
.
_
widget
)
{
this
.
widget
.
dispose
();
this
.
_
widget
.
dispose
();
this
.
widget
=
null
;
this
.
_
widget
=
null
;
}
}
this
.
editor
=
null
;
this
.
_
editor
=
null
;
}
}
public
isInPeekView
()
:
boolean
{
public
isInPeekView
()
:
boolean
{
...
@@ -103,7 +103,7 @@ export class FindReferencesController implements editorCommon.IEditorContributio
...
@@ -103,7 +103,7 @@ export class FindReferencesController implements editorCommon.IEditorContributio
}
}
public
processRequest
(
range
:
editorCommon
.
IEditorRange
,
referencesPromise
:
TPromise
<
IReference
[]
>
,
metaTitleFn
:(
references
:
IReference
[])
=>
string
)
:
ReferenceWidget
{
public
processRequest
(
range
:
editorCommon
.
IEditorRange
,
referencesPromise
:
TPromise
<
IReference
[]
>
,
metaTitleFn
:(
references
:
IReference
[])
=>
string
)
:
ReferenceWidget
{
var
widgetPosition
=
!
this
.
widget
?
null
:
this
.
widget
.
position
;
var
widgetPosition
=
!
this
.
_widget
?
null
:
this
.
_
widget
.
position
;
// clean up from previous invocation
// clean up from previous invocation
var
widgetClosed
=
this
.
clear
();
var
widgetClosed
=
this
.
clear
();
...
@@ -116,22 +116,26 @@ export class FindReferencesController implements editorCommon.IEditorContributio
...
@@ -116,22 +116,26 @@ export class FindReferencesController implements editorCommon.IEditorContributio
this
.
_referenceSearchVisible
.
set
(
true
);
this
.
_referenceSearchVisible
.
set
(
true
);
// close the widget on model/mode changes
// close the widget on model/mode changes
this
.
callOnClear
.
push
(
this
.
editor
.
addListener
(
editorCommon
.
EventType
.
ModelModeChanged
,
()
=>
{
this
.
clear
();
}));
this
.
_callOnClear
.
push
(
this
.
_
editor
.
addListener
(
editorCommon
.
EventType
.
ModelModeChanged
,
()
=>
{
this
.
clear
();
}));
this
.
callOnClear
.
push
(
this
.
editor
.
addListener
(
editorCommon
.
EventType
.
ModelChanged
,
()
=>
{
this
.
_callOnClear
.
push
(
this
.
_
editor
.
addListener
(
editorCommon
.
EventType
.
ModelChanged
,
()
=>
{
if
(
!
this
.
modelRevealing
)
{
if
(
!
this
.
_
modelRevealing
)
{
this
.
clear
();
this
.
clear
();
}
}
}));
}));
this
.
widget
=
new
ReferenceWidget
(
this
.
editorService
,
this
.
keybindingService
,
this
.
contextService
,
this
.
instantiationService
,
this
.
editor
);
this
.
_widget
=
new
ReferenceWidget
(
this
.
editorService
,
this
.
keybindingService
,
this
.
contextService
,
this
.
instantiationService
,
this
.
_editor
);
this
.
widget
.
setTitle
(
nls
.
localize
(
'
labelLoading
'
,
"
Loading...
"
));
this
.
_widget
.
setTitle
(
nls
.
localize
(
'
labelLoading
'
,
"
Loading...
"
));
this
.
widget
.
show
(
range
,
18
);
this
.
_widget
.
show
(
range
,
18
);
this
.
callOnClear
.
push
(
this
.
widget
.
addListener
(
Events
.
Closed
,
()
=>
{
this
.
_callOnClear
.
push
(
this
.
_widget
.
onDidClose
(()
=>
{
this
.
widget
=
null
;
this
.
_widget
=
null
;
referencesPromise
.
cancel
();
this
.
clear
();
this
.
clear
();
}));
}).
dispose
);
this
.
callOnClear
.
push
(
this
.
widget
.
addListener
(
ReferenceWidget
.
Events
.
EditorDoubleClick
,
(
event
:
any
)
=>
{
this
.
_callOnClear
.
push
(()
=>
{
referencesPromise
.
cancel
();
});
this
.
_callOnClear
.
push
(
this
.
_widget
.
onDidDoubleClick
(
event
=>
{
if
(
!
event
.
reference
)
{
if
(
!
event
.
reference
)
{
return
;
return
;
...
@@ -147,9 +151,9 @@ export class FindReferencesController implements editorCommon.IEditorContributio
...
@@ -147,9 +151,9 @@ export class FindReferencesController implements editorCommon.IEditorContributio
if
(
!
(
event
.
originalEvent
.
ctrlKey
||
event
.
originalEvent
.
metaKey
))
{
if
(
!
(
event
.
originalEvent
.
ctrlKey
||
event
.
originalEvent
.
metaKey
))
{
this
.
clear
();
this
.
clear
();
}
}
}));
})
.
dispose
);
var
requestId
=
++
this
.
requestIdPool
,
var
requestId
=
++
this
.
_
requestIdPool
,
editorModel
=
this
.
editor
.
getModel
();
editorModel
=
this
.
_
editor
.
getModel
();
var
timer
=
this
.
telemetryService
.
timedPublicLog
(
'
findReferences
'
,
{
var
timer
=
this
.
telemetryService
.
timedPublicLog
(
'
findReferences
'
,
{
mode
:
editorModel
.
getMode
().
getId
()
mode
:
editorModel
.
getMode
().
getId
()
...
@@ -158,31 +162,31 @@ export class FindReferencesController implements editorCommon.IEditorContributio
...
@@ -158,31 +162,31 @@ export class FindReferencesController implements editorCommon.IEditorContributio
referencesPromise
.
then
((
references
:
IReference
[])
=>
{
referencesPromise
.
then
((
references
:
IReference
[])
=>
{
// still current request? widget still open?
// still current request? widget still open?
if
(
requestId
!==
this
.
requestIdPool
||
!
this
.
widget
)
{
if
(
requestId
!==
this
.
_requestIdPool
||
!
this
.
_
widget
)
{
timer
.
stop
();
timer
.
stop
();
return
;
return
;
}
}
// has a result
// has a result
if
(
isFalsyOrEmpty
(
references
))
{
if
(
isFalsyOrEmpty
(
references
))
{
this
.
widget
.
showMessage
(
nls
.
localize
(
'
noResults
'
,
"
No results
"
));
this
.
_
widget
.
showMessage
(
nls
.
localize
(
'
noResults
'
,
"
No results
"
));
timer
.
stop
();
timer
.
stop
();
return
;
return
;
}
}
// create result model
// create result model
this
.
model
=
new
ReferencesModel
(
references
,
this
.
editorService
);
this
.
_
model
=
new
ReferencesModel
(
references
,
this
.
editorService
);
this
.
model
.
currentReference
=
this
.
model
.
findReference
(
editorModel
.
getAssociatedResource
(),
range
.
getStartPosition
());
this
.
_model
.
currentReference
=
this
.
_
model
.
findReference
(
editorModel
.
getAssociatedResource
(),
range
.
getStartPosition
());
var
unbind
=
this
.
model
.
addListener
(
EventType
.
CurrentReferenceChanged
,
()
=>
{
var
unbind
=
this
.
_
model
.
addListener
(
EventType
.
CurrentReferenceChanged
,
()
=>
{
this
.
modelRevealing
=
true
;
this
.
_
modelRevealing
=
true
;
this
.
editorService
.
openEditor
({
this
.
editorService
.
openEditor
({
resource
:
this
.
model
.
currentReference
.
resource
,
resource
:
this
.
_
model
.
currentReference
.
resource
,
options
:
{
selection
:
this
.
model
.
currentReference
.
range
}
options
:
{
selection
:
this
.
_
model
.
currentReference
.
range
}
}).
done
((
openedEditor
)
=>
{
}).
done
((
openedEditor
)
=>
{
if
(
!
openedEditor
||
openedEditor
.
getControl
()
!==
this
.
editor
)
{
if
(
!
openedEditor
||
openedEditor
.
getControl
()
!==
this
.
_
editor
)
{
// TODO@Alex TODO@Joh
// TODO@Alex TODO@Joh
// when opening the current reference we might end up
// when opening the current reference we might end up
// in a different editor instance. that means we also have
// in a different editor instance. that means we also have
...
@@ -193,22 +197,22 @@ export class FindReferencesController implements editorCommon.IEditorContributio
...
@@ -193,22 +197,22 @@ export class FindReferencesController implements editorCommon.IEditorContributio
this
.
clear
();
this
.
clear
();
return
;
return
;
}
}
this
.
modelRevealing
=
false
;
this
.
_
modelRevealing
=
false
;
this
.
widget
.
show
(
this
.
model
.
currentReference
.
range
,
18
);
this
.
_widget
.
show
(
this
.
_
model
.
currentReference
.
range
,
18
);
this
.
widget
.
focus
();
this
.
_
widget
.
focus
();
},
(
err
)
=>
{
},
(
err
)
=>
{
this
.
modelRevealing
=
false
;
this
.
_
modelRevealing
=
false
;
onUnexpectedError
(
err
);
onUnexpectedError
(
err
);
});
});
});
});
this
.
callOnClear
.
push
(
unbind
);
this
.
_
callOnClear
.
push
(
unbind
);
// show widget
// show widget
this
.
_startTime
=
Date
.
now
();
this
.
_startTime
=
Date
.
now
();
if
(
this
.
widget
)
{
if
(
this
.
_
widget
)
{
this
.
widget
.
setMetaTitle
(
metaTitleFn
(
references
));
this
.
_
widget
.
setMetaTitle
(
metaTitleFn
(
references
));
this
.
widget
.
setModel
(
this
.
model
);
this
.
_widget
.
setModel
(
this
.
_
model
);
}
}
timer
.
stop
();
timer
.
stop
();
...
@@ -217,7 +221,7 @@ export class FindReferencesController implements editorCommon.IEditorContributio
...
@@ -217,7 +221,7 @@ export class FindReferencesController implements editorCommon.IEditorContributio
timer
.
stop
();
timer
.
stop
();
});
});
return
this
.
widget
;
return
this
.
_
widget
;
}
}
private
clear
():
boolean
{
private
clear
():
boolean
{
...
@@ -232,19 +236,19 @@ export class FindReferencesController implements editorCommon.IEditorContributio
...
@@ -232,19 +236,19 @@ export class FindReferencesController implements editorCommon.IEditorContributio
this
.
_referenceSearchVisible
.
reset
();
this
.
_referenceSearchVisible
.
reset
();
cAll
(
this
.
callOnClear
);
cAll
(
this
.
_
callOnClear
);
this
.
model
=
null
;
this
.
_
model
=
null
;
var
result
=
false
;
var
result
=
false
;
if
(
this
.
widget
)
{
if
(
this
.
_
widget
)
{
this
.
widget
.
dispose
();
this
.
_
widget
.
dispose
();
this
.
widget
=
null
;
this
.
_
widget
=
null
;
result
=
true
;
result
=
true
;
}
}
this
.
editor
.
focus
();
this
.
_
editor
.
focus
();
this
.
requestIdPool
+=
1
;
// Cancel pending requests
this
.
_
requestIdPool
+=
1
;
// Cancel pending requests
return
result
;
return
result
;
}
}
...
...
src/vs/editor/contrib/referenceSearch/browser/referenceSearchWidget.ts
浏览文件 @
7cbf2790
...
@@ -9,6 +9,7 @@ import * as nls from 'vs/nls';
...
@@ -9,6 +9,7 @@ import * as nls from 'vs/nls';
import
*
as
collections
from
'
vs/base/common/collections
'
;
import
*
as
collections
from
'
vs/base/common/collections
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
getPathLabel
}
from
'
vs/base/common/labels
'
;
import
{
getPathLabel
}
from
'
vs/base/common/labels
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IDisposable
,
cAll
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
cAll
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
...
@@ -47,25 +48,24 @@ class DecorationsManager implements IDisposable {
...
@@ -47,25 +48,24 @@ class DecorationsManager implements IDisposable {
private
_decorationSet
=
collections
.
createStringDictionary
<
OneReference
>
();
private
_decorationSet
=
collections
.
createStringDictionary
<
OneReference
>
();
private
_decorationIgnoreSet
=
collections
.
createStringDictionary
<
OneReference
>
();
private
_decorationIgnoreSet
=
collections
.
createStringDictionary
<
OneReference
>
();
private
_callOnDispose
:
Function
[]
=
[];
private
callOnDispose
:
Function
[]
=
[];
private
_callOnModelChange
:
Function
[]
=
[];
private
callOnModelChange
:
Function
[]
=
[];
constructor
(
private
editor
:
ICodeEditor
,
private
model
:
ReferencesModel
)
{
constructor
(
private
editor
:
ICodeEditor
,
private
model
:
ReferencesModel
)
{
this
.
callOnDispose
.
push
(
this
.
editor
.
addListener
(
editorCommon
.
EventType
.
ModelChanged
,
()
=>
this
.
onModelChanged
()));
this
.
_callOnDispose
.
push
(
this
.
editor
.
addListener
(
editorCommon
.
EventType
.
ModelChanged
,
()
=>
this
.
_
onModelChanged
()));
this
.
onModelChanged
();
this
.
_
onModelChanged
();
}
}
public
dispose
():
void
{
public
dispose
():
void
{
this
.
callOnModelChange
=
cAll
(
this
.
callOnModelChange
);
this
.
_callOnModelChange
=
cAll
(
this
.
_
callOnModelChange
);
this
.
callOnDispose
=
cAll
(
this
.
callOnDispose
);
this
.
_callOnDispose
=
cAll
(
this
.
_
callOnDispose
);
this
.
removeDecorations
();
this
.
removeDecorations
();
}
}
private
onModelChanged
():
void
{
private
_
onModelChanged
():
void
{
this
.
removeDecorations
();
this
.
removeDecorations
();
this
.
callOnModelChange
=
cAll
(
this
.
callOnModelChange
);
this
.
_callOnModelChange
=
cAll
(
this
.
_
callOnModelChange
);
var
model
=
this
.
editor
.
getModel
();
var
model
=
this
.
editor
.
getModel
();
if
(
!
model
)
{
if
(
!
model
)
{
...
@@ -74,14 +74,14 @@ class DecorationsManager implements IDisposable {
...
@@ -74,14 +74,14 @@ class DecorationsManager implements IDisposable {
for
(
var
i
=
0
,
len
=
this
.
model
.
children
.
length
;
i
<
len
;
i
++
)
{
for
(
var
i
=
0
,
len
=
this
.
model
.
children
.
length
;
i
<
len
;
i
++
)
{
if
(
this
.
model
.
children
[
i
].
resource
.
toString
()
===
model
.
getAssociatedResource
().
toString
())
{
if
(
this
.
model
.
children
[
i
].
resource
.
toString
()
===
model
.
getAssociatedResource
().
toString
())
{
this
.
addDecorations
(
this
.
model
.
children
[
i
]);
this
.
_
addDecorations
(
this
.
model
.
children
[
i
]);
return
;
return
;
}
}
}
}
}
}
private
addDecorations
(
reference
:
FileReferences
):
void
{
private
_
addDecorations
(
reference
:
FileReferences
):
void
{
this
.
callOnModelChange
.
push
(
this
.
editor
.
getModel
().
addListener
(
editorCommon
.
EventType
.
ModelDecorationsChanged
,
(
event
)
=>
this
.
onDecorationChanged
(
event
)));
this
.
_callOnModelChange
.
push
(
this
.
editor
.
getModel
().
addListener
(
editorCommon
.
EventType
.
ModelDecorationsChanged
,
(
event
)
=>
this
.
_
onDecorationChanged
(
event
)));
this
.
editor
.
getModel
().
changeDecorations
((
accessor
)
=>
{
this
.
editor
.
getModel
().
changeDecorations
((
accessor
)
=>
{
var
newDecorations
:
editorCommon
.
IModelDeltaDecoration
[]
=
[];
var
newDecorations
:
editorCommon
.
IModelDeltaDecoration
[]
=
[];
...
@@ -107,7 +107,7 @@ class DecorationsManager implements IDisposable {
...
@@ -107,7 +107,7 @@ class DecorationsManager implements IDisposable {
});
});
}
}
private
onDecorationChanged
(
event
:
any
):
void
{
private
_
onDecorationChanged
(
event
:
any
):
void
{
var
addedOrChangedDecorations
=
<
any
[]
>
event
.
addedOrChangedDecorations
,
var
addedOrChangedDecorations
=
<
any
[]
>
event
.
addedOrChangedDecorations
,
toRemove
:
string
[]
=
[];
toRemove
:
string
[]
=
[];
...
@@ -212,7 +212,7 @@ class Controller extends DefaultController {
...
@@ -212,7 +212,7 @@ class Controller extends DefaultController {
if
(
element
instanceof
FileReferences
)
{
if
(
element
instanceof
FileReferences
)
{
event
.
preventDefault
();
event
.
preventDefault
();
event
.
stopPropagation
();
event
.
stopPropagation
();
return
this
.
expandCollapse
(
tree
,
element
);
return
this
.
_
expandCollapse
(
tree
,
element
);
}
}
var
result
=
super
.
onClick
(
tree
,
element
,
event
);
var
result
=
super
.
onClick
(
tree
,
element
,
event
);
...
@@ -237,7 +237,7 @@ class Controller extends DefaultController {
...
@@ -237,7 +237,7 @@ class Controller extends DefaultController {
return
super
.
onClick
(
tree
,
element
,
event
);
return
super
.
onClick
(
tree
,
element
,
event
);
}
}
private
expandCollapse
(
tree
:
tree
.
ITree
,
element
:
any
):
boolean
{
private
_
expandCollapse
(
tree
:
tree
.
ITree
,
element
:
any
):
boolean
{
if
(
tree
.
isExpanded
(
element
))
{
if
(
tree
.
isExpanded
(
element
))
{
tree
.
collapse
(
element
).
done
(
null
,
onUnexpectedError
);
tree
.
collapse
(
element
).
done
(
null
,
onUnexpectedError
);
...
@@ -254,7 +254,7 @@ class Controller extends DefaultController {
...
@@ -254,7 +254,7 @@ class Controller extends DefaultController {
public
onEnter
(
tree
:
tree
.
ITree
,
event
:
IKeyboardEvent
):
boolean
{
public
onEnter
(
tree
:
tree
.
ITree
,
event
:
IKeyboardEvent
):
boolean
{
var
element
=
tree
.
getFocus
();
var
element
=
tree
.
getFocus
();
if
(
element
instanceof
FileReferences
)
{
if
(
element
instanceof
FileReferences
)
{
return
this
.
expandCollapse
(
tree
,
element
);
return
this
.
_
expandCollapse
(
tree
,
element
);
}
}
var
result
=
super
.
onEnter
(
tree
,
event
);
var
result
=
super
.
onEnter
(
tree
,
event
);
...
@@ -268,41 +268,41 @@ class Controller extends DefaultController {
...
@@ -268,41 +268,41 @@ class Controller extends DefaultController {
public
onUp
(
tree
:
tree
.
ITree
,
event
:
IKeyboardEvent
):
boolean
{
public
onUp
(
tree
:
tree
.
ITree
,
event
:
IKeyboardEvent
):
boolean
{
super
.
onUp
(
tree
,
event
);
super
.
onUp
(
tree
,
event
);
this
.
fakeFocus
(
tree
,
event
);
this
.
_
fakeFocus
(
tree
,
event
);
return
true
;
return
true
;
}
}
public
onPageUp
(
tree
:
tree
.
ITree
,
event
:
IKeyboardEvent
):
boolean
{
public
onPageUp
(
tree
:
tree
.
ITree
,
event
:
IKeyboardEvent
):
boolean
{
super
.
onPageUp
(
tree
,
event
);
super
.
onPageUp
(
tree
,
event
);
this
.
fakeFocus
(
tree
,
event
);
this
.
_
fakeFocus
(
tree
,
event
);
return
true
;
return
true
;
}
}
public
onLeft
(
tree
:
tree
.
ITree
,
event
:
IKeyboardEvent
):
boolean
{
public
onLeft
(
tree
:
tree
.
ITree
,
event
:
IKeyboardEvent
):
boolean
{
super
.
onLeft
(
tree
,
event
);
super
.
onLeft
(
tree
,
event
);
this
.
fakeFocus
(
tree
,
event
);
this
.
_
fakeFocus
(
tree
,
event
);
return
true
;
return
true
;
}
}
public
onDown
(
tree
:
tree
.
ITree
,
event
:
IKeyboardEvent
):
boolean
{
public
onDown
(
tree
:
tree
.
ITree
,
event
:
IKeyboardEvent
):
boolean
{
super
.
onDown
(
tree
,
event
);
super
.
onDown
(
tree
,
event
);
this
.
fakeFocus
(
tree
,
event
);
this
.
_
fakeFocus
(
tree
,
event
);
return
true
;
return
true
;
}
}
public
onPageDown
(
tree
:
tree
.
ITree
,
event
:
IKeyboardEvent
):
boolean
{
public
onPageDown
(
tree
:
tree
.
ITree
,
event
:
IKeyboardEvent
):
boolean
{
super
.
onPageDown
(
tree
,
event
);
super
.
onPageDown
(
tree
,
event
);
this
.
fakeFocus
(
tree
,
event
);
this
.
_
fakeFocus
(
tree
,
event
);
return
true
;
return
true
;
}
}
public
onRight
(
tree
:
tree
.
ITree
,
event
:
IKeyboardEvent
):
boolean
{
public
onRight
(
tree
:
tree
.
ITree
,
event
:
IKeyboardEvent
):
boolean
{
super
.
onRight
(
tree
,
event
);
super
.
onRight
(
tree
,
event
);
this
.
fakeFocus
(
tree
,
event
);
this
.
_
fakeFocus
(
tree
,
event
);
return
true
;
return
true
;
}
}
private
fakeFocus
(
tree
:
tree
.
ITree
,
event
:
IKeyboardEvent
):
void
{
private
_
fakeFocus
(
tree
:
tree
.
ITree
,
event
:
IKeyboardEvent
):
void
{
// focus next item
// focus next item
var
focus
=
tree
.
getFocus
();
var
focus
=
tree
.
getFocus
();
tree
.
setSelection
([
focus
]);
tree
.
setSelection
([
focus
]);
...
@@ -372,89 +372,91 @@ export class ReferenceWidget extends PeekViewWidget {
...
@@ -372,89 +372,91 @@ export class ReferenceWidget extends PeekViewWidget {
public
static
INNER_EDITOR_CONTEXT_KEY
=
'
inReferenceSearchEditor
'
;
public
static
INNER_EDITOR_CONTEXT_KEY
=
'
inReferenceSearchEditor
'
;
public
static
Events
=
{
private
_editorService
:
IEditorService
;
EditorDoubleClick
:
'
editorDoubleClick
'
private
_contextService
:
IWorkspaceContextService
;
};
private
_instantiationService
:
IInstantiationService
;
private
editorService
:
IEditorService
;
private
_decorationsManager
:
DecorationsManager
;
private
contextService
:
IWorkspaceContextService
;
private
_model
:
ReferencesModel
;
private
instantiationService
:
IInstantiationService
;
private
_callOnModel
:
IDisposable
[]
=
[];
private
_onDidDoubleClick
=
new
Emitter
<
{
reference
:
URI
,
range
:
Range
,
originalEvent
:
MouseEvent
}
>
();
private
decorationsManager
:
DecorationsManager
;
private
model
:
ReferencesModel
;
private
_tree
:
Tree
;
private
callOnModel
:
IDisposable
[];
private
_treeContainer
:
Builder
;
private
_preview
:
ICodeEditor
;
private
tree
:
Tree
;
private
_previewNotAvailableMessage
:
Model
;
private
treeContainer
:
Builder
;
private
_previewContainer
:
Builder
;
private
_messageContainer
:
Builder
;
private
preview
:
ICodeEditor
;
private
previewNotAvailableMessage
:
Model
;
private
_lastHeight
:
string
;
private
previewContainer
:
Builder
;
private
previewDecorations
:
string
[];
constructor
(
private
messageContainer
:
Builder
;
editorService
:
IEditorService
,
keybindingService
:
IKeybindingService
,
private
lastHeight
:
string
;
contextService
:
IWorkspaceContextService
,
instantiationService
:
IInstantiationService
,
constructor
(
editorService
:
IEditorService
,
keybindingService
:
IKeybindingService
,
contextService
:
IWorkspaceContextService
,
instantiationService
:
IInstantiationService
,
editor
:
ICodeEditor
)
{
editor
:
ICodeEditor
)
{
super
(
editor
,
keybindingService
,
ReferenceWidget
.
INNER_EDITOR_CONTEXT_KEY
,
{
frameColor
:
'
#007ACC
'
,
showFrame
:
false
,
showArrow
:
true
});
super
(
editor
,
keybindingService
,
ReferenceWidget
.
INNER_EDITOR_CONTEXT_KEY
,
{
frameColor
:
'
#007ACC
'
,
showFrame
:
false
,
showArrow
:
true
});
this
.
editorService
=
editorService
;
this
.
_editorService
=
editorService
;
this
.
contextService
=
contextService
;
this
.
_contextService
=
contextService
;
this
.
instantiationService
=
instantiationService
.
createChild
(
new
ServiceCollection
([
IPeekViewService
,
this
]));
this
.
_instantiationService
=
instantiationService
.
createChild
(
new
ServiceCollection
([
IPeekViewService
,
this
]));
this
.
callOnModel
=
[];
this
.
tree
=
null
;
this
.
_
tree
=
null
;
this
.
treeContainer
=
null
;
this
.
_
treeContainer
=
null
;
this
.
preview
=
null
;
this
.
_preview
=
null
;
this
.
previewContainer
=
null
;
this
.
_previewContainer
=
null
;
this
.
previewDecorations
=
[];
this
.
lastHeight
=
null
;
this
.
_
lastHeight
=
null
;
this
.
create
();
this
.
create
();
}
}
_onTitleClick
(
e
:
Event
):
void
{
get
onDidDoubleClick
():
Event
<
{
reference
:
URI
,
range
:
Range
,
originalEvent
:
MouseEvent
}
>
{
if
(
!
this
.
preview
||
!
this
.
preview
.
getModel
())
{
return
this
.
_onDidDoubleClick
.
event
;
}
protected
_onTitleClick
(
e
:
MouseEvent
):
void
{
if
(
!
this
.
_preview
||
!
this
.
_preview
.
getModel
())
{
return
;
return
;
}
}
var
model
=
this
.
preview
.
getModel
(),
var
model
=
this
.
_
preview
.
getModel
(),
lineNumber
=
this
.
preview
.
getPosition
().
lineNumber
,
lineNumber
=
this
.
_
preview
.
getPosition
().
lineNumber
,
titleRange
=
new
Range
(
lineNumber
,
1
,
lineNumber
,
model
.
getLineMaxColumn
(
lineNumber
));
titleRange
=
new
Range
(
lineNumber
,
1
,
lineNumber
,
model
.
getLineMaxColumn
(
lineNumber
));
this
.
emit
(
ReferenceWidget
.
Events
.
EditorDoubleClick
,
{
reference
:
this
.
getFocusedReference
(),
range
:
titleRange
,
originalEvent
:
e
});
this
.
_onDidDoubleClick
.
fire
({
reference
:
this
.
_getFocusedReference
(),
range
:
titleRange
,
originalEvent
:
e
});
}
}
_fillBody
(
containerElement
:
HTMLElement
):
void
{
protected
_fillBody
(
containerElement
:
HTMLElement
):
void
{
var
container
=
$
(
containerElement
);
var
container
=
$
(
containerElement
);
container
.
addClass
(
'
reference-zone-widget
'
);
container
.
addClass
(
'
reference-zone-widget
'
);
// message pane
// message pane
container
.
div
({
'
class
'
:
'
messages
'
},
div
=>
{
container
.
div
({
'
class
'
:
'
messages
'
},
div
=>
{
this
.
messageContainer
=
div
.
hide
();
this
.
_
messageContainer
=
div
.
hide
();
});
});
// editor
// editor
container
.
div
({
'
class
'
:
'
preview inline
'
},
(
div
:
Builder
)
=>
{
container
.
div
({
'
class
'
:
'
preview inline
'
},
(
div
:
Builder
)
=>
{
var
options
:
editorCommon
.
IEditorOptions
=
{
var
options
:
editorCommon
.
IEditorOptions
=
{
scrollBeyondLastLine
:
false
,
scrollBeyondLastLine
:
false
,
scrollbar
:
DefaultConfig
.
editor
.
scrollbar
,
scrollbar
:
DefaultConfig
.
editor
.
scrollbar
,
overviewRulerLanes
:
2
overviewRulerLanes
:
2
};
};
this
.
preview
=
this
.
instantiationService
.
createInstance
(
EmbeddedCodeEditorWidget
,
div
.
getHTMLElement
(),
options
,
this
.
editor
);
this
.
_preview
=
this
.
_
instantiationService
.
createInstance
(
EmbeddedCodeEditorWidget
,
div
.
getHTMLElement
(),
options
,
this
.
editor
);
this
.
previewContainer
=
div
.
hide
();
this
.
_
previewContainer
=
div
.
hide
();
this
.
previewNotAvailableMessage
=
new
Model
(
nls
.
localize
(
'
missingPreviewMessage
'
,
"
no preview available
"
),
Model
.
DEFAULT_CREATION_OPTIONS
,
null
);
this
.
_
previewNotAvailableMessage
=
new
Model
(
nls
.
localize
(
'
missingPreviewMessage
'
,
"
no preview available
"
),
Model
.
DEFAULT_CREATION_OPTIONS
,
null
);
});
});
// tree
// tree
container
.
div
({
'
class
'
:
'
ref-tree inline
'
},
(
div
:
Builder
)
=>
{
container
.
div
({
'
class
'
:
'
ref-tree inline
'
},
(
div
:
Builder
)
=>
{
var
config
=
{
var
config
=
{
dataSource
:
this
.
instantiationService
.
createInstance
(
DataSource
),
dataSource
:
this
.
_
instantiationService
.
createInstance
(
DataSource
),
renderer
:
this
.
instantiationService
.
createInstance
(
Renderer
,
this
.
editor
),
renderer
:
this
.
_
instantiationService
.
createInstance
(
Renderer
,
this
.
editor
),
//sorter: new Sorter(),
//sorter: new Sorter(),
controller
:
new
Controller
()
controller
:
new
Controller
()
};
};
...
@@ -464,77 +466,77 @@ export class ReferenceWidget extends PeekViewWidget {
...
@@ -464,77 +466,77 @@ export class ReferenceWidget extends PeekViewWidget {
twistiePixels
:
20
,
twistiePixels
:
20
,
ariaLabel
:
nls
.
localize
(
'
treeAriaLabel
'
,
"
References
"
)
ariaLabel
:
nls
.
localize
(
'
treeAriaLabel
'
,
"
References
"
)
};
};
this
.
tree
=
new
Tree
(
div
.
getHTMLElement
(),
config
,
options
);
this
.
_
tree
=
new
Tree
(
div
.
getHTMLElement
(),
config
,
options
);
this
.
treeContainer
=
div
.
hide
();
this
.
_
treeContainer
=
div
.
hide
();
});
});
}
}
_doLayoutBody
(
heightInPixel
:
number
):
void
{
protected
_doLayoutBody
(
heightInPixel
:
number
):
void
{
super
.
_doLayoutBody
(
heightInPixel
);
super
.
_doLayoutBody
(
heightInPixel
);
var
h
=
heightInPixel
+
'
px
'
;
var
h
=
heightInPixel
+
'
px
'
;
if
(
h
===
this
.
lastHeight
)
{
if
(
h
===
this
.
_
lastHeight
)
{
return
;
return
;
}
}
// set height
// set height
this
.
treeContainer
.
style
({
height
:
h
});
this
.
_
treeContainer
.
style
({
height
:
h
});
this
.
previewContainer
.
style
({
height
:
h
});
this
.
_
previewContainer
.
style
({
height
:
h
});
// forward
// forward
this
.
tree
.
layout
(
heightInPixel
);
this
.
_
tree
.
layout
(
heightInPixel
);
this
.
preview
.
layout
();
this
.
_
preview
.
layout
();
this
.
lastHeight
=
h
;
this
.
_
lastHeight
=
h
;
}
}
public
onWidth
(
widthInPixel
:
number
):
void
{
public
onWidth
(
widthInPixel
:
number
):
void
{
this
.
preview
.
layout
();
this
.
_
preview
.
layout
();
}
}
public
setModel
(
newModel
:
ReferencesModel
):
void
{
public
setModel
(
newModel
:
ReferencesModel
):
void
{
// clean up
// clean up
this
.
callOnModel
=
dispose
(
this
.
callOnModel
);
this
.
_callOnModel
=
dispose
(
this
.
_
callOnModel
);
this
.
model
=
newModel
;
this
.
_
model
=
newModel
;
if
(
this
.
model
)
{
if
(
this
.
_
model
)
{
this
.
_onNewModel
();
this
.
_onNewModel
();
}
}
}
}
public
showMessage
(
message
:
string
):
void
{
public
showMessage
(
message
:
string
):
void
{
this
.
setTitle
(
''
);
this
.
setTitle
(
''
);
this
.
messageContainer
.
innerHtml
(
message
).
show
();
this
.
_
messageContainer
.
innerHtml
(
message
).
show
();
}
}
private
_onNewModel
():
void
{
private
_onNewModel
():
void
{
this
.
messageContainer
.
hide
();
this
.
_
messageContainer
.
hide
();
this
.
decorationsManager
=
new
DecorationsManager
(
this
.
preview
,
this
.
model
);
this
.
_decorationsManager
=
new
DecorationsManager
(
this
.
_preview
,
this
.
_
model
);
this
.
callOnModel
.
push
(
this
.
decorationsManager
);
this
.
_callOnModel
.
push
(
this
.
_
decorationsManager
);
// listen on model changes
// listen on model changes
this
.
callOnModel
.
push
(
this
.
model
.
addListener2
(
EventType
.
OnReferenceRangeChanged
,
(
reference
:
OneReference
)
=>
{
this
.
_callOnModel
.
push
(
this
.
_model
.
addListener2
(
EventType
.
OnReferenceRangeChanged
,
(
reference
:
OneReference
)
=>
{
this
.
tree
.
refresh
(
reference
);
this
.
_
tree
.
refresh
(
reference
);
}));
}));
// listen on selection and focus
// listen on selection and focus
this
.
callOnModel
.
push
(
this
.
tree
.
addListener2
(
Controller
.
Events
.
FOCUSED
,
(
element
)
=>
{
this
.
_callOnModel
.
push
(
this
.
_
tree
.
addListener2
(
Controller
.
Events
.
FOCUSED
,
(
element
)
=>
{
if
(
element
instanceof
OneReference
)
{
if
(
element
instanceof
OneReference
)
{
this
.
showReferencePreview
(
element
);
this
.
_
showReferencePreview
(
element
);
}
}
}));
}));
this
.
callOnModel
.
push
(
this
.
tree
.
addListener2
(
Controller
.
Events
.
SELECTED
,
(
element
:
any
)
=>
{
this
.
_callOnModel
.
push
(
this
.
_tree
.
addListener2
(
Controller
.
Events
.
SELECTED
,
(
element
:
any
)
=>
{
if
(
element
instanceof
OneReference
)
{
if
(
element
instanceof
OneReference
)
{
this
.
showReferencePreview
(
element
);
this
.
_
showReferencePreview
(
element
);
this
.
model
.
currentReference
=
element
;
this
.
_
model
.
currentReference
=
element
;
}
}
}));
}));
this
.
callOnModel
.
push
(
this
.
tree
.
addListener2
(
Controller
.
Events
.
OPEN_TO_SIDE
,
(
element
:
any
)
=>
{
this
.
_callOnModel
.
push
(
this
.
_tree
.
addListener2
(
Controller
.
Events
.
OPEN_TO_SIDE
,
(
element
:
any
)
=>
{
if
(
element
instanceof
OneReference
)
{
if
(
element
instanceof
OneReference
)
{
this
.
editorService
.
openEditor
({
this
.
_
editorService
.
openEditor
({
resource
:
(
<
OneReference
>
element
).
resource
,
resource
:
(
<
OneReference
>
element
).
resource
,
options
:
{
options
:
{
selection
:
element
.
range
selection
:
element
.
range
}
}
...
@@ -542,65 +544,65 @@ export class ReferenceWidget extends PeekViewWidget {
...
@@ -542,65 +544,65 @@ export class ReferenceWidget extends PeekViewWidget {
}
}
}));
}));
var
input
=
this
.
model
.
children
.
length
===
1
?
<
any
>
this
.
model
.
children
[
0
]
:
<
any
>
this
.
model
;
var
input
=
this
.
_model
.
children
.
length
===
1
?
<
any
>
this
.
_model
.
children
[
0
]
:
<
any
>
this
.
_
model
;
this
.
tree
.
setInput
(
input
).
then
(()
=>
{
this
.
_
tree
.
setInput
(
input
).
then
(()
=>
{
this
.
tree
.
setSelection
([
this
.
model
.
currentReference
]);
this
.
_tree
.
setSelection
([
this
.
_
model
.
currentReference
]);
}).
done
(
null
,
onUnexpectedError
);
}).
done
(
null
,
onUnexpectedError
);
// listen on editor
// listen on editor
this
.
callOnModel
.
push
(
this
.
preview
.
addListener2
(
editorCommon
.
EventType
.
MouseDown
,
(
e
:{
event
:
MouseEvent
;
target
:
IMouseTarget
;
})
=>
{
this
.
_callOnModel
.
push
(
this
.
_preview
.
addListener2
(
editorCommon
.
EventType
.
MouseDown
,
(
e
:
{
event
:
MouseEvent
;
target
:
IMouseTarget
;
})
=>
{
if
(
e
.
event
.
detail
===
2
)
{
if
(
e
.
event
.
detail
===
2
)
{
this
.
emit
(
ReferenceWidget
.
Events
.
EditorDoubleClick
,
{
reference
:
this
.
getFocusedReference
(),
range
:
e
.
target
.
range
,
originalEvent
:
e
.
event
});
this
.
_onDidDoubleClick
.
fire
({
reference
:
this
.
_
getFocusedReference
(),
range
:
e
.
target
.
range
,
originalEvent
:
e
.
event
});
}
}
}));
}));
// make sure things are rendered
// make sure things are rendered
dom
.
addClass
(
this
.
container
,
'
results-loaded
'
);
dom
.
addClass
(
this
.
container
,
'
results-loaded
'
);
this
.
treeContainer
.
show
();
this
.
_
treeContainer
.
show
();
this
.
previewContainer
.
show
();
this
.
_
previewContainer
.
show
();
this
.
preview
.
layout
();
this
.
_
preview
.
layout
();
this
.
tree
.
layout
();
this
.
_
tree
.
layout
();
this
.
focus
();
this
.
focus
();
// preview the current reference
// preview the current reference
this
.
showReferencePreview
(
this
.
model
.
nextReference
(
this
.
model
.
currentReference
));
this
.
_showReferencePreview
(
this
.
_model
.
nextReference
(
this
.
_
model
.
currentReference
));
}
}
private
getFocusedReference
():
URI
{
private
_
getFocusedReference
():
URI
{
var
element
=
this
.
tree
.
getFocus
();
var
element
=
this
.
_
tree
.
getFocus
();
if
(
element
instanceof
OneReference
)
{
if
(
element
instanceof
OneReference
)
{
return
(
<
OneReference
>
element
).
resource
;
return
(
<
OneReference
>
element
).
resource
;
}
else
if
(
element
instanceof
FileReferences
)
{
}
else
if
(
element
instanceof
FileReferences
)
{
var
referenceFile
=
(
<
FileReferences
>
element
);
var
referenceFile
=
(
<
FileReferences
>
element
);
if
(
referenceFile
.
children
.
length
>
0
)
{
if
(
referenceFile
.
children
.
length
>
0
)
{
return
referenceFile
.
children
[
0
].
resource
;
return
referenceFile
.
children
[
0
].
resource
;
}
}
}
}
return
null
;
return
null
;
}
}
public
focus
():
void
{
public
focus
():
void
{
this
.
tree
.
DOMFocus
();
this
.
_
tree
.
DOMFocus
();
}
}
private
showReferencePreview
(
reference
:
OneReference
):
void
{
private
_showReferencePreview
(
reference
:
OneReference
):
void
{
// show in editor
// show in editor
this
.
editorService
.
resolveEditorModel
({
resource
:
reference
.
resource
}).
done
((
model
)
=>
{
this
.
_
editorService
.
resolveEditorModel
({
resource
:
reference
.
resource
}).
done
((
model
)
=>
{
if
(
model
)
{
if
(
model
)
{
this
.
preview
.
setModel
(
model
.
textEditorModel
);
this
.
_
preview
.
setModel
(
model
.
textEditorModel
);
var
sel
=
Range
.
lift
(
reference
.
range
).
collapseToStart
();
var
sel
=
Range
.
lift
(
reference
.
range
).
collapseToStart
();
this
.
preview
.
setSelection
(
sel
);
this
.
_
preview
.
setSelection
(
sel
);
this
.
preview
.
revealRangeInCenter
(
sel
);
this
.
_
preview
.
revealRangeInCenter
(
sel
);
}
else
{
}
else
{
this
.
preview
.
setModel
(
this
.
previewNotAvailableMessage
);
this
.
_preview
.
setModel
(
this
.
_
previewNotAvailableMessage
);
}
}
// Update widget header
// Update widget header
if
(
reference
.
resource
.
scheme
!==
Schemas
.
inMemory
)
{
if
(
reference
.
resource
.
scheme
!==
Schemas
.
inMemory
)
{
this
.
setTitle
(
reference
.
name
,
getPathLabel
(
reference
.
directory
,
this
.
contextService
));
this
.
setTitle
(
reference
.
name
,
getPathLabel
(
reference
.
directory
,
this
.
_
contextService
));
}
else
{
}
else
{
this
.
setTitle
(
nls
.
localize
(
'
peekView.alternateTitle
'
,
"
References
"
));
this
.
setTitle
(
nls
.
localize
(
'
peekView.alternateTitle
'
,
"
References
"
));
}
}
...
@@ -608,17 +610,17 @@ export class ReferenceWidget extends PeekViewWidget {
...
@@ -608,17 +610,17 @@ export class ReferenceWidget extends PeekViewWidget {
},
onUnexpectedError
);
},
onUnexpectedError
);
// show in tree
// show in tree
this
.
tree
.
reveal
(
reference
)
this
.
_
tree
.
reveal
(
reference
)
.
then
(()
=>
{
.
then
(()
=>
{
this
.
tree
.
setSelection
([
reference
]);
this
.
_
tree
.
setSelection
([
reference
]);
this
.
tree
.
setFocus
(
reference
);
this
.
_
tree
.
setFocus
(
reference
);
})
})
.
done
(
null
,
onUnexpectedError
);
.
done
(
null
,
onUnexpectedError
);
}
}
public
dispose
():
void
{
public
dispose
():
void
{
this
.
setModel
(
null
);
this
.
setModel
(
null
);
dispose
(
<
IDisposable
[]
>
[
this
.
preview
,
this
.
previewNotAvailableMessage
,
this
.
tree
]);
dispose
(
<
IDisposable
[]
>
[
this
.
_preview
,
this
.
_previewNotAvailableMessage
,
this
.
_
tree
]);
super
.
dispose
();
super
.
dispose
();
}
}
}
}
src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts
浏览文件 @
7cbf2790
...
@@ -10,6 +10,7 @@ import * as nls from 'vs/nls';
...
@@ -10,6 +10,7 @@ import * as nls from 'vs/nls';
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
$
}
from
'
vs/base/browser/builder
'
;
import
{
$
}
from
'
vs/base/browser/builder
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
ActionBar
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
ActionBar
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
ServiceIdentifier
,
ServicesAccessor
,
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ServiceIdentifier
,
ServicesAccessor
,
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
@@ -23,18 +24,14 @@ export var IPeekViewService = createDecorator<IPeekViewService>('peekViewService
...
@@ -23,18 +24,14 @@ export var IPeekViewService = createDecorator<IPeekViewService>('peekViewService
export
interface
IPeekViewService
{
export
interface
IPeekViewService
{
serviceId
:
ServiceIdentifier
<
any
>
;
serviceId
:
ServiceIdentifier
<
any
>
;
isActive
:
boolean
;
isActive
:
boolean
;
contextKey
:
string
;
contextKey
:
string
;
getActiveWidget
():
PeekViewWidget
;
getActiveWidget
():
PeekViewWidget
;
}
}
export
namespace
Events
{
export
var
Closed
=
'
closed
'
;
}
var
CONTEXT_OUTER_EDITOR
=
'
outerEditorId
'
;
var
CONTEXT_OUTER_EDITOR
=
'
outerEditorId
'
;
export
function
getOuterEditor
(
accessor
:
ServicesAccessor
,
args
:
any
):
ICommonCodeEditor
{
export
function
getOuterEditor
(
accessor
:
ServicesAccessor
,
args
:
any
):
ICommonCodeEditor
{
var
outerEditorId
=
args
.
context
[
CONTEXT_OUTER_EDITOR
];
var
outerEditorId
=
args
.
context
[
CONTEXT_OUTER_EDITOR
];
if
(
!
outerEditorId
)
{
if
(
!
outerEditorId
)
{
return
null
;
return
null
;
...
@@ -43,47 +40,53 @@ export function getOuterEditor(accessor:ServicesAccessor, args: any): ICommonCod
...
@@ -43,47 +40,53 @@ export function getOuterEditor(accessor:ServicesAccessor, args: any): ICommonCod
}
}
export
class
PeekViewWidget
extends
ZoneWidget
implements
IPeekViewService
{
export
class
PeekViewWidget
extends
ZoneWidget
implements
IPeekViewService
{
public
serviceId
=
IPeekViewService
;
public
serviceId
=
IPeekViewService
;
public
contextKey
:
string
;
public
contextKey
:
string
;
private
_isActive
:
boolean
;
private
_onDidClose
=
new
Emitter
<
PeekViewWidget
>
();
private
_isActive
=
false
;
_headElement
:
HTMLDivElement
;
protected
_headElement
:
HTMLDivElement
;
_primaryHeading
:
HTMLElement
;
protected
_primaryHeading
:
HTMLElement
;
_secondaryHeading
:
HTMLElement
;
protected
_secondaryHeading
:
HTMLElement
;
_metaHeading
:
HTMLElement
;
protected
_metaHeading
:
HTMLElement
;
_actionbarWidget
:
ActionBar
;
protected
_actionbarWidget
:
ActionBar
;
_bodyElement
:
HTMLDivElement
;
protected
_bodyElement
:
HTMLDivElement
;
constructor
(
editor
:
ICodeEditor
,
keybindingService
:
IKeybindingService
,
contextKey
:
string
,
options
:
IOptions
=
{})
{
constructor
(
editor
:
ICodeEditor
,
keybindingService
:
IKeybindingService
,
contextKey
:
string
,
options
:
IOptions
=
{})
{
super
(
editor
,
options
);
super
(
editor
,
options
);
this
.
contextKey
=
contextKey
;
this
.
contextKey
=
contextKey
;
keybindingService
.
createKey
(
CONTEXT_OUTER_EDITOR
,
editor
.
getId
());
keybindingService
.
createKey
(
CONTEXT_OUTER_EDITOR
,
editor
.
getId
());
}
}
public
dispose
():
void
{
public
dispose
():
void
{
this
.
_isActive
=
false
;
this
.
_isActive
=
false
;
super
.
dispose
();
super
.
dispose
();
}
}
public
get
isActive
():
boolean
{
public
get
onDidClose
():
Event
<
PeekViewWidget
>
{
return
this
.
_onDidClose
.
event
;
}
public
get
isActive
():
boolean
{
return
this
.
_isActive
;
return
this
.
_isActive
;
}
}
public
getActiveWidget
():
PeekViewWidget
{
public
getActiveWidget
():
PeekViewWidget
{
return
this
;
return
this
;
}
}
public
show
(
where
:
any
,
heightInLines
:
number
):
void
{
public
show
(
where
:
any
,
heightInLines
:
number
):
void
{
this
.
_isActive
=
true
;
this
.
_isActive
=
true
;
super
.
show
(
where
,
heightInLines
);
super
.
show
(
where
,
heightInLines
);
}
}
public
fillContainer
(
container
:
HTMLElement
):
void
{
public
fillContainer
(
container
:
HTMLElement
):
void
{
$
(
container
).
addClass
(
'
peekview-widget
'
);
$
(
container
).
addClass
(
'
peekview-widget
'
);
this
.
_headElement
=
<
HTMLDivElement
>
$
(
'
.head
'
).
getHTMLElement
();
this
.
_headElement
=
<
HTMLDivElement
>
$
(
'
.head
'
).
getHTMLElement
();
this
.
_bodyElement
=
<
HTMLDivElement
>
$
(
'
.body
'
).
getHTMLElement
();
this
.
_bodyElement
=
<
HTMLDivElement
>
$
(
'
.body
'
).
getHTMLElement
();
this
.
_fillHead
(
this
.
_headElement
);
this
.
_fillHead
(
this
.
_headElement
);
this
.
_fillBody
(
this
.
_bodyElement
);
this
.
_fillBody
(
this
.
_bodyElement
);
...
@@ -92,9 +95,9 @@ export class PeekViewWidget extends ZoneWidget implements IPeekViewService {
...
@@ -92,9 +95,9 @@ export class PeekViewWidget extends ZoneWidget implements IPeekViewService {
container
.
appendChild
(
this
.
_bodyElement
);
container
.
appendChild
(
this
.
_bodyElement
);
}
}
_fillHead
(
container
:
HTMLElement
):
void
{
protected
_fillHead
(
container
:
HTMLElement
):
void
{
var
titleElement
=
$
(
'
.peekview-title
'
).
var
titleElement
=
$
(
'
.peekview-title
'
).
on
(
dom
.
EventType
.
CLICK
,
(
e
)
=>
this
.
_onTitleClick
(
e
)).
on
(
dom
.
EventType
.
CLICK
,
e
=>
this
.
_onTitleClick
(
<
MouseEvent
>
e
)).
appendTo
(
this
.
_headElement
).
appendTo
(
this
.
_headElement
).
getHTMLElement
();
getHTMLElement
();
...
@@ -109,18 +112,18 @@ export class PeekViewWidget extends ZoneWidget implements IPeekViewService {
...
@@ -109,18 +112,18 @@ export class PeekViewWidget extends ZoneWidget implements IPeekViewService {
this
.
_actionbarWidget
.
push
(
new
Action
(
'
peekview.close
'
,
nls
.
localize
(
'
label.close
'
,
"
Close
"
),
'
close-peekview-action
'
,
true
,
()
=>
{
this
.
_actionbarWidget
.
push
(
new
Action
(
'
peekview.close
'
,
nls
.
localize
(
'
label.close
'
,
"
Close
"
),
'
close-peekview-action
'
,
true
,
()
=>
{
this
.
dispose
();
this
.
dispose
();
this
.
emit
(
Events
.
Closed
,
this
);
this
.
_onDidClose
.
fire
(
this
);
return
null
;
return
null
;
}),
{
label
:
false
,
icon
:
true
});
}),
{
label
:
false
,
icon
:
true
});
}
}
_onTitleClick
(
event
:
Event
):
void
{
protected
_onTitleClick
(
event
:
MouseEvent
):
void
{
// implement me
// implement me
}
}
public
setTitle
(
primaryHeading
:
string
,
secondaryHeading
?:
string
):
void
{
public
setTitle
(
primaryHeading
:
string
,
secondaryHeading
?:
string
):
void
{
$
(
this
.
_primaryHeading
).
safeInnerHtml
(
primaryHeading
);
$
(
this
.
_primaryHeading
).
safeInnerHtml
(
primaryHeading
);
if
(
secondaryHeading
)
{
if
(
secondaryHeading
)
{
$
(
this
.
_secondaryHeading
).
safeInnerHtml
(
secondaryHeading
);
$
(
this
.
_secondaryHeading
).
safeInnerHtml
(
secondaryHeading
);
}
else
{
}
else
{
dom
.
clearNode
(
this
.
_secondaryHeading
);
dom
.
clearNode
(
this
.
_secondaryHeading
);
...
@@ -135,16 +138,16 @@ export class PeekViewWidget extends ZoneWidget implements IPeekViewService {
...
@@ -135,16 +138,16 @@ export class PeekViewWidget extends ZoneWidget implements IPeekViewService {
}
}
}
}
_fillBody
(
container
:
HTMLElement
):
void
{
protected
_fillBody
(
container
:
HTMLElement
):
void
{
// implement me
// implement me
}
}
public
doLayout
(
heightInPixel
:
number
):
void
{
public
doLayout
(
heightInPixel
:
number
):
void
{
if
(
heightInPixel
<
0
)
{
if
(
heightInPixel
<
0
)
{
// Looks like the view zone got folded away!
// Looks like the view zone got folded away!
this
.
dispose
();
this
.
dispose
();
this
.
emit
(
Events
.
Closed
,
this
);
this
.
_onDidClose
.
fire
(
this
);
return
;
return
;
}
}
...
@@ -155,12 +158,12 @@ export class PeekViewWidget extends ZoneWidget implements IPeekViewService {
...
@@ -155,12 +158,12 @@ export class PeekViewWidget extends ZoneWidget implements IPeekViewService {
this
.
_doLayoutBody
(
bodyHeight
);
this
.
_doLayoutBody
(
bodyHeight
);
}
}
_doLayoutHead
(
heightInPixel
:
number
):
void
{
protected
_doLayoutHead
(
heightInPixel
:
number
):
void
{
this
.
_headElement
.
style
.
height
=
strings
.
format
(
'
{0}px
'
,
heightInPixel
);
this
.
_headElement
.
style
.
height
=
strings
.
format
(
'
{0}px
'
,
heightInPixel
);
this
.
_headElement
.
style
.
lineHeight
=
this
.
_headElement
.
style
.
height
;
this
.
_headElement
.
style
.
lineHeight
=
this
.
_headElement
.
style
.
height
;
}
}
_doLayoutBody
(
heightInPixel
:
number
):
void
{
protected
_doLayoutBody
(
heightInPixel
:
number
):
void
{
this
.
_bodyElement
.
style
.
height
=
strings
.
format
(
'
{0}px
'
,
heightInPixel
);
this
.
_bodyElement
.
style
.
height
=
strings
.
format
(
'
{0}px
'
,
heightInPixel
);
}
}
}
}
src/vs/editor/contrib/zoneWidget/browser/zoneWidget.ts
浏览文件 @
7cbf2790
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
'
use strict
'
;
'
use strict
'
;
import
'
vs/css!./zoneWidget
'
;
import
'
vs/css!./zoneWidget
'
;
import
{
EventEmitter
,
ListenerUnbind
}
from
'
vs/base/common/eventEmitter
'
;
import
{
ListenerUnbind
}
from
'
vs/base/common/eventEmitter
'
;
import
*
as
objects
from
'
vs/base/common/objects
'
;
import
*
as
objects
from
'
vs/base/common/objects
'
;
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
EventType
,
IEditorLayoutInfo
,
IPosition
,
IRange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
EventType
,
IEditorLayoutInfo
,
IPosition
,
IRange
}
from
'
vs/editor/common/editorCommon
'
;
...
@@ -80,8 +80,7 @@ class OverlayWidgetDelegate implements IOverlayWidget {
...
@@ -80,8 +80,7 @@ class OverlayWidgetDelegate implements IOverlayWidget {
}
}
// TODO@Joh - this is an event emitter, why?
export
class
ZoneWidget
{
export
class
ZoneWidget
extends
EventEmitter
{
private
zoneId
:
number
;
private
zoneId
:
number
;
private
lastView
:
any
;
private
lastView
:
any
;
...
@@ -98,7 +97,6 @@ export class ZoneWidget extends EventEmitter {
...
@@ -98,7 +97,6 @@ export class ZoneWidget extends EventEmitter {
private
listenersToRemove
:
ListenerUnbind
[];
private
listenersToRemove
:
ListenerUnbind
[];
constructor
(
editor
:
ICodeEditor
,
options
:
IOptions
=
{})
{
constructor
(
editor
:
ICodeEditor
,
options
:
IOptions
=
{})
{
super
();
this
.
editor
=
editor
;
this
.
editor
=
editor
;
this
.
options
=
objects
.
mixin
(
objects
.
clone
(
defaultOptions
),
options
);
this
.
options
=
objects
.
mixin
(
objects
.
clone
(
defaultOptions
),
options
);
this
.
zoneId
=
-
1
;
this
.
zoneId
=
-
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录