Get usages of method

I’m developing a rule that checks the usages of some constant enums, and I plan to visit MemberSelectExpressionTree to find out the method that reference the enum, then get the usages of this method.

I’m currently calling the methodTree.symbol().usages(), but I found that this method only returned the usages in the same file. does it mean that when one rule is running, it cannot get the syntax tree of another file?

I’m wondering is there any way that I can get all the usages of the method?

Hey @richardcypher, you are correct: rules only see the usages within the same file.

From what I understand, you want to visit all methods looking for a specific enum, in an expression or an assignment, and then collect all usages of this method.

What is the end goal here? Are you trying to raise an issue on all method invocations? Some of them? Depending on specific usage combinations?

Is there a way for you to tell what method you are looking for exactly before running the analysis?

thanks for the reply~

What is the end goal here? Are you trying to raise an issue on all method invocations? Some of them? Depending on specific usage combinations?

I want to raise an issue on some of the usages, depending on the file path of the usage.