diff --git a/gradle.properties b/gradle.properties
index eab1672..02bb406 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -12,11 +12,11 @@ pluginUntilBuild = 243.*
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType = IU
-platformVersion = 2024.2
+platformVersion = 2024.3
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.jetbrains.php:203.4449.22, org.intellij.scala:2023.3.27@EAP
-platformPlugins = org.jetbrains.plugins.haml:242.20224.175
+platformPlugins = org.jetbrains.plugins.haml:243.21565.122, org.jetbrains.plugins.ruby:243.21565.211
# Example: platformBundledPlugins = com.intellij.java
platformBundledPlugins =
diff --git a/src/main/kotlin/me/benmelz/jetbrains/plugins/hamllint/HamlLint.kt b/src/main/kotlin/me/benmelz/jetbrains/plugins/hamllint/HamlLint.kt
index 0083a76..3021c32 100644
--- a/src/main/kotlin/me/benmelz/jetbrains/plugins/hamllint/HamlLint.kt
+++ b/src/main/kotlin/me/benmelz/jetbrains/plugins/hamllint/HamlLint.kt
@@ -1,11 +1,13 @@
package me.benmelz.jetbrains.plugins.hamllint
import com.google.gson.JsonParser
-import com.intellij.execution.configurations.GeneralCommandLine
-import com.intellij.execution.process.OSProcessHandler
+import com.intellij.execution.process.ProcessHandler
import com.intellij.execution.process.ScriptRunnerUtil
-import java.io.File
-import java.nio.charset.StandardCharsets
+import com.intellij.openapi.module.ModuleUtil
+import com.intellij.openapi.project.ProjectLocator
+import com.intellij.openapi.roots.ModuleRootManager
+import com.intellij.openapi.vfs.LocalFileSystem
+import org.jetbrains.plugins.ruby.gem.RubyGemExecutionContext
import java.nio.file.Path
import java.util.LinkedList
@@ -15,18 +17,15 @@ import java.util.LinkedList
* @param[haml] raw haml code to lint.
* @param[filePath] path to the file that is being linted.
* @param[workDirectory] work directory from which to run haml-lint.
- * @param[executionCommand] execution command with which to run haml-lint.
* @return a list of collected haml-lint offenses.
*/
fun hamlLint(
haml: CharSequence,
filePath: Path,
workDirectory: Path,
- executionCommand: List,
): List {
- val cli = hamlLintCommandLine(filePath, workDirectory, executionCommand)
- val processHandler = OSProcessHandler(cli)
- val stdin = processHandler.processInput
+ val processHandler = hamlLintProcessHandler(filePath, workDirectory)
+ val stdin = processHandler.processInput!!
haml.forEach { stdin.write(it.code) }
stdin.close()
return parseHamlLintOutput(
@@ -35,23 +34,29 @@ fun hamlLint(
}
/**
- * Builds an executable [GeneralCommandLine] that runs `haml-lint` in stdin mode and the json reporter.
+ * Builds an executable [ProcessHandler] that runs `haml-lint` in stdin mode and the json reporter.
*
* @param[filePath] original file path for the code that is being linted.
* @param[workDirectory] the directory from which to run `haml-lint`.
- * @param[executionCommand] the execution command with which to run haml-lint.
- * @return an executable [GeneralCommandLine].
+ * @return an executable [ProcessHandler].
*/
-private fun hamlLintCommandLine(
+private fun hamlLintProcessHandler(
filePath: Path,
workDirectory: Path,
- executionCommand: List,
-): GeneralCommandLine =
- GeneralCommandLine(executionCommand).apply {
- this.addParameters("--stdin", filePath.toString(), "--reporter", "json")
- this.charset = StandardCharsets.UTF_8
- this.workDirectory = File(workDirectory.toUri())
- }
+): ProcessHandler {
+ val virtualFile = LocalFileSystem.getInstance().findFileByPath(filePath.toString())!!
+ val project = ProjectLocator.getInstance().guessProjectForFile(virtualFile)!!
+ val module = ModuleUtil.findModuleForFile(virtualFile, project)!!
+ val moduleManager = ModuleRootManager.getInstance(module)
+ val sdk = moduleManager.sdk!!
+ val executionContext =
+ RubyGemExecutionContext
+ .create(sdk, "haml-lint")
+ .withModule(module)
+ .withWorkingDirPath(workDirectory.toString())
+ .withArguments("--stdin", filePath.toString(), "--reporter", "json")
+ return executionContext.toRubyScriptExecutionContext()!!.createProcessHandler()!!
+}
/**
* Parses the output of a `haml-lint` run using the `json` reporter as [HamlLintOffense]s.
diff --git a/src/main/kotlin/me/benmelz/jetbrains/plugins/hamllint/HamlLintConfiguration.kt b/src/main/kotlin/me/benmelz/jetbrains/plugins/hamllint/HamlLintConfiguration.kt
index 584e769..4c52c5d 100644
--- a/src/main/kotlin/me/benmelz/jetbrains/plugins/hamllint/HamlLintConfiguration.kt
+++ b/src/main/kotlin/me/benmelz/jetbrains/plugins/hamllint/HamlLintConfiguration.kt
@@ -6,11 +6,9 @@ package me.benmelz.jetbrains.plugins.hamllint
* @property[enabled] whether or not inspection is enabled.
* @property[errorSeverityKey] The name of the highlight severity to use for errors.
* @property[warningSeverityKey] The name of the highlight severity to use for errors.
- * @property[executionCommand] The command to execute with.
*/
data class HamlLintConfiguration(
val enabled: Boolean,
var errorSeverityKey: String,
var warningSeverityKey: String,
- var executionCommand: String,
)
diff --git a/src/main/kotlin/me/benmelz/jetbrains/plugins/hamllint/HamlLintExternalAnnotator.kt b/src/main/kotlin/me/benmelz/jetbrains/plugins/hamllint/HamlLintExternalAnnotator.kt
index 3a90c1a..d91e7fa 100644
--- a/src/main/kotlin/me/benmelz/jetbrains/plugins/hamllint/HamlLintExternalAnnotator.kt
+++ b/src/main/kotlin/me/benmelz/jetbrains/plugins/hamllint/HamlLintExternalAnnotator.kt
@@ -39,10 +39,7 @@ class HamlLintExternalAnnotator : ExternalAnnotator,
)
diff --git a/src/main/kotlin/me/benmelz/jetbrains/plugins/hamllint/HamlLintInspection.kt b/src/main/kotlin/me/benmelz/jetbrains/plugins/hamllint/HamlLintInspection.kt
index 47c913a..cf35dca 100644
--- a/src/main/kotlin/me/benmelz/jetbrains/plugins/hamllint/HamlLintInspection.kt
+++ b/src/main/kotlin/me/benmelz/jetbrains/plugins/hamllint/HamlLintInspection.kt
@@ -8,8 +8,6 @@ import com.intellij.codeInspection.options.OptPane.dropdown
import com.intellij.codeInspection.options.OptPane.group
import com.intellij.codeInspection.options.OptPane.option
import com.intellij.codeInspection.options.OptPane.pane
-import com.intellij.codeInspection.options.OptPane.separator
-import com.intellij.codeInspection.options.OptPane.string
import com.intellij.lang.annotation.HighlightSeverity
import com.intellij.psi.PsiElementVisitor
@@ -31,11 +29,6 @@ class HamlLintInspection : LocalInspectionTool() {
*/
var warningSeverityKey: String = HighlightSeverity.WEAK_WARNING.name
- /**
- * The execution command with which to run `haml-lint`.
- */
- var executionCommand: String = "bundle exec haml-lint"
-
/**
* Delegates inspection logic to a [HamlLintExternalAnnotator].
*
@@ -76,11 +69,6 @@ class HamlLintInspection : LocalInspectionTool() {
dropdown("errorSeverityKey", "Error: ", *severityOptions),
dropdown("warningSeverityKey", "Warning: ", *severityOptions),
),
- separator(),
- group(
- "Execution Command",
- string("executionCommand", "", 32),
- ),
)
}
}
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index 4aeacf7..7e79d52 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -6,6 +6,7 @@
com.intellij.modules.platform
org.jetbrains.plugins.haml
+ org.jetbrains.plugins.ruby
Use the Severities Mapping fields to customize the highlight levels.
-
- Use the Execution Command field to customize how haml-lint
will be invoked.
-