Generated files in xtext with xbase - xtext

I followed this tutorial: https://www.eclipse.org/Xtext/documentation/104_jvmdomainmodel.html, but the generated files are .java, I want to change the file extension as well as the grammar, but I want to keep some java features. Also the class DomainmodelGenerator extends AbstractGenerator does not get generated when I use grammar org.example.domainmodel.Domainmodel with org.eclipse.xtext.xbase.Xbase, only if I use terminals. How can I achieve that?

If you use Xbase then, JvmModelGenerator will be used as IGenerator(2). So you have to customize that one and override org.eclipse.xtext.xbase.DefaultXbaseRuntimeModule.bindIGenerator() for binding.
But also triple check if you really want to customize the generator and not enhance the inferrer

Related

IBM Integration Bus and xsd:anyType

I'm working with IIB v9 mxsd message definitions. I'd like to define one of the XML elements to be of type xsd:anyType. However, in the list of types I can choose from, only anySimpleType and anyUri are possible (besides all other types like string, integer, etc.).
How can I get around this limitation?
The XMLNSC parser supports the entire XML Schema specification, including xs:any and xs:anyType. In IIBv9 you should create a Library and import your xsds into it. Link your Application to the Library and the XMLNSC parser will find and use the model. You do not need to specify the name of the Library in the node properties; the XSD model will be automatically available to the entire application.
You do not need to use a message set at all in IIBv9 and later versions.
The mxsd file format is used only by the MRM (not DFDL) parser.
You shouldn't use an MXSD to model your XML data, use a normal XSD.
MXSD is for modelling data for the DFDL parser, but you should use the XMLNSC parser for XML messages and define them in XSDs, in which you can use anyType.
As far as I know DFDL doesn't support anyType.

How do I configure StaticParser using expression generator as of angular.dart 0.9.9?

For my production releases, I have been using the expression extractor to generate a file containing expressions that are being used by my templates. When in production, I was configure the StaticParser like so:
import '../gen/expression_cache.gen.dart' as expression_cache;
...
module.type(Parser, implementedBy: StaticParser);
module.value(StaticParserFunctions, expression_cache.functions()); // <-- this no longer works
Something has changed with how the expressions are generated, as the line configuring StaticParserFunctions no longer works. The functions() method no longer exists. So I'm wondering, what is the correct way to do this as of angular 0.9.9?
Is far as I know the Angular Dart tutorial is pretty much up to date.
https://github.com/angular/angular.dart.tutorial/blob/master/Chapter_07/web/initializer-prod.dart
https://angulardart.org/tutorial/09-ch07-deploying-your-app.html (search for generator)

Xtext: refering objects from other languages; namespaces and aliases for importURI?

I'm developing a xtext-based language which should refer to objects defined in a vendor-specific file format.
E.g. this file format defines messages, my language shall define Rules that work with these messages. Of course i want to use xtext features e.g. to autocomplete/validate message names, attributes etc.
Not sure if that is a good idea, but I came up with the following:
Use one xtext project to describe the file format
Add a dependency for this project to my DSL project, import the file format grammar to my grammar
import the description files via importURI
FileFormat grammar:
grammar com.example.xtext.fileformat.FileFormat;
generate fileformat "http://xtext.example.com/fileformat/FileFormat"
[...]
DSL grammar:
grammar com.example.xtext.dsl.DSL;
import "http://xtext.example.com/fileformat/FileFormat" AS ff;
Model:
rules += Rule*;
Rule: ImportFileRule | SampleRule;
ImportFileRule: "IMPORT" importURI=STRING "AS" name=ID ";";
SampleRule: "FORWARD" msg=[ff::Message] ";"
First of all: This works fine.
Now, different imported files may define messages with colliding names,
and I want to use fully qualified names for messages anyways.
The prefix for the message names should be defined in my DSL, e.g. the name of the ImportFileRule.
So I would like to use something like:
IMPORT "first-incredibly-long-filename-with-version-and-stuff.ff" AS first;
IMPORT "second-incredibly-long-filename-with-version-and-stuff.ff" AS second;
FORWARD first.msg_1; // references to msg_1 in first file
FORWARD second.msg_1; // references to msg_1 in second file
Unfortunately I don't see a easy way to achieve this with xtext.
At the moment I'm using a ID for the namespace qualifier and custom ProposalProvider/Validator classes,
which is ugly in detail and bypasses the EMF index, becoming slow with files of 1000 messages and 50000 attributes...
Would there be a right way to do it?
Was it a good idea to use xtext to parse the definition files in the first place?
I have two ideas what to check.
Xtext has a specific global scope provider called ImportedNameSpaceAwareScopeProvider. By using an overridden version of this, you could specify other headers to consider.
Check the implementation of the xtext grammar itself, as it supports such a feature with EPackage imports. I am not exactly sure, how it operates, but should work this way.
Finally, I ended up using the SimpleNamesFragment, ImportURIScopingFragment and a custom ScopeProvider derived from AbstractDeclarativeScopeProvider.
That way, I had to implement ScopeProvider methods for quiet a few rules but was much more flexible in using my "namespace prefix".
E.g. it is simple to implement syntaxes like
FORWARD FROM first: msg_01, msg_02;

Xtext: referencing existing java packages and methods

I developed a DSL which I use together with standard java code.
In my DSL I can write things like this:
package: packagename;
method: void testMethod (int, double);
What I want to do, is that the user of the DSL can only write package names and method signatures which already exist in the Java project.
Example:
When my project only consists of one package e.g. “TestPackage”, the user of the DSL should only be able to write:
package: TestPackage
the name “TestPackage” should also be suggested by the code completor. The same shall also work with the methods.
Is it possible? And how can I do this with Xtext?
I've not used it (yet), but take a look at the relevant Xtext documentation on this. Also, I'd look through the "7 Languages", find one that does what you want (which I think you'll find), and study the source.

How to add filters to OpenCover tool to skip some of the classes in a namespace

How can I add filters to skip some of the classes in a namespace/assembly. For example: SYM.UI is the base assembly and i want to skip SYM.UI.ViewModels. Writing the below filter but it is including all of them and not fulfilling my request:
+[SYM.UI*]* -[SYM.UI.ViewModels*]*
Kindly help me correcting this?
The opencover wiki is a good place to start.
The usage is described as +/-[modulefilter]typefilter (this is based on how you would see the types in IL; where the type filter also includes the namespace and module filter usually is the name of the assembly (without the file extension).
Thus to exclude your types you could use
+[SYM.UI]* -[SYM.UI]SYM.UI.ViewModels.*
NOTE: Exclusion filters take preference over inclusion filters.
You can use following:
"-filter:+[*]* -[SYM.UI]SYM.UI.ViewModels.*"
Note that the quotes must be around the -filter: part, too

Resources