Autocomplete XML Code

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Autocomplete XML Code

Postby Ravikant » Fri May 14, 2010 10:02 am

Hi Robert,

I had asked you help on Autocompletion feature to my XML Editor. I tried the way you told me but I'm clear with how can I get this done.
Kindly help to understand how can I Identify element and attribute using Token list.


Re: Autocomplete XML Code

Postby robert » Sat May 15, 2010 3:46 am

You may want to check out the HTML support in RSTALanguageSupport, in particular the HtmlCompletionProvider class. It uses the RSyntaxDocument of the RSyntaxTextArea to get tokens to help with its completions. It uses it to determine wheher or not it's in a tag, and if it is, if the user is typing a tag name or attribute.

In theory the HtmlTokenMaker isn't specifically tied to HTML, but rather gets its completion information from this XML file at runtime. I think you could check out the RSTALanguageSupport project, and modify to load a different XML file with the same structure, and it would do completions for your special markup language. Keep in mind though that it's not smart enough to handle nested elements properly, since in HTML, all standard tags are always uniquely named, and you don't have to know the parent tag hierarchy to determine what attributes are appropriate for a given tag. If your markup doesn't meet this requirement, then HtmlCompletionProvider will not be sufficient.

Also note that HtmlCompletionProvider, and all of RSTALanguageSupport, is LGPL, so if you'll have to be okay with that license in order to use it.
User avatar
Posts: 852
Joined: Sat May 10, 2008 5:16 pm

Return to Help

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests