From 3c1758c0413fe8ee9a355e5d8a4256166a4be45d Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Thu, 9 Feb 2012 21:05:03 +0400 Subject: [PATCH] Very temp commit for getting top level function descriptions from java package --- .../lang/resolve/java/JavaPackageScope.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaPackageScope.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaPackageScope.java index adb10877a72..51c8b73a988 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaPackageScope.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaPackageScope.java @@ -1,7 +1,9 @@ package org.jetbrains.jet.lang.resolve.java; import com.google.common.collect.Sets; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiMethod; import com.intellij.psi.PsiModifier; import com.intellij.psi.PsiPackage; import org.jetbrains.annotations.NotNull; @@ -11,11 +13,15 @@ import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; import java.util.Collection; +import java.util.HashSet; /** * @author abreslav */ public class JavaPackageScope extends JavaClassOrPackageScope { + + private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.migration.PsiMigrationImpl"); + private final String packageFQN; private Collection allDescriptors; @@ -86,7 +92,9 @@ public class JavaPackageScope extends JavaClassOrPackageScope { } for (PsiClass psiClass : javaPackage.getClasses()) { - if (isKotlinNamespace && JvmAbi.PACKAGE_CLASS.equals(psiClass.getName())) continue; + if (isKotlinNamespace && JvmAbi.PACKAGE_CLASS.equals(psiClass.getName())) { + continue; + } // If this is a Kotlin class, we have already taken it through a containing namespace descriptor ClassDescriptor kotlinClassDescriptor = semanticServices.getKotlinClassDescriptor(psiClass.getQualifiedName()); @@ -94,6 +102,22 @@ public class JavaPackageScope extends JavaClassOrPackageScope { continue; } + // TODO: Temp hack for collection function descriptors from java + if (JvmAbi.PACKAGE_CLASS.equals(psiClass.getName())) { + HashSet methodNames = new HashSet(); + for (PsiMethod psiMethod : psiClass.getMethods()) { + methodNames.add(psiMethod.getName()); + } + + for (String methodName : methodNames) { + try { + allDescriptors.addAll(getFunctions(methodName)); + } catch (RuntimeException ex) { + LOG.error(ex); + } + } + } + if (psiClass.hasModifierProperty(PsiModifier.PUBLIC)) { ClassDescriptor classDescriptor = descriptorResolver.resolveClass(psiClass); if (classDescriptor != null) {