/*
 * Copyright 2000-2009 JetBrains s.r.o.
 *
 * 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.intellij.codeInsight.unwrap;

import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.psi.PsiCatchSection;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiTryStatement;
import com.intellij.util.IncorrectOperationException;

public class JavaCatchRemover extends JavaUnwrapper {
  public JavaCatchRemover() {
    super(CodeInsightBundle.message("remove.catch"));
  }

  @Override
  public boolean isApplicableTo(PsiElement e) {
    return e instanceof PsiCatchSection && tryHasSeveralCatches(e);
  }

  private boolean tryHasSeveralCatches(PsiElement el) {
    return ((PsiTryStatement)el.getParent()).getCatchBlocks().length > 1;
  }

  @Override
  protected void doUnwrap(PsiElement element, Context context) throws IncorrectOperationException {
    context.delete(element);
  }
}

@@ -1126,16 +1126,34 @@
 lCatches
+OrResourcesDefined
 (e);%0A  %7D
@@ -1164,16 +1164,23 @@
 private 
+static 
 boolean 
@@ -1199,16 +1199,34 @@
 lCatches
+OrResourcesDefined
 (PsiElem
@@ -1243,16 +1243,39 @@
     
-return (
+PsiTryStatement tryStatement = 
 (Psi
@@ -1301,17 +1301,41 @@
 Parent()
-)
+;%0A    return tryStatement
 .getCatc
@@ -1354,16 +1354,58 @@
 ngth %3E 1
+ %7C%7C tryStatement.getResourceList() != null
 ;%0A  %7D%0A%0A 

allow to unwrap catch for try-with-resources statement