0

I have just started learning XTEXT, and I can see the bright future of automatic coding with it. :) Currently I am working on seven-languages training part and I am stucked on MongoDb example. I am following the description of that example but I am experiencing the issue of not resolved types inside DSL (when I try to define 'Album' or 'Track' inside 'Artist' the IDE displays "cannot be resolved as type")

Thanks in advance

grammar org.xtext.example.mydsl.MongoBeans with org.eclipse.xtext.xbase.Xbase

generate mongoBeans "http://www.xtext.org/example/mydsl/MongoBeans"

MongoFile:
    importSection=XImportSection?
    elements+=AbstractElement*;

AbstractElement:
    PackageDeclaration | MongoBean;

PackageDeclaration:
    'package' name=QualifiedName '{'
        elements+=AbstractElement*
    '}';

MongoBean:
    name=ValidID '{'
        features+=AbstractFeature*
    '}';

AbstractFeature:
    MongoOperation | MongoProperty;

MongoProperty:
    (type=JvmTypeReference | inlineType=MongoBean) (many?='*')? name=ValidID;

MongoOperation:
    =>(returnType=JvmTypeReference name=ValidID '(')
            (parameters+=FullJvmFormalParameter
                (',' parameters+=FullJvmFormalParameter)*
            )?
    ')'
    body=XBlockExpression;



package org.musicdb {
    // a mongo bean
    Artist {
        String name    // single valued property
        Album* album

        Album* albums  // array property
        // an operation
        Iterable<Track> getOeuvre() {
            albums.map[track].flatten
        }
    }

    // another mongo bean
    Album {
        String title
        int year
        // inline definition of a mongo bean
        Track {
            String title
            int seconds
        }* tracks
    }
}

0 Answers0