From 076d0402ce69862966b080034ba118c650919fab Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Thu, 13 Jan 2005 17:22:37 +0300 Subject: [PATCH] merged CVS and Subversion versions --- .../ipp/exceptions/DetailExceptionsIntention.java | 9 ++--- .../ipp/exceptions/DetailExceptionsPredicate.java | 15 ++++--- .../com/siyeh/ipp/exceptions/ExceptionUtils.java | 46 +++++++++++----------- 3 files changed, 33 insertions(+), 37 deletions(-) diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/DetailExceptionsIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/DetailExceptionsIntention.java index ed165e3108..332f079b84 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/DetailExceptionsIntention.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/DetailExceptionsIntention.java @@ -5,15 +5,13 @@ import com.intellij.openapi.project.Project; import com.intellij.psi.*; import com.intellij.util.IncorrectOperationException; import com.siyeh.ipp.*; +import com.siyeh.ipp.base.Intention; +import com.siyeh.ipp.base.PsiElementPredicate; import java.util.*; public class DetailExceptionsIntention extends Intention { - public DetailExceptionsIntention(Project project) - { - super(project); - } public String getText() { @@ -27,8 +25,7 @@ public class DetailExceptionsIntention extends Intention public PsiElementPredicate getElementPredicate() { - final Project project = getProject(); - return new DetailExceptionsPredicate(project); + return new DetailExceptionsPredicate(); } public void invoke(Project project, Editor editor, PsiFile file) throws IncorrectOperationException diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/DetailExceptionsPredicate.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/DetailExceptionsPredicate.java index eb923b3471..162bff043b 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/DetailExceptionsPredicate.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/DetailExceptionsPredicate.java @@ -1,20 +1,19 @@ package com.siyeh.ipp.exceptions; -import com.intellij.openapi.project.Project; import com.intellij.psi.*; import com.intellij.psi.tree.IElementType; -import com.siyeh.ipp.PsiElementPredicate; +import com.siyeh.ipp.base.PsiElementPredicate; -import java.util.*; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; class DetailExceptionsPredicate implements PsiElementPredicate { - private final Project m_project; - DetailExceptionsPredicate(Project project) + DetailExceptionsPredicate() { super(); - m_project = project; } public boolean satisfiedBy(PsiElement element) @@ -24,7 +23,7 @@ class DetailExceptionsPredicate implements PsiElementPredicate return false; } final IElementType tokenType = ((PsiJavaToken)element).getTokenType(); - if(tokenType!=JavaTokenType.TRY_KEYWORD) + if(!JavaTokenType.TRY_KEYWORD.equals(tokenType)) { return false; } @@ -34,7 +33,7 @@ class DetailExceptionsPredicate implements PsiElementPredicate } final PsiTryStatement tryStatement = (PsiTryStatement) element.getParent(); final Set exceptionsThrown = new HashSet(10); - final PsiManager mgr = PsiManager.getInstance(m_project); + final PsiManager mgr = element.getManager(); final PsiElementFactory factory = mgr.getElementFactory(); final PsiCodeBlock tryBlock = tryStatement.getTryBlock(); ExceptionUtils.calculateExceptionsThrownForCodeBlock(tryBlock, exceptionsThrown, factory); diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/ExceptionUtils.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/ExceptionUtils.java index ef27b1a0d3..a8b3a64e4b 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/ExceptionUtils.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/ExceptionUtils.java @@ -119,13 +119,13 @@ class ExceptionUtils } } - private static void calculateExceptionsThrownForLabeledStatement(final PsiLabeledStatement labeledStatement, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForLabeledStatement(PsiLabeledStatement labeledStatement, Set exceptionTypes, PsiElementFactory factory) { final PsiStatement statement = labeledStatement.getStatement(); calculateExceptionsThrownForStatement(statement, exceptionTypes, factory); } - private static void calculateExceptionsThrownForExpressionListStatement(final PsiExpressionListStatement listStatement, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForExpressionListStatement(PsiExpressionListStatement listStatement, Set exceptionTypes, PsiElementFactory factory) { final PsiExpressionList expressionList = listStatement.getExpressionList(); final PsiExpression[] expressions = expressionList.getExpressions(); @@ -135,7 +135,7 @@ class ExceptionUtils } } - private static void calculateExceptionsThrownForDeclarationStatemt(final PsiDeclarationStatement declStatement, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForDeclarationStatemt(PsiDeclarationStatement declStatement, Set exceptionTypes, PsiElementFactory factory) { final PsiElement[] elements = declStatement.getDeclaredElements(); for(int i = 0; i < elements.length; i++) @@ -149,7 +149,7 @@ class ExceptionUtils } } - private static void calculateExceptionsThrownForAssertStatement(final PsiAssertStatement assertStatement, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForAssertStatement(PsiAssertStatement assertStatement, Set exceptionTypes, PsiElementFactory factory) { final PsiExpression assertCondition = assertStatement.getAssertCondition(); calculateExceptionsThrown(assertCondition, exceptionTypes, factory); @@ -157,7 +157,7 @@ class ExceptionUtils calculateExceptionsThrown(assertDescription, exceptionTypes, factory); } - private static void calculateExceptionsThrownForThrowStatement(final PsiThrowStatement throwStatement, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForThrowStatement(PsiThrowStatement throwStatement, Set exceptionTypes, PsiElementFactory factory) { final PsiExpression exception = throwStatement.getException(); final PsiType type = exception.getType(); @@ -165,7 +165,7 @@ class ExceptionUtils calculateExceptionsThrown(exception, exceptionTypes, factory); } - private static void calculateExceptionsThrownForSwitchStatement(final PsiSwitchStatement switchStatement, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForSwitchStatement(PsiSwitchStatement switchStatement, Set exceptionTypes, PsiElementFactory factory) { final PsiExpression switchExpression = switchStatement.getExpression(); calculateExceptionsThrown(switchExpression, exceptionTypes, factory); @@ -173,7 +173,7 @@ class ExceptionUtils calculateExceptionsThrownForCodeBlock(body, exceptionTypes, factory); } - private static void calculateExceptionsThrownForTryStatement(final PsiTryStatement tryStatement, PsiElementFactory factory, Set exceptionTypes) + private static void calculateExceptionsThrownForTryStatement(PsiTryStatement tryStatement, PsiElementFactory factory, Set exceptionTypes) { final Set exceptionThrown = new HashSet(10); final PsiCodeBlock tryBlock = tryStatement.getTryBlock(); @@ -210,7 +210,7 @@ class ExceptionUtils } } - private static void calculateExceptionsThrownForIfStatement(final PsiIfStatement ifStatement, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForIfStatement(PsiIfStatement ifStatement, Set exceptionTypes, PsiElementFactory factory) { final PsiExpression condition = ifStatement.getCondition(); final PsiStatement thenBranch = ifStatement.getThenBranch(); @@ -220,13 +220,13 @@ class ExceptionUtils calculateExceptionsThrownForStatement(elseBranch, exceptionTypes, factory); } - private static void calculateExceptionsThrownForBlockStatement(final PsiBlockStatement block, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForBlockStatement(PsiBlockStatement block, Set exceptionTypes, PsiElementFactory factory) { final PsiCodeBlock codeBlock = block.getCodeBlock(); calculateExceptionsThrownForCodeBlock(codeBlock, exceptionTypes, factory); } - private static void calculateExceptionsThrownForSynchronizedStatement(final PsiSynchronizedStatement syncStatement, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForSynchronizedStatement(PsiSynchronizedStatement syncStatement, Set exceptionTypes, PsiElementFactory factory) { final PsiExpression lockExpression = syncStatement.getLockExpression(); if(lockExpression != null) @@ -237,7 +237,7 @@ class ExceptionUtils calculateExceptionsThrownForCodeBlock(body, exceptionTypes, factory); } - private static void calculateExceptionsThrownForDoWhileStatement(final PsiDoWhileStatement loopStatement, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForDoWhileStatement(PsiDoWhileStatement loopStatement, Set exceptionTypes, PsiElementFactory factory) { final PsiExpression condition = loopStatement.getCondition(); calculateExceptionsThrown(condition, exceptionTypes, factory); @@ -245,7 +245,7 @@ class ExceptionUtils calculateExceptionsThrownForStatement(body, exceptionTypes, factory); } - private static void calculateExceptionsThrownForWhileStatement(final PsiWhileStatement loopStatement, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForWhileStatement(PsiWhileStatement loopStatement, Set exceptionTypes, PsiElementFactory factory) { final PsiExpression condition = loopStatement.getCondition(); calculateExceptionsThrown(condition, exceptionTypes, factory); @@ -253,7 +253,7 @@ class ExceptionUtils calculateExceptionsThrownForStatement(body, exceptionTypes, factory); } - private static void calculateExceptionsThrownForForExpression(final PsiForStatement loopStatement, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForForExpression(PsiForStatement loopStatement, Set exceptionTypes, PsiElementFactory factory) { final PsiStatement initialization = loopStatement.getInitialization(); final PsiExpression condition = loopStatement.getCondition(); @@ -334,19 +334,19 @@ class ExceptionUtils } } - private static void calculateExceptionsThrownForTypeCast(final PsiTypeCastExpression typeCast, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForTypeCast(PsiTypeCastExpression typeCast, Set exceptionTypes, PsiElementFactory factory) { final PsiExpression operand = typeCast.getOperand(); calculateExceptionsThrown(operand, exceptionTypes, factory); } - private static void calculateExceptionsThrownForInstanceOf(final PsiInstanceOfExpression instExp, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForInstanceOf(PsiInstanceOfExpression instExp, Set exceptionTypes, PsiElementFactory factory) { final PsiExpression operand = instExp.getOperand(); calculateExceptionsThrown(operand, exceptionTypes, factory); } - private static void calculateExceptionsThrownForNewExpression(final PsiNewExpression newExp, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForNewExpression(PsiNewExpression newExp, Set exceptionTypes, PsiElementFactory factory) { final PsiExpressionList argumentList = newExp.getArgumentList(); if(argumentList != null) @@ -381,7 +381,7 @@ class ExceptionUtils } } - private static void calculateExceptionsThrownForMethodCall(final PsiMethodCallExpression methExp, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForMethodCall(PsiMethodCallExpression methExp, Set exceptionTypes, PsiElementFactory factory) { final PsiExpressionList argumentList = methExp.getArgumentList(); if(argumentList != null) @@ -410,7 +410,7 @@ class ExceptionUtils } } - private static void calculateExceptionsThrownForConditionalExcpression(final PsiConditionalExpression condExp, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForConditionalExcpression(PsiConditionalExpression condExp, Set exceptionTypes, PsiElementFactory factory) { final PsiExpression condition = condExp.getCondition(); final PsiExpression elseExpression = condExp.getElseExpression(); @@ -420,7 +420,7 @@ class ExceptionUtils calculateExceptionsThrown(thenExpression, exceptionTypes, factory); } - private static void calculateExceptionsThrownForBinaryExpression(final PsiBinaryExpression binaryExp, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForBinaryExpression(PsiBinaryExpression binaryExp, Set exceptionTypes, PsiElementFactory factory) { final PsiExpression lOperand = binaryExp.getLOperand(); calculateExceptionsThrown(lOperand, exceptionTypes, factory); @@ -428,7 +428,7 @@ class ExceptionUtils calculateExceptionsThrown(rhs, exceptionTypes, factory); } - private static void calculateExceptionsThrownForArrayInitializerExpression(final PsiArrayInitializerExpression arrayExp, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForArrayInitializerExpression(PsiArrayInitializerExpression arrayExp, Set exceptionTypes, PsiElementFactory factory) { final PsiExpression[] initializers = arrayExp.getInitializers(); for(int i = 0; i < initializers.length; i++) @@ -437,7 +437,7 @@ class ExceptionUtils } } - private static void calculateExceptionsThrownForArrayAccessExpression(final PsiArrayAccessExpression arrayAccessExp, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForArrayAccessExpression(PsiArrayAccessExpression arrayAccessExp, Set exceptionTypes, PsiElementFactory factory) { final PsiExpression arrayExpression = arrayAccessExp.getArrayExpression(); calculateExceptionsThrown(arrayExpression, exceptionTypes, factory); @@ -445,13 +445,13 @@ class ExceptionUtils calculateExceptionsThrown(indexExpression, exceptionTypes, factory); } - private static void calculateExceptionsThrownForPrefixException(final PsiPrefixExpression prefixExp, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForPrefixException(PsiPrefixExpression prefixExp, Set exceptionTypes, PsiElementFactory factory) { final PsiExpression operand = prefixExp.getOperand(); calculateExceptionsThrown(operand, exceptionTypes, factory); } - private static void calculateExceptionsThrownForPostixExpression(final PsiPostfixExpression postfixExp, Set exceptionTypes, PsiElementFactory factory) + private static void calculateExceptionsThrownForPostixExpression(PsiPostfixExpression postfixExp, Set exceptionTypes, PsiElementFactory factory) { final PsiExpression operand = postfixExp.getOperand(); calculateExceptionsThrown(operand, exceptionTypes, factory); -- 2.11.4.GIT