protected static String getPropertyName(final JvmOperation operation, final String methodName, final String prefix, final int params) { String _xblockexpression = null; { final int prefixLength = prefix.length(); String _xifexpression = null; if ((PropertyUtil.startsWithPrefix(methodName, prefix, prefixLength) && (operation.getParameters().size() == params))) { _xifexpression = Introspector.decapitalize(methodName.substring(prefixLength)); } _xblockexpression = _xifexpression; } return _xblockexpression; }
/** * Returns true, if the given operation matches this dispatch signature and is therefore a case * for this dispatcher. */ public boolean isDispatchCase(JvmOperation operation) { return arity == operation.getParameters().size() && simpleName.equals(operation.getSimpleName()); }
protected LightweightTypeReference getFirstParameterType(IIdentifiableElementDescription candidate) { JvmOperation operation = (JvmOperation) candidate.getElementOrProxy(); if (operation.getParameters().isEmpty()) { return null; } return getParameterType(operation.getParameters().get(0)); }
protected boolean isGetClass(JvmIdentifiableElement feature) { if (feature instanceof JvmOperation && feature.getSimpleName().equals("getClass")) { JvmOperation getClassOperation = (JvmOperation) feature; if (getClassOperation.getParameters().isEmpty() && "java.lang.Object".equals(getClassOperation.getDeclaringType().getIdentifier())) { return true; } } return false; }
public OperationBodyComputationState(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmOperation operation) { super(resolvedTypes.pushExpectedExceptions(operation), featureScopeSession, operation); for(JvmFormalParameter parameter: operation.getParameters()) { addLocalToCurrentScope(parameter); } }
public JvmOperation getDispatcherOperation(JvmDeclaredType type, DispatchSignature signature) { Iterable<JvmFeature> allByName = type.findAllFeaturesByName(signature.getSimpleName()); for(JvmFeature feature: allByName) { if (feature instanceof JvmOperation && signature.getArity() == ((JvmOperation) feature).getParameters().size()) { return (JvmOperation) feature; } } return null; }
protected List<JvmType> getParamTypes(JvmOperation jvmOperation, boolean wrapPrimitives) { List<JvmType> types = newArrayList(); for (JvmFormalParameter p : jvmOperation.getParameters()) { LightweightTypeReference typeReference = toLightweightTypeReference(p.getParameterType()); if (wrapPrimitives) { typeReference = typeReference.getWrapperTypeIfPrimitive(); } types.add(typeReference.getType()); } return types; }
@Override public void apply(final JvmOperation it) { EList<JvmFormalParameter> _parameters = it.getParameters(); JvmFormalParameter _specificationParameter = EmfParsleyDslJvmModelInferrer.this.specificationParameter(specification); EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _specificationParameter); EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.setBody(it, specification.getExpression()); } };
@Override public void apply(final JvmOperation it, final FeatureAssociatedExpression spec) { EList<JvmFormalParameter> _parameters = it.getParameters(); JvmFormalParameter _parameter = EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.toParameter(spec, "it", spec.getParameterType()); EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); } };
@Override public void apply(final JvmOperation it, final FeatureAssociatedExpression spec) { EList<JvmFormalParameter> _parameters = it.getParameters(); JvmFormalParameter _parameter = EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.toParameter(spec, "it", EmfParsleyDslJvmModelInferrer.this._typeReferenceBuilder.typeRef(EStructuralFeature.class)); EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); } };
@Override public void apply(final JvmOperation it, final FeatureAssociatedExpression spec) { EList<JvmFormalParameter> _parameters = it.getParameters(); JvmFormalParameter _parameter = EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.toParameter(spec, "parent", EmfParsleyDslJvmModelInferrer.this._typeReferenceBuilder.typeRef(Composite.class)); EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); EList<JvmFormalParameter> _parameters_1 = it.getParameters(); JvmFormalParameter _parameter_1 = EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.toParameter(spec, "it", EmfParsleyDslJvmModelInferrer.this._typeReferenceBuilder.typeRef(EStructuralFeature.class)); EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1); } };
private boolean hasPrimitiveParameters(JvmOperation op) { for (final JvmFormalParameter parameter : op.getParameters()) { final JvmTypeReference type = parameter.getParameterType(); if (type == null || !Utils.toLightweightTypeReference(type, this.services).isPrimitive()) { return false; } } return true; }
/** * Return the local cases that contribute to the given dispatch operation (in no particular order, but usually as defined in the file). */ public List<JvmOperation> getLocalDispatchCases(JvmOperation dispatcherOperation) { DispatchSignature dispatchSignature = new DispatchSignature(dispatcherOperation.getSimpleName(), dispatcherOperation.getParameters().size()); JvmDeclaredType type = dispatcherOperation.getDeclaringType(); return getLocalDispatchCases(type, dispatchSignature); }
protected LightweightTypeReference getClosureOperationParameterType(LightweightTypeReference closureType, JvmOperation operation, int i) { ITypeReferenceOwner owner = newTypeReferenceOwner(operation); Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> mapping = new DeclaratorTypeArgumentCollector().getTypeParameterMapping(closureType); LightweightTypeReference parameterType = owner.toLightweightTypeReference(operation.getParameters().get(i).getParameterType()); return new StandardTypeParameterSubstitutor(mapping, owner).substitute(parameterType); }
/** * Return all the cases that are associated with the given dispatch operation. */ public List<JvmOperation> getAllDispatchCases(JvmOperation dispatcherOperation) { DispatchSignature dispatchSignature = new DispatchSignature(dispatcherOperation.getSimpleName(), dispatcherOperation.getParameters().size()); JvmDeclaredType type = dispatcherOperation.getDeclaringType(); ITypeReferenceOwner owner = new StandardTypeReferenceOwner(services, type); ContextualVisibilityHelper contextualVisibilityHelper = new ContextualVisibilityHelper(visibilityHelper, owner.newParameterizedTypeReference(type)); return getAllDispatchMethods(dispatchSignature, type, contextualVisibilityHelper); }
@Override public void apply(final JvmOperation it) { EList<JvmFormalParameter> _parameters = it.getParameters(); JvmFormalParameter _parameter = EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.toParameter(spec, "it", spec.getParameterType()); EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.setBody(it, spec.getExpression()); } };
@Override public void apply(final JvmOperation it) { EmfParsleyDslJvmModelInferrer.this.addOverrideAnnotation(it); EList<JvmFormalParameter> _parameters = it.getParameters(); JvmFormalParameter _parameter = EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.toParameter(m, "it", EmfParsleyDslJvmModelInferrer.this._typeReferenceBuilder.typeRef(Resource.class)); EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.setBody(it, m.getBody()); } };
@Override public void apply(final JvmOperation it) { it.setVisibility(JvmVisibility.PROTECTED); EList<JvmFormalParameter> _parameters = it.getParameters(); JvmFormalParameter _parameter = EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.toParameter(spec, "it", EmfParsleyDslJvmModelInferrer.this._typeReferenceBuilder.typeRef(Control.class)); EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.setBody(it, spec.getTarget()); } };
private InferredPrototype getInferredPrototype(JvmOperation operation) { final XtendFunction fct = this.associations.getXtendFunction(operation); if (fct != null) { return getInferredPrototype(fct); } final QualifiedActionName actionKey = this.actionPrototypes.createQualifiedActionName( operation.getDeclaringType(), operation.getSimpleName()); // Compute the different action prototypes associated to the action to create. return this.actionPrototypes.createPrototypeFromJvmModel( actionKey, operation.isVarArgs(), operation.getParameters()); }
@Override public void apply(final JvmOperation it) { EList<JvmAnnotationReference> _annotations = it.getAnnotations(); JvmAnnotationReference _annotationRef = PatternMatcherClassInferrer.this.annBuilder.annotationRef(Override.class); PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); it.setVisibility(JvmVisibility.PROTECTED); EList<JvmFormalParameter> _parameters = it.getParameters(); JvmTypeReference _typeRef = PatternMatcherClassInferrer.this.builder.typeRef(Tuple.class); JvmFormalParameter _parameter = PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.toParameter(pattern, "t", _typeRef); PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); } };