/*
 * Copyright 2000-2007 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.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.jetbrains.plugins.groovy.lang.psi.impl.auxiliary;

import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiType;
import com.intellij.psi.tree.TokenSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl;
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;

/**
 * @author ilyas
 */
public class GrListOrMapImpl extends GroovyPsiElementImpl implements GrListOrMap {
  private static final TokenSet MAP_LITERAL_TOKENS = TokenSet.create(GroovyElementTypes.ARGUMENT, GroovyTokenTypes.mCOLON);

  public GrListOrMapImpl(@NotNull ASTNode node) {
    super(node);
  }

  public String toString() {
    return "Generalized list";
  }

  public PsiType getType() {
    if (isMapLiteral()) {
      return getManager().getElementFactory().createTypeByFQClassName("java.util.Map", getResolveScope());
    }
    return getManager().getElementFactory().createTypeByFQClassName("java.util.List", getResolveScope());
  }

  private boolean isMapLiteral() {
    return findChildByType(MAP_LITERAL_TOKENS) != null;
  }
}

@@ -716,16 +716,130 @@
 .psi.Psi
+Element;%0Aimport com.intellij.psi.PsiType;%0Aimport com.intellij.psi.PsiTypeElement;%0Aimport com.intellij.psi.PsiArray
 Type;%0Aim
@@ -962,109 +962,325 @@
 ang.
-psi.api.auxiliary.GrListOrMap;%0Aimport org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl
+lexer.GroovyTokenTypes;%0Aimport org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;%0Aimport org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;%0Aimport org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;%0Aimport org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration
 ;%0Aim
@@ -1323,32 +1323,34 @@
 ng.p
-arser.Groovy
+si.api.types.GrType
 Element
-Types
 ;%0Aim
@@ -1388,38 +1388,45 @@
 vy.lang.
-lexer.GroovyTokenTypes
+psi.impl.GroovyPsiElementImpl
 ;%0A%0A/**%0A 
@@ -1958,16 +1958,393 @@
 ;%0A    %7D%0A
+%0A    PsiElement parent = getParent();%0A    if (parent.getParent() instanceof GrVariableDeclaration) %7B%0A      GrTypeElement typeElement = ((GrVariableDeclaration) parent.getParent()).getTypeElementGroovy();%0A      if (typeElement != null) %7B%0A        PsiType declaredType = typeElement.getType();%0A        if (declaredType instanceof PsiArrayType) return declaredType;%0A      %7D%0A    %7D%0A%0A
     retu

fix type