<commit_before>package com.cholick.idea.spock.highlight;

import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.codeInsight.daemon.impl.analysis.HighlightInfoHolder;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.editor.markup.EffectType;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrLabel;

import java.awt.Color;
import java.awt.Font;
import java.util.Arrays;
import java.util.List;

public class SpockPsiElementVisitor extends PsiElementVisitor {

    private static final List<String> LABELS = Arrays.asList("given", "setup", "when", "then", "and", "expect");

    private HighlightInfoHolder highlightInfoHolder;

    @Override
    public void visitElement(PsiElement element) {
        if (!highlightInfoHolder.hasErrorResults()) {
            if (element instanceof GrLabel && LABELS.contains(element.getText())) {
                highlightInfoHolder.add(createHighlightInfo(element));
            }
        }
    }

    private static HighlightInfo createHighlightInfo(@NotNull PsiElement element) {
        TextRange range = element.getTextRange();
        int start = range.getStartOffset();
        int end = range.getEndOffset();

        TextAttributes textAttributes = new TextAttributes(Color.BLUE, null, null, EffectType.BOXED, Font.BOLD);
        return new HighlightInfo(textAttributes, SpockLabelHighlightInfoTypes.SPOCK_LABEL, start, end, null, null, HighlightSeverity.INFORMATION, false, null, false);
    }


    public void clearHighlightInfoHolder() {
        this.highlightInfoHolder = null;
    }

    public void setHighlightInfoHolder(HighlightInfoHolder highlightInfoHolder) {
        this.highlightInfoHolder = highlightInfoHolder;<commit_msg>Forgot to include the "where" label<commit_after>package com.cholick.idea.spock.highlight;

import com.cholick.idea.spock.config.SpockConfig;
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.codeInsight.daemon.impl.analysis.HighlightInfoHolder;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.editor.markup.EffectType;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrLabel;

import java.awt.Color;
import java.awt.Font;
import java.util.Arrays;
import java.util.List;

public class SpockPsiElementVisitor extends PsiElementVisitor {

    private static final List<String> LABELS = Arrays.asList("given", "setup", "when", "then", "and", "expect", "where");

    private HighlightInfoHolder highlightInfoHolder;
    private TextAttributes textAttributes;

    @Override
    public void visitElement(PsiElement element) {
        if (!highlightInfoHolder.hasErrorResults()) {
            if (element instanceof GrLabel && LABELS.contains(element.getText())) {
                highlightInfoHolder.add(createHighlightInfo(element));
            }
        }
    }

    private HighlightInfo createHighlightInfo(@NotNull PsiElement element) {
        TextRange range = element.getTextRange();
        int start = range.getStartOffset();
        int end = range.getEndOffset();

        return new HighlightInfo(buildTextAttributes(), SpockLabelHighlightInfoTypes.SPOCK_LABEL, start, end, null, null, HighlightSeverity.INFORMATION, false, null, false);
    }

    private TextAttributes buildTextAttributes() {
        if(textAttributes == null) {
            SpockConfig spockConfig = SpockConfig.load();
            int fontStyle = Font.PLAIN;
            if(spockConfig.getLabelBold()) {
                fontStyle = fontStyle | Font.BOLD;
            }
            textAttributes = new TextAttributes(Color.BLUE, null, null, EffectType.BOXED, fontStyle);
        }
        return textAttributes;
    }

    public void clear() {
        highlightInfoHolder = null;
        textAttributes = null;
    }

    public void setHighlightInfoHolder(HighlightInfoHolder highlightInfoHolder) {
        this.highlightInfoHolder = highlightInfoHolder;
{'fraction_non_alphanumeric': 0.09662054887729644, 'fraction_numerical': 0.0, 'mean_word_length': 3.9774266365688487, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6347082', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1222, 'n_words': 243}