Added UsageLocation parameter
This commit is contained in:
+4
-1
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
|
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.UsageLocation
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
import org.jetbrains.kotlin.types.*
|
import org.jetbrains.kotlin.types.*
|
||||||
import org.jetbrains.kotlin.types.typeUtil.isBoolean
|
import org.jetbrains.kotlin.types.typeUtil.isBoolean
|
||||||
@@ -144,7 +145,9 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : JetScopeImp
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> {
|
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<PropertyDescriptor> {
|
||||||
|
//TODO: use location parameter!
|
||||||
|
|
||||||
var result: SmartList<PropertyDescriptor>? = null
|
var result: SmartList<PropertyDescriptor>? = null
|
||||||
val processedTypes: MutableSet<TypeConstructor>? = if (receiverTypes.size() > 1) HashSet<TypeConstructor>() else null
|
val processedTypes: MutableSet<TypeConstructor>? = if (receiverTypes.size() > 1) HashSet<TypeConstructor>() else null
|
||||||
for (type in receiverTypes) {
|
for (type in receiverTypes) {
|
||||||
|
|||||||
+3
-2
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
|||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.parentsWithSelf
|
import org.jetbrains.kotlin.resolve.descriptorUtil.parentsWithSelf
|
||||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.UsageLocation
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
import org.jetbrains.kotlin.types.DescriptorSubstitutor
|
import org.jetbrains.kotlin.types.DescriptorSubstitutor
|
||||||
import org.jetbrains.kotlin.types.JetType
|
import org.jetbrains.kotlin.types.JetType
|
||||||
@@ -54,10 +55,10 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : JetScope by Jet
|
|||||||
return MyFunctionDescriptor(enhancedFunction)
|
return MyFunctionDescriptor(enhancedFunction)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name): Collection<FunctionDescriptor> {
|
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
|
||||||
var result: SmartList<FunctionDescriptor>? = null
|
var result: SmartList<FunctionDescriptor>? = null
|
||||||
for (type in receiverTypes) {
|
for (type in receiverTypes) {
|
||||||
for (function in type.memberScope.getFunctions(name)) {
|
for (function in type.memberScope.getFunctions(name, location)) {
|
||||||
val extension = extensionForFunction(function.original)
|
val extension = extensionForFunction(function.original)
|
||||||
if (extension != null) {
|
if (extension != null) {
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
|
|||||||
@@ -54,12 +54,12 @@ class AllUnderImportsScope : JetScope {
|
|||||||
return scopes.flatMap { it.getFunctions(name, location) }
|
return scopes.flatMap { it.getFunctions(name, location) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> {
|
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<PropertyDescriptor> {
|
||||||
return scopes.flatMap { it.getSyntheticExtensionProperties(receiverTypes, name) }
|
return scopes.flatMap { it.getSyntheticExtensionProperties(receiverTypes, name, location) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name): Collection<FunctionDescriptor> {
|
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
|
||||||
return scopes.flatMap { it.getSyntheticExtensionFunctions(receiverTypes, name) }
|
return scopes.flatMap { it.getSyntheticExtensionFunctions(receiverTypes, name, location) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor> {
|
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor> {
|
||||||
|
|||||||
@@ -258,14 +258,14 @@ class LazyImportScope(
|
|||||||
return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getFunctions(name, location) }
|
return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getFunctions(name, location) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> {
|
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<PropertyDescriptor> {
|
||||||
if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf()
|
if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf()
|
||||||
return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getSyntheticExtensionProperties(receiverTypes, name) }
|
return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getSyntheticExtensionProperties(receiverTypes, name, location) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name): Collection<FunctionDescriptor> {
|
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
|
||||||
if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf()
|
if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf()
|
||||||
return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getSyntheticExtensionFunctions(receiverTypes, name) }
|
return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getSyntheticExtensionFunctions(receiverTypes, name, location) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor> {
|
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor> {
|
||||||
|
|||||||
@@ -47,12 +47,12 @@ public abstract class AbstractScopeAdapter : JetScope {
|
|||||||
return workerScope.getProperties(name, location)
|
return workerScope.getProperties(name, location)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> {
|
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<PropertyDescriptor> {
|
||||||
return workerScope.getSyntheticExtensionProperties(receiverTypes, name)
|
return workerScope.getSyntheticExtensionProperties(receiverTypes, name, location)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name): Collection<FunctionDescriptor> {
|
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<FunctionDescriptor> {
|
||||||
return workerScope.getSyntheticExtensionFunctions(receiverTypes, name)
|
return workerScope.getSyntheticExtensionFunctions(receiverTypes, name, location)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor> {
|
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor> {
|
||||||
|
|||||||
@@ -64,11 +64,11 @@ public open class ChainedScope(
|
|||||||
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor>
|
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor>
|
||||||
= getFromAllScopes { it.getFunctions(name, location) }
|
= getFromAllScopes { it.getFunctions(name, location) }
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor>
|
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<PropertyDescriptor>
|
||||||
= getFromAllScopes { it.getSyntheticExtensionProperties(receiverTypes, name) }
|
= getFromAllScopes { it.getSyntheticExtensionProperties(receiverTypes, name, location) }
|
||||||
|
|
||||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name): Collection<FunctionDescriptor>
|
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<FunctionDescriptor>
|
||||||
= getFromAllScopes { it.getSyntheticExtensionFunctions(receiverTypes, name) }
|
= getFromAllScopes { it.getSyntheticExtensionFunctions(receiverTypes, name, location) }
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor>
|
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor>
|
||||||
= getFromAllScopes { it.getSyntheticExtensionProperties(receiverTypes) }
|
= getFromAllScopes { it.getSyntheticExtensionProperties(receiverTypes) }
|
||||||
|
|||||||
@@ -38,13 +38,17 @@ public class FilteringScope(private val workerScope: JetScope, private val predi
|
|||||||
|
|
||||||
override fun getProperties(name: Name, location: UsageLocation) = workerScope.getProperties(name, location).filter(predicate)
|
override fun getProperties(name: Name, location: UsageLocation) = workerScope.getProperties(name, location).filter(predicate)
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> = workerScope.getSyntheticExtensionProperties(receiverTypes, name).filter(predicate)
|
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<PropertyDescriptor>
|
||||||
|
= workerScope.getSyntheticExtensionProperties(receiverTypes, name, location).filter(predicate)
|
||||||
|
|
||||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name): Collection<FunctionDescriptor> = workerScope.getSyntheticExtensionFunctions(receiverTypes, name).filter(predicate)
|
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<FunctionDescriptor>
|
||||||
|
= workerScope.getSyntheticExtensionFunctions(receiverTypes, name, location).filter(predicate)
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor> = workerScope.getSyntheticExtensionProperties(receiverTypes).filter(predicate)
|
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor>
|
||||||
|
= workerScope.getSyntheticExtensionProperties(receiverTypes).filter(predicate)
|
||||||
|
|
||||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>): Collection<FunctionDescriptor> = workerScope.getSyntheticExtensionFunctions(receiverTypes).filter(predicate)
|
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>): Collection<FunctionDescriptor>
|
||||||
|
= workerScope.getSyntheticExtensionFunctions(receiverTypes).filter(predicate)
|
||||||
|
|
||||||
override fun getLocalVariable(name: Name) = filterDescriptor(workerScope.getLocalVariable(name))
|
override fun getLocalVariable(name: Name) = filterDescriptor(workerScope.getLocalVariable(name))
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ public interface JetScope {
|
|||||||
|
|
||||||
public fun getFunctions(name: Name, location: UsageLocation = UsageLocation.NO_LOCATION): Collection<FunctionDescriptor>
|
public fun getFunctions(name: Name, location: UsageLocation = UsageLocation.NO_LOCATION): Collection<FunctionDescriptor>
|
||||||
|
|
||||||
public fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor>
|
public fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation = UsageLocation.NO_LOCATION): Collection<PropertyDescriptor>
|
||||||
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name): Collection<FunctionDescriptor>
|
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation = UsageLocation.NO_LOCATION): Collection<FunctionDescriptor>
|
||||||
|
|
||||||
public fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor>
|
public fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor>
|
||||||
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>): Collection<FunctionDescriptor>
|
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>): Collection<FunctionDescriptor>
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ public abstract class JetScopeImpl : JetScope {
|
|||||||
|
|
||||||
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> = emptyList()
|
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> = emptyList()
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> = emptyList()
|
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<PropertyDescriptor> = emptyList()
|
||||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name): Collection<FunctionDescriptor> = emptyList()
|
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<FunctionDescriptor> = emptyList()
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor> = emptyList()
|
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor> = emptyList()
|
||||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>): Collection<FunctionDescriptor> = emptyList()
|
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>): Collection<FunctionDescriptor> = emptyList()
|
||||||
|
|||||||
@@ -70,11 +70,11 @@ public class SubstitutingScope(private val workerScope: JetScope, private val su
|
|||||||
|
|
||||||
override fun getFunctions(name: Name, location: UsageLocation) = substitute(workerScope.getFunctions(name, location))
|
override fun getFunctions(name: Name, location: UsageLocation) = substitute(workerScope.getFunctions(name, location))
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor>
|
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<PropertyDescriptor>
|
||||||
= substitute(workerScope.getSyntheticExtensionProperties(receiverTypes, name))
|
= substitute(workerScope.getSyntheticExtensionProperties(receiverTypes, name, location))
|
||||||
|
|
||||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name): Collection<FunctionDescriptor>
|
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: UsageLocation): Collection<FunctionDescriptor>
|
||||||
= substitute(workerScope.getSyntheticExtensionFunctions(receiverTypes, name))
|
= substitute(workerScope.getSyntheticExtensionFunctions(receiverTypes, name, location))
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor>
|
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor>
|
||||||
= substitute(workerScope.getSyntheticExtensionProperties(receiverTypes))
|
= substitute(workerScope.getSyntheticExtensionProperties(receiverTypes))
|
||||||
|
|||||||
@@ -96,7 +96,8 @@ public class ErrorUtils {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Collection<PropertyDescriptor> getSyntheticExtensionProperties(
|
public Collection<PropertyDescriptor> getSyntheticExtensionProperties(
|
||||||
@NotNull Collection<? extends JetType> receiverTypes, @NotNull Name name
|
@NotNull Collection<? extends JetType> receiverTypes, @NotNull Name name,
|
||||||
|
@NotNull UsageLocation location
|
||||||
) {
|
) {
|
||||||
return ERROR_PROPERTY_GROUP;
|
return ERROR_PROPERTY_GROUP;
|
||||||
}
|
}
|
||||||
@@ -104,7 +105,8 @@ public class ErrorUtils {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Collection<FunctionDescriptor> getSyntheticExtensionFunctions(
|
public Collection<FunctionDescriptor> getSyntheticExtensionFunctions(
|
||||||
@NotNull Collection<? extends JetType> receiverTypes, @NotNull Name name
|
@NotNull Collection<? extends JetType> receiverTypes, @NotNull Name name,
|
||||||
|
@NotNull UsageLocation location
|
||||||
) {
|
) {
|
||||||
return Collections.<FunctionDescriptor>singleton(createErrorFunction(this));
|
return Collections.<FunctionDescriptor>singleton(createErrorFunction(this));
|
||||||
}
|
}
|
||||||
@@ -228,7 +230,8 @@ public class ErrorUtils {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Collection<PropertyDescriptor> getSyntheticExtensionProperties(
|
public Collection<PropertyDescriptor> getSyntheticExtensionProperties(
|
||||||
@NotNull Collection<? extends JetType> receiverTypes, @NotNull Name name
|
@NotNull Collection<? extends JetType> receiverTypes, @NotNull Name name,
|
||||||
|
@NotNull UsageLocation location
|
||||||
) {
|
) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
@@ -236,7 +239,8 @@ public class ErrorUtils {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Collection<FunctionDescriptor> getSyntheticExtensionFunctions(
|
public Collection<FunctionDescriptor> getSyntheticExtensionFunctions(
|
||||||
@NotNull Collection<? extends JetType> receiverTypes, @NotNull Name name
|
@NotNull Collection<? extends JetType> receiverTypes, @NotNull Name name,
|
||||||
|
@NotNull UsageLocation location
|
||||||
) {
|
) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user