0

I want to know how I can access the parsed model of my program. I have a validation check written in xtend which accepts a rule A as it parameter. however I want to search the entire parsed tree and make sure that any other reference to this specific instance of A follows certain specifications.

@Check
    def checkActionBelongsToAssociatedRole(ActionDsc act){
        var pRole = act.parentRole
        var rs = new ResourceSetImpl()
//DONT KNOW IF THIS IS RIGHT
        var resource = rs.getResource(URI.createURI("./model/generated/Protocol.ecore"), true)
        for(r:resource.allContents.toIterable.filter(typeof(RoleDec))){
            if(r.name == pRole.name){
                //DO SOMETHING
            }
        }
    }

In the generator file that I have I already get the Resource object as a parameter.

override void doGenerate(Resource resource, IFileSystemAccess fsa) {
        //Generate code
    }

How can I do the same thing for my validator. Thank you in advance!

user804723
  • 329
  • 1
  • 3
  • 9

1 Answers1

1

act.eResource() allows to access the resource that contains the action.

Sebastian Zarnekow
  • 6,609
  • 20
  • 23