Skip to content

Commit

Permalink
feat(shirelang): add icon support and improve line marker provider #29
Browse files Browse the repository at this point in the history
Enable icon support for variables in `VariableCompletionProvider`. Refactor `ShirePsiExprLineMarkerProvider` to handle different cases and add pipeline icon. Add new icons in `ShireIcons`.
  • Loading branch information
phodal committed Jul 2, 2024
1 parent 1d4bb4b commit f12c199
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 16 deletions.
6 changes: 5 additions & 1 deletion shirelang/src/main/kotlin/com/phodal/shirelang/ShireIcons.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@ object ShireIcons {
@JvmField
val PsiExpr: Icon = IconLoader.getIcon("/icons/shire-psi-expr.svg", ShireIcons::class.java)
@JvmField
val Variable: Icon = IconLoader.getIcon("/icons/variable.svg", ShireIcons::class.java)
val Variable: Icon = IconLoader.getIcon("/icons/shire-variable.svg", ShireIcons::class.java)
@JvmField
val Pipeline: Icon = IconLoader.getIcon("/icons/shire-pipeline.svg", ShireIcons::class.java)
@JvmField
val Case: Icon = IconLoader.getIcon("/icons/shire-case.svg", ShireIcons::class.java)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.intellij.codeInsight.completion.PrioritizedLookupElement
import com.intellij.codeInsight.lookup.LookupElementBuilder
import com.intellij.util.ProcessingContext
import com.phodal.shirecore.provider.variable.PsiContextVariable
import com.phodal.shirelang.ShireIcons
import com.phodal.shirelang.completion.dataprovider.ContextVariable

class VariableCompletionProvider : CompletionProvider<CompletionParameters>() {
Expand All @@ -19,7 +20,7 @@ class VariableCompletionProvider : CompletionProvider<CompletionParameters>() {
val withTypeText =
PrioritizedLookupElement.withPriority(
LookupElementBuilder.create(it.variable)
// .withIcon(ShireIcons.Variable)
.withIcon(ShireIcons.Variable)
.withTypeText(it.description, true),
99.0
)
Expand All @@ -30,7 +31,7 @@ class VariableCompletionProvider : CompletionProvider<CompletionParameters>() {
val withTypeText =
PrioritizedLookupElement.withPriority(
LookupElementBuilder.create(it.variableName)
// .withIcon(ShireIcons.Variable)
.withIcon(ShireIcons.Variable)
.withTypeText(it.description, true)
,
90.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,36 @@ class ShirePsiExprLineMarkerProvider : LineMarkerProvider {
return null
}

if (element.functionStatement?.functionBody?.queryStatement == null) {
return null
if (element.functionStatement?.functionBody?.queryStatement != null) {
val firstChildKeyElement = element.frontMatterKey!!.firstChild

return LineMarkerInfo(
firstChildKeyElement,
firstChildKeyElement.textRange,
ShireIcons.PsiExpr,
null,
null,
GutterIconRenderer.Alignment.LEFT
) {
""
}
}

val firstChildKeyElement = element.frontMatterKey!!.firstChild

return LineMarkerInfo(
firstChildKeyElement,
firstChildKeyElement.textRange,
ShireIcons.PsiExpr,
null,
null,
GutterIconRenderer.Alignment.LEFT
) {
""
if (element.functionStatement?.functionBody?.actionBody != null) {
val firstChildKeyElement = element.frontMatterKey!!.firstChild

return LineMarkerInfo(
firstChildKeyElement,
firstChildKeyElement.textRange,
ShireIcons.Pipeline,
null,
null,
GutterIconRenderer.Alignment.LEFT
) {
""
}
}

return null
}
}
11 changes: 11 additions & 0 deletions shirelang/src/main/resources/icons/shire-case.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions shirelang/src/main/resources/icons/shire-pipeline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f12c199

Please sign in to comment.