Interface MutableExecutableDeclaration

All Superinterfaces:
AnnotationTarget, Declaration, Element, ExecutableDeclaration, MemberDeclaration, MutableAnnotationTarget, MutableDeclaration, MutableElement, MutableMemberDeclaration, MutableNamedElement, MutableTypeParameterDeclarator, NamedElement, TypeParameterDeclarator
All Known Subinterfaces:
MutableConstructorDeclaration, MutableMethodDeclaration

@Beta public interface MutableExecutableDeclaration extends MutableTypeParameterDeclarator, ExecutableDeclaration
Author:
Sven Efftinge
  • Method Details

    • getParameters

      Iterable<? extends MutableParameterDeclaration> getParameters()
      Specified by:
      getParameters in interface ExecutableDeclaration
      Returns:
      the declared parameters
    • setVarArgs

      void setVarArgs(boolean isVarArgs)
      Parameters:
      isVarArgs - whether the last argument is a var arg.
    • setBody

      void setBody(Expression body)
      Setting an expression will alter the scope of it accordingly. Each expression can only be assigned to one element, if this MutableExecutableDeclaration has already set another expression or compilation strategy the old one will be detached. If the given expression is already assigned to another MutableExecutableDeclaration or MutableFieldDeclaration it will be automatically detached from it.
      Parameters:
      body - the expression to set as the body of this executable
    • setBody

      void setBody(CompilationStrategy compilationStrategy)
      Sets the given CompilationStrategy as the body. The given CompilationStrategy will be executed later during code generation, not immediately. If this MutableExecutableDeclaration has already set another expression or compilation strategy the old one will be detached.
      Parameters:
      compilationStrategy - the compilation strategy, must not be null
      Throws:
      IllegalArgumentException - if compilationStrategy is null
    • setBody

      void setBody(org.eclipse.xtend2.lib.StringConcatenationClient compilationTemplate)
      Sets the given StringConcatenationClient as the body. The given StringConcatenationClient will be executed later during code generation, not immediately. If this MutableExecutableDeclaration has already set another expression or compilation strategy the old one will be detached.
      Parameters:
      compilationTemplate - the compilation strategy, must not be null
      Throws:
      IllegalArgumentException - if compilationStrategy is null
    • setExceptions

      void setExceptions(TypeReference... exceptions)
      Sets the declared exceptions.
      Parameters:
      exceptions - the declared exceptions
      Throws:
      IllegalArgumentException - if the exceptions is null or contains null
    • addParameter

      Adds a parameter
      Parameters:
      name - the name of the parameter, must be a valid java identifier
      type - the type of the parameter, must not be null
      Returns:
      the created parameter
      Throws:
      IllegalArgumentException - if the name is not a valid java identifier or the type is null
    • addParameter

      MutableParameterDeclaration addParameter(int position, String name, TypeReference type)
      Inserts a parameter at the specified position in the parameter list
      Parameters:
      name - the name of the parameter, must be a valid java identifier
      type - the type of the parameter, must not be null
      index - the position of the parameter, must be > 0 and invalid input: '<'= to the current number of parameters
      Returns:
      the created parameter
      Throws:
      IllegalArgumentException - if the name is not a valid java identifier or the type is null
      IndexOutOfBoundsException - if the index is out of range (index invalid input: '<' 0 || index > parameters.size())