com.intellij.psi
Interface PsiIfStatement

All Superinterfaces:
Iconable, PsiElement, PsiStatement, UserDataHolder

public interface PsiIfStatement
extends PsiStatement

Represents a Java if or if ... else statement.


Field Summary
 
Fields inherited from interface com.intellij.psi.PsiStatement
EMPTY_ARRAY
 
Fields inherited from interface com.intellij.openapi.util.Iconable
ICON_FLAG_CLOSED, ICON_FLAG_OPEN, ICON_FLAG_READ_STATUS, ICON_FLAG_VISIBILITY
 
Method Summary
 PsiExpression getCondition()
          Returns the expression representing the condition of the statement.
 PsiStatement getElseBranch()
          Returns the statement which is executed when the condition is true.
 PsiKeyword getElseElement()
          Returns the else keyword of the statement.
 PsiJavaToken getLParenth()
          Returns the opening parenthesis enclosing the statement condition.
 PsiJavaToken getRParenth()
          Returns the closing parenthesis enclosing the statement condition.
 PsiStatement getThenBranch()
          Returns the statement which is executed when the condition is true.
 void setElseBranch(PsiStatement statement)
          Sets the statement which is executed when the condition is false to the specified value.
 void setThenBranch(PsiStatement statement)
          Sets the statement which is executed when the condition is true to the specified value.
 
Methods inherited from interface com.intellij.psi.PsiElement
accept, acceptChildren, add, addAfter, addBefore, addRange, addRangeAfter, addRangeBefore, checkAdd, checkDelete, copy, delete, deleteChildRange, findElementAt, findReferenceAt, getChildren, getContainingFile, getContext, getCopyableUserData, getFirstChild, getLanguage, getLastChild, getManager, getNavigationElement, getNextSibling, getNode, getOriginalElement, getParent, getPrevSibling, getProject, getReference, getReferences, getResolveScope, getStartOffsetInParent, getText, getTextLength, getTextOffset, getTextRange, getUseScope, isPhysical, isValid, isWritable, processDeclarations, putCopyableUserData, replace, textContains, textMatches, textMatches, textToCharArray
 
Methods inherited from interface com.intellij.openapi.util.UserDataHolder
getUserData, putUserData
 
Methods inherited from interface com.intellij.openapi.util.Iconable
getIcon
 

Method Detail

getCondition

@Nullable
PsiExpression getCondition()
Returns the expression representing the condition of the statement.

Returns:
the expression instance, or null if the statement is incomplete.

getThenBranch

@Nullable
PsiStatement getThenBranch()
Returns the statement which is executed when the condition is true.

Returns:
the statement instance, or null if the statement is incomplete.

getElseBranch

@Nullable
PsiStatement getElseBranch()
Returns the statement which is executed when the condition is true.

Returns:
the statement instance, or null if the statement has no else part or is incomplete.

getElseElement

@Nullable
PsiKeyword getElseElement()
Returns the else keyword of the statement.

Returns:
the keyword instance, or null if the statement has no else part.

setElseBranch

void setElseBranch(@NotNull
                   PsiStatement statement)
                   throws IncorrectOperationException
Sets the statement which is executed when the condition is false to the specified value. Adds the else keyword if required.

Parameters:
statement - the statement to use as the else branch.
Throws:
IncorrectOperationException - if the modification fails for some reason (for example, the containing file is read-only).

setThenBranch

void setThenBranch(@NotNull
                   PsiStatement statement)
                   throws IncorrectOperationException
Sets the statement which is executed when the condition is true to the specified value. Adds the parentheses if required.

Parameters:
statement - the statement to use as the then branch.
Throws:
IncorrectOperationException - if the modification fails for some reason (for example, the containing file is read-only).

getLParenth

@Nullable
PsiJavaToken getLParenth()
Returns the opening parenthesis enclosing the statement condition.

Returns:
the opening parenthesis, or null if the statement is incomplete.

getRParenth

@Nullable
PsiJavaToken getRParenth()
Returns the closing parenthesis enclosing the statement condition.

Returns:
the closing parenthesis, or null if the statement is incomplete.