How can I relate Tokens with Elements?

Jun 9, 2014 at 10:16 AM
Hello,

I'm pretty new to building custom StyleCop rules so forgive me if I ask something evident. I'm trying to build a rule that enforces the usage of the base prefix if the element is defined in a base class.

To do this I'm searching the whole document for "this" Tokens and then I want to check if the element pointed by the "this" token is defined on the current document. If it is not I will assume that it is defined on a base class.

What I don't know is how to relate the "this" token found with the Elements of the document. Is there a way of doing this? Like asking for the element where a token is contained to a service or something like that.

Regards.