package net.kenro.ji.jin.purescript.highlighting;

import com.intellij.lang.annotation.Annotation;
import com.intellij.lang.annotation.AnnotationHolder;
import com.intellij.lang.annotation.Annotator;
import com.intellij.psi.PsiElement;
import net.kenro.ji.jin.purescript.psi.PSElements;
import org.jetbrains.annotations.NotNull;

import static com.intellij.patterns.PlatformPatterns.psiElement;


public class PSSyntaxHighlightAnnotator implements Annotator {
    @Override
    public void annotate(@NotNull final PsiElement element, @NotNull final AnnotationHolder holder) {
        if (psiElement(PSElements.ValueRef).accepts(element)) {
            final String text = element.getText();
            final Annotation ann = holder.createInfoAnnotation(element, text);
            ann.setTextAttributes(PSSyntaxHighlighter.IMPORT_REF);
        } else if (psiElement(PSElements.TypeAnnotationName).accepts(element)) {
            final Annotation ann = holder.createInfoAnnotation(element, element.getText());
            ann.setTextAttributes(PSSyntaxHighlighter.TYPE_ANNOTATION_NAME);
        } else if ((psiElement(PSElements.PositionedDeclarationRef).accepts(element)
                || psiElement(PSElements.TypeConstructor).accepts(element)
                || psiElement(PSElements.pClassName).accepts(element))) {
//                || psiElement(PSElements.pModuleName).accepts(element))) {
            final Annotation ann = holder.createInfoAnnotation(element, element.getText());
            ann.setTextAttributes(PSSyntaxHighlighter.TYPE_NAME);
        } else if ((psiElement(PSElements.GenericIdentifier).accepts(element)
                || psiElement(PSElements.Constructor).accepts(element)
                || psiElement(PSElements.qualifiedModuleName).accepts(element))) {
            final Annotation ann = holder.createInfoAnnotation(element, element.getText());
            ann.setTextAttributes(PSSyntaxHighlighter.TYPE_VARIABLE);
        } else if (psiElement(PSElements.LocalIdentifier).accepts(element)) {
            final Annotation ann = holder.createInfoAnnotation(element, element.getText());
            ann.setTextAttributes(PSSyntaxHighlighter.NUMBER);
        }
    }


}

@@ -193,16 +193,71 @@
 otator;%0A
+import com.intellij.lang.annotation.HighlightSeverity;%0A
 import c
@@ -755,74 +755,65 @@
     
-final Annotation ann = holder.createInfoAnnotation(element
+holder.newAnnotation(HighlightSeverity.INFORMATION
 , text)
-;
 %0A   
@@ -817,32 +817,30 @@
             
-ann.setT
+    .t
 extAttribute
@@ -872,16 +872,42 @@
 ORT_REF)
+%0A                .create()
 ;%0A      
@@ -997,66 +997,58 @@
     
-final Annotation ann = holder.createInfoAnnotation(element
+holder.newAnnotation(HighlightSeverity.INFORMATION
 , el
@@ -1055,33 +1055,32 @@
 ement.getText())
-;
 %0A            ann
@@ -1072,32 +1072,30 @@
             
-ann.setT
+    .t
 extAttribute
@@ -1133,24 +1133,50 @@
 TATION_NAME)
+%0A                .create()
 ;%0A        %7D 
@@ -1492,66 +1492,75 @@
     
-final Annotation ann = holder.createInfoAnnotation(element
+holder%0A                .newAnnotation(HighlightSeverity.INFORMATION
 , el
@@ -1567,33 +1567,32 @@
 ement.getText())
-;
 %0A            ann
@@ -1584,32 +1584,30 @@
             
-ann.setT
+    .t
 extAttribute
@@ -1638,16 +1638,42 @@
 PE_NAME)
+%0A                .create()
 ;%0A      
@@ -1914,66 +1914,58 @@
     
-final Annotation ann = holder.createInfoAnnotation(element
+holder.newAnnotation(HighlightSeverity.INFORMATION
 , el
@@ -1972,33 +1972,32 @@
 ement.getText())
-;
 %0A            ann
@@ -1989,32 +1989,30 @@
             
-ann.setT
+    .t
 extAttribute
@@ -2047,16 +2047,42 @@
 ARIABLE)
+%0A                .create()
 ;%0A      
@@ -2169,66 +2169,58 @@
     
-final Annotation ann = holder.createInfoAnnotation(element
+holder.newAnnotation(HighlightSeverity.INFORMATION
 , el
@@ -2235,17 +2235,16 @@
 tText())
-;
 %0A       
@@ -2252,16 +2252,14 @@
     
-ann.setT
+    .t
 extA
@@ -2295,16 +2295,42 @@
 .NUMBER)
+%0A                .create()
 ;%0A      

Use new annotations api