[Analysis API] simplify KotlinDeclarationProvider interface
This commit is contained in:
+3
-4
@@ -24,14 +24,13 @@ public abstract class KotlinDeclarationProvider {
|
||||
public abstract fun getAllClassesByClassId(classId: ClassId): Collection<KtClassOrObject>
|
||||
public abstract fun getAllTypeAliasesByClassId(classId: ClassId): Collection<KtTypeAlias>
|
||||
|
||||
public abstract fun getClassNamesInPackage(packageFqName: FqName): Set<Name>
|
||||
public abstract fun getTypeAliasNamesInPackage(packageFqName: FqName): Set<Name>
|
||||
public abstract fun getTopLevelKotlinClassLikeDeclarationNamesInPackage(packageFqName: FqName): Set<Name>
|
||||
|
||||
public abstract fun getTopLevelProperties(callableId: CallableId): Collection<KtProperty>
|
||||
public abstract fun getTopLevelFunctions(callableId: CallableId): Collection<KtNamedFunction>
|
||||
|
||||
public abstract fun getPropertyNamesInPackage(packageFqName: FqName): Set<Name>
|
||||
public abstract fun getFunctionsNamesInPackage(packageFqName: FqName): Set<Name>
|
||||
public abstract fun getTopLevelCallableNamesInPackage(packageFqName: FqName): Set<Name>
|
||||
|
||||
public abstract fun getFacadeFilesInPackage(packageFqName: FqName): Collection<KtFile>
|
||||
public abstract fun findFilesForFacade(facadeFqName: FqName): Collection<KtFile>
|
||||
}
|
||||
|
||||
+12
-28
@@ -51,37 +51,21 @@ public class KotlinStaticDeclarationProvider internal constructor(
|
||||
}
|
||||
?: emptyList()
|
||||
|
||||
override fun getClassNamesInPackage(packageFqName: FqName): Set<Name> =
|
||||
index.classMap[packageFqName]
|
||||
?.filter { ktClassOrObject ->
|
||||
ktClassOrObject.inScope
|
||||
}
|
||||
?.mapNotNullTo(mutableSetOf()) { it.nameAsName }
|
||||
?: emptySet()
|
||||
|
||||
override fun getTypeAliasNamesInPackage(packageFqName: FqName): Set<Name> =
|
||||
index.typeAliasMap[packageFqName]
|
||||
?.filter { ktTypeAlias ->
|
||||
ktTypeAlias.inScope
|
||||
}
|
||||
?.mapNotNullTo(mutableSetOf()) { it.nameAsName }
|
||||
?: emptySet()
|
||||
override fun getTopLevelKotlinClassLikeDeclarationNamesInPackage(packageFqName: FqName): Set<Name> {
|
||||
val classifiers = index.classMap[packageFqName].orEmpty() + index.typeAliasMap[packageFqName].orEmpty()
|
||||
return classifiers.filter { it.inScope }
|
||||
.mapNotNullTo(mutableSetOf()) { it.nameAsName }
|
||||
}
|
||||
|
||||
override fun getPropertyNamesInPackage(packageFqName: FqName): Set<Name> =
|
||||
index.topLevelPropertyMap[packageFqName]
|
||||
?.filter { ktProperty ->
|
||||
ktProperty.inScope
|
||||
}
|
||||
?.mapNotNullTo(mutableSetOf()) { it.nameAsName }
|
||||
?: emptySet()
|
||||
|
||||
override fun getFunctionsNamesInPackage(packageFqName: FqName): Set<Name> =
|
||||
index.topLevelFunctionMap[packageFqName]
|
||||
?.filter { ktNamedFunction ->
|
||||
ktNamedFunction.inScope
|
||||
}
|
||||
?.mapNotNullTo(mutableSetOf()) { it.nameAsName }
|
||||
?: emptySet()
|
||||
override fun getTopLevelCallableNamesInPackage(packageFqName: FqName): Set<Name> {
|
||||
val callables = index.topLevelPropertyMap[packageFqName].orEmpty() + index.topLevelFunctionMap[packageFqName].orEmpty()
|
||||
return callables
|
||||
.filter { it.inScope }
|
||||
.mapNotNullTo(mutableSetOf()) { it.nameAsName }
|
||||
}
|
||||
|
||||
|
||||
override fun getFacadeFilesInPackage(packageFqName: FqName): Collection<KtFile> =
|
||||
index.facadeFileMap[packageFqName]
|
||||
|
||||
Reference in New Issue
Block a user