Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix adding multiple CONAN_COMMAND #160

Merged
merged 2 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

### Bugfix
- Fixed when only the Conan executable path was changed, it was not updated
- Fixed adding multiple CONAN_COMMAND

## [2.0.1] - 2023-08-31

Expand Down
15 changes: 9 additions & 6 deletions src/main/kotlin/com/jfrog/conan/clion/cmake/CMake.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import com.intellij.notification.NotificationGroupManager
import com.intellij.notification.NotificationType
import com.intellij.openapi.components.service
import com.intellij.openapi.diagnostic.thisLogger

Check warning on line 7 in src/main/kotlin/com/jfrog/conan/clion/cmake/CMake.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive
import com.intellij.openapi.options.advanced.AdvancedSettings
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.Messages

Check warning on line 10 in src/main/kotlin/com/jfrog/conan/clion/cmake/CMake.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive
import com.jetbrains.cidr.cpp.cmake.CMakeSettings
import com.jetbrains.cidr.cpp.cmake.model.CMakeConfiguration
import com.jetbrains.cidr.cpp.execution.CMakeAppRunConfiguration
Expand Down Expand Up @@ -72,14 +72,17 @@
for (profile in profiles) {
if (profile.name == profileName) {
val existingGenerationOptions = profile.generationOptions ?: ""
val newGenerationOptions = mutableListOf<String>()

if (existingGenerationOptions.isNotEmpty()) {
newGenerationOptions.add(existingGenerationOptions)
val newGenerationOptions = if (existingGenerationOptions.isNotEmpty()) {
existingGenerationOptions.split(" ").toMutableList()
} else {
mutableListOf<String>()

Check notice on line 78 in src/main/kotlin/com/jfrog/conan/clion/cmake/CMake.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unnecessary type argument

Remove explicit type arguments
}

generationOptions.forEach { option ->
if (!existingGenerationOptions.contains(option)) {
val optionKey = option.split("=")[0]
val existingOptionIndex = newGenerationOptions.indexOfFirst { it.startsWith(optionKey) }
if (existingOptionIndex != -1) {
newGenerationOptions[existingOptionIndex] = option
} else {
newGenerationOptions.add(option)
}
}
Expand Down
Loading