Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » How to retrieve index of statement in java model?
How to retrieve index of statement in java model? [message #883868] Sat, 09 June 2012 12:22
Federico Nicoli is currently offline Federico Nicoli
Messages: 6
Registered: June 2012
Junior Member
This is my atl trasformation :
-- @atlcompiler atl2010

module ppp;
create OUT : java from IN : java;

rule createStatement2 {
	from

		imd : java!MethodDeclaration(
			--seleziono i metodi che hanno l'annotation
			imd.name = 'test1' 
		)
		to		
			
		do{
			imd.body.statements  <- imd.body.statements  -> insertAt(imd.body.statements.size() -1 ,thisModule.createFirstStatement(imd));
}
}
rule createFirstStatement( cu:java!CompilationUnit) {
	to
		newStatement_1_VarDeclarationStat: java!VariableDeclarationStatement (
			originalCompilationUnit <- cu.originalCompilationUnit,
			type <- newStatement_1_TypeAccess_2,
			fragments <- newStatement_1_VariableDeclFragm
		)
		,newStatement_1_TypeAccess: java!TypeAccess (
			type <- java!ClassDeclaration.allInstances() -> select(e | e.name =
					'String') -> first()
		),
		newStatement_1_TypeAccess_2: java!TypeAccess (
			type <- java!ClassDeclaration.allInstances() -> select(e | e.name =
					'String') -> first()
		),
		newStatement_1_VariableDeclFragm: java!VariableDeclarationFragment (
			name <- 'sbQuery',
			originalCompilationUnit <- cu.originalCompilationUnit,
			variablesContainer <- newStatement_1_VarDeclarationStat,
			initializer <- newStatement_1_ClassInstanceCreat
		),
		newStatement_1_ClassInstanceCreat: java!ClassInstanceCreation (
			originalCompilationUnit <- cu.originalCompilationUnit,
			method <- java!ConstructorDeclaration.allInstances() -> select(e | e.name =
					'String') -> first(),
			type <- newStatement_1_TypeAccess
		)
	do {
		newStatement_1_VarDeclarationStat; 
	}
}


insertAt instructions doesn't work because it is done append !
Can you help ?
Sorry for my english Smile
Previous Topic:m2m.atl.core.IModel- How to pull out objects?
Next Topic:Transformation Rules
Goto Forum:
  


Current Time: Fri Apr 18 06:53:29 EDT 2014

Powered by FUDForum. Page generated in 0.01680 seconds