Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

Commit

Permalink
Hover all (#9)
Browse files Browse the repository at this point in the history
* configure hover for all IDEs

change build logic to allow for multiple channels

* changelog

* test fix

* detekt fix

* detekt cleaner fix
  • Loading branch information
InTheCloudDan authored Dec 29, 2020
1 parent bc42d81 commit 1b1750d
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name: Release
on:
release:
types: [released]
types: [ released ]

jobs:

Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ intellij {
pluginName = pluginName
version = platformVersion
type = platformType
//alternativeIdePath = "/Applications/GoLand.app"
downloadSources = platformDownloadSources.toBoolean()
updateSinceUntilBuild = true

Expand Down Expand Up @@ -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())
}

}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<FlagStore>()

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) {
Expand All @@ -16,10 +44,10 @@ class LDDocumentationProvider : DocumentationProvider {
val getFlags = element.project.service<FlagStore>()
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()) {
Expand Down

0 comments on commit 1b1750d

Please sign in to comment.