@Override public void apply(final JvmConstructor it) { String _matcherClassName = PatternMatcherClassInferrer.this._eMFPatternLanguageJvmModelInferrerUtil.matcherClassName(pattern); it.setSimpleName(_matcherClassName); EList<JvmAnnotationReference> _annotations = it.getAnnotations(); JvmAnnotationReference _annotationRef = PatternMatcherClassInferrer.this.annBuilder.annotationRef(Deprecated.class); PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); it.setVisibility(JvmVisibility.PUBLIC); CharSequence _javadocMatcherConstructorEngine = PatternMatcherClassInferrer.this._javadocInferrer.javadocMatcherConstructorEngine(pattern); String _string = _javadocMatcherConstructorEngine.toString(); PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.setDocumentation(it, _string); EList<JvmFormalParameter> _parameters = it.getParameters(); JvmTypeReference _typeRef = PatternMatcherClassInferrer.this.builder.typeRef(IncQueryEngine.class); JvmFormalParameter _parameter = PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.toParameter(pattern, "engine", _typeRef); PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); EList<JvmTypeReference> _exceptions = it.getExceptions(); JvmTypeReference _typeRef_1 = PatternMatcherClassInferrer.this.builder.typeRef(IncQueryException.class); PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef_1); StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append("super(engine, querySpecification());"); } }; PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.setBody(it, _client); } };
protected IScope getThisOrSuperScope(XAbstractFeatureCall call, JvmConstructor constructor) { QualifiedName name = THIS; JvmIdentifiableElement logicalContainer = logicalContainerProvider.getNearestLogicalContainer(call); if (logicalContainer instanceof JvmConstructor) { JvmDeclaredType thisType = ((JvmConstructor) logicalContainer).getDeclaringType(); if (thisType != constructor.getDeclaringType()) { name = SUPER; } } return new SingletonScope(EObjectDescription.create(name, constructor), IScope.NULLSCOPE); }
associator.associatePrimary(anonymousClass.getConstructorCall(), constructor); if (visible) { constructor.setVisibility(JvmVisibility.DEFAULT); } else constructor.setVisibility(JvmVisibility.PRIVATE); constructor.setSimpleName(inferredLocalClass.getSimpleName()); constructor.setVarArgs(superConstructor.isVarArgs()); final List<JvmFormalParameter> parameters = superConstructor.getParameters(); for(JvmFormalParameter parameter: parameters) { constructor.getParameters().add(typesBuilder.cloneWithProxies(parameter)); for (JvmTypeReference exception : superConstructor.getExceptions()) constructor.getExceptions().add(typesBuilder.cloneWithProxies(exception));
public void completeJvmConstructor(JvmConstructor constructor) { JvmDeclaredType declaringType = constructor.getDeclaringType(); if(declaringType != null) { String simpleName = declaringType.getSimpleName(); if(simpleName != null) { constructor.setSimpleName(simpleName); return; } } constructor.setSimpleName("unset"); }
public List<JvmTypeParameter> getDeclaredTypeParameters(JvmConstructor constructor) { List<JvmTypeParameter> constructorTypeParameters = constructor.getTypeParameters(); if (constructorTypeParameters.isEmpty()) { JvmDeclaredType createdType = constructor.getDeclaringType(); if (createdType instanceof JvmTypeParameterDeclarator) { return ((JvmTypeParameterDeclarator) createdType).getTypeParameters(); } } else { JvmDeclaredType createdType = constructor.getDeclaringType(); if (createdType instanceof JvmTypeParameterDeclarator) { List<JvmTypeParameter> typeParameters = ((JvmTypeParameterDeclarator) createdType).getTypeParameters(); if (typeParameters.isEmpty()) { return constructorTypeParameters; } List<JvmTypeParameter> result = Lists.newArrayList(constructorTypeParameters); result.addAll(typeParameters); return result; } return constructorTypeParameters; } return Collections.emptyList(); }
if (it instanceof JvmConstructor) { final JvmConstructor op = (JvmConstructor) it; return op.getVisibility() != JvmVisibility.PRIVATE && (op.getVisibility() != JvmVisibility.DEFAULT || samePackage); for (final JvmConstructor constructor : constructors) { final ActionParameterTypes types = this.sarlSignatureProvider.createParameterTypesFromJvmModel( constructor.isVarArgs(), constructor.getParameters()); sortedConstructors.add(new Pair<>(constructor, types)); final JvmConstructor constructor = pair.getKey(); final JvmConstructor newCons = this.typesFactory.createJvmConstructor(); newCons.setDeprecated(constructor.isDeprecated()); newCons.setSimpleName(target.getSimpleName()); target.getMembers().add(newCons); for (final JvmFormalParameter parameter : constructor.getParameters()) { final JvmFormalParameter newParam = this.typesFactory.createJvmFormalParameter(); newParam.setName(parameter.getSimpleName()); newCons.getParameters().add(newParam); newCons.setVarArgs(constructor.isVarArgs()); JvmVisibility visibility = constructor.getVisibility(); if (visibility != null && minimalVisibility != null && minimalVisibility.compareTo(visibility) > 0) { visibility = minimalVisibility; newCons.setVisibility(visibility);
container.getMembers().add(constructor); this.associator.associatePrimary(source, constructor); constructor.setSimpleName(constructorName); setVisibility(constructor, source); constructor.setVarArgs(isVarArgs); constructor.getExceptions().add(this.typeBuilder.cloneWithProxies(exception)); isVarArgs, constructor.getParameters()); container.getMembers().add(constructor2); copyAndCleanDocumentationTo(source, constructor2); constructor2.setSimpleName(container.getSimpleName()); constructor2.setVisibility(constructor.getVisibility()); constructor2.setVarArgs(isVarArgs);
@Override public void apply(final JvmConstructor it) { String _matchClassName = PatternMatchClassInferrer.this._eMFPatternLanguageJvmModelInferrerUtil.matchClassName(pattern); it.setSimpleName(_matchClassName); it.setVisibility(JvmVisibility.PRIVATE); EList<Variable> _parameters = pattern.getParameters(); for (final Variable variable : _parameters) { EList<JvmFormalParameter> _parameters_1 = it.getParameters(); String _parameterName = PatternMatchClassInferrer.this._eMFPatternLanguageJvmModelInferrerUtil.parameterName(variable); JvmFormalParameter _parameter = PatternMatchClassInferrer.this._eMFJvmTypesBuilder.toParameter(variable, _parameterName, javaType);
private Collection<ActionParameterTypes> doGetConstructorParameterTypes(Class<?> type, Notifier context) { final Collection<ActionParameterTypes> parameters = new ArrayList<>(); final JvmTypeReference typeReference = this.typeReferences.getTypeForName(type, context); final JvmType jvmType = typeReference.getType(); if (jvmType instanceof JvmDeclaredType) { final JvmDeclaredType declaredType = (JvmDeclaredType) jvmType; for (final JvmConstructor constructor : declaredType.getDeclaredConstructors()) { final ActionParameterTypes types = this.sarlActionSignatures.createParameterTypesFromJvmModel( constructor.isVarArgs(), constructor.getParameters()); if (types != null) { parameters.add(types); } } } if (parameters.isEmpty()) { parameters.add(this.sarlActionSignatures.createParameterTypesForVoid()); } return parameters; }
protected JvmConstructor inferAnonymousClassConstructor(AnonymousClass anonymousClass, JvmGenericType inferredLocalClass) { XConstructorCall constructorCall = anonymousClass.getConstructorCall(); JvmConstructor constructor = TypesFactory.eINSTANCE.createJvmConstructor(); inferredLocalClass.getMembers().add(constructor); associator.associatePrimary(constructorCall, constructor); constructor.setVisibility(JvmVisibility.DEFAULT); constructor.setSimpleName(inferredLocalClass.getSimpleName()); return constructor; }
protected boolean isSameSignature(JvmConstructor constructor, JvmConstructor superConstructor) { if(constructor.getParameters().size() != superConstructor.getParameters().size()) return false; for(int i=0; i<constructor.getParameters().size(); ++i) { JvmTypeReference paramType = constructor.getParameters().get(i).getParameterType(); JvmTypeReference superParamType = superConstructor.getParameters().get(i).getParameterType(); if(!paramType.getIdentifier().equals(superParamType.getIdentifier())) return false; } return true; } }
@Override public void apply(final JvmConstructor it) { it.setVisibility(JvmVisibility.PRIVATE); String _groupClassName = PatternGroupClassInferrer.this.groupClassName(model); it.setSimpleName(_groupClassName); EList<JvmTypeReference> _exceptions = it.getExceptions(); PatternGroupClassInferrer.this._eMFJvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, incQueryException); StringConcatenationClient _client = new StringConcatenationClient() {
EList<JvmMember> _members = matchClass.getMembers(); final Procedure1<JvmConstructor> _function = (JvmConstructor it) -> { it.setVisibility(JvmVisibility.PRIVATE); EList<Variable> _parameters = pattern.getParameters(); for (final Variable variable : _parameters) { EList<JvmFormalParameter> _parameters_1 = it.getParameters(); JvmFormalParameter _parameter = this._eMFJvmTypesBuilder.toParameter(variable, this._eMFPatternLanguageJvmModelInferrerUtil.parameterName(variable), javaType); this._eMFJvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter);
public boolean isSingleSyntheticDefaultConstructor(final JvmConstructor it) { return ((((it.getParameters().isEmpty() && (this._iLogicalContainerProvider.getAssociatedExpression(it) == null)) && (this.getCompilationStrategy(it) == null)) && (this.getCompilationTemplate(it) == null)) && (IterableExtensions.size(Iterables.<JvmConstructor>filter(it.getDeclaringType().getMembers(), JvmConstructor.class)) == 1)); }
protected SignatureHashBuilder appendSignature(JvmConstructor operation) { appendVisibility(operation.getVisibility()).appendTypeParameters(operation).append("("); for (JvmFormalParameter p : operation.getParameters()) { appendType(p.getParameterType()).append(" "); } append(") "); for (JvmTypeReference ex : operation.getExceptions()) { appendType(ex).append(" "); } return this; }
if (constructor.getVisibility() != JvmVisibility.PRIVATE) { constructors.add(constructor); bitset.set(constructor.getVisibility().getValue()); if (constructor.isStatic()) { bitset.set(4); if (constructor.isVarArgs()) { bitset.set(5); for (final JvmFormalParameter parameter : constructor.getParameters()) { serialVersionUIDBuffer.append(parameter.getParameterType().getIdentifier());
@Override public void apply(final JvmConstructor it) { EList<JvmFormalParameter> _parameters = it.getParameters(); JvmFormalParameter _parameter = EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.toParameter(e, "adapterFactory", EmfParsleyDslJvmModelInferrer.this._typeReferenceBuilder.typeRef(AdapterFactory.class)); EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { @Override public void apply(final ITreeAppendable it) { it.append("super(adapterFactory);"); } }; EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function); EList<JvmAnnotationReference> _annotations = it.getAnnotations(); JvmAnnotationReference _annotationRef = EmfParsleyDslJvmModelInferrer.this._annotationTypesBuilder.annotationRef(Inject.class); EmfParsleyDslJvmModelInferrer.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); } };
public JvmGenericType getSuperType(AnonymousClass anonymousClass) { JvmConstructor constructor = anonymousClass.getConstructorCall().getConstructor(); if(constructor != null && ! constructor.eIsProxy()) { JvmDeclaredType declaringType = constructor.getDeclaringType(); JvmType superType = Iterables.getLast(declaringType.getSuperTypes()).getType(); if(superType instanceof JvmGenericType) return (JvmGenericType) superType; } return null; }
enhanceExecutable(result, constructor, declaringClass.getSimpleName(), genericParameterTypes, constructor.getParameterAnnotations(), offset); result.setVarArgs(constructor.isVarArgs()); Type[] exceptionTypes; try { InternalEList<JvmTypeReference> exceptions = (InternalEList<JvmTypeReference>)result.getExceptions(); for (Type exceptionType : exceptionTypes) { exceptions.addUnique(createTypeReference(exceptionType));
@SuppressWarnings("unused") protected void _computeTypes(Map<JvmIdentifiableElement, ResolvedTypes> preparedResolvedTypes, ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmConstructor constructor) { ResolvedTypes childResolvedTypes = preparedResolvedTypes.get(constructor); if (childResolvedTypes == null) { if (preparedResolvedTypes.containsKey(constructor)) return; throw new IllegalStateException("No resolved type found. Constructor was: " + constructor.getIdentifier()); } else { preparedResolvedTypes.put(constructor, null); } ConstructorBodyComputationState state = new ConstructorBodyComputationState(childResolvedTypes, featureScopeSession.toInstanceContext().toConstructorContext(), constructor); addExtensionProviders(state, constructor.getParameters()); state.computeTypes(); computeAnnotationTypes(childResolvedTypes, featureScopeSession, constructor); computeLocalTypes(preparedResolvedTypes, childResolvedTypes, featureScopeSession, constructor); mergeChildTypes(childResolvedTypes); }