More efficient code completion + fixed a few bugs

This commit is contained in:
Valentin Kipyatkov
2014-11-02 14:32:10 +03:00
parent f31832dea9
commit fe5dbbf9b3
21 changed files with 166 additions and 74 deletions
@@ -18,10 +18,11 @@ package org.jetbrains.jet.lang.resolve.java.descriptor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.SamConstructorDescriptor;
import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
public class SamConstructorDescriptor extends SimpleFunctionDescriptorImpl {
public SamConstructorDescriptor(@NotNull DeclarationDescriptor containingDeclaration, @NotNull JavaClassDescriptor samInterface) {
public class SamConstructorDescriptorImpl extends SimpleFunctionDescriptorImpl implements SamConstructorDescriptor {
public SamConstructorDescriptorImpl(@NotNull DeclarationDescriptor containingDeclaration, @NotNull JavaClassDescriptor samInterface) {
super(containingDeclaration, null, samInterface.getAnnotations(), samInterface.getName(),
Kind.SYNTHESIZED, samInterface.getSource());
}
@@ -22,6 +22,7 @@ import org.jetbrains.jet.lang.resolve.java.lazy.LazyJavaResolverContext
import org.jetbrains.jet.lang.resolve.java.lazy.withTypes
import org.jetbrains.jet.lang.resolve.java.structure.JavaMethod
import org.jetbrains.jet.lang.types.JetType
import org.jetbrains.jet.lang.resolve.java.descriptor.SamConstructorDescriptorImpl
public abstract class LazyJavaStaticScope(
c: LazyJavaResolverContext,
@@ -18,11 +18,11 @@ package org.jetbrains.jet.lang.resolve.java.resolver
import org.jetbrains.jet.lang.resolve.name.Name
import org.jetbrains.jet.lang.resolve.scopes.JetScope
import org.jetbrains.jet.lang.resolve.java.descriptor.SamConstructorDescriptor
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor
import org.jetbrains.jet.lang.types.JetType
import org.jetbrains.jet.lang.resolve.java.structure.JavaMethod
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaClassDescriptor
import org.jetbrains.jet.lang.descriptors.SamConstructorDescriptor
public trait SamConversionResolver {
public fun resolveSamConstructor(name: Name, scope: JetScope): SamConstructorDescriptor?
@@ -0,0 +1,20 @@
/*
* Copyright 2010-2014 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.jet.lang.descriptors;
public interface SamConstructorDescriptor extends SimpleFunctionDescriptor {
}
@@ -51,7 +51,7 @@ public trait JetScope {
* (that means that the implementation is not obliged to use the filters but may do so when it gives any performance advantage).
*/
public fun getDescriptors(kindFilterMask: Int = ALL_KINDS_MASK,
nameFilter: (Name) -> Boolean = { true }): Collection<DeclarationDescriptor>
nameFilter: (Name) -> Boolean = ALL_NAME_FILTER): Collection<DeclarationDescriptor>
/**
* Adds receivers to the list in order of locality, so that the closest (the most local) receiver goes first
@@ -100,6 +100,40 @@ public trait JetScope {
public val VARIABLES_AND_PROPERTIES_MASK: Int = LOCAL_VARIABLE or NON_EXTENSION_PROPERTY or EXTENSION_PROPERTY
public val ALL_NAME_FILTER: (Name) -> Boolean = { true }
public fun descriptorKind(descriptor: DeclarationDescriptor): Int {
return when (descriptor) {
is ClassDescriptor -> when (descriptor.getKind()) {
ClassKind.OBJECT, ClassKind.CLASS_OBJECT -> OBJECT
ClassKind.ENUM_ENTRY -> ENUM_ENTRY
else -> TYPE
}
is PackageFragmentDescriptor, is PackageViewDescriptor -> PACKAGE
is SamConstructorDescriptor -> SAM_CONSTRUCTOR
is FunctionDescriptor -> if (descriptor.getExtensionReceiverParameter() != null) EXTENSION_FUNCTION else ORDINARY_FUNCTION
is PropertyDescriptor -> if (descriptor.getExtensionReceiverParameter() != null) EXTENSION_PROPERTY else NON_EXTENSION_PROPERTY
is VariableDescriptor -> LOCAL_VARIABLE
else -> 0 /* unknown */
}
}
}
}
/**
* The same as getDescriptors(kindFilterMask, nameFilter) but the result is guaranteed to be filtered by kind and name.
*/
public fun JetScope.getDescriptorsFiltered(kindFilterMask: Int,
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
return getDescriptors(kindFilterMask, nameFilter).filter {
(JetScope.descriptorKind(it) and kindFilterMask) != 0 && nameFilter(it.getName())
}
}