/*
 * Copyright 2003-2005 Dave Griffith
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.siyeh.ipp.braces;

import com.intellij.psi.*;
import com.siyeh.ipp.base.PsiElementPredicate;

public class RemoveBracesPredicate implements PsiElementPredicate
{
	public boolean satisfiedBy(PsiElement element)
	{
		if (!(element instanceof PsiBlockStatement))
		{
			return false;
		}
		final PsiBlockStatement blockStatement = (PsiBlockStatement)element;
		final PsiElement parent = blockStatement.getParent();
		if(!(parent instanceof PsiIfStatement || parent instanceof PsiWhileStatement ||
			parent instanceof PsiDoWhileStatement || parent instanceof PsiForStatement ||
			parent instanceof PsiForeachStatement))
		{
			return false;
		}
		final PsiCodeBlock codeBlock = blockStatement.getCodeBlock();
		final PsiStatement[] statements = codeBlock.getStatements();
		return statements.length == 1;
	}
}
@@ -816,18 +816,24 @@
 ent)%0A%09%7B%0A
-%09%09
+        
 if (!(el
@@ -1383,41 +1383,295 @@
 ();%0A
-%09%09return statements.length == 1;%0A%09
+        if(statements.length != 1)%7B%0A            return false;%0A        %7D%0A        final PsiFile file = element.getContainingFile();%0A        //this intention doesn't work in JSP files, as it can't tell about tags%0A        // inside the braeces%0A        return file instanceof PsiJavaFile;%0A    
 %7D%0A%7D

Fix for IDEASCR 51423