From fecccc7b91613ad5918862b09aeeb85797dc53b3 Mon Sep 17 00:00:00 2001 From: DevSrSouza Date: Sun, 7 May 2023 10:39:34 -0300 Subject: [PATCH] fix: incompatibility with intellij versions on Gradle Sync --- .../dropboxfocus/services/FocusService.kt | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/br/com/devsrsouza/intellij/dropboxfocus/services/FocusService.kt b/src/main/kotlin/br/com/devsrsouza/intellij/dropboxfocus/services/FocusService.kt index f05a1be..6199c8f 100644 --- a/src/main/kotlin/br/com/devsrsouza/intellij/dropboxfocus/services/FocusService.kt +++ b/src/main/kotlin/br/com/devsrsouza/intellij/dropboxfocus/services/FocusService.kt @@ -99,6 +99,12 @@ class FocusService(private val project: Project) { ) } + private val requestConstructor by lazy { + GradleSyncInvoker.Request::class.java.getConstructor( + GradleSyncStats.Trigger::class.java + ) + } + fun syncGradle() { _focusOperationState.value = true @@ -112,12 +118,14 @@ class FocusService(private val project: Project) { ) }.onFailure { // AS 2022.1 Canary 1 does not have a function with [Trigger] type - requestProjectSyncMethodWithRequest.invoke( - gradleProjectImporterInstance, - project, - GradleSyncInvoker.Request(GradleSyncStats.Trigger.TRIGGER_PROJECT_MODIFIED), - null, - ) + try { + requestProjectSyncMethodWithRequest.invoke( + gradleProjectImporterInstance, + project, + requestConstructor.newInstance(GradleSyncStats.Trigger.TRIGGER_PROJECT_MODIFIED), + null, + ) + } catch (e: Throwable) {} } } } \ No newline at end of file