Package org.eclipse.cdt.core.dom.ast

# Interface IASTIfStatement

All Superinterfaces:
  `IASTAttributeOwner`, `IASTNode`, `IASTStatement`

All Known Subinterfaces:
  `ICPPASTIfStatement`

public interface IASTIfStatement extends IASTStatement
The 'if' statement including the optional else clause.

Restriction:
  This interface is not intended to be implemented by clients.
Restriction:
  This interface is not intended to be extended by clients.

## Nested Class Summary

## Nested classes/interfaces inherited from interface org.eclipse.cdt.core.dom.ast.IASTNode

`IASTNode.CopyStyle`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final ASTNodeProperty`
`CONDITION`
`CONDITION` represents the relationship between an `IASTIfStatement` and its nested `IASTExpression`.
`static final ASTNodeProperty`
`ELSE`
`ELSE` represents the relationship between an `IASTIfStatement` and its nested `IASTStatement` (else).
`static final ASTNodeProperty`
`THEN`
`THEN` represents the relationship between an `IASTIfStatement` and its nested `IASTStatement` (then).

### Fields inherited from interface org.eclipse.cdt.core.dom.ast.IASTAttributeOwner

`ATTRIBUTE, ATTRIBUTE_SPECIFIER`

### Fields inherited from interface org.eclipse.cdt.core.dom.ast.IASTNode

`EMPTY_NODE_ARRAY`

### Fields inherited from interface org.eclipse.cdt.core.dom.ast.IASTStatement

`EMPTY_STATEMENT_ARRAY`

## Method Summary

Modifier and Type
Method
Description
`IASTIfStatement`
`copy()`
Returns a mutable copy of the tree rooted at this node.
`IASTIfStatement`
`copy(IASTNode.CopyStyle style)`
Returns a mutable copy of the tree rooted at this node.
`IASTExpression`
`getConditionExpression()`
Returns the condition in the if statement.
`IASTStatement`
`getElseClause()`
Returns the statement that is executed if the condition is false.
`IASTStatement`
`getThenClause()`
Returns the statement that is executed if the condition is true.
`void`
`setConditionExpression(IASTExpression condition)`
Sets the condition in the if statement.
`void`
`setElseClause(IASTStatement elseClause)`
Sets the else clause.
`void`
`setThenClause(IASTStatement thenClause)`
Sets the statement that is executed if the condition is true.

### Methods inherited from interface org.eclipse.cdt.core.dom.ast.IASTAttributeOwner

`addAttribute, addAttributeSpecifier, getAttributes, getAttributeSpecifiers`

### Methods inherited from interface org.eclipse.cdt.core.dom.ast.IASTNode

`accept, contains, getChildren, getContainingFilename, getFileLocation, getLeadingSyntax, getNodeLocations, getOriginalNode, getParent, getPropertyInParent, getRawSignature, getSyntax, getTrailingSyntax, getTranslationUnit, isActive, isFrozen, isPartOfTranslationUnitFile, setParent, setPropertyInParent`

## Field Details

### CONDITION

static final ASTNodeProperty CONDITION
`CONDITION` represents the relationship between an `IASTIfStatement` and its nested `IASTExpression`.

### THEN

static final ASTNodeProperty THEN
`THEN` represents the relationship between an `IASTIfStatement` and its nested `IASTStatement` (then).

### ELSE

static final ASTNodeProperty ELSE
`ELSE` represents the relationship between an `IASTIfStatement` and its nested `IASTStatement` (else).

## Method Details

### getConditionExpression

IASTExpression getConditionExpression()
Returns the condition in the if statement.

Returns:
  the condition `IASTExpression`. May return `null` if the 'if' statement has condition declaration instead of condition expression (see `ICPPASTIfStatement`).

### setConditionExpression

void setConditionExpression(IASTExpression condition)
Sets the condition in the if statement.

Parameters:
  `condition` - `IASTExpression`

### getThenClause

IASTStatement getThenClause()
Returns the statement that is executed if the condition is true.

Returns:
  the then clause `IASTStatement`

### setThenClause

void setThenClause(IASTStatement thenClause)
Sets the statement that is executed if the condition is true.

Parameters:
  `thenClause` - `IASTStatement`

### getElseClause

IASTStatement getElseClause()
Returns the statement that is executed if the condition is false. This clause is optional and returns null if there is none.

Returns:
  the else clause or `null` `IASTStatement`

### setElseClause

void setElseClause(IASTStatement elseClause)
Sets the else clause.

Parameters:
  `elseClause` - `IASTStatement`

### copy

IASTIfStatement copy()
Description copied from interface: `IASTNode`
Returns a mutable copy of the tree rooted at this node. The following postconditions hold:

     copy.getParent() == null
     copy.getPropertyInParent() == null
     copy.isFrozen() == false

Preprocessor nodes do not currently support being copied. Implicit name nodes are not copied, instead they can be regenerated if required.

Calling this method is equivalent to `copy(CopyStyle.withoutLocations)`.

Specified by:
  `copy` in interface `IASTNode`
Specified by:
  `copy` in interface `IASTStatement`
Since:
  5.1

### copy

IASTIfStatement copy(IASTNode.CopyStyle style)
Description copied from interface: `IASTNode`
Returns a mutable copy of the tree rooted at this node. The following postconditions hold:

     copy.getParent() == null
     copy.getPropertyInParent() == null
     copy.isFrozen() == false

Preprocessor nodes do not currently support being copied. Implicit name nodes are not copied, instead they can be regenerated if required.

Specified by:
  `copy` in interface `IASTNode`
Specified by:
  `copy` in interface `IASTStatement`
Parameters:
  `style` - `IASTNode.CopyStyle` create a copy with or without locations. Please see `IASTNode.CopyStyle` for restrictions on copies with Locations.
Since:
  5.3