Search in sources :

Example 1 with ColorLineMarkerProvider

use of com.intellij.ui.ColorLineMarkerProvider in project intellij-plugins by JetBrains.

the class FlexMxmlColorAnnotator method annotate.

@Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
    if (!(element instanceof XmlAttribute) || !JavaScriptSupportLoader.isFlexMxmFile(element.getContainingFile())) {
        return;
    }
    if (!LineMarkerSettings.getSettings().isEnabled(new ColorLineMarkerProvider())) {
        return;
    }
    XmlAttribute attribute = (XmlAttribute) element;
    XmlAttributeDescriptor descriptor = attribute.getDescriptor();
    if (!(descriptor instanceof AnnotationBackedDescriptorImpl)) {
        return;
    }
    AnnotationBackedDescriptorImpl annotationBackedDescriptor = (AnnotationBackedDescriptorImpl) descriptor;
    String format = annotationBackedDescriptor.getFormat();
    if (!FlexCssPropertyDescriptor.COLOR_FORMAT.equals(format)) {
        return;
    }
    final String value = attribute.getValue();
    if (value == null || value.length() == 0) {
        return;
    }
    if (!JSCommonTypeNames.ARRAY_CLASS_NAME.equals(annotationBackedDescriptor.getType())) {
        XmlAttributeValue valueElement = attribute.getValueElement();
        if (valueElement != null) {
            Annotation annotation = holder.createInfoAnnotation(valueElement, null);
            annotation.setGutterIconRenderer(new MyRenderer(value, attribute));
        }
    }
}
Also used : ColorLineMarkerProvider(com.intellij.ui.ColorLineMarkerProvider) XmlAttribute(com.intellij.psi.xml.XmlAttribute) XmlAttributeDescriptor(com.intellij.xml.XmlAttributeDescriptor) XmlAttributeValue(com.intellij.psi.xml.XmlAttributeValue) AnnotationBackedDescriptorImpl(com.intellij.javascript.flex.mxml.schema.AnnotationBackedDescriptorImpl) Annotation(com.intellij.lang.annotation.Annotation)

Aggregations

AnnotationBackedDescriptorImpl (com.intellij.javascript.flex.mxml.schema.AnnotationBackedDescriptorImpl)1 Annotation (com.intellij.lang.annotation.Annotation)1 XmlAttribute (com.intellij.psi.xml.XmlAttribute)1 XmlAttributeValue (com.intellij.psi.xml.XmlAttributeValue)1 ColorLineMarkerProvider (com.intellij.ui.ColorLineMarkerProvider)1 XmlAttributeDescriptor (com.intellij.xml.XmlAttributeDescriptor)1