Added JetScope.getDescriptors(nameFilter, kindFilter) but the filters are never used yet

This commit is contained in:
Valentin Kipyatkov
2014-10-29 13:49:57 +03:00
parent e8a2039396
commit 760b9c4389
17 changed files with 94 additions and 31 deletions
@@ -173,7 +173,8 @@ public class LazyImportScope(private val resolveSession: ResolveSession,
override fun getDeclarationsByLabel(labelName: Name): Collection<DeclarationDescriptor> = listOf()
override fun getAllDescriptors() = collectFromImports(LookupMode.EVERYTHING, JetScopeSelectorUtil.ALL_DESCRIPTORS_SCOPE_SELECTOR)
override fun getDescriptors(kindFilter: (JetScope.DescriptorKind) -> Boolean,
nameFilter: (String) -> Boolean) = collectFromImports(LookupMode.EVERYTHING, JetScopeSelectorUtil.ALL_DESCRIPTORS_SCOPE_SELECTOR)
override fun getImplicitReceiversHierarchy() = listOf<ReceiverParameterDescriptor>()
@@ -143,7 +143,8 @@ public abstract class AbstractLazyMemberScope<D : DeclarationDescriptor, DP : De
override fun getDeclarationsByLabel(labelName: Name) = setOf<DeclarationDescriptor>()
override fun getAllDescriptors(): Collection<DeclarationDescriptor> {
override fun getDescriptors(kindFilter: (JetScope.DescriptorKind) -> Boolean,
nameFilter: (String) -> Boolean): Collection<DeclarationDescriptor> {
val result = LinkedHashSet(descriptorsFromDeclaredElements())
result.addAll(extraDescriptors())
return result
@@ -99,7 +99,8 @@ public class WritableScopeImpl(scope: JetScope,
super.clearImports()
}
override fun getAllDescriptors(): Collection<DeclarationDescriptor> {
override fun getDescriptors(kindFilter: (JetScope.DescriptorKind) -> Boolean,
nameFilter: (String) -> Boolean): Collection<DeclarationDescriptor> {
checkMayRead()
if (!allDescriptorsDone) {
@@ -31,7 +31,7 @@ import org.jetbrains.jet.utils.Printer
public class WriteThroughScope(outerScope: JetScope, private val writableWorker: WritableScope, redeclarationHandler: RedeclarationHandler, debugName: String)
: WritableScopeWithImports(outerScope, redeclarationHandler, debugName) {
private var allDescriptors: MutableCollection<DeclarationDescriptor>? = null
private var _allDescriptors: MutableCollection<DeclarationDescriptor>? = null
override fun getDeclarationsByLabel(labelName: Name): Collection<DeclarationDescriptor> {
checkMayRead()
@@ -164,18 +164,19 @@ public class WriteThroughScope(outerScope: JetScope, private val writableWorker:
writableWorker.setImplicitReceiver(implicitReceiver)
}
override fun getAllDescriptors(): Collection<DeclarationDescriptor> {
override fun getDescriptors(kindFilter: (JetScope.DescriptorKind) -> Boolean,
nameFilter: (String) -> Boolean): Collection<DeclarationDescriptor> {
checkMayRead()
if (allDescriptors == null) {
allDescriptors = Lists.newArrayList<DeclarationDescriptor>()
allDescriptors!!.addAll(workerScope.getAllDescriptors())
if (_allDescriptors == null) {
_allDescriptors = Lists.newArrayList<DeclarationDescriptor>()
_allDescriptors!!.addAll(workerScope.getAllDescriptors())
for (imported in getImports()) {
allDescriptors!!.addAll(imported.getAllDescriptors())
_allDescriptors!!.addAll(imported.getAllDescriptors())
}
}
return allDescriptors!!
return _allDescriptors!!
}
override fun printAdditionalScopeStructure(p: Printer) {