/* (non-Javadoc)
@see com.pogofish.jadt.emitter.ClassBodyEmitter#emitHashCode(com.pogofish.jadt.emitter.Sink, com.pogofish.jadt.ast.Constructor)
540905
@Override
    public void emitHashCode(final Sink sink, final String indent, Constructor constructor) {
    	logger.finest("Generating hashCode() for " + constructor.name);
        sink.write(indent + "@Override\n");
        sink.write(indent + "public int hashCode() {\n");
        if (constructor.args.isEmpty()) {
            sink.write(indent + "    return 0;\n");
        } else {
            sink.write(indent + "    final int prime = 31;\n");
            sink.write(indent + "    int result = 1;\n");
            for (final Arg arg : constructor.args) {
                arg.type._switch(new Type.SwitchBlock(){
                    @Override
                    public void _case(Ref x) {
                        x.type._switch(new RefType.SwitchBlock() {
                            @Override
                            public void _case(ClassType x) {
                                sink.write(indent + "    result = prime * result + ((" + arg.name + " == null) ? 0 : " + arg.name + ".hashCode());\n");                
                            }

                            @Override
                            public void _case(ArrayType x) {
                                sink.write(indent + "    result = prime * result + java.util.Arrays.hashCode(" + arg.name + ");\n");                
                            }});
                    }

                    @Override
                    public void _case(Primitive x) {
                        x.type._switch(new PrimitiveType.SwitchBlockWithDefault() {

                            @Override
                            public void _case(BooleanType x) {
                                sink.write(indent + "    result = prime * result + (" + arg.name + " ? 1 : 0);\n");
                            }

                            @Override
                            public void _case(IntType x) {
                                uncastedHashChunk(sink, arg);
                            }

                            private void uncastedHashChunk(final Sink sink, final Arg arg) {
                                sink.write(indent + "    result = prime * result + " + arg.name + ";\n");
                            }                            
                            
                            @Override
                            public void _case(ByteType x) {
                                uncastedHashChunk(sink, arg);
                            }

                            @Override
                            public void _case(CharType x) {
                                uncastedHashChunk(sink, arg);
                            }

                            @Override
                            public void _case(ShortType x) {
                                uncastedHashChunk(sink, arg);
                            }

                            @Override
                            public void _default(PrimitiveType x) {
                                sink.write(indent + "    result = prime * result + (int)" + arg.name + ";\n");
                            }});
                    }});
            }
            sink.write(indent + "    return result;\n");
        }
        sink.write(indent + "}");
    }
1038910
function BaseLauncher (id, emitter) {
  if (this.start) {
    return
  }

  // TODO(vojta): figure out how to do inheritance with DI
  Object.keys(EventEmitter.prototype).forEach(function (method) {
    this[method] = EventEmitter.prototype[method]
  }, this)

  this.bind = KarmaEventEmitter.prototype.bind.bind(this)
  this.emitAsync = KarmaEventEmitter.prototype.emitAsync.bind(this)

  this.id = id
  this._state = null
  Object.defineProperty(this, 'state', {
    get: () => {
      return this._state
    },
    set: (toState) => {
      log.debug(`${this._state} -> ${toState}`)
      this._state = toState
    }
  })

  this.error = null

  let killingPromise
  let previousUrl

  this.start = function (url) {
    previousUrl = url

    this.error = null
    this.state = BEING_CAPTURED
    this.emit('start', url + '?id=' + this.id + (helper.isDefined(this.displayName) ? '&displayName=' + encodeURIComponent(this.displayName) : ''))
  }

  this.kill = function () {
    // Already killed, or being killed.
    if (killingPromise) {
      return killingPromise
    }

    killingPromise = this.emitAsync('kill').then(() => {
      this.state = FINISHED
    })

    this.state = BEING_KILLED

    return killingPromise
  }

  this.forceKill = function () {
    this.kill()
    this.state = BEING_FORCE_KILLED

    return killingPromise
  }

  this.restart = function () {
    if (this.state === BEING_FORCE_KILLED) {
      return
    }

    if (!killingPromise) {
      killingPromise = this.emitAsync('kill')
    }

    killingPromise.then(() => {
      if (this.state === BEING_FORCE_KILLED) {
        this.state = FINISHED
      } else {
        killingPromise = null
        log.debug(`Restarting ${this.name}`)
        this.start(previousUrl)
      }
    })

    this.state = RESTARTING
  }

  this.markCaptured = function () {
    if (this.state === BEING_CAPTURED) {
      this.state = CAPTURED
    }
  }

  this.isCaptured = function () {
    return this.state === CAPTURED
  }

  this.toString = function () {
    return this.name
  }

  this._done = function (error) {
    killingPromise = killingPromise || Promise.resolve()

    this.error = this.error || error
    this.emit('done')

    if (this.error && this.state !== BEING_FORCE_KILLED && this.state !== RESTARTING) {
      emitter.emit('browser_process_failure', this)
    }

    this.state = FINISHED
  }

  this.STATE_BEING_CAPTURED = BEING_CAPTURED
  this.STATE_CAPTURED = CAPTURED
  this.STATE_BEING_KILLED = BEING_KILLED
  this.STATE_FINISHED = FINISHED
  this.STATE_RESTARTING = RESTARTING
  this.STATE_BEING_FORCE_KILLED = BEING_FORCE_KILLED
}
971526
function Instruction(pi) {
  _classCallCheck(this, Instruction);

  this.tag = pi.split('<?')[1].split(' ')[0];
  this.att = Object.create(null);
  var hit,
      atexp = Instruction._ATEXP;

  while (hit = atexp.exec(pi)) {
    var n = hit[1],
        v = hit[2];
    this.att[n] = cast(v);
  }
}
733407
function EventEmitter() {
    var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

    _classCallCheck(this, EventEmitter);

    this._events = {};
    if (opts.async) this.emit = emitAsync;
  }
634155
public void setCode(ExprCode code) {
        mCode = code;

        mStartPos = mCode.mStartPos;
        mCurIndex = mStartPos;
    }
464620
public void emitActivity(Activity p, PrintStream out) {
        HashMap<String,String> properties=new HashMap<String, String>();

        emitElement(p.getId(),
                    addURL(p.getId(), addActivityShape(p,addActivityLabel(p, addActivityColor(p,properties)))),
                    out);

        emitAnnotations("", p,out);
    }
31340
function getEmitter(config) {
      function Emitter(n) {
        n = n || this;
        n.__events = n.__events || {};
        n.__once = n.__once || {};
      }

      Emitter.prototype.on = function(name, fn) {
        fn = fn || Function();
        this.__events[name] = (this.__events[name] || [])
        this.__events[name].push(fn);
      }

      Emitter.prototype.once = function(name, fn) {
        fn = fn || Function();
        this.__once[name] = (this.__once[name] || []);
        this.__once[name].push(fn);
      }

      Emitter.prototype.off = function(name, fn) {
        var i;

        fn = fn || Function();
        i = (this.__events[name] || []).indexOf(fn);
        if (~i) this.__events[name].splice(i, 1);

        i = (this.__once[name] || []).indexOf(fn);
        if (~i) this.__once[name].splice(i, 1);
      }

      Emitter.prototype.emit = function(name) {
        var args = [].slice.call(arguments),
            es = (this.__events[name] || []).slice(),
            i, self = this;

        args.shift();
        es.push.apply(es, this.__once[name] || []);

        for (i = 0; i < es.length; i++) {
          es[i].apply(self, args);
        }

        this.__once[name] = [];
      }

      Emitter.prototype.emitCtx = function(name, ctx) {
        var args = [].slice.call(arguments),
            es = (this.__events[name] || []).slice(),
            i, self = this;

        args.shift(); args.shift();
        es.push.apply(es, this.__once[name] || []);

        for (i = 0; i < es.length; i++) {
          es[i].apply(ctx, args);
        }

        this.__once[name] = [];
      }

      return Emitter;
    }
109725
private void emitCodeLines(final StringBuilder out, final Line lines, final String meta, final boolean removeIndent)
    {
        Line line = lines;
        if (this.config.codeBlockEmitter != null)
        {
            final ArrayList<String> list = new ArrayList<String>();
            while (line != null)
            {
                if (line.isEmpty)
                {
                    list.add("");
                }
                else
                {
                    list.add(removeIndent ? line.value.substring(4) : line.value);
                }
                line = line.next;
            }
            this.config.codeBlockEmitter.emitBlock(out, list, meta);
        }
        else
        {
            while (line != null)
            {
                if (!line.isEmpty)
                {
                    for (int i = removeIndent ? 4 : 0; i < line.value.length(); i++)
                    {
                        final char c;
                        switch (c = line.value.charAt(i))
                        {
                        case '&':
                            out.append("&amp;");
                            break;
                        case '<':
                            out.append("&lt;");
                            break;
                        case '>':
                            out.append("&gt;");
                            break;
                        default:
                            out.append(c);
                            break;
                        }
                    }
                }
                out.append('\n');
                line = line.next;
            }
        }
    }
218695
public static JADT createDummyJADT(List<SyntaxError> syntaxErrors, List<SemanticError> semanticErrors, String testSrcInfo, SinkFactoryFactory factory) {
        final SourceFactory sourceFactory = new StringSourceFactory(TEST_STRING);
        final Doc doc = new Doc(TEST_SRC_INFO, Pkg._Pkg(NO_COMMENTS, "pkg"), Util.<Imprt> list(), Util.<DataType> list());
        final ParseResult parseResult = new ParseResult(doc, syntaxErrors);
        final DocEmitter docEmitter = new DummyDocEmitter(doc,  TEST_CLASS_NAME);
        final Parser parser = new DummyParser(parseResult, testSrcInfo, TEST_STRING);
        final Checker checker = new DummyChecker(semanticErrors);
        final JADT jadt = new JADT(sourceFactory, parser, checker, docEmitter, factory);
        return jadt;
    }
1111502
public static ExpressionInfo expressionInfo(String code, JShell state) {
        if (code == null || code.isEmpty()) {
            return null;
        }
        try {
            OuterWrap codeWrap = state.outerMap.wrapInTrialClass(Wrap.methodReturnWrap(code));
            AnalyzeTask at = state.taskFactory.new AnalyzeTask(codeWrap);
            CompilationUnitTree cu = at.firstCuTree();
            if (at.hasErrors() || cu == null) {
                return null;
            }
            return new ExpressionToTypeInfo(at, cu, state).typeOfExpression();
        } catch (Exception ex) {
            return null;
        }
    }
152844
public static <E extends BaseException> E createNew(Class<E> exceptionType, ErrorCode errorCode) {
        try {
            Constructor<E> constructor = exceptionType.getDeclaredConstructor(ErrorCode.class);
            constructor.setAccessible(true);
            return constructor.newInstance(errorCode);
        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException
                | InstantiationException e) {
            throw new IllegalArgumentException(exceptionType.getCanonicalName()
                    + " must implement a constructor with ErrorCode as parameter", e);
        }
    }
491311
function VK(options, redirectUri, code, token) {
    EventEmitter.call(self);
    self = this;
    if (options === undefined)
        throw 'No options passed to constructor';
    if (options.appID === undefined || options.appSecret === undefined)
        throw 'Wrong options';
    if (options.mode === 'undefined' || !(options.mode === 'oauth' || options.mode === 'sig'))
        options.mode = 'oauth';
    self.options = options;
    self.code = code || '';
    self.token = token || '';
    self.redirectUri = redirectUri || 'http://localhost';
    self.userId = 0;
}
759982
@Override
    protected void emitStartElement(final INodeReadTrx paramRTX) throws TTIOException {
        try {
            switch (paramRTX.getNode().getKind()) {
            case ROOT:
                if (mIndent) {
                    mOut.write(ECharsForSerializing.NEWLINE.getBytes());
                }
                break;
            case ELEMENT:
                // Emit start element.
                indent();
                final ITreeNameData namenode = (ITreeNameData)paramRTX.getNode();
                mOut.write(ECharsForSerializing.OPEN.getBytes());
                mOut.write(paramRTX.nameForKey(namenode.getNameKey()).getBytes());
                final long key = paramRTX.getNode().getDataKey();
                // Emit namespace declarations.
                for (int index = 0, length = ((ElementNode)namenode).getNamespaceCount(); index < length; index++) {
                    paramRTX.moveToNamespace(index);
                    if (paramRTX.nameForKey(((ITreeNameData)paramRTX.getNode()).getNameKey()).length() == 0) {
                        mOut.write(ECharsForSerializing.XMLNS.getBytes());
                        write(paramRTX.nameForKey(((ITreeNameData)paramRTX.getNode()).getURIKey()));
                        mOut.write(ECharsForSerializing.QUOTE.getBytes());
                    } else {
                        mOut.write(ECharsForSerializing.XMLNS_COLON.getBytes());
                        write(paramRTX.nameForKey(((ITreeNameData)paramRTX.getNode()).getNameKey()));
                        mOut.write(ECharsForSerializing.EQUAL_QUOTE.getBytes());
                        write(paramRTX.nameForKey(((ITreeNameData)paramRTX.getNode()).getURIKey()));
                        mOut.write(ECharsForSerializing.QUOTE.getBytes());
                    }
                    paramRTX.moveTo(key);
                }
                // Emit attributes.
                // Add virtual rest:id attribute.
                if (mSerializeId) {
                    if (mSerializeRest) {
                        mOut.write(ECharsForSerializing.REST_PREFIX.getBytes());
                    } else {
                        mOut.write(ECharsForSerializing.SPACE.getBytes());
                    }
                    mOut.write(ECharsForSerializing.ID.getBytes());
                    mOut.write(ECharsForSerializing.EQUAL_QUOTE.getBytes());
                    write(paramRTX.getNode().getDataKey());
                    mOut.write(ECharsForSerializing.QUOTE.getBytes());
                }

                // Iterate over all persistent attributes.
                for (int index = 0; index < ((ElementNode)paramRTX.getNode()).getAttributeCount(); index++) {
                    paramRTX.moveToAttribute(index);
                    mOut.write(ECharsForSerializing.SPACE.getBytes());
                    mOut.write(paramRTX.nameForKey(((ITreeNameData)paramRTX.getNode()).getNameKey()).getBytes());
                    mOut.write(ECharsForSerializing.EQUAL_QUOTE.getBytes());
                    mOut.write(paramRTX.getValueOfCurrentNode().getBytes());
                    mOut.write(ECharsForSerializing.QUOTE.getBytes());
                    paramRTX.moveTo(key);
                }
                if (((ITreeStructData)paramRTX.getNode()).hasFirstChild()) {
                    mOut.write(ECharsForSerializing.CLOSE.getBytes());
                } else {
                    mOut.write(ECharsForSerializing.SLASH_CLOSE.getBytes());
                }
                if (mIndent) {
                    mOut.write(ECharsForSerializing.NEWLINE.getBytes());
                }
                break;
            case TEXT:
                indent();
                mOut.write(paramRTX.getValueOfCurrentNode().getBytes());
                if (mIndent) {
                    mOut.write(ECharsForSerializing.NEWLINE.getBytes());
                }
                break;
            }
        } catch (final IOException exc) {
            exc.printStackTrace();
        }
    }
1008872
public void encode(AsnOutputStream aos) throws EncodeException {

        if (this.nationalErrorCode == null && this.privateErrorCode == null)
            throw new EncodeException("Error code: No error code set!");

        try {
            if (this.type == ErrorCodeType.National && this.nationalErrorCode != null) {
                aos.writeInteger(Tag.CLASS_PRIVATE, ErrorCode._TAG_NATIONAL, this.nationalErrorCode);
            } else if (this.type == ErrorCodeType.Private && this.privateErrorCode != null) {
                aos.writeInteger(Tag.CLASS_PRIVATE, ErrorCode._TAG_PRIVATE, this.privateErrorCode);
            } else {
                throw new EncodeException("Error code: No error code set!");
            }

        } catch (IOException e) {
            throw new EncodeException("IOException while encoding ErrorCode: " + e.getMessage(), e);
        } catch (AsnException e) {
            throw new EncodeException("AsnException while encoding ErrorCode: " + e.getMessage(), e);
        }
    }
1088163
@Override
    public void visitCode(final Code obj) {
        if (sourceLines == null) {
            return;
        }

        if (isAbstract) {
            return;
        }

        if (Values.STATIC_INITIALIZER.equals(methodName) || Values.CONSTRUCTOR.equals(methodName)) {
            return;
        }

        int methodStart = srcLineAnnotation.getStartLine() - 2;
        int methodLine = methodStart;
        String line;
        while ((methodLine >= 0) && (methodLine < sourceLines.length)) {
            line = sourceLines[methodLine];
            if (line.indexOf(methodName) >= 0) {
                break;
            }
            methodLine--;
        }

        if (methodLine < 0) {
            return;
        }

        for (int i = methodLine; i <= methodStart; i++) {
            if ((i < 0) || (i >= sourceLines.length)) {
                return;
            }
            line = sourceLines[i];
            if (line.indexOf("final") >= 0) {
                return;
            }
        }

        changedParms = new BitSet();
        super.visitCode(obj);

        BugInstance bi = null;
        for (int i = 0; i < firstLocalReg; i++) {
            if (changedParms.get(i)) {
                changedParms.clear(i);
                continue;
            }

            String parmName = getRegisterName(obj, i);
            if (bi == null) {
                bi = new BugInstance(this, BugType.FP_FINAL_PARAMETERS.name(), LOW_PRIORITY).addClass(this).addMethod(this).addSourceLine(this, 0);
                bugReporter.reportBug(bi);
            }
            bi.addString(parmName);
        }
        changedParms = null;
    }
939830
@Deprecated
  private void emitJvmMemMetrics(ServiceEmitter emitter)
  {
    // I have no idea why, but jvm/mem is slightly more than the sum of jvm/pool. Let's just include
    // them both.
    final Map<String, MemoryUsage> usages = ImmutableMap.of(
        "heap", ManagementFactory.getMemoryMXBean().getHeapMemoryUsage(),
        "nonheap", ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage()
    );
    for (Map.Entry<String, MemoryUsage> entry : usages.entrySet()) {
      final String kind = entry.getKey();
      final MemoryUsage usage = entry.getValue();
      final ServiceMetricEvent.Builder builder = builder().setDimension("memKind", kind);
      MonitorUtils.addDimensionsToBuilder(builder, dimensions);

      emitter.emit(builder.build("jvm/mem/max", usage.getMax()));
      emitter.emit(builder.build("jvm/mem/committed", usage.getCommitted()));
      emitter.emit(builder.build("jvm/mem/used", usage.getUsed()));
      emitter.emit(builder.build("jvm/mem/init", usage.getInit()));
    }

    // jvm/pool
    for (MemoryPoolMXBean pool : ManagementFactory.getMemoryPoolMXBeans()) {
      final String kind = pool.getType() == MemoryType.HEAP ? "heap" : "nonheap";
      final MemoryUsage usage = pool.getUsage();
      final ServiceMetricEvent.Builder builder = builder()
          .setDimension("poolKind", kind)
          .setDimension("poolName", pool.getName());
      MonitorUtils.addDimensionsToBuilder(builder, dimensions);

      emitter.emit(builder.build("jvm/pool/max", usage.getMax()));
      emitter.emit(builder.build("jvm/pool/committed", usage.getCommitted()));
      emitter.emit(builder.build("jvm/pool/used", usage.getUsed()));
      emitter.emit(builder.build("jvm/pool/init", usage.getInit()));
    }
  }
235241
@Override
	@SuppressWarnings({"checkstyle:methodlength", "checkstyle:cyclomaticcomplexity",
			"checkstyle:npathcomplexity", "checkstyle:booleanexpressioncomplexity"})
	protected void transform(final XtendFunction source, final JvmGenericType container, boolean allowDispatch) {
		final GenerationContext context = getContext(container);

		// Compute the operation name
		// Issue #355: null or empty name is possible.
		final String originalFunctionName = source.getName();
		if (!Strings.isNullOrEmpty(originalFunctionName)) {
			final StringBuilder sourceNameBuffer = new StringBuilder(originalFunctionName);
			if (allowDispatch && source.isDispatch()) {
				sourceNameBuffer.insert(0, "_"); //$NON-NLS-1$
			}
			final String sourceName = sourceNameBuffer.toString();

			// Create the main function
			final JvmOperation operation = this.typesFactory.createJvmOperation();
			container.getMembers().add(operation);
			operation.setSimpleName(sourceName);
			setVisibility(operation, source);
			operation.setStrictFloatingPoint(source.isStrictFloatingPoint());
			operation.setStatic(source.isStatic());
			operation.setSynchronized(source.isSynchonized());
			operation.setNative(source.isNative());
			boolean enableFunctionBody;
			if (container.isInterface()) {
				enableFunctionBody = false;
				if (context != null && context.isAtLeastJava8()
						&& !Utils.toLightweightTypeReference(container, this.services).isSubtypeOf(Capacity.class)) {
					if (operation.isStatic()) {
						enableFunctionBody = true;
					} else if (source.getExpression() != null && !operation.isAbstract()) {
						enableFunctionBody = true;
					}
				}
				operation.setDefault(enableFunctionBody && !operation.isStatic());
				operation.setAbstract(!enableFunctionBody);
				operation.setFinal(false);
			} else {
				operation.setDefault(false);
				enableFunctionBody = context != null && !source.isAbstract();
				operation.setAbstract(!enableFunctionBody);
				operation.setFinal(enableFunctionBody && source.isFinal());
			}
			this.associator.associatePrimary(source, operation);

			// Type parameters
			copyAndFixTypeParameters(source.getTypeParameters(), operation);

			// Compute the identifier of the action.
			final QualifiedActionName actionKey = this.sarlSignatureProvider.createQualifiedActionName(
					container, sourceName);

			// Compute the different action prototypes associated to the action to create.
			final boolean isVarArgs = Utils.isVarArg(source.getParameters());
			final InferredPrototype actionSignatures = this.sarlSignatureProvider.createPrototypeFromSarlModel(
					actionKey,
					isVarArgs, source.getParameters());

			// Compute the action prototype of the action without optional parameter
			final ActionPrototype actSigKey = this.sarlSignatureProvider.createActionPrototype(
					sourceName,
					actionSignatures.getFormalParameterTypes());

			// Generate the parameters
			final List<InferredStandardParameter> paramList = actionSignatures.getOriginalParameterTypes();
			translateSarlFormalParameters(
					context,
					operation, container, isVarArgs,
					source.getParameters(),
					container.isInterface(), paramList);

			// Get the super function
			final JvmOperation inheritedOperation;
			if (context != null) {
				JvmOperation tmpInheritedOperation = context.getInheritedFinalOperations().get(actSigKey);
				if (tmpInheritedOperation == null) {
					tmpInheritedOperation = context.getInheritedOverridableOperations().get(actSigKey);
				}
				if (tmpInheritedOperation == null) {
					tmpInheritedOperation = context.getInheritedOperationsToImplement().get(actSigKey);
				}
				inheritedOperation = tmpInheritedOperation;
			} else {
				inheritedOperation = null;
			}

			// Infer the return type
			final JvmTypeReference selectedReturnType = inferFunctionReturnType(source, operation, inheritedOperation);
			operation.setReturnType(selectedReturnType);

			// Exceptions
			for (final JvmTypeReference exception : source.getExceptions()) {
				operation.getExceptions().add(this.typeBuilder.cloneWithProxies(exception));
			}

			// Add the body
			if (enableFunctionBody) {
				setBody(operation, source.getExpression());
			}

			// User Annotations
			translateAnnotationsTo(source.getAnnotations(), operation);

			// Add @Inline annotation
			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));
			}

			// Add @Override annotation
			if (source.isOverride()
					&& this.annotationFinder.findAnnotation(operation, Override.class) == null
					&& this.typeReferences.findDeclaredType(Override.class, source) != null) {
				addAnnotationSafe(operation, Override.class);
			}

			// Add @Pure annotation
			final boolean addDynamicPureAnnotationGenerator;
			final boolean hasExplicitPureAnnotation = this.annotationFinder.findAnnotation(operation, Pure.class) != null;
			if (context != null && context.getGeneratorConfig2().isGeneratePureAnnotation()
					&& !hasExplicitPureAnnotation && this.typeReferences.findDeclaredType(Pure.class, source) != null) {
				addDynamicPureAnnotationGenerator = inheritedOperation == null;
				if (addDynamicPureAnnotationGenerator) {
					this.operationHelper.attachPureAnnotationAdapter(operation, (op, helper) -> {
						return helper.isPurableOperation(source);
					});
				} else {
					this.operationHelper.attachPureAnnotationAdapter(operation, (op, helper) -> {
						return helper.isPureOperation(inheritedOperation);
					});
				}
			} else {
				addDynamicPureAnnotationGenerator = false;
			}

			// Detecting if the action is an early-exit action.
			// If true, the Java code is annotated to be usable by the SARL validator.
			final List<JvmTypeReference> firedEvents;
			final boolean isEarlyExit;
			if (source instanceof SarlAction) {
				final SarlAction action = (SarlAction) source;
				firedEvents = action.getFiredEvents();
				isEarlyExit = this.earlyExitComputer.isEarlyExitOperation(action);
				if (isEarlyExit) {
					addAnnotationSafe(operation, EarlyExit.class);
				}
			} else {
				firedEvents = Collections.emptyList();
				isEarlyExit = false;
			}

			// Put the fired SARL events as Java annotations for being usable by the SARL validator.
			if (!firedEvents.isEmpty()) {
				operation.getAnnotations().add(annotationClassRef(FiredEvent.class, firedEvents));
			}

			// 1. Ensure that the Java annotations related to the default value are really present.
			//    They may be not present if the generated action is a specific version of an inherited
			//    action with default values for parameters.
			// 2. Update the two collections that describes the implemented and implementable operations.
			if (context != null) {
				final JvmOperation implementedOperation = context.getInheritedOperationsToImplement().remove(actSigKey);
				// Put the annotations that were defined in the implemented operation
				if (implementedOperation != null) {
					if (this.annotationFinder.findAnnotation(implementedOperation, DefaultValueSource.class) != null
							&& this.annotationFinder.findAnnotation(operation, DefaultValueSource.class) == null) {
						addAnnotationSafe(operation, DefaultValueSource.class);
					}
					// Reinject the @DefaultValue annotations
					final List<JvmFormalParameter> oparams = implementedOperation.getParameters();
					final List<JvmFormalParameter> cparams = operation.getParameters();
					assert oparams.size() == cparams.size();
					for (int i = 0; i < oparams.size(); ++i) {
						final JvmFormalParameter op = oparams.get(i);
						final JvmFormalParameter cp = cparams.get(i);
						final String ovalue = this.annotationUtils.findStringValue(op, DefaultValue.class);
						if (ovalue != null
								&& this.annotationFinder.findAnnotation(cp, DefaultValue.class) == null) {
							addAnnotationSafe(cp,
									DefaultValue.class,
									this.sarlSignatureProvider.qualifyDefaultValueID(
											implementedOperation.getDeclaringType().getIdentifier(),
											ovalue));
						}
					}
				}
				// Add the main operation into the list of overridable operations
				context.getInheritedOverridableOperations().put(actSigKey, operation);
			}

			copyAndCleanDocumentationTo(source, operation);

			@SuppressWarnings("checkstyle:anoninnerlength")
			final Runnable differedGeneration = () -> {
				// Generate the Java functions that correspond to the action with the parameter default values applied.
				for (final Entry<ActionParameterTypes, List<InferredStandardParameter>> otherSignature
						: actionSignatures.getInferredParameterTypes().entrySet()) {
					final ActionPrototype ak = SARLJvmModelInferrer.this.sarlSignatureProvider.createActionPrototype(
							sourceName,
							otherSignature.getKey());
					if (ak != null
							&& (context == null
							|| (!context.getInheritedFinalOperations().containsKey(ak)
									&& !context.getInheritedOverridableOperations().containsKey(ak)))) {

						// Generate the additional constructor that is invoke the main constructor previously generated.
						final JvmOperation operation2 = SARLJvmModelInferrer.this.typesFactory.createJvmOperation();
						container.getMembers().add(operation2);
						operation2.setSimpleName(operation.getSimpleName());
						operation2.setVisibility(operation.getVisibility());
						operation2.setVarArgs(operation.isVarArgs());
						operation2.setAbstract(operation.isAbstract());
						operation2.setDeprecated(operation.isDeprecated());
						operation2.setStatic(operation.isStatic());
						operation2.setFinal(!operation.isStatic() && !container.isInterface());
						operation2.setNative(false);
						operation2.setStrictFloatingPoint(false);
						operation2.setSynchronized(false);
						this.associator.associate(source, operation2);

						copyTypeParametersFromJvmOperation(operation, operation2);

						for (final JvmTypeReference exception : operation.getExceptions()) {
							operation2.getExceptions().add(SARLJvmModelInferrer.this.typeBuilder
									.cloneWithProxies(exception));
						}

						if (selectedReturnType instanceof XComputedTypeReference) {
							operation2.setReturnType(this.typeReferences.createDelegateTypeReference(selectedReturnType));
						} else {
							operation2.setReturnType(cloneWithTypeParametersAndProxies(selectedReturnType, operation2));
						}

						final List<String> args = translateSarlFormalParametersForSyntheticOperation(
								operation2, container, isVarArgs, otherSignature.getValue());

						if (context != null && context.isAtLeastJava8()) {
							operation2.setDefault(container.isInterface());
							operation2.setAbstract(false);
							setBody(operation2, it -> {
								final JvmTypeReference type = operation2.getReturnType();
								if (!SARLJvmModelInferrer.this.typeReferences.is(type, void.class)) {
									it.append("return "); //$NON-NLS-1$
								}
								it.append(sourceName);
								it.append("("); //$NON-NLS-1$
								it.append(IterableExtensions.join(args, ", ")); //$NON-NLS-1$
								it.append(");"); //$NON-NLS-1$
							});
						} else {
							operation2.setDefault(false);
							operation2.setAbstract(true);
						}

						// @Override annotation
						if (source.isOverride()
								&& SARLJvmModelInferrer.this.annotationFinder.findAnnotation(operation,
								Override.class) == null
								&& SARLJvmModelInferrer.this.typeReferences.findDeclaredType(
										Override.class, source) != null) {
							addAnnotationSafe(
									operation, Override.class);
						}

						// @DefaultValueUse annotation
						addAnnotationSafe(
								operation2, DefaultValueUse.class,
								actionSignatures.getFormalParameterTypes().toString());
						appendGeneratedAnnotation(operation2, context);

						// @EarlyExit annotation
						// If the main action is an early-exit action, the additional operation
						// is also an early-exit operation.
						if (isEarlyExit) {
							addAnnotationSafe(
									operation2, EarlyExit.class);
						}

						// @FiredEvent annotation
						// Put the fired SARL events as Java annotations for being usable by the SARL validator.
						if (!firedEvents.isEmpty()) {
							operation2.getAnnotations().add(
									annotationClassRef(FiredEvent.class, firedEvents));
						}

						// @Pure annotation
						if (addDynamicPureAnnotationGenerator) {
							this.operationHelper.attachPureAnnotationAdapter(operation2, (op, helper) -> {
								return helper.isPureOperation(operation);
							});
						} else if (hasExplicitPureAnnotation) {
							addAnnotationSafe(
									operation2, Pure.class);
						}

						// Copy the annotations from the original operations, and that are not overridden above
						for (final JvmAnnotationReference annotation : operation.getAnnotations()) {
							final String id = annotation.getAnnotation().getIdentifier();
							if (!DefaultValueSource.class.getName().equals(id)
									&& !DefaultValueUse.class.getName().equals(id)
									&& !Pure.class.getName().equals(id)
									&& !EarlyExit.class.getName().equals(id)
									&& !FiredEvent.class.getName().equals(id)
									&& !Inline.class.getName().equals(id)
									&& !Generated.class.getName().equals(id)) {
								try {
									final JvmAnnotationReference clone = SARLJvmModelInferrer.this._annotationTypesBuilder
											.annotationRef(id);
									for (final JvmAnnotationValue annotationValue : annotation.getExplicitValues()) {
										clone.getExplicitValues().add(EcoreUtil.copy(annotationValue));
									}
									operation2.getAnnotations().add(clone);
								} catch (IllegalArgumentException exception) {
									// ignore
								}
							}
						}

						// Copy and clean the documentation
						copyAndCleanDocumentationTo(operation, operation2);

						// Update the two collections that describes the implemented and implementable operations.
						if (context != null) {
							context.getInheritedOperationsToImplement().remove(ak);
							context.getInheritedOverridableOperations().put(ak, operation2);
						}
					}
				}
			};

			if (context != null) {
				context.getPreFinalizationElements().add(differedGeneration);
				context.setActionIndex(context.getActionIndex() + 1);
				context.incrementSerial(actSigKey.hashCode());
			} else {
				differedGeneration.run();
			}
		}
	}