Skip to content
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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pluginGroup = com.keepersecurity.jetbrains
pluginName = Keeper Security
pluginRepositoryUrl = https://github.com/Keeper-Security/keeper-jetbrains-plugin
# SemVer format -> https://semver.org
pluginVersion = 2.0.0
pluginVersion = 2.0.1

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 243
Expand Down
23 changes: 9 additions & 14 deletions src/main/kotlin/keepersecurity/action/KeeperGetSecretAction.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package keepersecurity.action

import com.intellij.ide.plugins.PluginManagerCore
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.editor.Editor
import com.intellij.ide.plugins.PluginManager
import com.intellij.openapi.extensions.PluginId
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.progress.ProgressIndicator
Expand Down Expand Up @@ -330,24 +330,19 @@ class KeeperGetSecretAction : AnAction("Get Keeper Secret") {
}

/**
* Detects HTTP Client request files via the FileType API. The `com.jetbrains.restClient`
* plugin is an optional dependency, so its classes are only on the classpath when it is
* loaded; the plugin check plus the try/catch keep the call safe on IDEs that do not bundle it.
*/
* Detects JetBrains HTTP Client request files by extension when the HTTP Client plugin is
* installed. Uses public [PluginManager.isPluginInstalled] (not Internal API
* [com.intellij.ide.plugins.PluginManagerCore.getPlugin]). The `$keeper` dynamic variable is
* registered only when optional `com.jetbrains.restClient` loads `keeper-http-client.xml`.
*/
private fun isHttpClientRequestFile(editor: Editor): Boolean {
val file: VirtualFile = FileDocumentManager.getInstance().getFile(editor.document) ?: return false
if (!isHttpClientPluginEnabled()) return false
return try {
file.fileType == com.intellij.httpClient.http.request.HttpRequestFileType.INSTANCE
} catch (_: Throwable) {
false
}
return file.extension?.lowercase() in setOf("http", "rest")
}

private fun isHttpClientPluginEnabled(): Boolean {
val descriptor = PluginManagerCore.getPlugin(PluginId.getId("com.jetbrains.restClient"))
return descriptor != null && descriptor.isEnabled
}
private fun isHttpClientPluginEnabled(): Boolean =
PluginManager.isPluginInstalled(PluginId.getId("com.jetbrains.restClient"))

/**
* Snippet for HTTP Client: no space after `{{` (see JetBrains HTTP Client variable docs).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.intellij.execution.configurations.ConfigurationFactory
import com.intellij.execution.configurations.ConfigurationTypeBase
import com.intellij.execution.configurations.RunConfiguration
import com.intellij.execution.configurations.RunConfigurationOptions
import com.intellij.execution.configurations.RunConfigurationSingletonPolicy
import com.intellij.openapi.project.Project
import com.intellij.icons.AllIcons

Expand All @@ -27,6 +28,7 @@ class KeeperSecureRunConfigurationType : ConfigurationTypeBase(

override fun getName(): String = "Run Keeper Securely"

override fun isConfigurationSingletonByDefault(): Boolean = false
override fun getSingletonPolicy(): RunConfigurationSingletonPolicy =
RunConfigurationSingletonPolicy.MULTIPLE_INSTANCE
}
}
4 changes: 2 additions & 2 deletions src/main/kotlin/keepersecurity/ui/KeeperListPickerDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ object KeeperListPickerDialog {
}

private fun nestedBadgeBackground(): Color =
JBUI.CurrentTheme.Link.linkColor().let { link ->
JBUI.CurrentTheme.Link.Foreground.ENABLED.let { link ->
Color(
(link.red + 255 * 4) / 5,
(link.green + 255 * 4) / 5,
Expand All @@ -260,6 +260,6 @@ object KeeperListPickerDialog {
)
}

private fun nestedBadgeForeground(): Color = JBUI.CurrentTheme.Link.linkColor()
private fun nestedBadgeForeground(): Color = JBUI.CurrentTheme.Link.Foreground.ENABLED
}
}
2 changes: 0 additions & 2 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
<vendor email="ops@keepersecurity.com" url="https://www.keepersecurity.com">Keeper Security</vendor>

<depends>com.intellij.modules.platform</depends>
<!-- Python: optional; enables reading project/module Python SDK for Run Keeper Securely defaults when PyCharm / Python plugin is present -->
<depends optional="true">com.intellij.modules.python</depends>
<!-- HTTP Client (Ultimate / WebStorm / etc.); optional so IC installs without it still load the plugin -->
<depends optional="true" config-file="keeper-http-client.xml">com.jetbrains.restClient</depends>

Expand Down
Loading