提交 ee3aa537 编写于 作者: C CyrusNajmabadi

Use immutable arrays in more places.

上级 841b60f7
......@@ -505,7 +505,7 @@ private List<SyntaxTrivia> GetPermutedTrivia(CSharpSyntaxNode node, List<XmlElem
return separators;
}
public override async Task<IEnumerable<SymbolAndProjectId>> DetermineCascadedSymbolsFromDelegateInvoke(
public override async Task<ImmutableArray<SymbolAndProjectId>> DetermineCascadedSymbolsFromDelegateInvoke(
SymbolAndProjectId<IMethodSymbol> symbolAndProjectId,
Document document,
CancellationToken cancellationToken)
......@@ -514,9 +514,9 @@ private List<SyntaxTrivia> GetPermutedTrivia(CSharpSyntaxNode node, List<XmlElem
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var nodes = root.DescendantNodes();
var nodes = root.DescendantNodes().ToImmutableArray();
var convertedMethodGroups = nodes
.Where(
.WhereAsArray(
n =>
{
if (!n.IsKind(SyntaxKind.IdentifierName) ||
......@@ -539,9 +539,9 @@ private List<SyntaxTrivia> GetPermutedTrivia(CSharpSyntaxNode node, List<XmlElem
return convertedType == symbol.ContainingType;
})
.Select(n => semanticModel.GetSymbolInfo(n, cancellationToken).Symbol);
.SelectAsArray(n => semanticModel.GetSymbolInfo(n, cancellationToken).Symbol);
return convertedMethodGroups.Select(symbolAndProjectId.WithSymbol);
return convertedMethodGroups.SelectAsArray(symbolAndProjectId.WithSymbol);
}
protected override IEnumerable<IFormattingRule> GetFormattingRules(Document document)
......@@ -549,4 +549,4 @@ protected override IEnumerable<IFormattingRule> GetFormattingRules(Document docu
return new[] { new ChangeSignatureFormattingRule() }.Concat(Formatter.GetDefaultFormattingRules(document));
}
}
}
}
\ No newline at end of file
......@@ -135,22 +135,24 @@ private bool IsAfterNameEqualsArgument(SyntaxToken token)
return false;
}
private async Task<IEnumerable<CompletionItem>> GetNameEqualsItemsAsync(CompletionContext context, SemanticModel semanticModel,
private async Task<ImmutableArray<CompletionItem>> GetNameEqualsItemsAsync(
CompletionContext context, SemanticModel semanticModel,
SyntaxToken token, AttributeSyntax attributeSyntax, ISet<string> existingNamedParameters)
{
var attributeNamedParameters = GetAttributeNamedParameters(semanticModel, context.Position, attributeSyntax, context.CancellationToken);
var unspecifiedNamedParameters = attributeNamedParameters.Where(p => !existingNamedParameters.Contains(p.Name));
var text = await semanticModel.SyntaxTree.GetTextAsync(context.CancellationToken).ConfigureAwait(false);
return from p in attributeNamedParameters
where !existingNamedParameters.Contains(p.Name)
select SymbolCompletionItem.Create(
var q = from p in attributeNamedParameters
where !existingNamedParameters.Contains(p.Name)
select SymbolCompletionItem.Create(
displayText: p.Name.ToIdentifierToken().ToString() + SpaceEqualsString,
insertionText: null,
symbol: p,
contextPosition: token.SpanStart,
sortText: p.Name,
rules: CompletionItemRules.Default);
return q.ToImmutableArray();
}
private async Task<IEnumerable<CompletionItem>> GetNameColonItemsAsync(
......
......@@ -35,7 +35,7 @@ internal abstract class AbstractChangeSignatureService : ILanguageService
/// </summary>
public abstract SyntaxNode FindNodeToUpdate(Document document, SyntaxNode node);
public abstract Task<IEnumerable<SymbolAndProjectId>> DetermineCascadedSymbolsFromDelegateInvoke(
public abstract Task<ImmutableArray<SymbolAndProjectId>> DetermineCascadedSymbolsFromDelegateInvoke(
SymbolAndProjectId<IMethodSymbol> symbolAndProjectId, Document document, CancellationToken cancellationToken);
public abstract SyntaxNode ChangeSignature(
......@@ -48,13 +48,13 @@ internal abstract class AbstractChangeSignatureService : ILanguageService
protected abstract IEnumerable<IFormattingRule> GetFormattingRules(Document document);
public async Task<IEnumerable<ChangeSignatureCodeAction>> GetChangeSignatureCodeActionAsync(Document document, TextSpan span, CancellationToken cancellationToken)
public async Task<ImmutableArray<ChangeSignatureCodeAction>> GetChangeSignatureCodeActionAsync(Document document, TextSpan span, CancellationToken cancellationToken)
{
var context = await GetContextAsync(document, span.Start, restrictToDeclarations: true, cancellationToken: cancellationToken).ConfigureAwait(false);
return context.CanChangeSignature
? SpecializedCollections.SingletonEnumerable(new ChangeSignatureCodeAction(this, context))
: SpecializedCollections.EmptyEnumerable<ChangeSignatureCodeAction>();
? ImmutableArray.Create(new ChangeSignatureCodeAction(this, context))
: ImmutableArray<ChangeSignatureCodeAction>.Empty;
}
internal ChangeSignatureResult ChangeSignature(Document document, int position, Action<string, NotificationSeverity> errorHandler, CancellationToken cancellationToken)
......
......@@ -489,7 +489,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ChangeSignature
Public Overrides Async Function DetermineCascadedSymbolsFromDelegateInvoke(
methodAndProjectId As SymbolAndProjectId(Of IMethodSymbol),
document As Document,
cancellationToken As CancellationToken) As Task(Of IEnumerable(Of SymbolAndProjectId))
cancellationToken As CancellationToken) As Task(Of ImmutableArray(Of SymbolAndProjectId))
Dim symbol = methodAndProjectId.Symbol
Dim root = Await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(False)
......@@ -497,7 +497,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ChangeSignature
Dim nodes = root.DescendantNodes()
Dim results = New List(Of ISymbol)
Dim results = ArrayBuilder(Of ISymbol).GetInstance()
For Each n In nodes
If n.IsKind(SyntaxKind.AddressOfExpression) Then
......@@ -537,7 +537,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ChangeSignature
End If
Next
Return results.Select(Function(s) SymbolAndProjectId.Create(s, document.Project.Id))
Return results.ToImmutableAndFree().
SelectAsArray(Function(s) SymbolAndProjectId.Create(s, document.Project.Id))
End Function
Protected Overrides Function GetFormattingRules(document As Document) As IEnumerable(Of IFormattingRule)
......
......@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Composition;
using System.Diagnostics;
using System.Linq;
......@@ -770,7 +771,7 @@ private SyntaxToken RenameWithinToken(SyntaxToken oldToken, SyntaxToken newToken
return false;
}
public async Task<IEnumerable<Location>> ComputeDeclarationConflictsAsync(
public async Task<ImmutableArray<Location>> ComputeDeclarationConflictsAsync(
string replacementText,
ISymbol renamedSymbol,
ISymbol renameSymbol,
......@@ -782,7 +783,7 @@ private SyntaxToken RenameWithinToken(SyntaxToken oldToken, SyntaxToken newToken
{
try
{
var conflicts = new List<Location>();
var conflicts = ArrayBuilder<Location>.GetInstance();
// If we're renaming a named type, we can conflict with members w/ our same name. Note:
// this doesn't apply to enums.
......@@ -840,7 +841,8 @@ private SyntaxToken RenameWithinToken(SyntaxToken oldToken, SyntaxToken newToken
}
}
ConflictResolver.AddConflictingParametersOfProperties(properties.Distinct(), replacementText, conflicts);
ConflictResolver.AddConflictingParametersOfProperties(
properties.Distinct(), replacementText, conflicts);
}
else if (renamedSymbol.Kind == SymbolKind.Alias)
{
......@@ -904,7 +906,7 @@ private SyntaxToken RenameWithinToken(SyntaxToken oldToken, SyntaxToken newToken
}
}
return conflicts;
return conflicts.ToImmutableAndFree();
}
catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
{
......@@ -941,7 +943,9 @@ private static async Task<ISymbol> GetVBPropertyFromAccessorOrAnOverrideAsync(IS
}
}
private void AddSymbolSourceSpans(List<Location> conflicts, IEnumerable<ISymbol> symbols, IDictionary<Location, Location> reverseMappedLocations)
private void AddSymbolSourceSpans(
ArrayBuilder<Location> conflicts, IEnumerable<ISymbol> symbols,
IDictionary<Location, Location> reverseMappedLocations)
{
foreach (var symbol in symbols)
{
......@@ -959,7 +963,8 @@ private void AddSymbolSourceSpans(List<Location> conflicts, IEnumerable<ISymbol>
}
}
public async Task<IEnumerable<Location>> ComputeImplicitReferenceConflictsAsync(ISymbol renameSymbol, ISymbol renamedSymbol, IEnumerable<ReferenceLocation> implicitReferenceLocations, CancellationToken cancellationToken)
public async Task<ImmutableArray<Location>> ComputeImplicitReferenceConflictsAsync(
ISymbol renameSymbol, ISymbol renamedSymbol, IEnumerable<ReferenceLocation> implicitReferenceLocations, CancellationToken cancellationToken)
{
// Handle renaming of symbols used for foreach
bool implicitReferencesMightConflict = renameSymbol.Kind == SymbolKind.Property &&
......@@ -983,16 +988,16 @@ public async Task<IEnumerable<Location>> ComputeImplicitReferenceConflictsAsync(
switch (token.Kind())
{
case SyntaxKind.ForEachKeyword:
return SpecializedCollections.SingletonEnumerable(((CommonForEachStatementSyntax)token.Parent).Expression.GetLocation());
return ImmutableArray.Create(((CommonForEachStatementSyntax)token.Parent).Expression.GetLocation());
}
}
}
}
return SpecializedCollections.EmptyEnumerable<Location>();
return ImmutableArray<Location>.Empty;
}
public IEnumerable<Location> ComputePossibleImplicitUsageConflicts(
public ImmutableArray<Location> ComputePossibleImplicitUsageConflicts(
ISymbol renamedSymbol,
SemanticModel semanticModel,
Location originalDeclarationLocation,
......@@ -1029,7 +1034,7 @@ public async Task<IEnumerable<Location>> ComputeImplicitReferenceConflictsAsync(
{
if (!method.ReturnsVoid && !method.Parameters.Any() && method.ReturnType.SpecialType == SpecialType.System_Boolean)
{
return SpecializedCollections.SingletonEnumerable(originalDeclarationLocation);
return ImmutableArray.Create(originalDeclarationLocation);
}
}
else if (symbol.Name == "GetEnumerator")
......@@ -1039,7 +1044,7 @@ public async Task<IEnumerable<Location>> ComputeImplicitReferenceConflictsAsync(
if (!method.ReturnsVoid &&
!method.Parameters.Any())
{
return SpecializedCollections.SingletonEnumerable(originalDeclarationLocation);
return ImmutableArray.Create(originalDeclarationLocation);
}
}
}
......@@ -1049,14 +1054,14 @@ public async Task<IEnumerable<Location>> ComputeImplicitReferenceConflictsAsync(
if (!property.Parameters.Any() && !property.IsWriteOnly)
{
return SpecializedCollections.SingletonEnumerable(originalDeclarationLocation);
return ImmutableArray.Create(originalDeclarationLocation);
}
}
}
}
}
return SpecializedCollections.EmptyEnumerable<Location>();
return ImmutableArray<Location>.Empty;
}
#endregion
......
......@@ -237,7 +237,8 @@ private static bool IsRenameValid(ConflictResolution conflictResolution, ISymbol
}
}
internal static void AddConflictingParametersOfProperties(IEnumerable<ISymbol> properties, string newPropertyName, List<Location> conflicts)
internal static void AddConflictingParametersOfProperties(
IEnumerable<ISymbol> properties, string newPropertyName, ArrayBuilder<Location> conflicts)
{
// check if the new property name conflicts with any parameter of the properties.
// Note: referencedSymbols come from the original solution, so there is no need to reverse map the locations of the parameters
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.FindSymbols;
......@@ -43,7 +44,7 @@ internal interface IRenameRewriterLanguageService : ILanguageService
/// <param name="reverseMappedLocations">A mapping from new to old locations.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>All locations where conflicts were caused because the new declaration.</returns>
Task<IEnumerable<Location>> ComputeDeclarationConflictsAsync(
Task<ImmutableArray<Location>> ComputeDeclarationConflictsAsync(
string replacementText,
ISymbol renamedSymbol,
ISymbol renameSymbol,
......@@ -61,7 +62,7 @@ internal interface IRenameRewriterLanguageService : ILanguageService
/// <param name="implicitReferenceLocations">All implicit reference locations.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A list of implicit conflicts.</returns>
Task<IEnumerable<Location>> ComputeImplicitReferenceConflictsAsync(
Task<ImmutableArray<Location>> ComputeImplicitReferenceConflictsAsync(
ISymbol renameSymbol,
ISymbol renamedSymbol,
IEnumerable<ReferenceLocation> implicitReferenceLocations,
......@@ -76,7 +77,7 @@ internal interface IRenameRewriterLanguageService : ILanguageService
/// <param name="newDeclarationLocationStartingPosition">The starting position of the renamedSymbol in the new solution</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A list of implicit conflicts.</returns>
IEnumerable<Location> ComputePossibleImplicitUsageConflicts(
ImmutableArray<Location> ComputePossibleImplicitUsageConflicts(
ISymbol renamedSymbol,
SemanticModel semanticModel,
Location originalDeclarationLocation,
......@@ -113,4 +114,4 @@ internal interface IRenameRewriterLanguageService : ILanguageService
/// <returns></returns>
SyntaxNode GetExpansionTargetForLocation(SyntaxToken token);
}
}
}
\ No newline at end of file
......@@ -12,6 +12,7 @@
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
using System.Text.RegularExpressions;
using System.Collections.Immutable;
namespace Microsoft.CodeAnalysis.Rename
{
......@@ -265,22 +266,23 @@ private static string TrimNameToAfterLastDot(string name)
/// <summary>
/// Given a ISymbol, returns the renameable locations for a given symbol.
/// </summary>
public static async Task<IEnumerable<RenameLocation>> GetRenamableDefinitionLocationsAsync(ISymbol referencedSymbol, ISymbol originalSymbol, Solution solution, CancellationToken cancellationToken)
public static async Task<ImmutableArray<RenameLocation>> GetRenamableDefinitionLocationsAsync(
ISymbol referencedSymbol, ISymbol originalSymbol, Solution solution, CancellationToken cancellationToken)
{
var shouldIncludeSymbol = await ShouldIncludeSymbolAsync(referencedSymbol, originalSymbol, solution, false, cancellationToken).ConfigureAwait(false);
if (!shouldIncludeSymbol)
{
return SpecializedCollections.EmptyEnumerable<RenameLocation>();
return ImmutableArray<RenameLocation>.Empty;
}
// Namespaces are definitions and references all in one. Since every definition
// location is also a reference, we'll ignore it's definitions.
if (referencedSymbol.Kind == SymbolKind.Namespace)
{
return SpecializedCollections.EmptyEnumerable<RenameLocation>();
return ImmutableArray<RenameLocation>.Empty;
}
var results = new List<RenameLocation>();
var results = ArrayBuilder<RenameLocation>.GetInstance();
// If the original symbol was an alias, then the definitions will just be the
// location of the alias, always
......@@ -288,7 +290,7 @@ public static async Task<IEnumerable<RenameLocation>> GetRenamableDefinitionLoca
{
var location = originalSymbol.Locations.Single();
results.Add(new RenameLocation(location, solution.GetDocument(location.SourceTree).Id));
return results;
return results.ToImmutableAndFree();
}
var isRenamableAccessor = await IsPropertyAccessorOrAnOverride(referencedSymbol, solution, cancellationToken).ConfigureAwait(false);
......@@ -328,7 +330,7 @@ public static async Task<IEnumerable<RenameLocation>> GetRenamableDefinitionLoca
}
}
return results;
return results.ToImmutableAndFree();
}
internal static async Task<IEnumerable<RenameLocation>> GetRenamableReferenceLocationsAsync(ISymbol referencedSymbol, ISymbol originalSymbol, ReferenceLocation location, Solution solution, CancellationToken cancellationToken)
......
......@@ -10,11 +10,11 @@ namespace Microsoft.CodeAnalysis.Shared.Extensions
{
internal static partial class ISolutionExtensions
{
public static async Task<IEnumerable<INamespaceSymbol>> GetGlobalNamespacesAsync(
public static async Task<ImmutableArray<INamespaceSymbol>> GetGlobalNamespacesAsync(
this Solution solution,
CancellationToken cancellationToken)
{
var results = new List<INamespaceSymbol>();
var results = ArrayBuilder<INamespaceSymbol>.GetInstance();
foreach (var projectId in solution.ProjectIds)
{
......@@ -23,7 +23,7 @@ internal static partial class ISolutionExtensions
results.Add(compilation.Assembly.GlobalNamespace);
}
return results;
return results.ToImmutableAndFree();
}
public static IEnumerable<DocumentId> GetChangedDocuments(this Solution newSolution, Solution oldSolution)
......
......@@ -1755,7 +1755,8 @@ public async Task<bool> ContainsSymbolsWithNameAsync(ProjectId id, Func<string,
return compilation.ContainsSymbolsWithName(predicate, filter, cancellationToken);
}
public async Task<IEnumerable<DocumentState>> GetDocumentsWithNameAsync(ProjectId id, Func<string, bool> predicate, SymbolFilter filter, CancellationToken cancellationToken)
public async Task<ImmutableArray<DocumentState>> GetDocumentsWithNameAsync(
ProjectId id, Func<string, bool> predicate, SymbolFilter filter, CancellationToken cancellationToken)
{
// this will be used to find documents that contain declaration information in IDE cache such as DeclarationSyntaxTreeInfo for "NavigateTo"
var trees = GetCompilationTracker(id).GetSyntaxTreesWithNameFromDeclarationOnlyCompilation(predicate, filter, cancellationToken);
......@@ -1769,15 +1770,16 @@ public async Task<IEnumerable<DocumentState>> GetDocumentsWithNameAsync(ProjectI
if (compilation == null)
{
// some projects don't support compilations (e.g., TypeScript) so there's nothing to check
return SpecializedCollections.EmptyEnumerable<DocumentState>();
return ImmutableArray<DocumentState>.Empty;
}
return ConvertTreesToDocuments(
id, compilation.GetSymbolsWithName(predicate, filter, cancellationToken).SelectMany(s => s.DeclaringSyntaxReferences.Select(r => r.SyntaxTree)));
}
private IEnumerable<DocumentState> ConvertTreesToDocuments(ProjectId id, IEnumerable<SyntaxTree> trees)
private ImmutableArray<DocumentState> ConvertTreesToDocuments(ProjectId id, IEnumerable<SyntaxTree> trees)
{
var result = ArrayBuilder<DocumentState>.GetInstance();
foreach (var tree in trees)
{
var document = GetDocumentState(tree, id);
......@@ -1787,8 +1789,10 @@ private IEnumerable<DocumentState> ConvertTreesToDocuments(ProjectId id, IEnumer
continue;
}
yield return document;
result.Add(document);
}
return result.ToImmutableAndFree();
}
/// <summary>
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports System.Threading
Imports System.Threading.Tasks
Imports Microsoft.CodeAnalysis
......@@ -653,8 +654,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
newSolution As Solution,
reverseMappedLocations As IDictionary(Of Location, Location),
cancellationToken As CancellationToken
) As Task(Of IEnumerable(Of Location)) Implements IRenameRewriterLanguageService.ComputeDeclarationConflictsAsync
Dim conflicts As New List(Of Location)
) As Task(Of ImmutableArray(Of Location)) Implements IRenameRewriterLanguageService.ComputeDeclarationConflictsAsync
Dim conflicts = ArrayBuilder(Of Location).GetInstance()
If renamedSymbol.Kind = SymbolKind.Parameter OrElse
renamedSymbol.Kind = SymbolKind.Local OrElse
......@@ -735,10 +737,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
Next
End If
Return Task.FromResult(Of IEnumerable(Of Location))(conflicts)
Return Task.FromResult(conflicts.ToImmutableAndFree())
End Function
Public Async Function ComputeImplicitReferenceConflictsAsync(renameSymbol As ISymbol, renamedSymbol As ISymbol, implicitReferenceLocations As IEnumerable(Of ReferenceLocation), cancellationToken As CancellationToken) As Task(Of IEnumerable(Of Location)) Implements IRenameRewriterLanguageService.ComputeImplicitReferenceConflictsAsync
Public Async Function ComputeImplicitReferenceConflictsAsync(
renameSymbol As ISymbol, renamedSymbol As ISymbol,
implicitReferenceLocations As IEnumerable(Of ReferenceLocation),
cancellationToken As CancellationToken) As Task(Of ImmutableArray(Of Location)) Implements IRenameRewriterLanguageService.ComputeImplicitReferenceConflictsAsync
' Handle renaming of symbols used for foreach
Dim implicitReferencesMightConflict = renameSymbol.Kind = SymbolKind.Property AndAlso
......@@ -757,13 +762,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
implicitReferenceLocation.Location.SourceSpan.Start, cancellationToken, findInsideTrivia:=False).ConfigureAwait(False)
If token.Kind = SyntaxKind.ForKeyword AndAlso token.Parent.IsKind(SyntaxKind.ForEachStatement) Then
Return SpecializedCollections.SingletonEnumerable(DirectCast(token.Parent, ForEachStatementSyntax).Expression.GetLocation())
Return ImmutableArray.Create(DirectCast(token.Parent, ForEachStatementSyntax).Expression.GetLocation())
End If
Next
End If
End If
Return SpecializedCollections.EmptyEnumerable(Of Location)()
Return ImmutableArray(Of Location).Empty
End Function
#End Region
......@@ -841,7 +846,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
semanticModel As SemanticModel,
originalDeclarationLocation As Location,
newDeclarationLocationStartingPosition As Integer,
cancellationToken As CancellationToken) As IEnumerable(Of Location) Implements IRenameRewriterLanguageService.ComputePossibleImplicitUsageConflicts
cancellationToken As CancellationToken) As ImmutableArray(Of Location) Implements IRenameRewriterLanguageService.ComputePossibleImplicitUsageConflicts
' TODO: support other implicitly used methods like dispose
If CaseInsensitiveComparison.Equals(renamedSymbol.Name, "MoveNext") OrElse
......@@ -853,13 +858,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
If DirectCast(renamedSymbol, IMethodSymbol).IsOverloads AndAlso
(renamedSymbol.GetAllTypeArguments().Length <> 0 OrElse
DirectCast(renamedSymbol, IMethodSymbol).Parameters.Length <> 0) Then
Return SpecializedCollections.EmptyEnumerable(Of Location)()
Return ImmutableArray(Of Location).Empty
End If
End If
If TypeOf renamedSymbol Is IPropertySymbol Then
If DirectCast(renamedSymbol, IPropertySymbol).IsOverloads Then
Return SpecializedCollections.EmptyEnumerable(Of Location)()
Return ImmutableArray(Of Location).Empty
End If
End If
......@@ -884,14 +889,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
If CaseInsensitiveComparison.Equals(symbol.Name, "MoveNext") Then
If Not method.ReturnsVoid AndAlso Not method.Parameters.Any() AndAlso method.ReturnType.SpecialType = SpecialType.System_Boolean Then
Return SpecializedCollections.SingletonEnumerable(originalDeclarationLocation)
Return ImmutableArray.Create(originalDeclarationLocation)
End If
ElseIf CaseInsensitiveComparison.Equals(symbol.Name, "GetEnumerator") Then
' we are a bit pessimistic here.
' To be sure we would need to check if the returned type Is having a MoveNext And Current as required by foreach
If Not method.ReturnsVoid AndAlso
Not method.Parameters.Any() Then
Return SpecializedCollections.SingletonEnumerable(originalDeclarationLocation)
Return ImmutableArray.Create(originalDeclarationLocation)
End If
End If
......@@ -899,14 +904,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
Dim [property] = DirectCast(symbol, IPropertySymbol)
If Not [property].Parameters.Any() AndAlso Not [property].IsWriteOnly Then
Return SpecializedCollections.SingletonEnumerable(originalDeclarationLocation)
Return ImmutableArray.Create(originalDeclarationLocation)
End If
End If
Next
End If
End If
Return SpecializedCollections.EmptyEnumerable(Of Location)()
Return ImmutableArray(Of Location).Empty
End Function
Public Sub TryAddPossibleNameConflicts(symbol As ISymbol, replacementText As String, possibleNameConflicts As ICollection(Of String)) Implements IRenameRewriterLanguageService.TryAddPossibleNameConflicts
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册