Skip to content

Commit c3e1330

Browse files
committed
fix: finalize indexing API; remove api versions index
1 parent f3e460c commit c3e1330

File tree

20 files changed

+96
-183
lines changed

20 files changed

+96
-183
lines changed

.idea/compiler.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ dependencies {
8787
implementation(libs.common.retrofit.gson)
8888
implementation(libs.common.charts)
8989
implementation(libs.common.hiddenApiBypass)
90+
implementation(libs.aapt2.common)
9091

9192
implementation(libs.google.auto.service.annotations)
9293
implementation(libs.google.gson)

core/indexing-core/src/main/java/com/itsaky/androidide/indexing/core/internal/platform/PlatformIndexService.kt renamed to core/app/src/main/java/com/itsaky/androidide/indexing/platform/PlatformIndexService.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
1616
*/
1717

18-
package com.itsaky.androidide.indexing.core.internal.platform
18+
package com.itsaky.androidide.indexing.platform
1919

2020
import com.google.auto.service.AutoService
2121
import com.itsaky.androidide.indexing.IIndexService
22-
import com.itsaky.androidide.progress.IProgressIndicator
2322
import com.itsaky.androidide.projects.api.Project
23+
import org.slf4j.LoggerFactory
2424
import java.io.File
2525

2626
/**
@@ -29,19 +29,26 @@ import java.io.File
2929
@AutoService(IIndexService::class)
3030
internal class PlatformIndexService : IIndexService {
3131

32+
companion object {
33+
private val log = LoggerFactory.getLogger(PlatformIndexService::class.java)
34+
}
35+
36+
override val displayName: String
37+
get() = "Android Platform Indexing Service"
38+
3239
override fun scanFiles(project: Project): Collection<File> {
3340
return mutableListOf<File>().apply {
3441
project.findAndroidModules().forEach { androidModule ->
35-
add(androidModule.getPlatformDir() ?: return@forEach)
42+
add(androidModule.getPlatformDir()?.also {
43+
log.debug("Adding {} to the list of indexable paths", it)
44+
} ?: return@forEach)
3645
}
3746
}
3847
}
3948

4049
override suspend fun indexFiles(
4150
project: Project,
42-
progress: IProgressIndicator,
4351
files: Collection<File>
4452
) {
45-
TODO("Not yet implemented")
4653
}
4754
}

core/app/src/main/java/com/itsaky/androidide/projects/ProjectManagerImpl.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import com.itsaky.androidide.projects.api.AndroidModule
3333
import com.itsaky.androidide.projects.api.ModuleProject
3434
import com.itsaky.androidide.projects.api.Project
3535
import com.itsaky.androidide.projects.builder.BuildService
36-
import com.itsaky.androidide.projects.util.ProjectTransformer
3736
import com.itsaky.androidide.tasks.executeAsync
3837
import com.itsaky.androidide.tooling.api.IAndroidProject
3938
import com.itsaky.androidide.tooling.api.IProject

core/projects/src/main/java/com/itsaky/androidide/projects/util/ProjectTransformer.kt renamed to core/app/src/main/java/com/itsaky/androidide/projects/ProjectTransformer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
1616
*/
1717

18-
package com.itsaky.androidide.projects.util
18+
package com.itsaky.androidide.projects
1919

2020
import com.itsaky.androidide.projects.api.AndroidModule
2121
import com.itsaky.androidide.projects.api.GradleProject

core/indexing-api/src/main/java/com/itsaky/androidide/indexing/AbstractDBIndex.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import io.realm.Realm
2525
* @property params The index parameters.
2626
* @author Akash Yadav
2727
*/
28-
abstract class AbstractDBIndex<T : IIndexable, C : IIndexParams>(
28+
abstract class AbstractDBIndex<T : IIndexable>(
2929
protected val params: IIndexParams?
30-
) : IIndex<T, C> {
30+
) : IDatabaseIndex<T> {
3131

3232
protected abstract val realm: Realm
3333

core/indexing-core/src/main/java/com/itsaky/androidide/indexing/core/platform/IApiVersionsIndex.kt renamed to core/indexing-api/src/main/java/com/itsaky/androidide/indexing/IDatabaseIndex.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,19 @@
1515
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
1616
*/
1717

18-
package com.itsaky.androidide.indexing.core.platform
18+
package com.itsaky.androidide.indexing
1919

20-
import com.itsaky.androidide.indexing.IIndexParams
21-
import com.itsaky.androidide.indexing.core.platform.IApiVersionsIndex.Params
20+
import io.realm.RealmQuery
2221

2322
/**
24-
* Index which provides access to the API versions informations (`api-versions.xml`) from the
25-
* Android SDK.
23+
* An index which is stored in the database.
2624
*
2725
* @author Akash Yadav
2826
*/
29-
interface IApiVersionsIndex : IPlatformIndex<ClassOrMemberInfo, Params> {
27+
interface IDatabaseIndex<IndexableT : IIndexable> : IIndex<IndexableT> {
3028

31-
class Params(
32-
val platformId: String
33-
) : IIndexParams
29+
/**
30+
* Perform a query on the Realm database.
31+
*/
32+
fun query(): RealmQuery<IndexableT>
3433
}

core/indexing-api/src/main/java/com/itsaky/androidide/indexing/IIndex.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import com.itsaky.androidide.db.IRealmProvider
2424
*
2525
* @author Akash Yadav
2626
*/
27-
interface IIndex<IndexableT : IIndexable, ConfigT : IIndexParams> {
27+
interface IIndex<IndexableT : IIndexable> {
2828

2929
companion object {
3030

@@ -36,7 +36,7 @@ interface IIndex<IndexableT : IIndexable, ConfigT : IIndexParams> {
3636
/**
3737
* Base path for indices.
3838
*/
39-
const val INDEX_BASE_PATH = "${IRealmProvider.PATH_SEPARATOR}index"
39+
val INDEX_BASE_PATH = createIndexPath("", "index")
4040

4141
private const val DEF_IS_ASYNC = true
4242

@@ -91,9 +91,9 @@ interface IIndex<IndexableT : IIndexable, ConfigT : IIndexParams> {
9191
*
9292
* @return The created sub-index.
9393
*/
94-
fun <I : IIndexable, C : IIndexParams> createSubIndex(
94+
fun <I : IIndexable> createSubIndex(
9595
params: IIndexParams? = null
96-
): IIndex<I, C> {
96+
): IIndex<I> {
9797
throw UnsupportedOperationException()
9898
}
9999

core/indexing-api/src/main/java/com/itsaky/androidide/indexing/IIndexFactory.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ interface IIndexFactory<I : IIndexable, P : IIndexParams> {
4949
* @return The created [IIndex].
5050
*/
5151
@Throws(NotFoundException::class)
52-
fun create(): IIndex<I, P>
52+
fun create(): IIndex<I>
5353

5454
companion object {
5555

@@ -99,10 +99,10 @@ interface IIndexFactory<I : IIndexable, P : IIndexParams> {
9999
return factory
100100
}
101101

102-
val impls = ServiceLoader.load(symTyp).iterator()
102+
val impls = ServiceLoader.load(IIndexFactory::class.java).iterator()
103103
while (impls.hasNext()) {
104104
val impl = impls.next()
105-
if (impl is IIndexFactory<*, *> && symTyp == impl.indexableType()) {
105+
if (symTyp == impl.indexableType()) {
106106
if (factory == null) {
107107
factory = impl as IIndexFactory<T, P>
108108
continue

core/indexing-api/src/main/java/com/itsaky/androidide/indexing/IIndexParams.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
package com.itsaky.androidide.indexing
1919

2020
/**
21-
* Index configuration
21+
* Index configuration parameters. All implementations of this interface must implement the
22+
* [Object.equals] and [Object.hashCode] methods properly as the parameters may be used to cache
23+
* the index implementations in [IIndexFactory]s.
2224
*
2325
* @author Akash Yadav
2426
*/

0 commit comments

Comments
 (0)