Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a920f227
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,发现更多精彩内容 >>
提交
a920f227
编写于
1月 28, 2019
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #66685
上级
b257ca20
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
125 addition
and
66 deletion
+125
-66
src/vs/workbench/parts/markers/electron-browser/constants.ts
src/vs/workbench/parts/markers/electron-browser/constants.ts
+1
-0
src/vs/workbench/parts/markers/electron-browser/markers.contribution.ts
...ch/parts/markers/electron-browser/markers.contribution.ts
+16
-2
src/vs/workbench/parts/markers/electron-browser/markersPanel.ts
.../workbench/parts/markers/electron-browser/markersPanel.ts
+18
-14
src/vs/workbench/parts/markers/electron-browser/markersPanelActions.ts
...nch/parts/markers/electron-browser/markersPanelActions.ts
+15
-2
src/vs/workbench/parts/markers/electron-browser/markersTreeViewer.ts
...bench/parts/markers/electron-browser/markersTreeViewer.ts
+75
-48
未找到文件。
src/vs/workbench/parts/markers/electron-browser/constants.ts
浏览文件 @
a920f227
...
@@ -16,6 +16,7 @@ export default {
...
@@ -16,6 +16,7 @@ export default {
MARKERS_PANEL_SHOW_SINGLELINE_MESSAGE
:
'
problems.action.showSinglelineMessage
'
,
MARKERS_PANEL_SHOW_SINGLELINE_MESSAGE
:
'
problems.action.showSinglelineMessage
'
,
MARKER_OPEN_SIDE_ACTION_ID
:
'
problems.action.openToSide
'
,
MARKER_OPEN_SIDE_ACTION_ID
:
'
problems.action.openToSide
'
,
MARKER_SHOW_PANEL_ID
:
'
workbench.action.showErrorsWarnings
'
,
MARKER_SHOW_PANEL_ID
:
'
workbench.action.showErrorsWarnings
'
,
MARKER_SHOW_QUICK_FIX
:
'
problems.action.showQuickFixes
'
,
MarkerPanelFocusContextKey
:
new
RawContextKey
<
boolean
>
(
'
problemsViewFocus
'
,
false
),
MarkerPanelFocusContextKey
:
new
RawContextKey
<
boolean
>
(
'
problemsViewFocus
'
,
false
),
MarkerFocusContextKey
:
new
RawContextKey
<
boolean
>
(
'
problemFocus
'
,
false
),
MarkerFocusContextKey
:
new
RawContextKey
<
boolean
>
(
'
problemFocus
'
,
false
),
...
...
src/vs/workbench/parts/markers/electron-browser/markers.contribution.ts
浏览文件 @
a920f227
...
@@ -53,6 +53,20 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
...
@@ -53,6 +53,20 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
}
}
});
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
Constants
.
MARKER_SHOW_QUICK_FIX
,
weight
:
KeybindingWeight
.
WorkbenchContrib
,
when
:
Constants
.
MarkerFocusContextKey
,
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
US_DOT
,
handler
:
(
accessor
,
args
:
any
)
=>
{
const
markersPanel
=
(
<
MarkersPanel
>
accessor
.
get
(
IPanelService
).
getActivePanel
());
const
focusedElement
=
markersPanel
.
getFocusElement
();
if
(
focusedElement
instanceof
Marker
)
{
markersPanel
.
showQuickFixes
(
focusedElement
);
}
}
});
// configuration
// configuration
Registry
.
as
<
IConfigurationRegistry
>
(
Extensions
.
Configuration
).
registerConfiguration
({
Registry
.
as
<
IConfigurationRegistry
>
(
Extensions
.
Configuration
).
registerConfiguration
({
'
id
'
:
'
problems
'
,
'
id
'
:
'
problems
'
,
...
@@ -161,7 +175,7 @@ registerAction({
...
@@ -161,7 +175,7 @@ registerAction({
const
panelService
=
accessor
.
get
(
IPanelService
);
const
panelService
=
accessor
.
get
(
IPanelService
);
const
panel
=
panelService
.
getActivePanel
();
const
panel
=
panelService
.
getActivePanel
();
if
(
panel
instanceof
MarkersPanel
)
{
if
(
panel
instanceof
MarkersPanel
)
{
panel
.
markersView
State
.
multiline
=
true
;
panel
.
markersView
Model
.
multiline
=
true
;
}
}
},
},
title
:
localize
(
'
show multiline
'
,
"
Show message in multiple lines
"
),
title
:
localize
(
'
show multiline
'
,
"
Show message in multiple lines
"
),
...
@@ -177,7 +191,7 @@ registerAction({
...
@@ -177,7 +191,7 @@ registerAction({
const
panelService
=
accessor
.
get
(
IPanelService
);
const
panelService
=
accessor
.
get
(
IPanelService
);
const
panel
=
panelService
.
getActivePanel
();
const
panel
=
panelService
.
getActivePanel
();
if
(
panel
instanceof
MarkersPanel
)
{
if
(
panel
instanceof
MarkersPanel
)
{
panel
.
markersView
State
.
multiline
=
false
;
panel
.
markersView
Model
.
multiline
=
false
;
}
}
},
},
title
:
localize
(
'
show singleline
'
,
"
Show message in single line
"
),
title
:
localize
(
'
show singleline
'
,
"
Show message in single line
"
),
...
...
src/vs/workbench/parts/markers/electron-browser/markersPanel.ts
浏览文件 @
a920f227
...
@@ -14,7 +14,7 @@ import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/
...
@@ -14,7 +14,7 @@ import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/
import
Constants
from
'
vs/workbench/parts/markers/electron-browser/constants
'
;
import
Constants
from
'
vs/workbench/parts/markers/electron-browser/constants
'
;
import
{
Marker
,
ResourceMarkers
,
RelatedInformation
,
MarkersModel
}
from
'
vs/workbench/parts/markers/electron-browser/markersModel
'
;
import
{
Marker
,
ResourceMarkers
,
RelatedInformation
,
MarkersModel
}
from
'
vs/workbench/parts/markers/electron-browser/markersModel
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
MarkersFilterActionItem
,
MarkersFilterAction
,
QuickFixAction
,
QuickFixActionItem
,
IMarkersFilterActionChangeEvent
,
IMarkerFilterController
}
from
'
vs/workbench/parts/markers/electron-browser/markersPanelActions
'
;
import
{
MarkersFilterActionItem
,
MarkersFilterAction
,
IMarkersFilterActionChangeEvent
,
IMarkerFilterController
}
from
'
vs/workbench/parts/markers/electron-browser/markersPanelActions
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
Messages
from
'
vs/workbench/parts/markers/electron-browser/messages
'
;
import
Messages
from
'
vs/workbench/parts/markers/electron-browser/messages
'
;
import
{
RangeHighlightDecorations
}
from
'
vs/workbench/browser/parts/editor/rangeDecorations
'
;
import
{
RangeHighlightDecorations
}
from
'
vs/workbench/browser/parts/editor/rangeDecorations
'
;
...
@@ -33,7 +33,7 @@ import { IExpression, getEmptyExpression } from 'vs/base/common/glob';
...
@@ -33,7 +33,7 @@ import { IExpression, getEmptyExpression } from 'vs/base/common/glob';
import
{
mixin
,
deepClone
}
from
'
vs/base/common/objects
'
;
import
{
mixin
,
deepClone
}
from
'
vs/base/common/objects
'
;
import
{
IWorkspaceFolder
,
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IWorkspaceFolder
,
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
isAbsolute
,
join
}
from
'
vs/base/common/paths
'
;
import
{
isAbsolute
,
join
}
from
'
vs/base/common/paths
'
;
import
{
FilterData
,
Filter
,
VirtualDelegate
,
ResourceMarkersRenderer
,
MarkerRenderer
,
RelatedInformationRenderer
,
TreeElement
,
MarkersTreeAccessibilityProvider
,
MarkersView
State
}
from
'
vs/workbench/parts/markers/electron-browser/markersTreeViewer
'
;
import
{
FilterData
,
Filter
,
VirtualDelegate
,
ResourceMarkersRenderer
,
MarkerRenderer
,
RelatedInformationRenderer
,
TreeElement
,
MarkersTreeAccessibilityProvider
,
MarkersView
Model
}
from
'
vs/workbench/parts/markers/electron-browser/markersTreeViewer
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
Separator
,
ActionItem
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
Separator
,
ActionItem
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
IMenuService
,
MenuId
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IMenuService
,
MenuId
}
from
'
vs/platform/actions/common/actions
'
;
...
@@ -89,7 +89,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
...
@@ -89,7 +89,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
private
cachedFilterStats
:
{
total
:
number
;
filtered
:
number
;
}
|
undefined
=
undefined
;
private
cachedFilterStats
:
{
total
:
number
;
filtered
:
number
;
}
|
undefined
=
undefined
;
private
currentResourceGotAddedToMarkersData
:
boolean
=
false
;
private
currentResourceGotAddedToMarkersData
:
boolean
=
false
;
readonly
markersView
State
:
MarkersViewState
;
readonly
markersView
Model
:
MarkersViewModel
;
private
disposables
:
IDisposable
[]
=
[];
private
disposables
:
IDisposable
[]
=
[];
constructor
(
constructor
(
...
@@ -109,8 +109,8 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
...
@@ -109,8 +109,8 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
super
(
Constants
.
MARKERS_PANEL_ID
,
telemetryService
,
themeService
,
storageService
);
super
(
Constants
.
MARKERS_PANEL_ID
,
telemetryService
,
themeService
,
storageService
);
this
.
panelFoucusContextKey
=
Constants
.
MarkerPanelFocusContextKey
.
bindTo
(
contextKeyService
);
this
.
panelFoucusContextKey
=
Constants
.
MarkerPanelFocusContextKey
.
bindTo
(
contextKeyService
);
this
.
panelState
=
this
.
getMemento
(
StorageScope
.
WORKSPACE
);
this
.
panelState
=
this
.
getMemento
(
StorageScope
.
WORKSPACE
);
this
.
markersView
State
=
new
MarkersViewState
(
this
.
panelState
[
'
multiline
'
]);
this
.
markersView
Model
=
instantiationService
.
createInstance
(
MarkersViewModel
,
this
.
panelState
[
'
multiline
'
]);
this
.
markersView
State
.
onDidChangeViewStat
e
(
this
.
onDidChangeViewState
,
this
,
this
.
disposables
);
this
.
markersView
Model
.
onDidChang
e
(
this
.
onDidChangeViewState
,
this
,
this
.
disposables
);
this
.
setCurrentActiveEditor
();
this
.
setCurrentActiveEditor
();
}
}
...
@@ -178,6 +178,13 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
...
@@ -178,6 +178,13 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
return
this
.
actions
;
return
this
.
actions
;
}
}
public
showQuickFixes
(
marker
:
Marker
):
void
{
const
viewModel
=
this
.
markersViewModel
.
getViewModel
(
marker
);
if
(
viewModel
)
{
viewModel
.
quickFixAction
.
run
();
}
}
public
openFileAtElement
(
element
:
any
,
preserveFocus
:
boolean
,
sideByside
:
boolean
,
pinned
:
boolean
):
boolean
{
public
openFileAtElement
(
element
:
any
,
preserveFocus
:
boolean
,
sideByside
:
boolean
,
pinned
:
boolean
):
boolean
{
const
{
resource
,
selection
,
event
,
data
}
=
element
instanceof
Marker
?
{
resource
:
element
.
resource
,
selection
:
element
.
range
,
event
:
'
problems.selectDiagnostic
'
,
data
:
this
.
getTelemetryData
(
element
.
marker
)
}
:
const
{
resource
,
selection
,
event
,
data
}
=
element
instanceof
Marker
?
{
resource
:
element
.
resource
,
selection
:
element
.
range
,
event
:
'
problems.selectDiagnostic
'
,
data
:
this
.
getTelemetryData
(
element
.
marker
)
}
:
element
instanceof
RelatedInformation
?
{
resource
:
element
.
raw
.
resource
,
selection
:
element
.
raw
,
event
:
'
problems.selectRelatedInformation
'
,
data
:
this
.
getTelemetryData
(
element
.
marker
)
}
:
{
resource
:
null
,
selection
:
null
,
event
:
null
,
data
:
null
};
element
instanceof
RelatedInformation
?
{
resource
:
element
.
raw
.
resource
,
selection
:
element
.
raw
,
event
:
'
problems.selectRelatedInformation
'
,
data
:
this
.
getTelemetryData
(
element
.
marker
)
}
:
{
resource
:
null
,
selection
:
null
,
event
:
null
,
data
:
null
};
...
@@ -306,10 +313,10 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
...
@@ -306,10 +313,10 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
this
.
treeLabels
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
ResourceLabels
,
this
));
this
.
treeLabels
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
ResourceLabels
,
this
));
const
virtualDelegate
=
new
VirtualDelegate
(
this
.
markersView
State
);
const
virtualDelegate
=
new
VirtualDelegate
(
this
.
markersView
Model
);
const
renderers
=
[
const
renderers
=
[
this
.
instantiationService
.
createInstance
(
ResourceMarkersRenderer
,
this
.
treeLabels
,
onDidChangeRenderNodeCount
.
event
),
this
.
instantiationService
.
createInstance
(
ResourceMarkersRenderer
,
this
.
treeLabels
,
onDidChangeRenderNodeCount
.
event
),
this
.
instantiationService
.
createInstance
(
MarkerRenderer
,
this
.
markersView
State
,
a
=>
this
.
getActionItem
(
a
)
),
this
.
instantiationService
.
createInstance
(
MarkerRenderer
,
this
.
markersView
Model
),
this
.
instantiationService
.
createInstance
(
RelatedInformationRenderer
)
this
.
instantiationService
.
createInstance
(
RelatedInformationRenderer
)
];
];
this
.
filter
=
new
Filter
();
this
.
filter
=
new
Filter
();
...
@@ -408,11 +415,11 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
...
@@ -408,11 +415,11 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
private
onDidChangeModel
(
resources
:
URI
[])
{
private
onDidChangeModel
(
resources
:
URI
[])
{
for
(
const
resource
of
resources
)
{
for
(
const
resource
of
resources
)
{
this
.
markersView
State
.
remove
(
resource
);
this
.
markersView
Model
.
remove
(
resource
);
const
resourceMarkers
=
this
.
markersWorkbenchService
.
markersModel
.
getResourceMarkers
(
resource
);
const
resourceMarkers
=
this
.
markersWorkbenchService
.
markersModel
.
getResourceMarkers
(
resource
);
if
(
resourceMarkers
)
{
if
(
resourceMarkers
)
{
for
(
const
marker
of
resourceMarkers
.
markers
)
{
for
(
const
marker
of
resourceMarkers
.
markers
)
{
this
.
markersView
State
.
add
(
marker
);
this
.
markersView
Model
.
add
(
marker
);
}
}
}
}
}
}
...
@@ -657,9 +664,6 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
...
@@ -657,9 +664,6 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
this
.
filterInputActionItem
=
this
.
instantiationService
.
createInstance
(
MarkersFilterActionItem
,
this
.
filterAction
,
this
);
this
.
filterInputActionItem
=
this
.
instantiationService
.
createInstance
(
MarkersFilterActionItem
,
this
.
filterAction
,
this
);
return
this
.
filterInputActionItem
;
return
this
.
filterInputActionItem
;
}
}
if
(
action
.
id
===
QuickFixAction
.
ID
)
{
return
this
.
instantiationService
.
createInstance
(
QuickFixActionItem
,
action
);
}
return
super
.
getActionItem
(
action
);
return
super
.
getActionItem
(
action
);
}
}
...
@@ -701,7 +705,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
...
@@ -701,7 +705,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
this
.
panelState
[
'
filter
'
]
=
this
.
filterAction
.
filterText
;
this
.
panelState
[
'
filter
'
]
=
this
.
filterAction
.
filterText
;
this
.
panelState
[
'
filterHistory
'
]
=
this
.
filterAction
.
filterHistory
;
this
.
panelState
[
'
filterHistory
'
]
=
this
.
filterAction
.
filterHistory
;
this
.
panelState
[
'
useFilesExclude
'
]
=
this
.
filterAction
.
useFilesExclude
;
this
.
panelState
[
'
useFilesExclude
'
]
=
this
.
filterAction
.
useFilesExclude
;
this
.
panelState
[
'
multiline
'
]
=
this
.
markersView
State
.
multiline
;
this
.
panelState
[
'
multiline
'
]
=
this
.
markersView
Model
.
multiline
;
super
.
saveState
();
super
.
saveState
();
}
}
...
@@ -709,7 +713,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
...
@@ -709,7 +713,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
public
dispose
():
void
{
public
dispose
():
void
{
super
.
dispose
();
super
.
dispose
();
this
.
tree
.
dispose
();
this
.
tree
.
dispose
();
this
.
markersView
State
.
dispose
();
this
.
markersView
Model
.
dispose
();
this
.
disposables
=
dispose
(
this
.
disposables
);
this
.
disposables
=
dispose
(
this
.
disposables
);
}
}
}
}
\ No newline at end of file
src/vs/workbench/parts/markers/electron-browser/markersPanelActions.ts
浏览文件 @
a920f227
...
@@ -29,7 +29,7 @@ import { Marker } from 'vs/workbench/parts/markers/electron-browser/markersModel
...
@@ -29,7 +29,7 @@ import { Marker } from 'vs/workbench/parts/markers/electron-browser/markersModel
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
isEqual
}
from
'
vs/base/common/resources
'
;
import
{
isEqual
}
from
'
vs/base/common/resources
'
;
import
{
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
FilterOptions
}
from
'
vs/workbench/parts/markers/electron-browser/markersFilterOptions
'
;
import
{
FilterOptions
}
from
'
vs/workbench/parts/markers/electron-browser/markersFilterOptions
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
...
@@ -297,12 +297,16 @@ export class QuickFixAction extends Action {
...
@@ -297,12 +297,16 @@ export class QuickFixAction extends Action {
private
updated
:
boolean
=
false
;
private
updated
:
boolean
=
false
;
private
disposables
:
IDisposable
[]
=
[];
private
disposables
:
IDisposable
[]
=
[];
private
_onShowQuickFixes
:
Emitter
<
void
>
=
new
Emitter
<
void
>
();
readonly
onShowQuickFixes
:
Event
<
void
>
=
this
.
_onShowQuickFixes
.
event
;
constructor
(
constructor
(
readonly
marker
:
Marker
,
readonly
marker
:
Marker
,
@
IModelService
modelService
:
IModelService
,
@
IModelService
modelService
:
IModelService
,
@
IMarkersWorkbenchService
private
readonly
markerWorkbenchService
:
IMarkersWorkbenchService
,
@
IMarkersWorkbenchService
private
readonly
markerWorkbenchService
:
IMarkersWorkbenchService
,
)
{
)
{
super
(
QuickFixAction
.
ID
,
Messages
.
MARKERS_PANEL_ACTION_TOOLTIP_QUICKFIX
,
'
markers-panel-action-quickfix
'
,
false
);
super
(
QuickFixAction
.
ID
,
Messages
.
MARKERS_PANEL_ACTION_TOOLTIP_QUICKFIX
,
'
markers-panel-action-quickfix
'
,
false
);
this
.
disposables
.
push
(
this
.
_onShowQuickFixes
);
if
(
modelService
.
getModel
(
this
.
marker
.
resource
))
{
if
(
modelService
.
getModel
(
this
.
marker
.
resource
))
{
this
.
update
();
this
.
update
();
}
else
{
}
else
{
...
@@ -314,6 +318,11 @@ export class QuickFixAction extends Action {
...
@@ -314,6 +318,11 @@ export class QuickFixAction extends Action {
}
}
}
}
run
():
Promise
<
void
>
{
this
.
_onShowQuickFixes
.
fire
();
return
Promise
.
resolve
();
}
private
update
():
void
{
private
update
():
void
{
if
(
!
this
.
updated
)
{
if
(
!
this
.
updated
)
{
this
.
markerWorkbenchService
.
hasQuickFixes
(
this
.
marker
).
then
(
hasFixes
=>
this
.
enabled
=
hasFixes
);
this
.
markerWorkbenchService
.
hasQuickFixes
(
this
.
marker
).
then
(
hasFixes
=>
this
.
enabled
=
hasFixes
);
...
@@ -338,13 +347,17 @@ export class QuickFixActionItem extends ActionItem {
...
@@ -338,13 +347,17 @@ export class QuickFixActionItem extends ActionItem {
public
onClick
(
event
:
DOM
.
EventLike
):
void
{
public
onClick
(
event
:
DOM
.
EventLike
):
void
{
DOM
.
EventHelper
.
stop
(
event
,
true
);
DOM
.
EventHelper
.
stop
(
event
,
true
);
this
.
showQuickFixes
();
}
public
showQuickFixes
():
void
{
if
(
!
this
.
element
)
{
if
(
!
this
.
element
)
{
return
;
return
;
}
}
const
elementPosition
=
DOM
.
getDomNodePagePosition
(
this
.
element
);
const
elementPosition
=
DOM
.
getDomNodePagePosition
(
this
.
element
);
this
.
markerWorkbenchService
.
getQuickFixActions
((
<
QuickFixAction
>
this
.
getAction
()).
marker
).
then
(
actions
=>
{
this
.
markerWorkbenchService
.
getQuickFixActions
((
<
QuickFixAction
>
this
.
getAction
()).
marker
).
then
(
actions
=>
{
this
.
contextMenuService
.
showContextMenu
({
this
.
contextMenuService
.
showContextMenu
({
getAnchor
:
()
=>
({
x
:
elementPosition
.
left
+
10
,
y
:
elementPosition
.
top
+
elementPosition
.
height
}),
getAnchor
:
()
=>
({
x
:
elementPosition
.
left
+
10
,
y
:
elementPosition
.
top
+
elementPosition
.
height
+
4
}),
getActions
:
()
=>
actions
getActions
:
()
=>
actions
});
});
});
});
...
...
src/vs/workbench/parts/markers/electron-browser/markersTreeViewer.ts
浏览文件 @
a920f227
...
@@ -16,8 +16,8 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
...
@@ -16,8 +16,8 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import
{
attachBadgeStyler
}
from
'
vs/platform/theme/common/styler
'
;
import
{
attachBadgeStyler
}
from
'
vs/platform/theme/common/styler
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IDisposable
,
dispose
,
Disposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
,
Disposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ActionBar
,
IActionItemProvider
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
ActionBar
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
QuickFixAction
}
from
'
vs/workbench/parts/markers/electron-browser/markersPanelActions
'
;
import
{
QuickFixAction
,
QuickFixActionItem
}
from
'
vs/workbench/parts/markers/electron-browser/markersPanelActions
'
;
import
{
ILabelService
}
from
'
vs/platform/label/common/label
'
;
import
{
ILabelService
}
from
'
vs/platform/label/common/label
'
;
import
{
dirname
}
from
'
vs/base/common/resources
'
;
import
{
dirname
}
from
'
vs/base/common/resources
'
;
import
{
IListVirtualDelegate
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
IListVirtualDelegate
}
from
'
vs/base/browser/ui/list/list
'
;
...
@@ -76,12 +76,12 @@ const enum TemplateId {
...
@@ -76,12 +76,12 @@ const enum TemplateId {
export
class
VirtualDelegate
implements
IListVirtualDelegate
<
TreeElement
>
{
export
class
VirtualDelegate
implements
IListVirtualDelegate
<
TreeElement
>
{
constructor
(
private
readonly
markersViewState
:
MarkersView
State
)
{
}
constructor
(
private
readonly
markersViewState
:
MarkersView
Model
)
{
}
getHeight
(
element
:
TreeElement
):
number
{
getHeight
(
element
:
TreeElement
):
number
{
if
(
element
instanceof
Marker
)
{
if
(
element
instanceof
Marker
)
{
const
view
State
=
this
.
markersViewState
.
getViewState
(
element
);
const
view
Model
=
this
.
markersViewState
.
getViewModel
(
element
);
const
noOfLines
=
!
view
State
||
viewState
.
multiline
?
element
.
lines
.
length
:
1
;
const
noOfLines
=
!
view
Model
||
viewModel
.
multiline
?
element
.
lines
.
length
:
1
;
return
noOfLines
*
22
;
return
noOfLines
*
22
;
}
}
return
22
;
return
22
;
...
@@ -201,8 +201,7 @@ export class FileResourceMarkersRenderer extends ResourceMarkersRenderer {
...
@@ -201,8 +201,7 @@ export class FileResourceMarkersRenderer extends ResourceMarkersRenderer {
export
class
MarkerRenderer
implements
ITreeRenderer
<
Marker
,
MarkerFilterData
,
IMarkerTemplateData
>
{
export
class
MarkerRenderer
implements
ITreeRenderer
<
Marker
,
MarkerFilterData
,
IMarkerTemplateData
>
{
constructor
(
constructor
(
private
readonly
markersViewState
:
MarkersViewState
,
private
readonly
markersViewState
:
MarkersViewModel
,
private
actionItemProvider
:
IActionItemProvider
,
@
IInstantiationService
protected
instantiationService
:
IInstantiationService
@
IInstantiationService
protected
instantiationService
:
IInstantiationService
)
{
}
)
{
}
...
@@ -210,7 +209,7 @@ export class MarkerRenderer implements ITreeRenderer<Marker, MarkerFilterData, I
...
@@ -210,7 +209,7 @@ export class MarkerRenderer implements ITreeRenderer<Marker, MarkerFilterData, I
renderTemplate
(
container
:
HTMLElement
):
IMarkerTemplateData
{
renderTemplate
(
container
:
HTMLElement
):
IMarkerTemplateData
{
const
data
:
IMarkerTemplateData
=
Object
.
create
(
null
);
const
data
:
IMarkerTemplateData
=
Object
.
create
(
null
);
data
.
markerWidget
=
new
MarkerWidget
(
container
,
this
.
markersViewState
,
this
.
actionItemProvider
,
this
.
instantiationService
);
data
.
markerWidget
=
new
MarkerWidget
(
container
,
this
.
markersViewState
,
this
.
instantiationService
);
return
data
;
return
data
;
}
}
...
@@ -234,14 +233,15 @@ class MarkerWidget extends Disposable {
...
@@ -234,14 +233,15 @@ class MarkerWidget extends Disposable {
constructor
(
constructor
(
parent
:
HTMLElement
,
parent
:
HTMLElement
,
private
readonly
markersViewState
:
MarkersViewState
,
private
readonly
markersViewModel
:
MarkersViewModel
,
actionItemProvider
:
IActionItemProvider
,
instantiationService
:
IInstantiationService
private
instantiationService
:
IInstantiationService
)
{
)
{
super
();
super
();
this
.
actionBar
=
this
.
_register
(
new
ActionBar
(
dom
.
append
(
parent
,
dom
.
$
(
'
.actions
'
)),
{
actionItemProvider
}));
this
.
actionBar
=
this
.
_register
(
new
ActionBar
(
dom
.
append
(
parent
,
dom
.
$
(
'
.actions
'
)),
{
actionItemProvider
:
(
action
)
=>
action
.
id
===
QuickFixAction
.
ID
?
instantiationService
.
createInstance
(
QuickFixActionItem
,
action
)
:
null
}));
this
.
icon
=
dom
.
append
(
parent
,
dom
.
$
(
'
.icon
'
));
this
.
icon
=
dom
.
append
(
parent
,
dom
.
$
(
'
.icon
'
));
this
.
multilineActionbar
=
this
.
_register
(
new
ActionBar
(
dom
.
append
(
parent
,
dom
.
$
(
'
.multiline-actions
'
))
,
{
actionItemProvider
}
));
this
.
multilineActionbar
=
this
.
_register
(
new
ActionBar
(
dom
.
append
(
parent
,
dom
.
$
(
'
.multiline-actions
'
))));
this
.
messageAndDetailsContainer
=
dom
.
append
(
parent
,
dom
.
$
(
'
.marker-message-details
'
));
this
.
messageAndDetailsContainer
=
dom
.
append
(
parent
,
dom
.
$
(
'
.marker-message-details
'
));
this
.
_register
(
toDisposable
(()
=>
this
.
disposables
=
dispose
(
this
.
disposables
)));
this
.
_register
(
toDisposable
(()
=>
this
.
disposables
=
dispose
(
this
.
disposables
)));
}
}
...
@@ -254,38 +254,47 @@ class MarkerWidget extends Disposable {
...
@@ -254,38 +254,47 @@ class MarkerWidget extends Disposable {
}
}
dom
.
clearNode
(
this
.
messageAndDetailsContainer
);
dom
.
clearNode
(
this
.
messageAndDetailsContainer
);
this
.
renderQuickfixActionbar
(
element
);
this
.
icon
.
className
=
'
marker-icon
'
+
MarkerWidget
.
iconClassNameFor
(
element
.
marker
);
this
.
icon
.
className
=
'
marker-icon
'
+
MarkerWidget
.
iconClassNameFor
(
element
.
marker
);
this
.
renderQuickfixActionbar
(
element
);
this
.
renderMultilineActionbar
(
element
);
this
.
renderMultilineActionbar
(
element
);
this
.
renderMessageAndDetails
(
element
,
filterData
);
this
.
renderMessageAndDetails
(
element
,
filterData
);
}
}
private
renderQuickfixActionbar
(
marker
:
Marker
):
void
{
private
renderQuickfixActionbar
(
marker
:
Marker
):
void
{
const
quickFixAction
=
this
.
instantiationService
.
createInstance
(
QuickFixAction
,
marker
);
const
viewModel
=
this
.
markersViewModel
.
getViewModel
(
marker
);
this
.
actionBar
.
push
([
quickFixAction
],
{
icon
:
true
,
label
:
false
});
if
(
viewModel
)
{
dom
.
toggleClass
(
this
.
icon
,
'
quickFix
'
,
quickFixAction
.
enabled
);
const
quickFixAction
=
viewModel
.
quickFixAction
;
quickFixAction
.
onDidChange
(({
enabled
})
=>
{
this
.
actionBar
.
push
([
quickFixAction
],
{
icon
:
true
,
label
:
false
});
if
(
!
isUndefinedOrNull
(
enabled
))
{
dom
.
toggleClass
(
this
.
icon
,
'
quickFix
'
,
quickFixAction
.
enabled
);
dom
.
toggleClass
(
this
.
icon
,
'
quickFix
'
,
enabled
);
quickFixAction
.
onDidChange
(({
enabled
})
=>
{
}
if
(
!
isUndefinedOrNull
(
enabled
))
{
},
this
,
this
.
disposables
);
dom
.
toggleClass
(
this
.
icon
,
'
quickFix
'
,
enabled
);
}
},
this
,
this
.
disposables
);
quickFixAction
.
onShowQuickFixes
(()
=>
{
const
quickFixActionItem
=
<
QuickFixActionItem
>
this
.
actionBar
.
items
[
0
];
if
(
quickFixActionItem
)
{
quickFixActionItem
.
showQuickFixes
();
}
},
this
,
this
.
disposables
);
}
}
}
private
renderMultilineActionbar
(
marker
:
Marker
):
void
{
private
renderMultilineActionbar
(
marker
:
Marker
):
void
{
const
view
State
=
this
.
markersViewState
.
getViewState
(
marker
);
const
view
Model
=
this
.
markersViewModel
.
getViewModel
(
marker
);
const
multiline
=
view
State
&&
viewState
.
multiline
;
const
multiline
=
view
Model
&&
viewModel
.
multiline
;
const
action
=
new
Action
(
'
problems.action.toggleMultiline
'
);
const
action
=
new
Action
(
'
problems.action.toggleMultiline
'
);
action
.
enabled
=
view
State
&&
marker
.
lines
.
length
>
1
;
action
.
enabled
=
view
Model
&&
marker
.
lines
.
length
>
1
;
action
.
tooltip
=
multiline
?
localize
(
'
single line
'
,
"
Show message in single line
"
)
:
localize
(
'
multi line
'
,
"
Show message in multiple lines
"
);
action
.
tooltip
=
multiline
?
localize
(
'
single line
'
,
"
Show message in single line
"
)
:
localize
(
'
multi line
'
,
"
Show message in multiple lines
"
);
action
.
class
=
multiline
?
'
octicon octicon-chevron-up
'
:
'
octicon octicon-chevron-down
'
;
action
.
class
=
multiline
?
'
octicon octicon-chevron-up
'
:
'
octicon octicon-chevron-down
'
;
action
.
run
=
()
=>
{
if
(
view
State
)
{
viewState
.
multiline
=
!
viewState
.
multiline
;
}
return
Promise
.
resolve
();
};
action
.
run
=
()
=>
{
if
(
view
Model
)
{
viewModel
.
multiline
=
!
viewModel
.
multiline
;
}
return
Promise
.
resolve
();
};
this
.
multilineActionbar
.
push
([
action
],
{
icon
:
true
,
label
:
false
});
this
.
multilineActionbar
.
push
([
action
],
{
icon
:
true
,
label
:
false
});
}
}
private
renderMessageAndDetails
(
element
:
Marker
,
filterData
:
MarkerFilterData
)
{
private
renderMessageAndDetails
(
element
:
Marker
,
filterData
:
MarkerFilterData
)
{
const
{
marker
,
lines
}
=
element
;
const
{
marker
,
lines
}
=
element
;
const
viewState
=
this
.
markersView
State
.
getViewState
(
element
);
const
viewState
=
this
.
markersView
Model
.
getViewModel
(
element
);
const
multiline
=
!
viewState
||
viewState
.
multiline
;
const
multiline
=
!
viewState
||
viewState
.
multiline
;
const
lineMatches
=
filterData
&&
filterData
.
lineMatches
||
[];
const
lineMatches
=
filterData
&&
filterData
.
lineMatches
||
[];
const
messageContainer
=
dom
.
append
(
this
.
messageAndDetailsContainer
,
dom
.
$
(
'
.marker-message
'
));
const
messageContainer
=
dom
.
append
(
this
.
messageAndDetailsContainer
,
dom
.
$
(
'
.marker-message
'
));
...
@@ -461,10 +470,17 @@ export class Filter implements ITreeFilter<TreeElement, FilterData> {
...
@@ -461,10 +470,17 @@ export class Filter implements ITreeFilter<TreeElement, FilterData> {
}
}
}
}
export
class
MarkerView
State
extends
Disposable
{
export
class
MarkerView
Model
extends
Disposable
{
private
readonly
_onDidChangeViewState
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
private
readonly
_onDidChange
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
readonly
onDidChangeViewState
:
Event
<
void
>
=
this
.
_onDidChangeViewState
.
event
;
readonly
onDidChange
:
Event
<
void
>
=
this
.
_onDidChange
.
event
;
constructor
(
private
readonly
marker
:
Marker
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
)
{
super
();
}
private
_multiline
:
boolean
=
true
;
private
_multiline
:
boolean
=
true
;
get
multiline
():
boolean
{
get
multiline
():
boolean
{
...
@@ -474,37 +490,48 @@ export class MarkerViewState extends Disposable {
...
@@ -474,37 +490,48 @@ export class MarkerViewState extends Disposable {
set
multiline
(
value
:
boolean
)
{
set
multiline
(
value
:
boolean
)
{
if
(
this
.
_multiline
!==
value
)
{
if
(
this
.
_multiline
!==
value
)
{
this
.
_multiline
=
value
;
this
.
_multiline
=
value
;
this
.
_onDidChangeViewState
.
fire
();
this
.
_onDidChange
.
fire
();
}
}
private
_quickFixAction
:
QuickFixAction
;
get
quickFixAction
():
QuickFixAction
{
if
(
!
this
.
_quickFixAction
)
{
this
.
_quickFixAction
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
QuickFixAction
,
this
.
marker
));
}
}
return
this
.
_quickFixAction
;
}
}
}
}
export
class
MarkersView
State
extends
Disposable
{
export
class
MarkersView
Model
extends
Disposable
{
private
readonly
_onDidChange
ViewState
:
Emitter
<
Marker
|
undefined
>
=
this
.
_register
(
new
Emitter
<
Marker
|
undefined
>
());
private
readonly
_onDidChange
:
Emitter
<
Marker
|
undefined
>
=
this
.
_register
(
new
Emitter
<
Marker
|
undefined
>
());
readonly
onDidChange
ViewState
:
Event
<
Marker
|
undefined
>
=
this
.
_onDidChangeViewStat
e
.
event
;
readonly
onDidChange
:
Event
<
Marker
|
undefined
>
=
this
.
_onDidChang
e
.
event
;
private
readonly
markersViewStates
:
Map
<
string
,
{
view
State
:
MarkerViewState
,
disposables
:
IDisposable
[]
}
>
=
new
Map
<
string
,
{
viewState
:
MarkerViewState
,
disposables
:
IDisposable
[]
}
>
();
private
readonly
markersViewStates
:
Map
<
string
,
{
view
Model
:
MarkerViewModel
,
disposables
:
IDisposable
[]
}
>
=
new
Map
<
string
,
{
viewModel
:
MarkerViewModel
,
disposables
:
IDisposable
[]
}
>
();
private
readonly
markersPerResource
:
Map
<
string
,
Marker
[]
>
=
new
Map
<
string
,
Marker
[]
>
();
private
readonly
markersPerResource
:
Map
<
string
,
Marker
[]
>
=
new
Map
<
string
,
Marker
[]
>
();
private
bulkUpdate
:
boolean
=
false
;
private
bulkUpdate
:
boolean
=
false
;
constructor
(
multiline
:
boolean
=
true
)
{
constructor
(
multiline
:
boolean
=
true
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
)
{
super
();
super
();
this
.
_multiline
=
multiline
;
this
.
_multiline
=
multiline
;
}
}
add
(
marker
:
Marker
):
void
{
add
(
marker
:
Marker
):
void
{
if
(
!
this
.
markersViewStates
.
has
(
marker
.
hash
))
{
if
(
!
this
.
markersViewStates
.
has
(
marker
.
hash
))
{
const
disposables
:
IDisposable
[]
=
[]
;
const
viewModel
=
this
.
instantiationService
.
createInstance
(
MarkerViewModel
,
marker
)
;
const
viewState
=
new
MarkerViewState
()
;
const
disposables
:
IDisposable
[]
=
[
viewModel
]
;
view
State
.
multiline
=
this
.
multiline
;
view
Model
.
multiline
=
this
.
multiline
;
view
State
.
onDidChangeViewStat
e
(()
=>
{
view
Model
.
onDidChang
e
(()
=>
{
if
(
!
this
.
bulkUpdate
)
{
if
(
!
this
.
bulkUpdate
)
{
this
.
_onDidChange
ViewState
.
fire
(
marker
);
this
.
_onDidChange
.
fire
(
marker
);
}
}
},
this
,
disposables
);
},
this
,
disposables
);
this
.
markersViewStates
.
set
(
marker
.
hash
,
{
view
State
,
disposables
});
this
.
markersViewStates
.
set
(
marker
.
hash
,
{
view
Model
,
disposables
});
const
markers
=
this
.
markersPerResource
.
get
(
marker
.
resource
.
toString
())
||
[];
const
markers
=
this
.
markersPerResource
.
get
(
marker
.
resource
.
toString
())
||
[];
markers
.
push
(
marker
);
markers
.
push
(
marker
);
...
@@ -524,9 +551,9 @@ export class MarkersViewState extends Disposable {
...
@@ -524,9 +551,9 @@ export class MarkersViewState extends Disposable {
this
.
markersPerResource
.
delete
(
resource
.
toString
());
this
.
markersPerResource
.
delete
(
resource
.
toString
());
}
}
getView
State
(
marker
:
Marker
):
MarkerViewState
|
null
{
getView
Model
(
marker
:
Marker
):
MarkerViewModel
|
null
{
const
value
=
this
.
markersViewStates
.
get
(
marker
.
hash
);
const
value
=
this
.
markersViewStates
.
get
(
marker
.
hash
);
return
value
?
value
.
view
State
:
null
;
return
value
?
value
.
view
Model
:
null
;
}
}
private
_multiline
:
boolean
=
true
;
private
_multiline
:
boolean
=
true
;
...
@@ -541,15 +568,15 @@ export class MarkersViewState extends Disposable {
...
@@ -541,15 +568,15 @@ export class MarkersViewState extends Disposable {
changed
=
true
;
changed
=
true
;
}
}
this
.
bulkUpdate
=
true
;
this
.
bulkUpdate
=
true
;
this
.
markersViewStates
.
forEach
(({
view
State
})
=>
{
this
.
markersViewStates
.
forEach
(({
view
Model
})
=>
{
if
(
view
State
.
multiline
!==
value
)
{
if
(
view
Model
.
multiline
!==
value
)
{
view
State
.
multiline
=
value
;
view
Model
.
multiline
=
value
;
changed
=
true
;
changed
=
true
;
}
}
});
});
this
.
bulkUpdate
=
false
;
this
.
bulkUpdate
=
false
;
if
(
changed
)
{
if
(
changed
)
{
this
.
_onDidChange
ViewState
.
fire
(
undefined
);
this
.
_onDidChange
.
fire
(
undefined
);
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录