Auto-completion for a Domain-Specific-Language: Easiest way to extract currently completed data type

I want to write a ReSharper 2017 plugin that extends the built-in autocompletion and gives the user additional hints when using a domain specific language.

Basically, whenever a certain function is called on a specific class, I want to generate additional completions that match the current context. For that, I need to extract the data-type on which the completion currently operates, for example when entering

    var someVariable = ...

    someVariable.Method( ...  // <- cursor

I need to extract the Type of the variable "someVariable" in order to determine the possible arguments. 

One way to get this type, would be to use PSI to fetch the Token under the current cursor and manually traverse the syntax tree for every single construct that might return a data type, like "local variables", "class member", "method return type", "property", "etc".

I guess that the R# Autocompletion already has to extract this information somewhere for its own autocompletion, is there any way to access it without too much effort?

Thanks in advance for your help


Please sign in to leave a comment.