Search in sources :

Example 1 with PropertiesValueHighlighter

use of com.intellij.lang.properties.editor.PropertiesValueHighlighter in project intellij-community by JetBrains.

the class PropertiesAnnotator method annotate.

public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
    if (!(element instanceof IProperty))
        return;
    final Property property = (Property) element;
    PropertiesFile propertiesFile = property.getPropertiesFile();
    Collection<IProperty> others = propertiesFile.findPropertiesByKey(property.getUnescapedKey());
    ASTNode keyNode = ((PropertyImpl) property).getKeyNode();
    if (others.size() != 1) {
        Annotation annotation = holder.createErrorAnnotation(keyNode, PropertiesBundle.message("duplicate.property.key.error.message"));
        annotation.registerFix(PropertiesQuickFixFactory.getInstance().createRemovePropertyFix(property));
    }
    highlightTokens(property, keyNode, holder, new PropertiesHighlighter());
    ASTNode valueNode = ((PropertyImpl) property).getValueNode();
    if (valueNode != null) {
        highlightTokens(property, valueNode, holder, new PropertiesValueHighlighter());
    }
}
Also used : ASTNode(com.intellij.lang.ASTNode) PropertiesFile(com.intellij.lang.properties.psi.PropertiesFile) PropertyImpl(com.intellij.lang.properties.psi.impl.PropertyImpl) Property(com.intellij.lang.properties.psi.Property) Annotation(com.intellij.lang.annotation.Annotation) PropertiesValueHighlighter(com.intellij.lang.properties.editor.PropertiesValueHighlighter)

Aggregations

ASTNode (com.intellij.lang.ASTNode)1 Annotation (com.intellij.lang.annotation.Annotation)1 PropertiesValueHighlighter (com.intellij.lang.properties.editor.PropertiesValueHighlighter)1 PropertiesFile (com.intellij.lang.properties.psi.PropertiesFile)1 Property (com.intellij.lang.properties.psi.Property)1 PropertyImpl (com.intellij.lang.properties.psi.impl.PropertyImpl)1