/*
 * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
 *
 * 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.psiutils;

import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiErrorElement;
import com.intellij.psi.PsiRecursiveElementWalkingVisitor;
import com.intellij.psi.util.PsiUtil;

public class ErrorUtil{

    private ErrorUtil(){}

	/**
	 * Checks only immediate children. No expensive full tree traversal.
	 * @return true, if an PsiErrorElement was found, false otherwise.
	 */
	public static boolean containsError(PsiElement element){
        // check only immediate children, full tree traveral is too expensive
        return PsiUtil.hasErrorElementChild(element);
    }

	/**
	 * Does full tree traversal check for PsiErrorElements.
	 * @return true, if an PsiErrorElement was found, false otherwise.
	 */
	public static boolean containsDeepError(PsiElement element){
		final ErrorElementVisitor visitor = new ErrorElementVisitor();
		element.accept(visitor);
		return visitor.containsErrorElement();
	}

    private static class ErrorElementVisitor extends PsiRecursiveElementWalkingVisitor {
        private boolean containsErrorElement = false;

        @Override public void visitErrorElement(PsiErrorElement element){
            containsErrorElement = true;
        }

        public boolean containsErrorElement(){
            return containsErrorElement;
        }
    }
}
@@ -21,9 +21,9 @@
 -200
-7
+9
  Dav
@@ -868,22 +868,28 @@
 il()%7B%7D%0A%0A
-%09/**%0A%09
+    /**%0A    
  * Check
@@ -949,17 +949,20 @@
 versal.%0A
-%09
+    
  * @retu
@@ -1012,38 +1012,44 @@
 alse otherwise.%0A
-%09 */%0A%09
+     */%0A    
 public static bo
@@ -1147,16 +1147,17 @@
 e traver
+s
 al is to
@@ -1233,14 +1233,20 @@
  %7D%0A%0A
-%09/**%0A%09
+    /**%0A    
  * D
@@ -1297,17 +1297,20 @@
 ements.%0A
-%09
+    
  * @retu
@@ -1372,14 +1372,20 @@
 se.%0A
-%09 */%0A%09
+     */%0A    
 publ
@@ -1441,18 +1441,24 @@
 ement)%7B%0A
-%09%09
+        
 final Er
@@ -1512,18 +1512,24 @@
 itor();%0A
-%09%09
+        
 element.
@@ -1549,10 +1549,16 @@
 r);%0A
-%09%09
+        
 retu
@@ -1596,9 +1596,12 @@
 ();%0A
-%09
+    
 %7D%0A%0A 

fix typo in comment