EA-20339
authorAlexey Kudravtsev <cdr@intellij.com>
Thu, 19 Aug 2010 13:59:08 +0000 (17:59 +0400)
committerAlexey Kudravtsev <cdr@intellij.com>
Fri, 20 Aug 2010 07:57:05 +0000 (11:57 +0400)
java/java-impl/src/com/intellij/psi/impl/source/PsiParameterImpl.java

index e7dd313c5fc46348e3b7be70f56f617145c55cf7..595131f2375751c31360e099e3182e915c223eba 100644 (file)
@@ -178,6 +178,7 @@ public class PsiParameterImpl extends JavaStubPsiElement<PsiParameterStub> imple
   @NotNull
   public PsiElement getDeclarationScope() {
     final PsiElement parent = getParent();
+    if (parent == null) return this;
     if (parent instanceof PsiParameterList){
       return parent.getParent();
     }
@@ -188,12 +189,15 @@ public class PsiParameterImpl extends JavaStubPsiElement<PsiParameterStub> imple
       return parent;
     }
     PsiElement[] children = parent.getChildren();
-    for(int i = 0; i < children.length; i++){
-      if (children[i].equals(this)){
-        while(!(children[i] instanceof PsiCodeBlock)){
-          i++;
+    //noinspection ConstantConditions
+    if (children != null) {
+      for(int i = 0; i < children.length; i++){
+        if (children[i].equals(this)){
+          while(!(children[i] instanceof PsiCodeBlock)){
+            i++;
+          }
+          return children[i];
         }
-        return children[i];
       }
     }
     LOG.error("codeblock not found among parameter' "+this+" parents children: "+ Arrays.asList(children));