| [module ServiceUtils('http://www.eclipse.org/acceleo/mt/2.6.0')/] |
| |
| [query public isOperationCall(call : Call) : Boolean = |
| if call.arguments->size() > 0 then |
| true |
| else |
| let callName : String = |
| call.name |
| in |
| callName.isEObjectService() or |
| callName.isRequestService() or |
| callName.isResourceService() or |
| callName.isStringService() or |
| callName.isSystemService() or |
| callName.isXPathService() or |
| call.isENodeService() or |
| callName.isContextService() or |
| callName.isPropertiesService() or |
| call.isScriptCall() or |
| call.isServiceCall() endif/] |
| |
| [query private isScriptCall(call : Call) : Boolean = |
| call.ancestors()->last().allScripts() |
| ->collect(descriptor.name)->includes(call.name)/] |
| [query public isServiceCall(call : Call) : Boolean = |
| call.ancestors()->last().allMethods()->collect(name) |
| ->includes(call.name)/] |
| |
| [query public getTargetService(call : Call) : Set(Method) = |
| call.ancestors()->last().allMethods() |
| ->select(name = call.name)->asSet()/] |
| |
| [comment this has been externalized here to make use of the query's caching/] |
| [query private allScripts(root : OclAny) : Sequence(Script) = |
| root.eAllContents(mt::core::Script)/] |
| [query private allMethods(root : OclAny) : Sequence(Method) = |
| root.eAllContents(mt::core::Method)/] |
| |
| [query public signature(method : Method) : String = |
| method.name.concat('(').concat(parametersSignature()).concat(')')/] |
| |
| [query private parametersSignature(method : Method) : String = |
| let parameters : Sequence(String) = |
| method.parameters.type->sep(', ').oclAsType(String) |
| in |
| parameters->iterate(param; res : String = '' | res.concat(param)) |
| /] |
| |
| [query public isEObjectService(callName : String) : Boolean = |
| let serviceNames : Sequence(String) = |
| Sequence{'eAllContents', 'eClass', |
| 'eContainer','eContainingFeature', |
| 'eContainmentFeature','eContents', |
| 'eCrossReferences','eResource', |
| 'eResourceName','getRootContainer','load'} |
| in |
| serviceNames->includes(callName) |
| /] |
| |
| [query public isRequestService(callName : String) : Boolean = |
| let serviceNames : Sequence(String) = |
| Sequence{'select','delete','evaluate'} |
| in |
| serviceNames->includes(callName) |
| /] |
| |
| [query public isResourceService(callName : String) : Boolean = |
| let serviceNames : Sequence(String) = |
| Sequence{'getFileContent','getChainPath'} |
| in |
| serviceNames->includes(callName) |
| /] |
| |
| [query public isStringService(callName : String) : Boolean = |
| let serviceNames : Sequence(String) = |
| Sequence{'length','toUpperCase','toLowerCase', |
| 'toU1Case','toL1Case','substring', |
| 'replaceAll','replaceFirst','trim', |
| 'startsWith','endsWith','equalsIgnoreCase', |
| 'matches','charAt','indexOf','lastIndexOf', |
| 'split','indentSpace','indentTab'} |
| in |
| serviceNames->includes(callName) |
| /] |
| |
| [query public isSystemService(callName : String) : Boolean = |
| let serviceNames : Sequence(String) = |
| Sequence{'i','args'} |
| in |
| serviceNames->includes(callName) |
| /] |
| |
| [query public isXPathService(callName : String) : Boolean = |
| let serviceNames : Sequence(String) = |
| Sequence{'ancestor','parent','self','child','descendant', |
| 'precedingSibling','preceding','followingSibling','following'} |
| in |
| serviceNames->includes(callName) |
| /] |
| |
| [query public isENodeService(call : Call) : Boolean = |
| let serviceNamesNoArg : Sequence(String) = |
| Sequence{'current','debug','trace','nPut','nPeek','nPop','nPush', |
| 'nMinimize','minimize','nFirst','nLast','nReverse','reverse', |
| 'nSize','nSort','sort','sep','sepStr','toString'}, |
| serviceNamesArg : Sequence(String) = |
| Sequence{'adapt','cast','filter','nContains','nGet','sep','sepStr' |
| ,'until'} |
| in |
| if serviceNamesNoArg->includes(call.name) then |
| true |
| else if serviceNamesArg->includes(call.name) |
| and not call.arguments->isEmpty() then |
| true |
| else |
| false |
| endif endif |
| /] |
| |
| [query public isENodeServiceStr(callName : String) : Boolean = |
| let serviceNames : Sequence(String) = |
| Sequence{'adapt','cast','filter','current','debug','trace','nPut', |
| 'nGet','nPeek','nPop','nPush','nMinimize','minimize', |
| 'nContains','nFirst','nLast','nReverse','reverse','nSize', |
| 'nSort','sort','sep','sepStr','toString','until'} |
| in |
| serviceNames->includes(callName) |
| /] |
| |
| [query public isContextService(callName : String) : Boolean = |
| let serviceNames : Sequence(String) = |
| Sequence{'get','peek','pop','push','put'} |
| in |
| serviceNames->includes(callName) |
| /] |
| |
| [query public isPropertiesService(callName : String) : Boolean = |
| let serviceNames : Sequence(String) = |
| Sequence{'getBestProperty','getProperty'} |
| in |
| serviceNames->includes(callName) |
| /] |