Skip to content

Commit

Permalink
Ignore operations not in the current syntax tree.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yey007 committed Jun 20, 2024
1 parent db72095 commit 32a441a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Src/ILGPU.Analyzers/MethodUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ public static class MethodUtil
{
IsPartialDefinition: false,
DeclaringSyntaxReferences: var refs,
} => refs.Length > 0 ? model.GetOperation(refs[0].GetSyntax()) : null,
} => refs.Length > 0 ? GetOperationIfInTree(model, refs[0].GetSyntax()) : null,
{
PartialImplementationPart: { DeclaringSyntaxReferences: var refs },
} => refs.Length > 0 ? model.GetOperation(refs[0].GetSyntax()) : null,
} => refs.Length > 0 ? GetOperationIfInTree(model, refs[0].GetSyntax()) : null,
_ => null
};
}

private static IOperation? GetOperationIfInTree(SemanticModel model, SyntaxNode node)
{
var root = model.SyntaxTree.GetRoot();
return root.Contains(node) ? model.GetOperation(node) : null;
}
}
}
}

0 comments on commit 32a441a

Please sign in to comment.