c# - How to use language’s parser to get the tokens to populate the completion list in VS SDK? -


[environment]:vs2017+c#

i want extend intellisense, reorder completion list. read doc:walkthrough: displaying statement completion

doc say:

the completion source responsible collecting set of identifiers , adding content completion window when user types completion trigger, such first letters of identifier. in example, identifiers , descriptions hard-coded in augmentcompletionsession method. in real-world uses, use language’s parser tokens populate completion list.

 void icompletionsource.augmentcompletionsession(icompletionsession session, ilist<completionset> completionsets) {     list<string> strlist = new list<string>();     strlist.add("addition");    // ☹hard coded !!!     strlist.add("adaptation");     strlist.add("subtraction");     strlist.add("summation");     m_complist = new list<completion>();     foreach (string str in strlist)         m_complist.add(new completion(str, str, str, null, null));      completionsets.add(new completionset(         "tokens",    //the non-localized title of tab         "tokens",    //the display title of tab         findtokenspanatposition(session.gettriggerpoint(m_textbuffer),             session),         m_complist,         null)); }   } 

so, how use language’s parser tokens populate completion list? need default completion list reorder it.

i think document trying that they've hard-coded list of tokens make example easier understand , in real life have more complicated.

exactly have depend on many things including language trying process. example, if trying extend intellisense c# or visual basic might use roslyn parse source in project way of creating list of tokens use build completion list.

if working other language have find (or create) tool parse language working with.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -