Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [xtext-dev] Questions about XText

Hi Samantha,

I am in  the process of evaluating XText for use in my product.  Before I start answering questions, I'd like to thank all the XText committers and community for building such a cool technology.  My initial experience with XText has been very positive.  Not only does the sample work flawlessly, I can easily get my own dsl editor up and running within a few days.  It was very impressive.

Good to hear.

During my evaluation, I came across with a few things that I cannot quite understand.  I am hoping you can help me figure out the answers.  If this is not the right forum to ask these questions, please let me know where I should send the questions.

Please use the TMF newsgroup for this kind of questions:



I am using XText 0.8.0, and I am interested in some of the new features for this release.  The "New and Noteworthy" indicated that there is a new builder infrastructure, and all files of XText languages are indexed by this infrastructure.  Can you explain to me how this infrastructure work?  How is indexing done, and what is the relationship between the XText project support and the indexing (if any?)  ?  Where can I find some design docs on how this works?  Or, if you can point me to the code to start looking at this, it will be great.

The code can be found in the project (bundle) org.eclipse.xtext.builder.
It is basically an IncrementalProjectBuilder which reads and validates resources on change and stores important information in the form of descriptions.

We'll have a comprehensive documentation for the release in June.


Secondly, one of my requirements is to embed the XText editor into a multipage editor.  I experimented with this by programmatically creating the XText editor in my multipage editor, and got the editor to show up ok.  However, none of the XText actions, like format, open declaration, etc in the context menu.  I added the same set of actions by adding these actions in my own plugin.xml.  The actions will show up, but will not run, because some of the actions expect the calling editor is an XTextEditor.  The actions have hard-coded casts to XTextEditor, and result ClassCastException when they are run.  I think the problem is that the XTextEditor is never designed to be hosted in other editors,and therefore the actions do not work.  What are you thoughts on hosting the XTextEditor in a multipage editor?  Is this a supported scenario?

You may want to open a bugzilla (bugs.eclipse.org) so we can discuss this further.


Finally, the language that I am dealing with is really a combination of two sub-languages, much similar to _javascript_ in a JSP.  I need the editor to understand a different set of grammar depending on what the user is writing in an application file.  For example, if the user is within some boundaries, the editor will interpret the code using a set of grammar rules, everything else outside that boundary will be treated as comments.  If the user switches to another part of the application, the editor will switch grammar on the fly, and will interpret the code differently, i.e. building a different AST tree, etc.  The question is, is it possible to switch grammar on the fly, maybe switching grammar if some tokens are found?

It's possible but not supported out of the box. Also the editor and it's functionality usually expects one language (parser) per file. So you might need to adapt /change a lot of functionality in order to get this working.

Cheers,
Sven


Back to the top