IDEADEV-27754 for IPP
[fedora-idea.git] / plugins / IntentionPowerPak / src / com / siyeh / ipp / parenthesis / RemoveUnnecessaryParenthesesIntention.java
blobd4978f5aafcf705b9c650731262689555a6198a3
1 /*
2 * Copyright 2003-2008 Dave Griffith, Bas Leijdekkers
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.siyeh.ipp.parenthesis;
18 import com.intellij.psi.PsiElement;
19 import com.intellij.psi.PsiExpression;
20 import com.intellij.util.IncorrectOperationException;
21 import com.siyeh.ipp.base.Intention;
22 import com.siyeh.ipp.base.PsiElementPredicate;
23 import com.siyeh.ipp.psiutils.ParenthesesUtils;
24 import org.jetbrains.annotations.NotNull;
26 public class RemoveUnnecessaryParenthesesIntention extends Intention {
28 @Override @NotNull
29 public PsiElementPredicate getElementPredicate() {
30 return new UnnecessaryParenthesesPredicate();
33 @Override
34 public void processIntention(@NotNull PsiElement element)
35 throws IncorrectOperationException {
36 PsiExpression expression = (PsiExpression)element;
37 while (expression.getParent() instanceof PsiExpression) {
38 expression = (PsiExpression)expression.getParent();
39 assert expression != null;
41 ParenthesesUtils.removeParentheses(expression);