summaryrefslogtreecommitdiff
path: root/plugins/IntentionPowerPak/src/com/siyeh/ipp/junit/FlipAssertLiteralIntention.java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/IntentionPowerPak/src/com/siyeh/ipp/junit/FlipAssertLiteralIntention.java')
-rw-r--r--plugins/IntentionPowerPak/src/com/siyeh/ipp/junit/FlipAssertLiteralIntention.java15
1 files changed, 7 insertions, 8 deletions
diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/junit/FlipAssertLiteralIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/junit/FlipAssertLiteralIntention.java
index d3a8d4cefc7b..d331042244a6 100644
--- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/junit/FlipAssertLiteralIntention.java
+++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/junit/FlipAssertLiteralIntention.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2014 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.
@@ -15,8 +15,8 @@
*/
package com.siyeh.ipp.junit;
-import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.psi.*;
+import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.siyeh.IntentionPowerPackBundle;
import com.siyeh.ig.PsiReplacementUtil;
@@ -67,11 +67,10 @@ public class FlipAssertLiteralIntention extends MutablyNamedIntention {
@NonNls final StringBuilder newCall = new StringBuilder();
final PsiElement qualifier = methodExpression.getQualifier();
if (qualifier == null) {
- final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(call, PsiMethod.class);
- if (containingMethod != null && AnnotationUtil.isAnnotated(containingMethod, "org.junit.Test", true)) {
- if (!ImportUtils.addStaticImport("org.junit.Assert", toMethodName, element)) {
- newCall.append("org.junit.Assert.");
- }
+ final PsiClass containingClass = PsiTreeUtil.getParentOfType(element, PsiClass.class);
+ if (!InheritanceUtil.isInheritor(containingClass, "junit.framework.Assert") &&
+ !ImportUtils.addStaticImport("org.junit.Assert", toMethodName, element)) {
+ newCall.append("org.junit.Assert.");
}
}
else {
@@ -88,6 +87,6 @@ public class FlipAssertLiteralIntention extends MutablyNamedIntention {
newCall.append(BoolUtils.getNegatedExpressionText(arguments[1]));
}
newCall.append(')');
- PsiReplacementUtil.replaceExpression(call, newCall.toString());
+ PsiReplacementUtil.replaceExpressionAndShorten(call, newCall.toString());
}
} \ No newline at end of file