Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
891b1805
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,发现更多精彩内容 >>
提交
891b1805
编写于
3月 06, 2020
作者:
A
Allison Chou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Get text synchronously instead
上级
712f475b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
20 deletion
+16
-20
src/EditorFeatures/Core.Wpf/InlineRename/AbstractEditorInlineRenameService.SymbolRenameInfo.cs
...ame/AbstractEditorInlineRenameService.SymbolRenameInfo.cs
+15
-9
src/EditorFeatures/Core.Wpf/InlineRename/AbstractEditorInlineRenameService.cs
...ore.Wpf/InlineRename/AbstractEditorInlineRenameService.cs
+1
-11
未找到文件。
src/EditorFeatures/Core.Wpf/InlineRename/AbstractEditorInlineRenameService.SymbolRenameInfo.cs
浏览文件 @
891b1805
...
...
@@ -37,8 +37,6 @@ private partial class SymbolInlineRenameInfo : IInlineRenameInfoWithFileRename
private
Task
<
RenameLocations
>
_underlyingFindRenameLocationsTask
;
private
readonly
string
_triggerSpanText
;
/// <summary>
/// Whether or not we shortened the trigger span (say because we were renaming an attribute,
/// and we didn't select the 'Attribute' portion of the name).
...
...
@@ -49,7 +47,7 @@ private partial class SymbolInlineRenameInfo : IInlineRenameInfoWithFileRename
public
string
LocalizedErrorMessage
{
get
;
}
public
TextSpan
TriggerSpan
{
get
;
}
public
SymbolAndProjectId
RenameSymbolAndProjectId
{
get
;
}
public
bool
HasOverloads
{
get
;
}
public
bool
HasOverloads
{
get
;
set
;
}
public
bool
ForceRenameOverloads
{
get
;
}
/// <summary>
...
...
@@ -66,7 +64,6 @@ private partial class SymbolInlineRenameInfo : IInlineRenameInfoWithFileRename
SymbolAndProjectId
renameSymbolAndProjectId
,
bool
forceRenameOverloads
,
ImmutableArray
<
DocumentSpan
>
definitionLocations
,
string
triggerSpanText
,
CancellationToken
cancellationToken
)
{
this
.
CanRename
=
true
;
...
...
@@ -82,7 +79,6 @@ private partial class SymbolInlineRenameInfo : IInlineRenameInfoWithFileRename
this
.
TriggerSpan
=
GetReferenceEditSpan
(
new
InlineRenameLocation
(
document
,
triggerSpan
),
cancellationToken
);
this
.
DefinitionLocations
=
definitionLocations
;
_triggerSpanText
=
triggerSpanText
;
}
private
bool
CanRenameAttributePrefix
(
Document
document
,
TextSpan
triggerSpan
,
CancellationToken
cancellationToken
)
...
...
@@ -99,7 +95,8 @@ private bool CanRenameAttributePrefix(Document document, TextSpan triggerSpan, C
// we need to rename the entire attribute).
var
nameWithoutAttribute
=
GetWithoutAttributeSuffix
(
this
.
RenameSymbol
.
Name
);
return
_triggerSpanText
.
StartsWith
(
_triggerSpanText
);
// TODO: Always true? What was it supposed to do?
var
triggerText
=
GetSpanText
(
document
,
triggerSpan
,
cancellationToken
);
return
triggerText
.
StartsWith
(
triggerText
);
// TODO: Always true? What was it supposed to do?
}
/// <summary>
...
...
@@ -125,7 +122,8 @@ public TextSpan GetReferenceEditSpan(InlineRenameLocation location, Cancellation
searchName
=
GetWithoutAttributeSuffix
(
this
.
RenameSymbol
.
Name
);
}
var
index
=
_triggerSpanText
.
LastIndexOf
(
searchName
,
StringComparison
.
Ordinal
);
var
spanText
=
GetSpanText
(
location
.
Document
,
location
.
TextSpan
,
cancellationToken
);
var
index
=
spanText
.
LastIndexOf
(
searchName
,
StringComparison
.
Ordinal
);
if
(
index
<
0
)
{
...
...
@@ -140,13 +138,14 @@ public TextSpan GetReferenceEditSpan(InlineRenameLocation location, Cancellation
public
TextSpan
?
GetConflictEditSpan
(
InlineRenameLocation
location
,
string
replacementText
,
CancellationToken
cancellationToken
)
{
var
position
=
_triggerSpanText
.
LastIndexOf
(
replacementText
,
StringComparison
.
Ordinal
);
var
spanText
=
GetSpanText
(
location
.
Document
,
location
.
TextSpan
,
cancellationToken
);
var
position
=
spanText
.
LastIndexOf
(
replacementText
,
StringComparison
.
Ordinal
);
if
(
_isRenamingAttributePrefix
)
{
// We're only renaming the attribute prefix part. We want to adjust the span of
// the reference we've found to only update the prefix portion.
var
index
=
_triggerS
panText
.
LastIndexOf
(
replacementText
+
AttributeSuffix
,
StringComparison
.
Ordinal
);
var
index
=
s
panText
.
LastIndexOf
(
replacementText
+
AttributeSuffix
,
StringComparison
.
Ordinal
);
position
=
index
>=
0
?
index
:
position
;
}
...
...
@@ -164,6 +163,13 @@ private string GetWithoutAttributeSuffix(string value)
private
bool
HasAttributeSuffix
(
string
value
)
=>
value
.
TryGetWithoutAttributeSuffix
(
isCaseSensitive
:
_document
.
GetLanguageService
<
ISyntaxFactsService
>().
IsCaseSensitive
,
result
:
out
var
_
);
private
static
string
GetSpanText
(
Document
document
,
TextSpan
triggerSpan
,
CancellationToken
cancellationToken
)
{
var
sourceText
=
document
.
GetTextSynchronously
(
cancellationToken
);
var
triggerText
=
sourceText
.
ToString
(
triggerSpan
);
return
triggerText
;
}
internal
bool
IsRenamingAttributeTypeWithAttributeSuffix
()
{
if
(
this
.
RenameSymbol
.
IsAttribute
()
||
(
this
.
RenameSymbol
.
Kind
==
SymbolKind
.
Alias
&&
((
IAliasSymbol
)
this
.
RenameSymbol
).
Target
.
IsAttribute
()))
...
...
src/EditorFeatures/Core.Wpf/InlineRename/AbstractEditorInlineRenameService.cs
浏览文件 @
891b1805
...
...
@@ -12,7 +12,6 @@
using
Microsoft.CodeAnalysis.PooledObjects
;
using
Microsoft.CodeAnalysis.Rename
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Text
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.Editor.Implementation.InlineRename
...
...
@@ -192,18 +191,9 @@ public async Task<IInlineRenameInfo> GetRenameInfoAsync(Document document, int p
}
}
var
triggerSpanText
=
await
GetSpanTextAsync
(
document
,
triggerToken
.
Span
,
cancellationToken
).
ConfigureAwait
(
false
);
return
new
SymbolInlineRenameInfo
(
refactorNotifyServices
,
document
,
triggerToken
.
Span
,
symbolAndProjectId
,
forceRenameOverloads
,
documentSpans
.
ToImmutableAndFree
(),
triggerSpanText
,
cancellationToken
);
static
async
Task
<
string
>
GetSpanTextAsync
(
Document
document
,
TextSpan
triggerSpan
,
CancellationToken
cancellationToken
)
{
var
sourceText
=
await
document
.
GetTextAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
triggerText
=
sourceText
.
ToString
(
triggerSpan
);
return
triggerText
;
}
symbolAndProjectId
,
forceRenameOverloads
,
documentSpans
.
ToImmutableAndFree
(),
cancellationToken
);
}
private
async
Task
<
SyntaxToken
>
GetTriggerTokenAsync
(
Document
document
,
int
position
,
CancellationToken
cancellationToken
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录