accept that with different library versions inheritance relation may be intransitive...
[idea/community.git] / java / java-impl / src / com / intellij / util / xml / impl / ExtendsClassChecker.java
index c54ff5089a644f5d59e7dc5703b52d727160a2ff..3fe146e787c0300e7141a7a9af120ab45cad718d 100644 (file)
@@ -19,7 +19,6 @@ import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
 import com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReference;
 import com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReferenceProvider;
-import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.util.InheritanceUtil;
 import com.intellij.psi.util.PsiUtil;
 import com.intellij.util.ProcessingContext;
@@ -82,7 +81,7 @@ public class ExtendsClassChecker extends DomCustomAnnotationChecker<ExtendClass>
                                                                    final boolean allowEnum,
                                                                    final DomElementAnnotationHolder holder) {
     final Project project = element.getManager().getProject();
-    PsiClass extendClass = JavaPsiFacade.getInstance(project).findClass(name, GlobalSearchScope.allScope(project));
+    PsiClass extendClass = JavaPsiFacade.getInstance(project).findClass(name, value.getResolveScope());
     final SmartList<DomElementProblemDescriptor> list = new SmartList<DomElementProblemDescriptor>();
     if (extendClass != null) {
       if (!name.equals(value.getQualifiedName()) && !value.isInheritor(extendClass, true)) {
@@ -105,12 +104,15 @@ public class ExtendsClassChecker extends DomCustomAnnotationChecker<ExtendClass>
           for (PsiMethod method : value.getConstructors()) {
             final PsiParameterList psiParameterList = method.getParameterList();
             if (psiParameterList.getParametersCount() != 1) continue;
-            final PsiType psiType = psiParameterList.getParameters()[0].getTypeElement().getType();
-            if (psiType instanceof PsiClassType) {
-              final PsiClass psiClass = ((PsiClassType)psiType).resolve();
-              if (psiClass != null && InheritanceUtil.isInheritorOrSelf(psiClass, extendClass, true)) {
-                hasConstructor = true;
-                break;
+            PsiTypeElement typeElement = psiParameterList.getParameters()[0].getTypeElement();
+            if (typeElement != null) {
+              final PsiType psiType = typeElement.getType();
+              if (psiType instanceof PsiClassType) {
+                final PsiClass psiClass = ((PsiClassType)psiType).resolve();
+                if (psiClass != null && InheritanceUtil.isInheritorOrSelf(psiClass, extendClass, true)) {
+                  hasConstructor = true;
+                  break;
+                }
               }
             }
           }