Skip to content

Commit

Permalink
[GH-56] - getting semantic model only if syntax tree is within compil…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
tpodolak committed Dec 4, 2018
1 parent cbeafd3 commit aa3b4a6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ public ReEntrantCallVisitor(ReEntrantCallFinder reEntrantCallFinder, Compilation

public override void VisitInvocationExpression(InvocationExpressionSyntax node)
{
var semanticModel = _compilation.GetSemanticModel(node.SyntaxTree);
var symbolInfo = semanticModel.GetSymbolInfo(node);
if (_reEntrantCallFinder.IsReturnsLikeMethod(semanticModel, symbolInfo.Symbol))
if (_compilation.ContainsSyntaxTree(node.SyntaxTree))
{
_invocationSymbols.Add(symbolInfo.Symbol);
var semanticModel = _compilation.GetSemanticModel(node.SyntaxTree);
var symbolInfo = semanticModel.GetSymbolInfo(node);
if (_reEntrantCallFinder.IsReturnsLikeMethod(semanticModel, symbolInfo.Symbol))
{
_invocationSymbols.Add(symbolInfo.Symbol);
}
}

base.VisitInvocationExpression(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ public ReEntrantCallVisitor(ReEntrantCallFinder reEntrantCallFinder, Compilation

public override void VisitInvocationExpression(InvocationExpressionSyntax node)
{
var semanticModel = _compilation.GetSemanticModel(node.SyntaxTree);
var symbolInfo = semanticModel.GetSymbolInfo(node);
if (_reEntrantCallFinder.IsReturnsLikeMethod(semanticModel, symbolInfo.Symbol))
if (_compilation.ContainsSyntaxTree(node.SyntaxTree))
{
_invocationSymbols.Add(symbolInfo.Symbol);
var semanticModel = _compilation.GetSemanticModel(node.SyntaxTree);
var symbolInfo = semanticModel.GetSymbolInfo(node);
if (_reEntrantCallFinder.IsReturnsLikeMethod(semanticModel, symbolInfo.Symbol))
{
_invocationSymbols.Add(symbolInfo.Symbol);
}
}

base.VisitInvocationExpression(node);
Expand Down

0 comments on commit aa3b4a6

Please sign in to comment.