Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
a51d518f
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a51d518f
编写于
3月 13, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Strict null check mainThreadComments
上级
1e8d0211
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
46 addition
and
26 deletion
+46
-26
src/vs/editor/common/modes.ts
src/vs/editor/common/modes.ts
+5
-5
src/vs/workbench/api/electron-browser/mainThreadComments.ts
src/vs/workbench/api/electron-browser/mainThreadComments.ts
+40
-20
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+1
-1
未找到文件。
src/vs/editor/common/modes.ts
浏览文件 @
a51d518f
...
...
@@ -1203,7 +1203,7 @@ export interface Command {
* @internal
*/
export
interface
CommentInfo
{
extensionId
:
string
;
extensionId
?
:
string
;
threads
:
CommentThread
[];
commentingRanges
?:
(
IRange
[]
|
CommentingRanges
);
reply
?:
Command
;
...
...
@@ -1266,8 +1266,8 @@ export interface CommentThread2 {
comments
:
Comment
[];
onDidChangeComments
:
Event
<
Comment
[]
>
;
collapsibleState
?:
CommentThreadCollapsibleState
;
input
:
CommentInput
;
onDidChangeInput
:
Event
<
CommentInput
>
;
input
:
CommentInput
|
undefined
;
onDidChangeInput
:
Event
<
CommentInput
|
undefined
>
;
acceptInputCommand
?:
Command
;
additionalCommands
:
Command
[];
onDidChangeAcceptInputCommand
:
Event
<
Command
>
;
...
...
@@ -1368,8 +1368,8 @@ export interface CommentThreadChangedEvent {
*/
export
interface
DocumentCommentProvider
{
provideDocumentComments
(
resource
:
URI
,
token
:
CancellationToken
):
Promise
<
CommentInfo
>
;
createNewCommentThread
(
resource
:
URI
,
range
:
Range
,
text
:
string
,
token
:
CancellationToken
):
Promise
<
CommentThread
>
;
replyToCommentThread
(
resource
:
URI
,
range
:
Range
,
thread
:
CommentThread
,
text
:
string
,
token
:
CancellationToken
):
Promise
<
CommentThread
>
;
createNewCommentThread
(
resource
:
URI
,
range
:
Range
,
text
:
string
,
token
:
CancellationToken
):
Promise
<
CommentThread
|
null
>
;
replyToCommentThread
(
resource
:
URI
,
range
:
Range
,
thread
:
CommentThread
,
text
:
string
,
token
:
CancellationToken
):
Promise
<
CommentThread
|
null
>
;
editComment
(
resource
:
URI
,
comment
:
Comment
,
text
:
string
,
token
:
CancellationToken
):
Promise
<
void
>
;
deleteComment
(
resource
:
URI
,
comment
:
Comment
,
token
:
CancellationToken
):
Promise
<
void
>
;
startDraft
?(
resource
:
URI
,
token
:
CancellationToken
):
Promise
<
void
>
;
...
...
src/vs/workbench/api/electron-browser/mainThreadComments.ts
浏览文件 @
a51d518f
...
...
@@ -127,7 +127,7 @@ export class MainThreadCommentThread implements modes.CommentThread2 {
}
get
acceptInputCommand
():
modes
.
Command
{
return
this
.
_acceptInputCommand
;
return
this
.
_acceptInputCommand
!
;
}
private
_onDidChangeAcceptInputCommand
=
new
Emitter
<
modes
.
Command
>
();
...
...
@@ -249,7 +249,7 @@ export class MainThreadCommentController {
}
deleteCommentThread
(
commentThreadHandle
:
number
)
{
let
thread
=
this
.
_threads
.
get
(
commentThreadHandle
);
let
thread
=
this
.
getKnownThread
(
commentThreadHandle
);
this
.
_threads
.
delete
(
commentThreadHandle
);
this
.
_commentService
.
updateComments
(
this
.
_uniqueId
,
{
...
...
@@ -263,7 +263,7 @@ export class MainThreadCommentController {
}
updateComments
(
commentThreadHandle
:
number
,
comments
:
modes
.
Comment
[])
{
let
thread
=
this
.
_threads
.
get
(
commentThreadHandle
);
let
thread
=
this
.
getKnownThread
(
commentThreadHandle
);
thread
.
comments
=
comments
;
this
.
_commentService
.
updateComments
(
this
.
_uniqueId
,
{
...
...
@@ -275,27 +275,27 @@ export class MainThreadCommentController {
}
updateAcceptInputCommand
(
commentThreadHandle
:
number
,
acceptInputCommand
:
modes
.
Command
)
{
let
thread
=
this
.
_threads
.
get
(
commentThreadHandle
);
let
thread
=
this
.
getKnownThread
(
commentThreadHandle
);
thread
.
acceptInputCommand
=
acceptInputCommand
;
}
updateAdditionalCommands
(
commentThreadHandle
:
number
,
additionalCommands
:
modes
.
Command
[])
{
let
thread
=
this
.
_threads
.
get
(
commentThreadHandle
);
let
thread
=
this
.
getKnownThread
(
commentThreadHandle
);
thread
.
additionalCommands
=
additionalCommands
;
}
updateCollapsibleState
(
commentThreadHandle
:
number
,
collapseState
:
modes
.
CommentThreadCollapsibleState
)
{
let
thread
=
this
.
_threads
.
get
(
commentThreadHandle
);
let
thread
=
this
.
getKnownThread
(
commentThreadHandle
);
thread
.
collapsibleState
=
collapseState
;
}
updateCommentThreadRange
(
commentThreadHandle
:
number
,
range
:
IRange
)
{
let
thread
=
this
.
_threads
.
get
(
commentThreadHandle
);
let
thread
=
this
.
getKnownThread
(
commentThreadHandle
);
thread
.
range
=
range
;
}
updateCommentThreadLabel
(
commentThreadHandle
:
number
,
label
:
string
)
{
let
thread
=
this
.
_threads
.
get
(
commentThreadHandle
);
let
thread
=
this
.
getKnownThread
(
commentThreadHandle
);
thread
.
label
=
label
;
}
...
...
@@ -309,11 +309,21 @@ export class MainThreadCommentController {
}
}
private
getKnownThread
(
commentThreadHandle
:
number
)
{
const
thread
=
this
.
_threads
.
get
(
commentThreadHandle
);
if
(
!
thread
)
{
throw
new
Error
(
'
unknown thread
'
);
}
return
thread
;
}
async
getDocumentComments
(
resource
:
URI
,
token
)
{
let
ret
=
[];
let
ret
:
modes
.
CommentThread2
[]
=
[];
for
(
let
thread
of
keys
(
this
.
_threads
))
{
if
(
this
.
_threads
.
get
(
thread
).
resource
===
resource
.
toString
())
{
ret
.
push
(
this
.
_threads
.
get
(
thread
));
const
commentThread
=
this
.
_threads
.
get
(
thread
)
!
;
if
(
commentThread
.
resource
===
resource
.
toString
())
{
ret
.
push
(
commentThread
);
}
}
...
...
@@ -338,9 +348,9 @@ export class MainThreadCommentController {
}
getAllComments
():
MainThreadCommentThread
[]
{
let
ret
=
[];
let
ret
:
MainThreadCommentThread
[]
=
[];
for
(
let
thread
of
keys
(
this
.
_threads
))
{
ret
.
push
(
this
.
_threads
.
get
(
thread
));
ret
.
push
(
this
.
_threads
.
get
(
thread
)
!
);
}
return
ret
;
...
...
@@ -540,17 +550,17 @@ export class MainThreadComments extends Disposable implements MainThreadComments
keys
(
this
.
_workspaceProviders
).
forEach
(
handle
=>
{
this
.
_proxy
.
$provideWorkspaceComments
(
handle
).
then
(
commentThreads
=>
{
if
(
commentThreads
)
{
const
providerId
=
this
.
_handlers
.
get
(
handle
);
const
providerId
=
this
.
getHandler
(
handle
);
this
.
_commentService
.
setWorkspaceComments
(
providerId
,
commentThreads
);
}
});
});
keys
(
this
.
_commentControllers
).
forEach
(
handle
=>
{
let
threads
=
this
.
_commentControllers
.
get
(
handle
).
getAllComments
();
let
threads
=
this
.
_commentControllers
.
get
(
handle
)
!
.
getAllComments
();
if
(
threads
.
length
)
{
const
providerId
=
this
.
_handlers
.
get
(
handle
);
const
providerId
=
this
.
getHandler
(
handle
);
this
.
_commentService
.
setWorkspaceComments
(
providerId
,
threads
);
}
});
...
...
@@ -564,6 +574,13 @@ export class MainThreadComments extends Disposable implements MainThreadComments
}
}
private
getHandler
(
handle
:
number
)
{
if
(
!
this
.
_handlers
.
has
(
handle
))
{
throw
new
Error
(
'
Unknown handler
'
);
}
return
this
.
_handlers
.
get
(
handle
)
!
;
}
$registerWorkspaceCommentProvider
(
handle
:
number
,
extensionId
:
ExtensionIdentifier
):
void
{
this
.
_workspaceProviders
.
set
(
handle
,
undefined
);
...
...
@@ -611,7 +628,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
$unregisterDocumentCommentProvider
(
handle
:
number
):
void
{
this
.
_documentProviders
.
delete
(
handle
);
const
handlerId
=
this
.
_handlers
.
get
(
handle
);
const
handlerId
=
this
.
getHandler
(
handle
);
this
.
_commentService
.
unregisterDataProvider
(
handlerId
);
this
.
_handlers
.
delete
(
handle
);
}
...
...
@@ -627,14 +644,14 @@ export class MainThreadComments extends Disposable implements MainThreadComments
}
}
const
handlerId
=
this
.
_handlers
.
get
(
handle
);
const
handlerId
=
this
.
getHandler
(
handle
);
this
.
_commentService
.
removeWorkspaceComments
(
handlerId
);
this
.
_handlers
.
delete
(
handle
);
}
$onDidCommentThreadsChange
(
handle
:
number
,
event
:
modes
.
CommentThreadChangedEvent
)
{
// notify comment service
const
providerId
=
this
.
_handlers
.
get
(
handle
);
const
providerId
=
this
.
getHandler
(
handle
);
this
.
_commentService
.
updateComments
(
providerId
,
event
);
}
...
...
@@ -658,7 +675,10 @@ export class MainThreadComments extends Disposable implements MainThreadComments
async
provideWorkspaceComments
():
Promise
<
modes
.
CommentThread
[]
>
{
const
result
:
modes
.
CommentThread
[]
=
[];
for
(
const
handle
of
keys
(
this
.
_workspaceProviders
))
{
result
.
push
(...
await
this
.
_proxy
.
$provideWorkspaceComments
(
handle
));
const
result
=
await
this
.
_proxy
.
$provideWorkspaceComments
(
handle
);
if
(
Array
.
isArray
(
result
))
{
result
.
push
(...
result
);
}
}
return
result
;
}
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
a51d518f
...
...
@@ -1106,7 +1106,7 @@ export interface ExtHostProgressShape {
export
interface
ExtHostCommentsShape
{
$provideDocumentComments
(
handle
:
number
,
document
:
UriComponents
):
Promise
<
modes
.
CommentInfo
>
;
$createNewCommentThread
(
handle
:
number
,
document
:
UriComponents
,
range
:
IRange
,
text
:
string
):
Promise
<
modes
.
CommentThread
|
null
>
;
$onCommentWidgetInputChange
(
commentControllerHandle
:
number
,
input
:
string
):
Promise
<
number
|
undefined
>
;
$onCommentWidgetInputChange
(
commentControllerHandle
:
number
,
input
:
string
|
undefined
):
Promise
<
number
|
undefined
>
;
$provideCommentingRanges
(
commentControllerHandle
:
number
,
uriComponents
:
UriComponents
,
token
:
CancellationToken
):
Promise
<
IRange
[]
|
undefined
>
;
$createNewCommentWidgetCallback
(
commentControllerHandle
:
number
,
uriComponents
:
UriComponents
,
range
:
IRange
,
token
:
CancellationToken
):
void
;
$replyToCommentThread
(
handle
:
number
,
document
:
UriComponents
,
range
:
IRange
,
commentThread
:
modes
.
CommentThread
,
text
:
string
):
Promise
<
modes
.
CommentThread
|
null
>
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录