Thanks to visit codestin.com
Credit goes to github.com

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
18 changes: 17 additions & 1 deletion src/main/kotlin/com/akefirad/groom/spock/SpockLabelAnnotator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import com.intellij.lang.annotation.AnnotationHolder
import com.intellij.lang.annotation.Annotator
import com.intellij.lang.annotation.HighlightSeverity
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors
import com.intellij.openapi.editor.colors.TextAttributesKey
import com.intellij.openapi.editor.markup.TextAttributes
import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElement
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrLabeledStatement
import java.awt.Font


class SpockLabelAnnotator : Annotator {
Expand All @@ -23,9 +26,22 @@ class SpockLabelAnnotator : Annotator {
val range = TextRange.from(e.startOffset, label.name.label.length + 1)
.let { if (label.hasTitle) it.union(e.lastChild.textRange) else it }

val boldAttributesKey = TextAttributesKey.createTextAttributesKey(
"SPOCK_LABEL_BOLD",
DefaultLanguageHighlighterColors.HIGHLIGHTED_REFERENCE
)

h.newSilentAnnotation(HighlightSeverity.INFORMATION)
.textAttributes(DefaultLanguageHighlighterColors.HIGHLIGHTED_REFERENCE)
.textAttributes(boldAttributesKey)
.range(range)
.enforcedTextAttributes(TextAttributes().apply {
val base = DefaultLanguageHighlighterColors.HIGHLIGHTED_REFERENCE.defaultAttributes
foregroundColor = base.foregroundColor
backgroundColor = base.backgroundColor
effectType = base.effectType
effectColor = base.effectColor
fontType = Font.BOLD
})
.create()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixture4TestC
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory
import org.junit.Test

class SpockNameAnnotatorTest extends LightPlatformCodeInsightFixture4TestCase {
class SpockLabelAnnotatorTest extends LightPlatformCodeInsightFixture4TestCase {

private GroovyPsiElementFactory elementFactory

Expand Down
Loading