Merge branch 'master' into changeSignature
authorMaxim Medvedev <maxim.medvedev@jetbrains.com>
Tue, 11 May 2010 10:36:06 +0000 (14:36 +0400)
committerMaxim Medvedev <maxim.medvedev@jetbrains.com>
Tue, 11 May 2010 10:36:06 +0000 (14:36 +0400)
1  2 
platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java
plugins/groovy/src/META-INF/plugin.xml
plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrArgumentLabelImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrClosureSignatureUtil.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java

index a9e3286f4cf88a143bcd7cc398faf424810a13a8,81f3d30f028e3e052b5bacccf32c0218ea7442f6..f1706a99b5b1e70f9b82bd172f68a37a777a026d
@@@ -21,7 -21,7 +21,8 @@@ import com.intellij.openapi.util.TextRa
  import com.intellij.psi.*;
  import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
  import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference;
 +import com.intellij.psi.util.InheritanceUtil;
+ import com.intellij.psi.tree.IElementType;
  import com.intellij.psi.util.PropertyUtil;
  import com.intellij.util.ArrayUtil;
  import com.intellij.util.IncorrectOperationException;
index 7582e9798de418128fb57e52aba07c1b8124b877,157ded922b175f226655dbb1a44ce568ec413779..eb6147bad1058daeffe411ac50320514cd6f526e
@@@ -17,17 -17,11 +17,18 @@@ package org.jetbrains.plugins.groovy.la
  
  import com.intellij.openapi.util.Pair;
  import com.intellij.psi.*;
 +import com.intellij.psi.search.GlobalSearchScope;
 +import com.intellij.psi.util.InheritanceUtil;
  import com.intellij.psi.util.MethodSignature;
  import com.intellij.psi.util.MethodSignatureUtil;
 -import gnu.trove.THashMap;
 +import com.intellij.util.containers.MultiMap;
 +import org.jetbrains.annotations.NotNull;
 +import org.jetbrains.annotations.Nullable;
+ import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
 +import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
 +import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
  import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
 +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
  import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
  import org.jetbrains.plugins.groovy.lang.psi.api.types.GrClosureParameter;
  import org.jetbrains.plugins.groovy.lang.psi.api.types.GrClosureSignature;
index a4f0001101d4ebffbfe9cb10b3fcc2d967e532ff,05762449c31eb803aa4d43f90eca7b5585fded21..e3cf85bfad1bc694b907ddf6fd0676407ee96bb6
@@@ -129,13 -130,16 +130,13 @@@ public class PsiUtil 
  
      //check for default constructor
      if (method.isConstructor() && method.getParameterList().getParametersCount() == 0 && argumentTypes.length == 1) {
 -      final PsiType type = argumentTypes[0];
 -      final PsiClassType mapType = JavaPsiFacade.getElementFactory(method.getProject())
 -        .createTypeByFQClassName(CommonClassNames.JAVA_UTIL_MAP, method.getResolveScope());
 -      return TypesUtil.isAssignable(mapType, type, place);
 +      return InheritanceUtil.isInheritor(argumentTypes[0], CommonClassNames.JAVA_UTIL_MAP);
      }
      LOG.assertTrue(signature != null);
-     return GrClosureSignatureUtil.isSignatureApplicable(signature, argumentTypes, method.getManager(), method.getResolveScope());
+     return GrClosureSignatureUtil.isSignatureApplicable(signature, argumentTypes, place);
    }
  
-   public static boolean isApplicable(@Nullable PsiType[] argumentTypes, GrClosureType type, PsiManager manager) {
+   public static boolean isApplicable(@Nullable PsiType[] argumentTypes, GrClosureType type, GroovyPsiElement context) {
      if (argumentTypes == null) return true;
  
      GrClosureSignature signature = type.getSignature();
      }
    }
  
 +  public static boolean isMethodUsage(PsiElement element) {
 +    if (element instanceof GrEnumConstant) return true;
 +    if (!(element instanceof GrReferenceElement)) return false;
 +    PsiElement parent = element.getParent();
 +    if (parent instanceof GrCall) {
 +      return true;
 +    }
 +    else if (parent instanceof GrAnonymousClassDefinition) {
 +      return element.equals(((GrAnonymousClassDefinition)parent).getBaseClassReferenceGroovy());
 +    }
 +    return false;
 +  }
++
+   public static GroovyResolveResult[] getConstructorCandidates(GroovyPsiElement place, GroovyResolveResult[] classCandidates, PsiType[] argTypes) {
+     List<GroovyResolveResult> constructorResults = new ArrayList<GroovyResolveResult>();
+     for (GroovyResolveResult classResult : classCandidates) {
+       final PsiElement element = classResult.getElement();
+       if (element instanceof PsiClass) {
+         final GroovyPsiElement context = classResult.getCurrentFileResolveContext();
+         PsiClass clazz = (PsiClass)element;
+         String className = clazz.getName();
+         PsiType thisType = JavaPsiFacade.getInstance(place.getProject()).getElementFactory().createType(clazz, classResult.getSubstitutor());
+         final MethodResolverProcessor processor = new MethodResolverProcessor(className, place, true, thisType, argTypes, PsiType.EMPTY_ARRAY)
+           ;
+         processor.setCurrentFileResolveContext(context);
+         PsiSubstitutor substitutor = classResult.getSubstitutor();
+         final boolean toBreak =
+           element.processDeclarations(processor, ResolveState.initial().put(PsiSubstitutor.KEY, substitutor), null, place);
+         for (NonCodeMembersProcessor membersProcessor : NonCodeMembersProcessor.EP_NAME.getExtensions()) {
+           if (!membersProcessor.processNonCodeMembers(thisType, processor, place, true)) break;
+         }
+         constructorResults.addAll(Arrays.asList(processor.getCandidates()));
+         if (!toBreak) break;
+       }
+     }
+     return constructorResults.toArray(new GroovyResolveResult[constructorResults.size()]);
+   }
  }