/** Add the @Generated annotation to the given target. * * @param target the target of the annotation. * @param context the generation context. * @param sarlCode the code that is the cause of the generation. */ protected void appendGeneratedAnnotation(JvmAnnotationTarget target, GenerationContext context, String sarlCode) { final GeneratorConfig config = context.getGeneratorConfig(); if (config.isGenerateGeneratedAnnotation()) { addAnnotationSafe(target, Generated.class, getClass().getName()); } if (target instanceof JvmFeature) { addAnnotationSafe(target, SyntheticMember.class); } if (!Strings.isNullOrEmpty(sarlCode)) { addAnnotationSafe(target, SarlSourceCode.class, sarlCode); } }
private static boolean isAppendCloneFunctionsEnable(GenerationContext context) { return context.getGeneratorConfig2().isGenerateCloneFunctions(); }
context.getInheritedFinalOperations(), context.getInheritedOverridableOperations(), null, context.getInheritedOperationsToImplement(), null, this.sarlSignatureProvider); if (context.isSupportedMember(feature) && (!(feature instanceof SarlCapacityUses)) && (!(feature instanceof SarlRequiredCapacity))) { if (context.isSupportedMember(feature) && ((feature instanceof SarlCapacityUses) || (feature instanceof SarlRequiredCapacity))) {
if (container.isInterface()) { enableFunctionBody = false; if (context != null && context.isAtLeastJava8() && !Utils.toLightweightTypeReference(container, this.services).isSubtypeOf(Capacity.class)) { if (operation.isStatic()) { JvmOperation tmpInheritedOperation = context.getInheritedFinalOperations().get(actSigKey); if (tmpInheritedOperation == null) { tmpInheritedOperation = context.getInheritedOverridableOperations().get(actSigKey); tmpInheritedOperation = context.getInheritedOperationsToImplement().get(actSigKey); if (context != null && context.isAtLeastJava8() && context.getGeneratorConfig2().isGenerateInlineAnnotation() && !source.isAbstract() && !container.isInterface() && (source.isStatic() || source.isFinal() || container.isFinal()) && context.getParentContext() == null && this.annotationFinder.findAnnotation(operation, Inline.class) == null) { context.getPostFinalizationElements().add( () -> this.inlineExpressionCompiler.appendInlineAnnotation(operation, source)); if (context != null && context.getGeneratorConfig2().isGeneratePureAnnotation() && !hasExplicitPureAnnotation && this.typeReferences.findDeclaredType(Pure.class, source) != null) { addDynamicPureAnnotationGenerator = inheritedOperation == null; final JvmOperation implementedOperation = context.getInheritedOperationsToImplement().remove(actSigKey); context.getInheritedOverridableOperations().put(actSigKey, operation);
if (type instanceof JvmGenericType && !context.getGeneratedCapacityUseFields().contains(capacityType.getIdentifier())) { if (context.isAtLeastJava8()) { context.getPostFinalizationElements().add(() -> { final String inlineExpression = Utils.HIDDEN_MEMBER_CHARACTER + "castSkill(" + capacityType.getSimpleName() //$NON-NLS-1$ if (context.getGeneratorConfig2().isGeneratePureAnnotation()) { addAnnotationSafe(operation, Pure.class); context.addGeneratedCapacityUseField(capacityType.getIdentifier()); context.incrementSerial(capacityType.getIdentifier().hashCode());
final Iterator<Runnable> differedGeneration = context.getPreFinalizationElements().iterator(); while (differedGeneration.hasNext()) { final Runnable runnable = differedGeneration.next(); int actIndex = context.getActionIndex(); for (final Entry<ActionPrototype, JvmOperation> missedOperation : context.getInheritedOperationsToImplement() .entrySet()) { final JvmOperation redefinedOperation = context.getInheritedOverridableOperations().get( this.sarlSignatureProvider.createActionPrototype( missedOperation.getKey().getActionName(), context.setActionIndex(actIndex);
context.getGeneratedConstructors().put(sigKey, constructor); : constructorSignatures.getInferredParameterTypes().entrySet()) { if (context == null || !context.getGeneratedConstructors().containsKey(entry.getKey())) { final List<InferredStandardParameter> otherSignature = entry.getValue(); context.getGeneratedConstructors().put(entry.getKey(), constructor2); context.getPreFinalizationElements().add(differedGeneration); context.setActionIndex(context.getActionIndex() + 1); context.incrementSerial(sigKey.hashCode()); } else { differedGeneration.run();
context.getBehaviorUnitIndex()); if (context.getGeneratorConfig2().isGeneratePureAnnotation() && !this.services.getExpressionHelper().hasSideEffects(source.getExpression())) { addAnnotationSafe(bodyOperation, Pure.class); final Collection<Procedure1<? super ITreeAppendable>> evaluators = context.getGuardEvalationCodeFor(source); assert evaluators != null; context.getBehaviorUnitIndex()); if (context.getGeneratorConfig2().isGeneratePureAnnotation()) { addAnnotationSafe(guardOperation, Pure.class); context.setBehaviorUnitIndex(context.getBehaviorUnitIndex() + 1); context.incrementSerial(bodyMethodName.hashCode()); } else { logInternalError(Messages.SARLJvmModelInferrer_10);
null, source.getExtends(), context.getInheritedFinalOperations(), context.getInheritedOverridableOperations(), null, context.getInheritedOperationsToImplement(), null, this.sarlSignatureProvider);
if (context != null) { final Collection<Pair<SarlBehaviorUnit, Collection<Procedure1<? super ITreeAppendable>>>> allEvaluators = context.getGuardEvaluationCodes(); if (allEvaluators == null || allEvaluators.isEmpty()) { return;
source.getExtends(), source.getImplements(), context.getInheritedFinalOperations(), context.getInheritedOverridableOperations(), null, context.getInheritedOperationsToImplement(), null, this.sarlSignatureProvider);
private static boolean isAppendSerialNumbersEnable(GenerationContext context) { return context.getGeneratorConfig2().isGenerateSerialNumberFields(); }
/** Replies if the compiler is using Java8 or higher. * * @return <code>true</code> if the compiler uses Java8 or higher. Otherwise <code>false</code>. */ public boolean isAtLeastJava8() { final JavaVersion javaVersion = JavaVersion.fromQualifier(SARLVersion.MINIMAL_JDK_VERSION); return javaVersion != null && getGeneratorConfig().getJavaSourceVersion().isAtLeast(javaVersion); }
private static boolean isAppendToStringFunctionsEnable(GenerationContext context) { return context.getGeneratorConfig2().isGenerateToStringFunctions(); }
private boolean isAppendComparisonFunctionsEnable(GenerationContext context, JvmGenericType target) { if (context.getGeneratorConfig2().isGenerateEqualityTestFunctions()) { JvmGenericType current = target; final Set<String> encounteredTypes = new TreeSet<>(); do { encounteredTypes.add(current.getIdentifier()); if (this.annotationFinder.findAnnotation(current, NoEqualityTestFunctionsGeneration.class) != null) { return false; } final JvmTypeReference superType = current.getExtendedClass(); current = null; if (superType != null) { final JvmType type = superType.getType(); if (type instanceof JvmGenericType) { current = (JvmGenericType) type; if (encounteredTypes.contains(current.getIdentifier())) { current = null; } } } } while (current != null); return true; } return false; }
if (!isEqualsUserDefined) { final JvmOperation op = toEqualsMethod(source, target, declaredInstanceFields, context.getGeneratorConfig2().isGeneratePureAnnotation()); if (op != null) { appendGeneratedAnnotation(op, context); context.getGeneratorConfig2().isGeneratePureAnnotation()); if (op != null) { appendGeneratedAnnotation(op, context);
if (op != null) { appendGeneratedAnnotation(op, context); if (context.getGeneratorConfig2().isGeneratePureAnnotation()) { addAnnotationSafe(op, Pure.class);
operation.setVisibility(JvmVisibility.PUBLIC); addAnnotationSafe(operation, Override.class); if (context.getGeneratorConfig2().isGeneratePureAnnotation()) { addAnnotationSafe(operation, Pure.class);