Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Make my model nodes implement an interface?
Make my model nodes implement an interface? [message #901088] Thu, 09 August 2012 17:26 Go to next message
Dobes Vandermeer is currently offline Dobes VandermeerFriend
Messages: 26
Registered: July 2009
Junior Member
I have this horrible piece of code:


	public static class GetDeclName extends AstSwitch<DeclName> {
		@Override public DeclName caseAxiom(Axiom object) { return object.getName(); }
		@Override public DeclName caseCEnum(CEnum object) { return object.getName(); }
		@Override public DeclName caseClass(Class object) { return object.getName(); }
		@Override public DeclName caseCStructDef(CStructDef object) { return object.getName(); }
		@Override public DeclName caseEnumDef(EnumDef object) { return object.getName(); }
		@Override public DeclName caseFun(Fun object) { return object.getName(); }
		@Override public DeclName caseInsertion(Insertion object) { return object.getName(); }
		@Override public DeclName caseInstance(Instance object) { return object.getName(); }
		@Override public DeclName caseLemma(Lemma object) { return object.getName(); }
		@Override public DeclName caseModule(Module object) { return object.getName(); }
		@Override public DeclName caseObjectFunction(ObjectFunction object) { return object.getName(); }
		@Override public DeclName caseParameter(Parameter object) { return object.getName(); }
		@Override public DeclName caseProc(Proc object) { return object.getName(); }
		@Override public DeclName caseReduce(Reduce object) { return object.getName(); }
		@Override public DeclName caseRename(Rename object) { return object.getName(); }
		@Override public DeclName caseStructDef(StructDef object) { return object.getName(); }
		@Override public DeclName caseTheorem(Theorem object) { return object.getName(); }
		@Override public DeclName caseTypeDecl(TypeDecl object) { return object.getName(); }
		@Override public DeclName caseTypedef(Typedef object) { return object.getName(); }
		@Override public DeclName caseTVar(TVar object) { return object.getName(); }
		@Override public DeclName caseUnionDef(UnionDef object) { return object.getName(); }
	}


I'm wonder if I could just have an interface like HasName and convince Xtext to put "implements HasName" on the appropriate nodes.

Is this kind of customization possible?
Re: Make my model nodes implement an interface? [message #901091 is a reply to message #901088] Thu, 09 August 2012 17:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6543
Registered: July 2009
Senior Member
Hi,

introducing an abstract Rule

Named: Axiom | CEnum | ... | UnionDef ;

doesnt work?

~Christian

Re: Make my model nodes implement an interface? [message #901142 is a reply to message #901091] Fri, 10 August 2012 02:09 Go to previous message
Dobes Vandermeer is currently offline Dobes VandermeerFriend
Messages: 26
Registered: July 2009
Junior Member
That is very smart! Thanks!
Previous Topic:Xtext standalone application beginner tutorial
Next Topic:problem with if expression
Goto Forum:
  


Current Time: Thu Dec 18 16:23:07 GMT 2014

Powered by FUDForum. Page generated in 0.16000 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software