Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
3dd856a8
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,发现更多精彩内容 >>
提交
3dd856a8
编写于
7月 16, 2018
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #52627
上级
22e16c76
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
80 addition
and
27 deletion
+80
-27
src/vs/editor/contrib/codeAction/codeActionTrigger.ts
src/vs/editor/contrib/codeAction/codeActionTrigger.ts
+1
-0
src/vs/workbench/parts/markers/electron-browser/markersModel.ts
.../workbench/parts/markers/electron-browser/markersModel.ts
+39
-18
src/vs/workbench/parts/markers/electron-browser/markersTreeController.ts
...h/parts/markers/electron-browser/markersTreeController.ts
+14
-9
src/vs/workbench/parts/markers/electron-browser/markersTreeViewer.ts
...bench/parts/markers/electron-browser/markersTreeViewer.ts
+9
-0
src/vs/workbench/parts/markers/electron-browser/media/lightbulb-dark.svg
...h/parts/markers/electron-browser/media/lightbulb-dark.svg
+1
-0
src/vs/workbench/parts/markers/electron-browser/media/lightbulb.svg
...kbench/parts/markers/electron-browser/media/lightbulb.svg
+1
-0
src/vs/workbench/parts/markers/electron-browser/media/markers.css
...orkbench/parts/markers/electron-browser/media/markers.css
+15
-0
未找到文件。
src/vs/editor/contrib/codeAction/codeActionTrigger.ts
浏览文件 @
3dd856a8
...
...
@@ -9,6 +9,7 @@ export class CodeActionKind {
private
static
readonly
sep
=
'
.
'
;
public
static
readonly
Empty
=
new
CodeActionKind
(
''
);
public
static
readonly
QuickFix
=
new
CodeActionKind
(
'
quickfix
'
);
public
static
readonly
Refactor
=
new
CodeActionKind
(
'
refactor
'
);
public
static
readonly
Source
=
new
CodeActionKind
(
'
source
'
);
public
static
readonly
SourceOrganizeImports
=
new
CodeActionKind
(
'
source.organizeImports
'
);
...
...
src/vs/workbench/parts/markers/electron-browser/markersModel.ts
浏览文件 @
3dd856a8
...
...
@@ -7,7 +7,7 @@
import
*
as
paths
from
'
vs/base/common/paths
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
Range
,
IRange
}
from
'
vs/editor/common/core/range
'
;
import
{
IMarker
,
MarkerSeverity
,
IRelatedInformation
}
from
'
vs/platform/markers/common/markers
'
;
import
{
IMarker
,
MarkerSeverity
,
IRelatedInformation
,
IMarkerData
}
from
'
vs/platform/markers/common/markers
'
;
import
{
IFilter
,
IMatch
,
or
,
matchesContiguousSubString
,
matchesPrefix
,
matchesFuzzy
}
from
'
vs/base/common/filters
'
;
import
Messages
from
'
vs/workbench/parts/markers/electron-browser/messages
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
...
...
@@ -18,7 +18,7 @@ import * as strings from 'vs/base/common/strings';
import
{
ITextModelService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
CodeAction
}
from
'
vs/editor/common/modes
'
;
import
{
getCodeActions
}
from
'
vs/editor/contrib/codeAction/codeAction
'
;
import
{
CodeAction
Trigger
}
from
'
vs/editor/contrib/codeAction/codeActionTrigger
'
;
import
{
CodeAction
Kind
}
from
'
vs/editor/contrib/codeAction/codeActionTrigger
'
;
function
compareUris
(
a
:
URI
,
b
:
URI
)
{
if
(
a
.
toString
()
<
b
.
toString
())
{
...
...
@@ -38,6 +38,7 @@ export class ResourceMarkers extends NodeWithId {
private
_name
:
string
=
null
;
private
_path
:
string
=
null
;
private
_allFixesPromise
:
Promise
<
CodeAction
[]
>
;
markers
:
Marker
[]
=
[];
isExcluded
:
boolean
=
false
;
...
...
@@ -46,7 +47,8 @@ export class ResourceMarkers extends NodeWithId {
uriMatches
:
IMatch
[]
=
[];
constructor
(
readonly
uri
:
URI
readonly
uri
:
URI
,
private
textModelService
:
ITextModelService
)
{
super
(
uri
.
toString
());
}
...
...
@@ -65,6 +67,37 @@ export class ResourceMarkers extends NodeWithId {
return
this
.
_name
;
}
public
getFixes
(
marker
:
Marker
):
Promise
<
CodeAction
[]
>
{
return
this
.
_getFixes
(
new
Range
(
marker
.
range
.
startLineNumber
,
marker
.
range
.
startColumn
,
marker
.
range
.
endLineNumber
,
marker
.
range
.
endColumn
));
}
public
async
hasFixes
(
marker
:
Marker
):
Promise
<
boolean
>
{
if
(
!
this
.
_allFixesPromise
)
{
this
.
_allFixesPromise
=
this
.
_getFixes
();
}
const
allFixes
=
await
this
.
_allFixesPromise
;
if
(
allFixes
.
length
)
{
const
markerKey
=
IMarkerData
.
makeKey
(
marker
.
raw
);
for
(
const
fix
of
allFixes
)
{
if
(
fix
.
diagnostics
&&
fix
.
diagnostics
.
some
(
d
=>
IMarkerData
.
makeKey
(
d
)
===
markerKey
))
{
return
true
;
}
}
}
return
false
;
}
private
async
_getFixes
(
range
?:
Range
):
Promise
<
CodeAction
[]
>
{
const
modelReference
=
await
this
.
textModelService
.
createModelReference
(
this
.
uri
);
if
(
modelReference
)
{
const
model
=
modelReference
.
object
.
textEditorModel
;
const
codeActions
=
await
getCodeActions
(
model
,
range
?
range
:
model
.
getFullModelRange
(),
{
type
:
'
manual
'
,
filter
:
{
kind
:
CodeActionKind
.
QuickFix
}
});
modelReference
.
dispose
();
return
codeActions
;
}
return
[];
}
static
compare
(
a
:
ResourceMarkers
,
b
:
ResourceMarkers
):
number
{
let
[
firstMarkerOfA
]
=
a
.
markers
;
let
[
firstMarkerOfB
]
=
b
.
markers
;
...
...
@@ -88,8 +121,7 @@ export class Marker extends NodeWithId {
constructor
(
id
:
string
,
readonly
raw
:
IMarker
,
private
textModelService
:
ITextModelService
readonly
raw
:
IMarker
)
{
super
(
id
);
}
...
...
@@ -102,17 +134,6 @@ export class Marker extends NodeWithId {
return
this
.
raw
;
}
public
async
getCodeActions
(
trigger
:
CodeActionTrigger
):
Promise
<
CodeAction
[]
>
{
const
modelReference
=
await
this
.
textModelService
.
createModelReference
(
this
.
resource
);
if
(
modelReference
)
{
const
model
=
modelReference
.
object
.
textEditorModel
;
const
codeActions
=
await
getCodeActions
(
model
,
new
Range
(
this
.
range
.
startLineNumber
,
this
.
range
.
startColumn
,
this
.
range
.
endLineNumber
,
this
.
range
.
endColumn
),
trigger
);
modelReference
.
dispose
();
return
codeActions
;
}
return
[];
}
public
toString
():
string
{
return
JSON
.
stringify
({
...
this
.
raw
,
...
...
@@ -289,11 +310,11 @@ export class MarkersModel {
private
createResource
(
uri
:
URI
,
rawMarkers
:
IMarker
[]):
ResourceMarkers
{
const
markers
:
Marker
[]
=
[];
const
resource
=
new
ResourceMarkers
(
uri
);
const
resource
=
new
ResourceMarkers
(
uri
,
this
.
textModelService
);
this
.
updateResource
(
resource
);
rawMarkers
.
forEach
((
rawMarker
,
index
)
=>
{
const
marker
=
new
Marker
(
uri
.
toString
()
+
index
,
rawMarker
,
this
.
textModelService
);
const
marker
=
new
Marker
(
uri
.
toString
()
+
index
,
rawMarker
);
if
(
rawMarker
.
relatedInformation
)
{
const
groupedByResource
=
groupBy
(
rawMarker
.
relatedInformation
,
MarkersModel
.
_compareMarkersByUri
);
groupedByResource
.
sort
((
a
,
b
)
=>
compareUris
(
a
[
0
].
resource
,
b
[
0
].
resource
));
...
...
src/vs/workbench/parts/markers/electron-browser/markersTreeController.ts
浏览文件 @
3dd856a8
...
...
@@ -7,7 +7,7 @@
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
*
as
mouse
from
'
vs/base/browser/mouseEvent
'
;
import
*
as
tree
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
MarkersModel
,
Marker
}
from
'
vs/workbench/parts/markers/electron-browser/markersModel
'
;
import
{
MarkersModel
,
Marker
,
ResourceMarkers
}
from
'
vs/workbench/parts/markers/electron-browser/markersModel
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IMenuService
,
MenuId
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IAction
,
Action
}
from
'
vs/base/common/actions
'
;
...
...
@@ -19,6 +19,7 @@ import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService';
import
{
applyCodeAction
}
from
'
vs/editor/contrib/codeAction/codeActionCommands
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IEditorService
,
ACTIVE_GROUP
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
localize
}
from
'
vs/nls
'
;
export
class
Controller
extends
WorkbenchTreeController
{
...
...
@@ -79,10 +80,14 @@ export class Controller extends WorkbenchTreeController {
private
async
_getMenuActions
(
tree
:
WorkbenchTree
,
element
:
any
):
Promise
<
IAction
[]
>
{
const
result
:
IAction
[]
=
[];
const
quickFixActions
=
await
this
.
_getQuickFixActions
(
element
);
if
(
quickFixActions
.
length
)
{
result
.
push
(...
quickFixActions
);
if
(
element
instanceof
Marker
)
{
const
quickFixActions
=
await
this
.
_getQuickFixActions
(
tree
,
element
);
if
(
quickFixActions
.
length
)
{
result
.
push
(...
quickFixActions
);
}
else
{
result
.
push
(
new
Action
(
'
problems.no.fixes
'
,
localize
(
'
no fixes available
'
,
"
No fixes available
"
),
void
0
,
false
));
}
result
.
push
(
new
Separator
());
}
...
...
@@ -100,9 +105,10 @@ export class Controller extends WorkbenchTreeController {
return
result
;
}
private
async
_getQuickFixActions
(
element
:
any
):
Promise
<
IAction
[]
>
{
if
(
element
instanceof
Marker
)
{
const
codeActions
=
await
element
.
getCodeActions
({
type
:
'
manual
'
});
private
async
_getQuickFixActions
(
tree
:
WorkbenchTree
,
element
:
Marker
):
Promise
<
IAction
[]
>
{
const
parent
=
tree
.
getNavigator
(
element
).
parent
();
if
(
parent
instanceof
ResourceMarkers
)
{
const
codeActions
=
await
parent
.
getFixes
(
element
);
return
codeActions
.
map
(
codeAction
=>
new
Action
(
codeAction
.
command
?
codeAction
.
command
.
id
:
codeAction
.
title
,
codeAction
.
title
,
...
...
@@ -112,9 +118,8 @@ export class Controller extends WorkbenchTreeController {
return
this
.
openFileAtMarker
(
element
)
.
then
(()
=>
applyCodeAction
(
codeAction
,
this
.
bulkEditService
,
this
.
commandService
));
}));
}
return
Promise
.
resolve
([])
;
return
[]
;
}
public
openFileAtMarker
(
element
:
Marker
):
TPromise
<
void
>
{
...
...
src/vs/workbench/parts/markers/electron-browser/markersTreeViewer.ts
浏览文件 @
3dd856a8
...
...
@@ -31,6 +31,7 @@ interface IResourceMarkersTemplateData {
interface
IMarkerTemplateData
{
icon
:
HTMLElement
;
lightbulb
:
HTMLElement
;
source
:
HighlightedLabel
;
description
:
HighlightedLabel
;
lnCol
:
HTMLElement
;
...
...
@@ -179,6 +180,7 @@ export class Renderer implements IRenderer {
private
renderMarkerTemplate
(
container
:
HTMLElement
):
IMarkerTemplateData
{
const
data
:
IMarkerTemplateData
=
Object
.
create
(
null
);
data
.
icon
=
dom
.
append
(
container
,
dom
.
$
(
'
.marker-icon
'
));
data
.
lightbulb
=
dom
.
append
(
container
,
dom
.
$
(
'
.icon.lightbulb
'
));
data
.
source
=
new
HighlightedLabel
(
dom
.
append
(
container
,
dom
.
$
(
''
)));
data
.
description
=
new
HighlightedLabel
(
dom
.
append
(
container
,
dom
.
$
(
'
.marker-description
'
)));
data
.
lnCol
=
dom
.
append
(
container
,
dom
.
$
(
'
span.marker-line
'
));
...
...
@@ -208,7 +210,9 @@ export class Renderer implements IRenderer {
private
renderMarkerElement
(
tree
:
ITree
,
element
:
Marker
,
templateData
:
IMarkerTemplateData
)
{
let
marker
=
element
.
raw
;
templateData
.
icon
.
className
=
'
icon
'
+
Renderer
.
iconClassNameFor
(
marker
);
dom
.
removeClass
(
templateData
.
lightbulb
,
'
quick-fixes
'
);
templateData
.
source
.
set
(
marker
.
source
,
element
.
sourceMatches
);
dom
.
toggleClass
(
templateData
.
source
.
element
,
'
marker-source
'
,
!!
marker
.
source
);
...
...
@@ -217,6 +221,11 @@ export class Renderer implements IRenderer {
templateData
.
description
.
element
.
title
=
marker
.
message
;
templateData
.
lnCol
.
textContent
=
Messages
.
MARKERS_PANEL_AT_LINE_COL_NUMBER
(
marker
.
startLineNumber
,
marker
.
startColumn
);
const
parent
=
tree
.
getNavigator
(
element
).
parent
();
if
(
parent
instanceof
ResourceMarkers
)
{
parent
.
hasFixes
(
element
).
then
(
hasFixes
=>
dom
.
toggleClass
(
templateData
.
lightbulb
,
'
quick-fixes
'
,
hasFixes
));
}
}
private
renderRelatedInfoElement
(
tree
:
ITree
,
element
:
RelatedInformation
,
templateData
:
IRelatedInformationTemplateData
)
{
...
...
src/vs/workbench/parts/markers/electron-browser/media/lightbulb-dark.svg
0 → 100644
浏览文件 @
3dd856a8
<svg
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 16 16"
enable-background=
"new 0 0 16 16"
height=
"16"
width=
"16"
><path
fill=
"#1E1E1E"
d=
"M13.5 4.2C13.1 2.1 10.8 0 9.3 0H6.7c-.4 0-.6.2-.6.2C4 .8 2.5 2.7 2.5 4.9c0 .5-.1 2.3 1.7 3.8.5.5 1.2 2 1.3 2.4v3.3L7.1 16h2l1.5-1.6V11c.1-.4.8-1.9 1.3-2.3 1.1-.9 1.5-1.9 1.6-2.7V4.2z"
/><g><g
fill=
"#C5C5C5"
><path
d=
"M6.5 12h3v1h-3zM7.5 15h1.1l.9-1h-3z"
/></g><path
fill=
"#DDB204"
d=
"M12.6 5c0-2.3-1.8-4.1-4.1-4.1-.1 0-1.4.1-1.4.1-2.1.3-3.7 2-3.7 4 0 .1-.2 1.6 1.4 3 .7.7 1.5 2.4 1.6 2.9l.1.1h3l.1-.2c.1-.5.9-2.2 1.6-2.9 1.6-1.3 1.4-2.8 1.4-2.9zm-3 1l-.5 3h-.6V6c1.1 0 .9-1 .9-1H6.5v.1c0 .2.1.9 1 .9v3H7l-.2-.7L6.5 6c-.7 0-.9-.4-1-.7v-.4c0-.8.9-.9.9-.9h3.1s1 .1 1 1c0 0 .1 1-.9 1z"
/></g><path
fill=
"#252526"
d=
"M10.5 5c0-.9-1-1-1-1H6.4s-.9.1-.9.9v.4c0 .3.3.7.9.7l.4 2.3.2.7h.5V6c-1 0-1-.7-1-.9V5h3s.1 1-.9 1v3h.6l.5-3c.9 0 .8-1 .8-1z"
/></svg>
\ No newline at end of file
src/vs/workbench/parts/markers/electron-browser/media/lightbulb.svg
0 → 100644
浏览文件 @
3dd856a8
<svg
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 16 16"
enable-background=
"new 0 0 16 16"
height=
"16"
width=
"16"
><path
fill=
"#F6F6F6"
d=
"M13.5 4.2C13.1 2.1 10.8 0 9.3 0H6.7c-.4 0-.6.2-.6.2C4 .8 2.5 2.7 2.5 4.9c0 .5-.1 2.3 1.7 3.8.5.5 1.2 2 1.3 2.4v3.3L7.1 16h2l1.5-1.6V11c.1-.4.8-1.9 1.3-2.3 1.1-.9 1.5-1.9 1.6-2.7V4.2z"
/><g><g
fill=
"#848484"
><path
d=
"M6.5 12h3v1h-3zM7.5 15h1.1l.9-1h-3z"
/></g><path
fill=
"#fc0"
d=
"M12.6 5c0-2.3-1.8-4.1-4.1-4.1-.1 0-1.4.1-1.4.1-2.1.3-3.7 2-3.7 4 0 .1-.2 1.6 1.4 3 .7.7 1.5 2.4 1.6 2.9l.1.1h3l.1-.2c.1-.5.9-2.2 1.6-2.9 1.6-1.3 1.4-2.8 1.4-2.9zm-3 1l-.5 3h-.6V6c1.1 0 .9-1 .9-1H6.5v.1c0 .2.1.9 1 .9v3H7l-.2-.7L6.5 6c-.7 0-.9-.4-1-.7v-.4c0-.8.9-.9.9-.9h3.1s1 .1 1 1c0 0 .1 1-.9 1z"
/></g><path
fill=
"#F0EFF1"
d=
"M10.5 5c0-.9-1-1-1-1H6.4s-.9.1-.9.9v.4c0 .3.3.7.9.7l.4 2.3.2.7h.5V6c-1 0-1-.7-1-.9V5h3s.1 1-.9 1v3h.6l.5-3c.9 0 .8-1 .8-1z"
/></svg>
\ No newline at end of file
src/vs/workbench/parts/markers/electron-browser/media/markers.css
浏览文件 @
3dd856a8
...
...
@@ -164,4 +164,19 @@
.vs-dark
.markers-panel
.icon.info
{
background
:
url('status-info-inverse.svg')
center
center
no-repeat
;
}
.markers-panel
.icon.lightbulb
{
background
:
url('lightbulb.svg')
center
/
40%
no-repeat
;
position
:
absolute
;
width
:
24px
;
height
:
30px
;
}
.vs-dark
.markers-panel
.icon.lightbulb
{
background
:
url('lightbulb-dark.svg')
center
/
40%
no-repeat
;
}
.markers-panel
.icon.lightbulb
:not
(
.quick-fixes
)
{
display
:
none
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录