Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
fix: ILogger.Priority deserialization issues due to r8's enum unboxing
Browse files Browse the repository at this point in the history
  • Loading branch information
itsaky committed Nov 4, 2023
1 parent fcefb13 commit e28da6b
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import com.itsaky.androidide.BuildConfig
import com.itsaky.androidide.app.BaseApplication
import com.itsaky.androidide.lookup.Lookup
import com.itsaky.androidide.managers.ToolsManager
import com.itsaky.androidide.models.LogLine
import com.itsaky.androidide.preferences.internal.isBuildCacheEnabled
import com.itsaky.androidide.preferences.internal.isDebugEnabled
import com.itsaky.androidide.preferences.internal.isInfoEnabled
Expand All @@ -51,13 +50,15 @@ import com.itsaky.androidide.tooling.api.IToolingApiClient
import com.itsaky.androidide.tooling.api.IToolingApiServer
import com.itsaky.androidide.tooling.api.LogSenderConfig.PROPERTY_LOGSENDER_ENABLED
import com.itsaky.androidide.tooling.api.messages.InitializeProjectParams
import com.itsaky.androidide.tooling.api.messages.LogMessageParams
import com.itsaky.androidide.tooling.api.messages.TaskExecutionMessage
import com.itsaky.androidide.tooling.api.messages.result.BuildCancellationRequestResult
import com.itsaky.androidide.tooling.api.messages.result.BuildInfo
import com.itsaky.androidide.tooling.api.messages.result.BuildResult
import com.itsaky.androidide.tooling.api.messages.result.GradleWrapperCheckResult
import com.itsaky.androidide.tooling.api.messages.result.InitializeResult
import com.itsaky.androidide.tooling.api.messages.result.TaskExecutionResult
import com.itsaky.androidide.tooling.api.messages.toLogLine
import com.itsaky.androidide.tooling.events.ProgressEvent
import com.itsaky.androidide.utils.Environment
import com.itsaky.androidide.utils.ILogger
Expand Down Expand Up @@ -233,7 +234,8 @@ class GradleBuildService : Service(), BuildService, IToolingApiClient,
return _toolingApiClient!!
}

override fun logMessage(line: LogLine) {
override fun logMessage(params: LogMessageParams) {
val line = params.toLogLine()
serverLogger.log(line.priority, line.formattedTagAndMessage())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.itsaky.androidide.models.LogLine;
import com.itsaky.androidide.tooling.api.IToolingApiClient;
import com.itsaky.androidide.tooling.api.messages.LogMessageParams;
import com.itsaky.androidide.tooling.api.util.ToolingApiLauncher;
import com.itsaky.androidide.tooling.impl.internal.ProjectImpl;
import com.itsaky.androidide.tooling.impl.progress.ForwardingProgressListener;
Expand Down Expand Up @@ -126,7 +127,7 @@ public static void finalizeLauncher(ConfigurableLauncher<?> launcher) {

private static void onLog(Priority priority, String tag, String message) {
if (client != null) {
client.logMessage(LogLine.obtain(priority, tag, message));
client.logMessage(new LogMessageParams(priority.priorityChar, tag, message));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package com.itsaky.androidide.tooling.api

import com.itsaky.androidide.models.LogLine
import com.itsaky.androidide.tooling.api.messages.LogMessageParams
import com.itsaky.androidide.tooling.api.messages.result.BuildInfo
import com.itsaky.androidide.tooling.api.messages.result.BuildResult
import com.itsaky.androidide.tooling.api.messages.result.GradleWrapperCheckResult
Expand All @@ -31,8 +31,8 @@ import java.util.concurrent.CompletableFuture
*/
class ForwardingToolingApiClient(var client: IToolingApiClient?) : IToolingApiClient {

override fun logMessage(line: LogLine) {
client?.logMessage(line)
override fun logMessage(params: LogMessageParams) {
client?.logMessage(params)
}

override fun logOutput(line: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package com.itsaky.androidide.tooling.api

import com.itsaky.androidide.models.LogLine
import com.itsaky.androidide.tooling.api.messages.LogMessageParams
import com.itsaky.androidide.tooling.api.messages.result.BuildInfo
import com.itsaky.androidide.tooling.api.messages.result.BuildResult
import com.itsaky.androidide.tooling.api.messages.result.GradleWrapperCheckResult
Expand All @@ -38,9 +38,9 @@ interface IToolingApiClient {
/**
* Log the given log message.
*
* @param line The [LogLine] to log.
* @param params The parameters to log the message.
*/
@JsonNotification fun logMessage(line: LogLine)
@JsonNotification fun logMessage(params: LogMessageParams)

/**
* Log the build output received from Gradle.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/

package com.itsaky.androidide.tooling.api.messages

import com.itsaky.androidide.models.LogLine
import com.itsaky.androidide.utils.ILogger

/**
* Parameters for sending a log message from the tooling API to the IDE.
*
* @author Akash Yadav
*/
data class LogMessageParams(val level: Char, val tag: String, val message: String)

/**
* Creates a new [LogLine] instance from this [LogMessageParams].
*/
fun LogMessageParams.toLogLine(): LogLine {
return LogLine.obtain(ILogger.Priority.forChar(level), tag, message)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@

package com.itsaky.androidide.tooling.testing

import com.itsaky.androidide.models.LogLine
import com.itsaky.androidide.tooling.api.IProject
import com.itsaky.androidide.tooling.api.IToolingApiClient
import com.itsaky.androidide.tooling.api.IToolingApiServer
import com.itsaky.androidide.tooling.api.messages.GradleDistributionParams
import com.itsaky.androidide.tooling.api.messages.InitializeProjectParams
import com.itsaky.androidide.tooling.api.messages.LogMessageParams
import com.itsaky.androidide.tooling.api.messages.result.BuildInfo
import com.itsaky.androidide.tooling.api.messages.result.BuildResult
import com.itsaky.androidide.tooling.api.messages.result.GradleWrapperCheckResult
import com.itsaky.androidide.tooling.api.messages.result.InitializeResult
import com.itsaky.androidide.tooling.api.messages.toLogLine
import com.itsaky.androidide.tooling.api.util.ToolingApiLauncher
import com.itsaky.androidide.tooling.events.ProgressEvent
import com.itsaky.androidide.utils.FileProvider
Expand Down Expand Up @@ -150,7 +151,8 @@ class ToolingApiTestLauncher {
"DO NOT EDIT - Automatically generated file"
}

override fun logMessage(line: LogLine) {
override fun logMessage(params: LogMessageParams) {
val line = params.toLogLine()
log.log(line.priority, line.formattedTagAndMessage())
}

Expand Down

0 comments on commit e28da6b

Please sign in to comment.