1515import net .seesharpsoft .intellij .plugins .csv .psi .CsvTypes ;
1616import org .jetbrains .annotations .NotNull ;
1717
18+ import java .awt .*;
19+
1820import static com .intellij .spellchecker .SpellCheckerSeveritiesProvider .TYPO ;
1921
2022public class CsvAnnotator implements Annotator {
2123
22- private static final TextAttributes EMPTY_TEXT_ATTRIBUTES =
23- TextAttributes .fromFlyweight (AttributesFlyweight .create (null , null , 0 , null , null , null ));
24+ public static final TextAttributes [] COLUMNS = new TextAttributes [] {
25+ TextAttributes .fromFlyweight (AttributesFlyweight .create (null , null , 0 , null , null , null )),
26+ TextAttributes .fromFlyweight (AttributesFlyweight .create (null , new Color (240 , 240 , 240 ), 0 , null , null , null )),
27+ TextAttributes .fromFlyweight (AttributesFlyweight .create (null , new Color (255 , 240 , 240 ), 0 , null , null , null )),
28+ TextAttributes .fromFlyweight (AttributesFlyweight .create (null , new Color (240 , 255 , 240 ), 0 , null , null , null )),
29+ TextAttributes .fromFlyweight (AttributesFlyweight .create (null , new Color (240 , 240 , 255 ), 0 , null , null , null )),
30+ TextAttributes .fromFlyweight (AttributesFlyweight .create (null , new Color (255 , 255 , 240 ), 0 , null , null , null )),
31+ TextAttributes .fromFlyweight (AttributesFlyweight .create (null , new Color (255 , 240 , 255 ), 0 , null , null , null )),
32+ TextAttributes .fromFlyweight (AttributesFlyweight .create (null , new Color (240 , 255 , 255 ), 0 , null , null , null )),
33+ TextAttributes .fromFlyweight (AttributesFlyweight .create (null , new Color (255 , 255 , 255 ), 0 , null , null , null )),
34+ };
2435
2536 public static final HighlightSeverity CSV_COLUMN_INFO_SEVERITY =
2637 new HighlightSeverity ("CSV_COLUMN_INFO_SEVERITY" , TYPO .myVal + 5 );
@@ -50,8 +61,12 @@ public void annotate(@NotNull final PsiElement element, @NotNull final Annotatio
5061 }
5162
5263 Annotation annotation = holder .createAnnotation (CSV_COLUMN_INFO_SEVERITY , textRange , message , tooltip );
53- annotation .setEnforcedTextAttributes (EMPTY_TEXT_ATTRIBUTES );
64+ annotation .setEnforcedTextAttributes (getTextAttributes ( columnInfo ) );
5465 annotation .setNeedsUpdateOnTyping (false );
5566 }
5667 }
68+
69+ protected TextAttributes getTextAttributes (CsvColumnInfo <PsiElement > columnInfo ) {
70+ return COLUMNS [columnInfo .getColumnIndex () % COLUMNS .length ];
71+ }
5772}
0 commit comments