/** * Constructs new operation call for the given operation and execution context. * * @param operation a valid AST operation to be called. <code>Note:</code> This must be an * operation owned by a valid QVT Library module * @param context non-QVT transformation context in which this operation will be called * @exception IllegalArgumentException If the passed <code>operation</code> or <code>context * </code> are <code>null</code>; or the operation is not valid AST element for construction * of the call */ HelperOperationCall(Helper operation, NonTransformationExecutionContext context) { if (operation == null || context == null) { throw new IllegalArgumentException(); } fOwningModule = QvtOperationalParserUtil.getOwningModule(operation); if (fOwningModule == null) { throw new IllegalArgumentException("Not a library query or helper"); // $NON-NLS-1$ } fOperation = operation; fContextType = QvtOperationalParserUtil.getContextualType(fOperation); fArgumentTypes = new ArrayList<EClassifier>(fOperation.getEParameters().size()); for (EParameter eParam : fOperation.getEParameters()) { EClassifier paramType = eParam.getEType(); if (paramType == null) { throw new IllegalArgumentException("Parameter with no type"); // $NON-NLS-1$ } fArgumentTypes.add(paramType); } fContext = context; }
protected void handleEParameters( List<EParameter> parameters, Set<EPackage> visitedPackages, Set<Object> visited) { if (parameters != null) { for (EParameter parameter : parameters) { handleEClassifier(parameter.getEType(), visitedPackages, visited); handleEGenericType(parameter.getEGenericType(), visitedPackages, visited); } } }
@Override public Object caseEOperation(EOperation object) { Operation operation = new Operation(object.getName()); operation.type = getType(object.getEType()); operation.setBounds(object.getLowerBound(), object.getUpperBound()); operation.setStatic(false); operation.setScope(Scope.PUBLIC); for (EParameter epar : object.getEParameters()) { TypedElement fpar = new TypedElement(epar.getName()); fpar.type = getType(epar.getEType()); operation.addFormalParameter(fpar); } return operation; }
@Override public String getColumnText(Object element, int index) { if (element instanceof EParameter) { EParameter eParameter = (EParameter) element; StringBuilder builder = new StringBuilder(); builder.append(eParameter.getName()); builder.append(' '); builder.append(':'); builder.append(' '); return EcoreTextUtil.append(builder, eParameter.getEType()).toString(); } return getText(element); }