PreviousNextTracker indexSee it online !

(56/161) 2726418 - sidekick: completion for modes different to the buffer's

At the moment, sidekick looks at the mode of the buffer to choose which parser it uses (the getParserForBuffer method).
But some buffers have more than one mode, take jsp with some java in as an exemple. it would be quite useful to be able to use java completions within a jsp buffer, completion of beanshell within an actions.xml file, ...

Submitted rfrancois - 2009-04-02 - 08:46:32z Assigned nobody
Priority 5 Category None
Status Open Group None
Resolution None Visibility No


2009-04-02 - 13:54:52z
You're mentioning completion, but what about the actual parsing? If a different parser is used for an inner block in the buffer, that belongs to a different mode, then how is the sidekick tree part created for that block? It should be the same wrt completion I think.
2009-04-02 - 14:13:44z
Yes, that is tricky.
Maybe we could treat the chunk of code that is inside as another buffer, parse this "buffer", and add the nodes to the main tree.

completion is easier, because for many languages, you have all the information on the line where the caret is, so you can just pretend that the buffer is of the inner mode to get completion. That is what I have done here to get R completion inside sweave (latex-like) document :

2009-04-02 - 14:23:59z
Sidekick already has some framework for parsing different modes within the same file. See sidekick.enhanced.PartialParser, and see the HTML sidekick (in XML sidekick) for an example of how it delegates to the javascript and css sidekicks for <script> and <style> sections within the html document.
2009-04-02 - 14:38:16z
Nice ! Did not know about that. Thank you.
Why is this not using positions instead of lines ? (just curious)

Could this be used to delegate the completion as well, does not seem to work for me.