Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add completion words dynamically to VS2013 Syntax Extension (MEF)

It's very possible that I just don't understand the problem space, but I'm having trouble figuring out the MEF (Editor Classifier project).

I've created (piecing together the Walkthrough guides from MSDN https://msdn.microsoft.com/en-us/library/ee197665.aspx) a syntax highligher for Informix Stored Procedure language.

One major problem I have is - I want to be able to find all instances of the keyword "DEFINE" and populate the word directly following it into the Statement Completion extension I have (currently it's populated from a defined list of words).

Much like C#'s native support - when you define a variable, it becomes available in the autocompletion dropdown.

I got rid of the in class hardcoding (from the walkthrough) and my completion words are defined like this:

List<Completion> completions = new List<Completion>();

CompletionTags completionTags = new CompletionTags();

foreach (string completionTag in completionTags.completionTags)
{
    completions.Add(new Completion(completionTag));
};

My CompletionTags class is pretty simple:

class CompletionTags { public List completionTags;

public CompletionTags()
{
    this.completionTags = new List<string> {
        // SQL keywords
        "COUNT",
        "FROM",
        "HAVING",
    };
}

I know WHAT I need to do. I somehow need to hijack the buffer when it changes and find all occurrences of 'DEFINE ([a-zA-Z0-9_]{1,})' and add \1 to the completionTags list.

I have no idea HOW to do this. Any pointers in the right (or any) direction at this point would be greatly appreciated.

Be kind - we've all been out of our depth at some stage (I've been programming in C# now for 3 days)...

like image 778
Trent Avatar asked May 15 '15 06:05

Trent


1 Answers

Reading this answer will be helpful. Look at:

XML Editor IntelliSense Features

Schema Cache

like image 151
Aly Elhaddad Avatar answered Oct 14 '22 10:10

Aly Elhaddad