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

Download target data only on first setup, not plugin init #151

Merged
merged 1 commit into from
Aug 31, 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
12 changes: 0 additions & 12 deletions src/main/kotlin/com/jfrog/conan/clion/services/ConanPluginInit.kt

This file was deleted.

11 changes: 7 additions & 4 deletions src/main/kotlin/com/jfrog/conan/clion/services/ConanService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.jfrog.conan.clion.models.LibraryData
import com.jfrog.conan.clion.models.PersistentStorageKeys
import kotlinx.serialization.SerializationException
import kotlinx.serialization.decodeFromString

Check warning on line 17 in src/main/kotlin/com/jfrog/conan/clion/services/ConanService.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive
import kotlinx.serialization.json.Json
import java.io.File

Expand All @@ -30,7 +30,7 @@

fun onWindowReady() {
fireOnConfiguredListeners(isPluginConfigured())
fireOnLibraryDataChanged(getRemoteData())
fireOnLibraryDataChanged(getTargetData())
}

fun fireOnConfiguredListeners(isConfigured: Boolean) {
Expand All @@ -53,7 +53,7 @@
if (!cmake.checkConanUsedInAnyActiveProfile()) {
Messages.showMessageDialog(
"Looks like Conan support may have not been added to the project. \n" +
"Please click on the add button to add Conan support", "Add Conan support to the project",

Check warning on line 56 in src/main/kotlin/com/jfrog/conan/clion/services/ConanService.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Incorrect string capitalization

String 'Add Conan support to the project' is not properly capitalized. It should have title capitalization
Messages.getWarningIcon()
)
}
Expand Down Expand Up @@ -161,6 +161,9 @@
if (!targetFile.exists() || update && ConanPluginUtils.fileHasOverwriteComment(targetFile)) {
targetFile.parentFile.mkdirs()
targetFile.downloadFromUrl(cmakeProviderURL)
// TODO: Check if cmakeProviderURL was downloaded correctly,
// else save the copy from the plugin into the project

// Re-write it, but adding the overwrite header
ConanPluginUtils.writeToFileWithOverwriteComment(targetFile, targetFile.readText())
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(targetFile)
Expand Down Expand Up @@ -196,17 +199,17 @@
}
}

fun getRemoteData(): LibraryData {
fun getTargetData(): LibraryData {
return try {
val targetData = getRemoteDataText()
val targetData = getTargetDataText()
Json { ignoreUnknownKeys = true }.decodeFromString<LibraryData>(targetData)
} catch (e: SerializationException) {
thisLogger().error(e)
LibraryData(hashMapOf())
}
}

fun getRemoteDataText(): String {
fun getTargetDataText(): String {
val userHomeFile = getRemoteDataFile()
if (!userHomeFile.exists()) {
val defaultFile = ConanService::class.java.classLoader.getResource("conan/targets-data.json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
}
}

private val targetsData = project.service<ConanService>().getRemoteDataText()
private val libraryData = project.service<ConanService>().getRemoteData()
private val targetsDataAsText = project.service<ConanService>().getTargetDataText()
private val libraryData = project.service<ConanService>().getTargetData()

fun getTitleHtml(name: String): String {
val description = libraryData.libraries[name]?.description
Expand All @@ -43,7 +43,7 @@
private fun getScript(name: String): String {
return """
function fillExtraData() {
const data = $targetsData;
const data = $targetsDataAsText;
const libraries = data["libraries"]
const infoDiv = document.getElementById("info");
const selected_lib = "$name";
Expand Down Expand Up @@ -80,7 +80,7 @@
""".trimIndent()
}

fun getHtml(name: String): String {

Check notice on line 83 in src/main/kotlin/com/jfrog/conan/clion/toolWindow/ReadmePanel.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Function 'getHtml' could be private
val themeStyles = generateThemeStyles()
val script = getScript(name)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
setOpenLinksInExternalBrowser(true)
}

private val libraryData = project.service<ConanService>().getRemoteData()
private val libraryData = project.service<ConanService>().getTargetData()

private fun getScript(names: List<String>): String {
val filteredLibraryData = LibraryData(libraries = HashMap())
Expand Down Expand Up @@ -88,7 +88,7 @@
""".trimIndent()
}

fun getHtml(names: List<String>): String {

Check notice on line 91 in src/main/kotlin/com/jfrog/conan/clion/toolWindow/UsedPackagesPanel.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Function 'getHtml' could be private
val themeStyles = generateThemeStyles()
val script = getScript(names)

Expand Down
1 change: 0 additions & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<notificationGroup id="com.jfrog.conan.clion.notifications.general"
displayType="BALLOON"
key="generalNotificationKey"/>
<postStartupActivity implementation="com.jfrog.conan.clion.services.ConanPluginInit"/>
</extensions>

<projectListeners>
Expand Down
Loading