Search code examples
eclipsedslxtextmetamodelecore

Xtext assign object in xtext file


Trying to make a meta model for Mongoose and MondoDb, using metamodeling concepts, eclipse and xtext.

I am trying to assign object that i created in my test.mydsl file to another object in the same file, but i get error in my test.mydsl file.

I am trying to assign created Schema(sc1) object to Collection(col) object, but currently getting an error

error message

the feature 'validate' of 'paket.impl.NCollectionImpl@67d76e14{platform:/resource/test/classes/test.mydsl#//@collections.0}' contains an unresolved proxy 'paket.impl.SchemaImpl@361d8284{platform:/resource/test/classes/test.mydsl#|0}'

my grammar for Schema and Collection

Schema returns Schema:
    {Schema}
    ('Schema' '<' Name=EString) '>'
    '{'
        (schemaExpression+=Expression ( "," schemaExpression+=Expression)*)?
        (verificationDocumentElement+=VerDocElement ( "," verificationDocumentElement+=VerDocElement)*)?
    '}';

NCollection returns NCollection:
    {NCollection}
    ('Collection' '<' Name=EString) ',' (validate=[Schema|EString])? '>'
    '{'
        (document+=Document ( "," document+=Document)*)?
    '}';

my test.mydsl

Database<db1>{

    Schema<sc1>{
        var ja=lp   
        ime:{
            type:String,
            min:123.0
        }

    }
    Collection<col, sc1> 
    {

    }
}

I tried all, but unsuccessful.

Any ideas what to do?

Thanks

EDIT:

Maybe I was not clear enough. The major problem is with "validate" attribute in NCollection rule. When I create my Schema object(sc1 in test.mydsl) and then try to pass it to Collection(col in test.mydsl) as a "sc1", the "validate" attribute cannot accept it like string, and I don't know how to pass it like Schema object. I hope this explanation helps.


Solution

  • Please try to use name=EStringinstead of Name=EString as Xtext imposes a special default semantics for the attribute name. Also I recommend to look into the documentation.