Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
7a17eb72
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
7a17eb72
编写于
3月 26, 2020
作者:
C
CyrusNajmabadi
提交者:
GitHub
3月 26, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #42821 from CyrusNajmabadi/legacyTodo
Add back in a legacy todo-comment entrypoint for TypeScript.
上级
79cad10b
0370934b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
58 addition
and
9 deletion
+58
-9
src/Features/Core/Portable/TodoComments/ITodoCommentService.cs
...eatures/Core/Portable/TodoComments/ITodoCommentService.cs
+6
-2
src/VisualStudio/Core/Def/ExternalAccess/VSTypeScript/Api/IVsTypeScriptTodoCommentService.cs
...ccess/VSTypeScript/Api/IVsTypeScriptTodoCommentService.cs
+22
-0
src/VisualStudio/Core/Def/Implementation/TodoComments/IVisualStudioTodoCommentsService.cs
...entation/TodoComments/IVisualStudioTodoCommentsService.cs
+0
-1
src/VisualStudio/Core/Def/Implementation/TodoComments/VisualStudioTodoCommentsService.cs
...mentation/TodoComments/VisualStudioTodoCommentsService.cs
+30
-6
未找到文件。
src/Features/Core/Portable/TodoComments/ITodoCommentService.cs
浏览文件 @
7a17eb72
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System
;
using
System.Collections.Immutable
;
using
System.Threading
;
...
...
@@ -29,12 +31,14 @@ public TodoComment(TodoCommentDescriptor descriptor, string message, int positio
}
internal
TodoCommentData
CreateSerializableData
(
Document
document
,
SourceText
text
,
SyntaxTree
tree
)
Document
document
,
SourceText
text
,
SyntaxTree
?
tree
)
{
// make sure given position is within valid text range.
var
textSpan
=
new
TextSpan
(
Math
.
Min
(
text
.
Length
,
Math
.
Max
(
0
,
Position
)),
0
);
var
location
=
tree
.
GetLocation
(
textSpan
);
var
location
=
tree
==
null
?
Location
.
Create
(
document
.
FilePath
!,
textSpan
,
text
.
Lines
.
GetLinePositionSpan
(
textSpan
))
:
tree
.
GetLocation
(
textSpan
);
var
originalLineInfo
=
location
.
GetLineSpan
();
var
mappedLineInfo
=
location
.
GetMappedLineSpan
();
...
...
src/VisualStudio/Core/Def/ExternalAccess/VSTypeScript/Api/IVsTypeScriptTodoCommentService.cs
0 → 100644
浏览文件 @
7a17eb72
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using
System.Collections.Immutable
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.TodoComments
;
namespace
Microsoft.VisualStudio.LanguageServices.ExternalAccess.VSTypeScript.Api
{
internal
interface
IVsTypeScriptTodoCommentService
{
/// <summary>
/// Legacy entry-point to allow existing in-process TypeScript language service to report todo comments.
/// TypeScript is responsible for determining when to compute todo comments (for example, on <see
/// cref="Workspace.WorkspaceChanged"/>). This can be called on any thread.
/// </summary>
Task
ReportTodoCommentsAsync
(
Document
document
,
ImmutableArray
<
TodoComment
>
todoComments
,
CancellationToken
cancellationToken
);
}
}
src/VisualStudio/Core/Def/Implementation/TodoComments/IVisualStudioTodoCommentsService.cs
浏览文件 @
7a17eb72
...
...
@@ -5,7 +5,6 @@
#
nullable
enable
using
System.Threading
;
using
Microsoft.CodeAnalysis.Host
;
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.TodoComments
{
...
...
src/VisualStudio/Core/Def/Implementation/TodoComments/VisualStudioTodoCommentsService.cs
浏览文件 @
7a17eb72
...
...
@@ -21,14 +21,20 @@
using
Microsoft.CodeAnalysis.PooledObjects
;
using
Microsoft.CodeAnalysis.Remote
;
using
Microsoft.CodeAnalysis.TodoComments
;
using
Microsoft.VisualStudio.LanguageServices.ExternalAccess.VSTypeScript.Api
;
using
Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
;
using
Roslyn.Utilities
;
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.TodoComments
{
[
Export
(
typeof
(
IVisualStudioTodoCommentsService
))]
[
Export
(
typeof
(
IVsTypeScriptTodoCommentService
))]
internal
class
VisualStudioTodoCommentsService
:
ForegroundThreadAffinitizedObject
,
IVisualStudioTodoCommentsService
,
ITodoCommentsListener
,
ITodoListProvider
:
ForegroundThreadAffinitizedObject
,
IVisualStudioTodoCommentsService
,
ITodoCommentsListener
,
ITodoListProvider
,
IVsTypeScriptTodoCommentService
{
private
readonly
VisualStudioWorkspaceImpl
_workspace
;
private
readonly
EventListenerTracker
<
ITodoListProvider
>
_eventListenerTracker
;
...
...
@@ -181,20 +187,38 @@ public ImmutableArray<TodoCommentData> GetTodoItems(Workspace workspace, Documen
/// <summary>
/// Callback from the OOP service back into us.
/// </summary>
public
Task
ReportTodoCommentDataAsync
(
DocumentId
documentId
,
ImmutableArray
<
TodoCommentData
>
infos
,
CancellationToken
cancellationToken
)
public
Task
OnDocumentRemovedAsync
(
DocumentId
documentId
,
CancellationToken
cancellationToken
)
{
Contract
.
ThrowIfNull
(
_workQueue
);
_workQueue
.
AddWork
(
new
DocumentAndComments
(
documentId
,
infos
));
_documentToInfos
.
TryRemove
(
documentId
,
out
_
);
return
Task
.
CompletedTask
;
}
/// <summary>
/// Callback from the OOP service back into us.
/// </summary>
public
Task
OnDocumentRemovedAsync
(
DocumentId
documentId
,
CancellationToken
cancellationToken
)
public
Task
ReportTodoCommentDataAsync
(
DocumentId
documentId
,
ImmutableArray
<
TodoCommentData
>
infos
,
CancellationToken
cancellationToken
)
{
_documentToInfos
.
TryRemove
(
documentId
,
out
_
);
Contract
.
ThrowIfNull
(
_workQueue
);
_workQueue
.
AddWork
(
new
DocumentAndComments
(
documentId
,
infos
));
return
Task
.
CompletedTask
;
}
/// <inheritdoc cref="IVsTypeScriptTodoCommentService.ReportTodoCommentsAsync(Document, ImmutableArray{TodoComment}, CancellationToken)"/>
async
Task
IVsTypeScriptTodoCommentService
.
ReportTodoCommentsAsync
(
Document
document
,
ImmutableArray
<
TodoComment
>
todoComments
,
CancellationToken
cancellationToken
)
{
using
var
_
=
ArrayBuilder
<
TodoCommentData
>.
GetInstance
(
out
var
converted
);
var
text
=
await
document
.
GetTextAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
tree
=
document
.
SupportsSyntaxTree
?
await
document
.
GetSyntaxTreeAsync
(
cancellationToken
).
ConfigureAwait
(
false
)
:
null
;
foreach
(
var
comment
in
todoComments
)
converted
.
Add
(
comment
.
CreateSerializableData
(
document
,
text
,
tree
));
await
ReportTodoCommentDataAsync
(
document
.
Id
,
converted
.
ToImmutable
(),
cancellationToken
).
ConfigureAwait
(
false
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录