generated from JetBrains/intellij-platform-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
53 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/kotlin/com/dsoftware/ghmanager/psi/actions/UpdateActionVersionFix.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.dsoftware.ghmanager.psi.actions | ||
|
||
import com.dsoftware.ghmanager.i18n.MessagesBundle.message | ||
import com.intellij.codeInspection.LocalQuickFix | ||
import com.intellij.codeInspection.ProblemDescriptor | ||
import com.intellij.openapi.components.service | ||
import com.intellij.openapi.project.Project | ||
import org.jetbrains.yaml.YAMLElementGenerator | ||
import org.jetbrains.yaml.psi.YAMLKeyValue | ||
|
||
class UpdateActionVersionFix( | ||
private val actionName: String, fullLatestVersion: String, | ||
) : LocalQuickFix { | ||
private val latestVersion = fullLatestVersion.split(".").first() | ||
|
||
override fun getFamilyName(): String { | ||
return message("ghmanager.update.action.version.fix.family.name", actionName, latestVersion) | ||
} | ||
|
||
|
||
override fun applyFix(project: Project, descriptor: ProblemDescriptor) { | ||
val yamlKeyValue = descriptor.psiElement as YAMLKeyValue | ||
val actionName = yamlKeyValue.valueText.split("@").firstOrNull() ?: return | ||
val yamlElementGenerator = yamlKeyValue.project.service<YAMLElementGenerator>() | ||
val newYamlKeyValue = | ||
yamlElementGenerator.createYamlKeyValue(yamlKeyValue.keyText, "$actionName@$latestVersion") | ||
yamlKeyValue.setValue(newYamlKeyValue.value!!) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters