|Mixin Xtext with other models [message #1787570]
||Tue, 29 May 2018 09:20
| Daniel Lipski
Registered: May 2018
currently we are working on our first Xtext project. I've read Xtext docs, "Implementing Domain-Specific Languages with Xtext and Xtend 2ed" book and other Internet articles but I couldn't find answers to my questions.
First let me shortly describe what we would like to achieve. We are building web app (xtext+lsp+monaco) where user can upload a file (xlsx or xml) and have special editor to manipulate/calculate file contents.
For example if I upload a xlsx:
|10 |20 |30 |
and if I write an expression: (row.columnX+row,columnY)/row.columnZ
the evaluator should return: 1; (10+20)/30
We started writing Xtext grammar for our expression language - this part is not so hard because there is a lot of examples (book & internet).
Currently we are working on content assist (if I type "row." the editor should suggest: columnX, columnY, columnZ) and type checking (if I type "row.columnTEST" the editor should show error because our sample Excel contains only 3 columns)
Here problems starts :), below are our supposition/assumptions:
1)As far as I understand what we would like to achieve (content assist and type checking) in our case is related with cross-references
2)The expression grammar (or ecore model) should reference ecore objects representing uploaded files (excel columns or xml structure) to let content assist/type checking work properly
3)The xtext index should contain ecore objects for file(xlsx/xml) structures
4)We should provide xtext scope implementation/configuration to limit valid suggestions in specific context.
If someone could briefly describe how to achieve these goals (if they are correct) I will be grateful. Bellow are questions related to above assumptions
Ad2)Our grammar is only for typing expressions, there are no language constructs allowing to define data structures -> generated ecore model does not define classes to describe xlsx/xml file structure (we cannot reference to this object in our grammar). Do we have to add to the generated model such classes and turn of auto-generation of model from our grammar (import instead of generate) or there is another way ? (create separate model for file structure and import this model into grammar - leaving auto-generation of expression model ?)
Ad3)How to fill the Xtext index with ecore objects (EObjectDescription) when user uploads a file (xlsx/xml) describing structure of this file (existing columns in Excel or tags in XML)? This file is not our "source file" - there are no expression to parse, no AST is build, nor xtext index is filled with ecore objects. I suspect we should do this with GlobalScope and some custom ResourceDescription ? This part it the less known for us.
Sorry if this questions are a little chaotic but we don't know Xtext and EMF internals very well and we fell like we are walking around in a fog ;)
Powered by FUDForum
. Page generated in 0.02860 seconds