@Nullable PsiParameter.getTypeElement (EA-28714)
authorpeter <peter@jetbrains.com>
Fri, 8 Jul 2011 15:50:59 +0000 (17:50 +0200)
committerpeter <peter@jetbrains.com>
Fri, 8 Jul 2011 17:47:05 +0000 (19:47 +0200)
java/java-impl/src/com/intellij/util/xml/impl/ExtendsClassChecker.java
java/openapi/src/com/intellij/psi/PsiParameter.java

index c54ff5089a644f5d59e7dc5703b52d727160a2ff..bcf0c747dc13f01ef286991680158ad0890b8b99 100644 (file)
@@ -105,12 +105,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;
+                }
               }
             }
           }
index 4d0c63d8fed3ff86d5270702a29daedd54ae577c..8c5ec61ec43cfeeb2d70f5db7c082a600d134a6d 100644 (file)
@@ -17,6 +17,7 @@ package com.intellij.psi;
 
 import com.intellij.util.ArrayFactory;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * Represents the parameter of a Java method, foreach (enhanced for) statement or catch block.
@@ -59,6 +60,6 @@ public interface PsiParameter extends PsiVariable {
   /**
    * {@inheritDoc}
    */
-  @NotNull
+  @Nullable
   PsiTypeElement getTypeElement();
 }