IG: register problem on navigation element when identifier is not physical (in Groovy)

This commit is contained in:
Bas Leijdekkers
2016-09-14 12:19:11 +02:00
parent d772d1d37a
commit 28c8d7a22f
2 changed files with 25 additions and 8 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -15,10 +15,7 @@
*/
package com.siyeh.ig.junit;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiModifier;
import com.intellij.psi.PsiTypeParameter;
import com.intellij.psi.*;
import com.intellij.psi.util.InheritanceUtil;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspectionVisitor;
@@ -96,7 +93,17 @@ public class JUnitAbstractTestClassNamingConventionInspectionBase extends Conven
if (isValid(name)) {
return;
}
registerClassError(aClass, name);
final PsiIdentifier identifier = aClass.getNameIdentifier();
if (identifier == null) {
return;
}
if (!identifier.isPhysical()) {
final PsiElement navigationElement = identifier.getNavigationElement();
registerError(navigationElement, name);
}
else {
registerClassError(aClass, name);
}
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -95,7 +95,17 @@ public class JUnitTestClassNamingConventionInspectionBase extends ConventionInsp
if (isValid(name)) {
return;
}
registerClassError(aClass, name);
final PsiIdentifier identifier = aClass.getNameIdentifier();
if (identifier == null) {
return;
}
if (!identifier.isPhysical()) {
final PsiElement navigationElement = identifier.getNavigationElement();
registerError(navigationElement, name);
}
else {
registerClassError(aClass, name);
}
}
private boolean hasJUnit4TestMethods(@NotNull PsiClass aClass) {