Skip to content

Commit

Permalink
[GH-153] - removing indexer specific code from CallInfoAnalyzers
Browse files Browse the repository at this point in the history
  • Loading branch information
tpodolak committed Dec 20, 2020
1 parent 4c80162 commit 6539523
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,14 @@ private IReadOnlyList<IArgumentOperation> GetSubstituteCallArgumentOperations(

private IndexerInfo GetIndexerInfo(SyntaxNodeAnalysisContext syntaxNodeAnalysisContext, TIndexerExpressionSyntax indexerExpressionSyntax)
{
var info = GetIndexerSymbol(syntaxNodeAnalysisContext, indexerExpressionSyntax);
var operation = syntaxNodeAnalysisContext.SemanticModel.GetOperation(indexerExpressionSyntax);
ISymbol info = operation switch
{
IInvocationOperation inv => inv.TargetMethod,
IArrayElementReferenceOperation x => x.Type,
_ => null
};

var symbol = info as IMethodSymbol;
var verifyIndexerCast = symbol == null || symbol.Name != MetadataNames.CallInfoArgTypesMethod;
var verifyAssignment = symbol == null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ namespace NSubstitute.Analyzers.Shared.DiagnosticAnalyzers
{
internal class CallInfoContext<TInvocationExpressionSyntax, TIndexerSyntax>
{
public List<TIndexerSyntax> IndexerAccesses { get; }
public IReadOnlyList<TIndexerSyntax> IndexerAccesses { get; }

public List<TInvocationExpressionSyntax> ArgAtInvocations { get; }
public IReadOnlyList<TInvocationExpressionSyntax> ArgAtInvocations { get; }

public List<TInvocationExpressionSyntax> ArgInvocations { get; }
public IReadOnlyList<TInvocationExpressionSyntax> ArgInvocations { get; }

public CallInfoContext(
List<TInvocationExpressionSyntax> argAtInvocations,
List<TInvocationExpressionSyntax> argInvocations,
List<TIndexerSyntax> indexerAccesses)
IReadOnlyList<TInvocationExpressionSyntax> argAtInvocations,
IReadOnlyList<TInvocationExpressionSyntax> argInvocations,
IReadOnlyList<TIndexerSyntax> indexerAccesses)
{
IndexerAccesses = indexerAccesses;
ArgAtInvocations = argAtInvocations;
Expand Down

0 comments on commit 6539523

Please sign in to comment.