From fd13dce5e0aac24b3178d1b6390715e12d0bbf9a Mon Sep 17 00:00:00 2001 From: Akash Yadav Date: Sun, 15 May 2022 22:44:20 +0530 Subject: [PATCH] Updated KDoc --- .../tooling/impl/ToolingApiServerImpl.kt | 3 +- .../impl/model/InternalForwardingProject.kt | 28 ++++++++++++++---- .../test/test-home/.androidide/init/model.jar | Bin 85813 -> 85813 bytes 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/build-tools/tooling-api-impl/src/main/java/com/itsaky/androidide/tooling/impl/ToolingApiServerImpl.kt b/build-tools/tooling-api-impl/src/main/java/com/itsaky/androidide/tooling/impl/ToolingApiServerImpl.kt index 0deaabbf0..605d831d5 100644 --- a/build-tools/tooling-api-impl/src/main/java/com/itsaky/androidide/tooling/impl/ToolingApiServerImpl.kt +++ b/build-tools/tooling-api-impl/src/main/java/com/itsaky/androidide/tooling/impl/ToolingApiServerImpl.kt @@ -60,7 +60,8 @@ import org.gradle.tooling.exceptions.UnsupportedOperationConfigurationException * * @author Akash Yadav */ -internal class ToolingApiServerImpl (val forwardingProject: InternalForwardingProject) : IToolingApiServer { +internal class ToolingApiServerImpl(private val forwardingProject: InternalForwardingProject) : + IToolingApiServer { private var initialized = false private var client: IToolingApiClient? = null diff --git a/build-tools/tooling-api-impl/src/main/java/com/itsaky/androidide/tooling/impl/model/InternalForwardingProject.kt b/build-tools/tooling-api-impl/src/main/java/com/itsaky/androidide/tooling/impl/model/InternalForwardingProject.kt index af49196de..9a4c6d93d 100644 --- a/build-tools/tooling-api-impl/src/main/java/com/itsaky/androidide/tooling/impl/model/InternalForwardingProject.kt +++ b/build-tools/tooling-api-impl/src/main/java/com/itsaky/androidide/tooling/impl/model/InternalForwardingProject.kt @@ -17,6 +17,7 @@ package com.itsaky.androidide.tooling.impl.model +import com.itsaky.androidide.tooling.api.IToolingApiClient import com.itsaky.androidide.tooling.api.model.IProject import com.itsaky.androidide.tooling.api.model.IdeAndroidModule import com.itsaky.androidide.tooling.api.model.IdeGradleProject @@ -25,42 +26,59 @@ import com.itsaky.androidide.utils.ILogger import java.io.File import java.util.concurrent.* -/** @author Akash Yadav */ +/** + * An [IProject] implementation which forwards all calls to another [IProject]. + * + * We provide [IProject] as a service to the [IToolingApiClient]. As there is no real project + * instance available when the server starts, we use this implementation. When the project is + * initialized, the Tooling API server updates the project instance here. Once the project instance + * is available, the client can fetch real information about the project. + * + * @author Akash Yadav + */ class InternalForwardingProject(var project: IProject?) : IProject { private val log = ILogger.newInstance(javaClass.simpleName) - override fun getName(): CompletableFuture { - log.debug("getName", "this.project", this.project) - return if (this.project != null) this.project!!.name else CompletableFuture.completedFuture("") - } + override fun getName(): CompletableFuture = + if (this.project != null) this.project!!.name else CompletableFuture.completedFuture("") + override fun getDescription(): CompletableFuture = if (this.project != null) this.project!!.description else CompletableFuture.completedFuture("") + override fun getProjectPath(): CompletableFuture = if (this.project != null) this.project!!.projectPath else CompletableFuture.completedFuture("") + override fun getProjectDir(): CompletableFuture = if (this.project != null) this.project!!.projectDir else CompletableFuture.completedFuture(File(".")) + override fun getBuildDir(): CompletableFuture = if (this.project != null) this.project!!.buildDir else CompletableFuture.completedFuture(File(".")) + override fun getBuildScript(): CompletableFuture = if (this.project != null) this.project!!.buildScript else CompletableFuture.completedFuture(File(".")) + override fun getTasks(): CompletableFuture> = if (this.project != null) this.project!!.tasks else CompletableFuture.completedFuture(mutableListOf()) + override fun getModules(): CompletableFuture> = if (this.project != null) this.project!!.modules else CompletableFuture.completedFuture(mutableListOf()) + override fun findByPath(path: String): CompletableFuture = if (this.project != null) this.project!!.findByPath(path) else CompletableFuture.completedFuture(null) + override fun findAndroidModules(): CompletableFuture> = if (this.project != null) this.project!!.findAndroidModules() else CompletableFuture.completedFuture(mutableListOf()) + override fun findFirstAndroidModule(): CompletableFuture = if (this.project != null) this.project!!.findFirstAndroidModule() else CompletableFuture.completedFuture(null) diff --git a/build-tools/tooling-api-impl/src/test/test-home/.androidide/init/model.jar b/build-tools/tooling-api-impl/src/test/test-home/.androidide/init/model.jar index 22a82e5caf47b85fa3dea0b8187a647bc1483629..0a5f4759ce53326e0468984e3219b92b84c6e56c 100644 GIT binary patch delta 35 rcmdlwk9F%jR-OQFW)?061`ZAe?JbQwTX`5Knlou{**@Q#ahf;)s8k7y delta 35 rcmdlwk9F%jR-OQFW)?061`ZB}C7T<0w(>AeG-q0}dHZ~G#%baJw1x_M