diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2470794..d203b20 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,7 @@ name: Release on: release: - types: [released] + types: [ released ] jobs: @@ -31,6 +31,7 @@ jobs: - name: Publish Plugin env: PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} + GIT_RELEASE: ${{ github.event.release.tag_name }} run: ./gradlew publishPlugin # Commit patched Changelog diff --git a/CHANGELOG.md b/CHANGELOG.md index 4871dc1..63f9605 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ # intellij-plugin-ld Changelog +## [0.1.12] +### Fixed +- Handle stream connections in separate thread + +### Changed +- DocumentationProvider should work for all languages now, not just JVM + ## [0.1.11-alpha] ### Fixed - Handling stream connection not being available diff --git a/build.gradle.kts b/build.gradle.kts index db472f3..ef8e225 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -60,6 +60,7 @@ intellij { pluginName = pluginName version = platformVersion type = platformType + //alternativeIdePath = "/Applications/GoLand.app" downloadSources = platformDownloadSources.toBoolean() updateSinceUntilBuild = true @@ -127,7 +128,8 @@ tasks { publishPlugin { dependsOn("patchChangelog") token(System.getenv("PUBLISH_TOKEN")) - channels("alpha") + @Suppress("NonNullable") + channels((System.getenv("GIT_RELEASE") ?: "").split('-').getOrElse(1) { "default" }.split('.').first()) } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 77dd8b4..0943dee 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ # -> https://www.jetbrains.org/intellij/sdk/docs/reference_guide/intellij_artifacts.html pluginGroup=com.github.intheclouddan.intellijpluginld pluginName=intellij-plugin-ld -pluginVersion=0.1.11-alpha +pluginVersion=0.1.12 pluginSinceBuild=201 pluginUntilBuild=203.* platformType=IC diff --git a/src/main/kotlin/com/github/intheclouddan/intellijpluginld/DocumentationProvider.kt b/src/main/kotlin/com/github/intheclouddan/intellijpluginld/DocumentationProvider.kt index cd1ef06..40f7014 100644 --- a/src/main/kotlin/com/github/intheclouddan/intellijpluginld/DocumentationProvider.kt +++ b/src/main/kotlin/com/github/intheclouddan/intellijpluginld/DocumentationProvider.kt @@ -2,12 +2,40 @@ package com.github.intheclouddan.intellijpluginld import com.github.intheclouddan.intellijpluginld.featurestore.FlagConfiguration import com.github.intheclouddan.intellijpluginld.settings.LaunchDarklyMergedSettings -import com.intellij.lang.documentation.DocumentationProvider +import com.intellij.lang.documentation.AbstractDocumentationProvider import com.intellij.openapi.components.service +import com.intellij.openapi.editor.Editor import com.intellij.psi.PsiElement +import com.intellij.psi.PsiFile +import com.intellij.psi.util.PsiTreeUtil import com.launchdarkly.api.model.FeatureFlag -class LDDocumentationProvider : DocumentationProvider { +class LDDocumentationProvider : AbstractDocumentationProvider() { + // Not sure how this is all working yet but it works for custom documentation in other IDEs than IDEA + override fun getCustomDocumentationElement(editor: Editor, file: PsiFile, contextElement: PsiElement?): PsiElement? { + if (contextElement == null) return null + + if (editor.caretModel.currentCaret.offset == contextElement.textRange.startOffset) { + return getElementForDocumentation(PsiTreeUtil.prevLeaf(contextElement)) + } + + return getElementForDocumentation(contextElement) + } + + private fun getElementForDocumentation(contextElement: PsiElement?): PsiElement? { + if (contextElement == null) return null + val getFlags = contextElement.project.service() + + var flag: FeatureFlag? = getFlags.flags?.items?.find { it.key == contextElement.text.removeSurrounding("\"") } + if (flag != null) { + return contextElement + } + return contextElement?.parent + } + + override fun generateHoverDoc(element: PsiElement, originalElement: PsiElement?): String? { + return generateDoc(element, originalElement) + } override fun generateDoc(element: PsiElement?, originalElement: PsiElement?): String? { if (element == null) { @@ -16,10 +44,10 @@ class LDDocumentationProvider : DocumentationProvider { val getFlags = element.project.service() val settings = LaunchDarklyMergedSettings.getInstance(element.project) - val flag: FeatureFlag? = getFlags.flags.items.find { it.key == element.text.drop(1).dropLast(1) } + var flag: FeatureFlag? = getFlags.flags.items.find { it.key == element.text.removeSurrounding("\"") } // TODO: gracefully handle API call working and Datastore being unavailable if (flag != null) { - val env: FlagConfiguration = getFlags.flagConfigs[element.text.drop(1).dropLast(1)] + val env: FlagConfiguration = getFlags.flagConfigs[flag.key] ?: FlagConfiguration(flag.key, null, null, listOf(), listOf(), arrayOf(), false, -1) val result = StringBuilder() val prereqs = if (env.prerequisites.isNotEmpty()) {