Module org.eclipse.xtend.lib.macro
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 Summary
Modifier and TypeMethodDescriptionaddParameter(int position, String name, TypeReference type) Inserts a parameter at the specified position in the parameter listaddParameter(String name, TypeReference type) Adds a parameterIterable<? extends MutableParameterDeclaration> voidsetBody(CompilationStrategy compilationStrategy) Sets the givenCompilationStrategyas the body.voidsetBody(Expression body) Setting an expression will alter the scope of it accordingly.voidsetBody(org.eclipse.xtend2.lib.StringConcatenationClient compilationTemplate) Sets the givenStringConcatenationClientas the body.voidsetExceptions(TypeReference... exceptions) Sets the declared exceptions.voidsetVarArgs(boolean isVarArgs) Methods inherited from interface org.eclipse.xtend.lib.macro.declaration.AnnotationTarget
findAnnotation, getAnnotationsMethods inherited from interface org.eclipse.xtend.lib.macro.declaration.ExecutableDeclaration
getBody, getExceptions, isVarArgsMethods inherited from interface org.eclipse.xtend.lib.macro.declaration.MemberDeclaration
getDocComment, getModifiers, getVisibility, isDeprecatedMethods inherited from interface org.eclipse.xtend.lib.macro.declaration.MutableAnnotationTarget
addAnnotation, removeAnnotationMethods inherited from interface org.eclipse.xtend.lib.macro.declaration.MutableDeclaration
markAsReadMethods inherited from interface org.eclipse.xtend.lib.macro.declaration.MutableElement
removeMethods inherited from interface org.eclipse.xtend.lib.macro.declaration.MutableMemberDeclaration
getDeclaringType, setDeprecated, setDocComment, setVisibilityMethods inherited from interface org.eclipse.xtend.lib.macro.declaration.MutableNamedElement
setSimpleNameMethods inherited from interface org.eclipse.xtend.lib.macro.declaration.MutableTypeParameterDeclarator
addTypeParameter, getTypeParametersMethods inherited from interface org.eclipse.xtend.lib.macro.declaration.NamedElement
getCompilationUnit, getSimpleName
-
Method Details
-
getParameters
Iterable<? extends MutableParameterDeclaration> getParameters()- Specified by:
getParametersin interfaceExecutableDeclaration- Returns:
- the declared parameters
-
setVarArgs
void setVarArgs(boolean isVarArgs) - Parameters:
isVarArgs- whether the last argument is a var arg.
-
setBody
Setting an expression will alter the scope of it accordingly. Each expression can only be assigned to one element, if thisMutableExecutableDeclarationhas already set another expression or compilation strategy the old one will be detached. If the given expression is already assigned to anotherMutableExecutableDeclarationorMutableFieldDeclarationit will be automatically detached from it.- Parameters:
body- the expression to set as the body of this executable
-
setBody
Sets the givenCompilationStrategyas the body. The givenCompilationStrategywill be executed later during code generation, not immediately. If thisMutableExecutableDeclarationhas already set another expression or compilation strategy the old one will be detached.- Parameters:
compilationStrategy- the compilation strategy, must not benull- Throws:
IllegalArgumentException- ifcompilationStrategyisnull
-
setBody
void setBody(org.eclipse.xtend2.lib.StringConcatenationClient compilationTemplate) Sets the givenStringConcatenationClientas the body. The givenStringConcatenationClientwill be executed later during code generation, not immediately. If thisMutableExecutableDeclarationhas already set another expression or compilation strategy the old one will be detached.- Parameters:
compilationTemplate- the compilation strategy, must not benull- Throws:
IllegalArgumentException- ifcompilationStrategyisnull
-
setExceptions
Sets the declared exceptions.- Parameters:
exceptions- the declared exceptions- Throws:
IllegalArgumentException- if theexceptionsisnullor containsnull
-
addParameter
Adds a parameter- Parameters:
name- the name of the parameter, must be a valid java identifiertype- the type of the parameter, must not benull- Returns:
- the created parameter
- Throws:
IllegalArgumentException- if the name is not a valid java identifier or the type isnull
-
addParameter
Inserts a parameter at the specified position in the parameter list- Parameters:
name- the name of the parameter, must be a valid java identifiertype- the type of the parameter, must not benullindex- 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 isnullIndexOutOfBoundsException- if the index is out of range (index invalid input: '<' 0 || index > parameters.size())
-