Skip to content

Commit

Permalink
feat(VariableCompletionProvider): add icon to variable lookup elements
Browse files Browse the repository at this point in the history
…#29

Added ShireIcons.Variable to the LookupElementBuilder for both ContextVariable and PsiContextVariable in VariableCompletionProvider. Also added new icons to ShireIcons.
  • Loading branch information
phodal committed Jul 1, 2024
1 parent 564b0fe commit 7ae12c5
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
4 changes: 4 additions & 0 deletions shirelang/src/main/kotlin/com/phodal/shirelang/ShireIcons.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ object ShireIcons {
val Terminal: Icon = IconLoader.getIcon("/icons/terminal.svg", ShireIcons::class.java)
@JvmField
val Idea: Icon = IconLoader.getIcon("/icons/idea.svg", ShireIcons::class.java)
@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)
}
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 @@ -18,7 +19,9 @@ class VariableCompletionProvider : CompletionProvider<CompletionParameters>() {
ContextVariable.values().forEach {
val withTypeText =
PrioritizedLookupElement.withPriority(
LookupElementBuilder.create(it.variable).withTypeText(it.description, true),
LookupElementBuilder.create(it.variable)
// .withIcon(ShireIcons.Variable)
.withTypeText(it.description, true),
99.0
)
result.addElement(withTypeText)
Expand All @@ -27,7 +30,10 @@ class VariableCompletionProvider : CompletionProvider<CompletionParameters>() {
PsiContextVariable.values().forEach {
val withTypeText =
PrioritizedLookupElement.withPriority(
LookupElementBuilder.create(it.variableName).withTypeText(it.description, true),
LookupElementBuilder.create(it.variableName)
// .withIcon(ShireIcons.Variable)
.withTypeText(it.description, true)
,
90.0
)
result.addElement(withTypeText)
Expand Down
46 changes: 46 additions & 0 deletions shirelang/src/main/resources/icons/shire-psi-expr.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions shirelang/src/main/resources/icons/shire-variable.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 7ae12c5

Please sign in to comment.