Search in sources :

Example 86 with Annotation

use of com.intellij.lang.annotation.Annotation in project android by JetBrains.

the class AndroidColorAnnotatorTest method testColorInValues1.

public void testColorInValues1() {
    // Color definition in a values file
    Annotation annotation = findAnnotation("res/values/colors1.xml", "3F51B5", XmlTag.class);
    checkAnnotationColor(annotation, new Color(63, 81, 181));
}
Also used : Annotation(com.intellij.lang.annotation.Annotation)

Example 87 with Annotation

use of com.intellij.lang.annotation.Annotation in project android by JetBrains.

the class AndroidColorAnnotatorTest method testColorStateListInValues.

public void testColorStateListInValues() {
    // Color definition in a color state list file
    Annotation annotation = findAnnotation("res/color/selector.xml", "ffff0000", XmlAttributeValue.class);
    checkAnnotationColor(annotation, new Color(255, 0, 0));
    annotation = findAnnotation("res/color/selector.xml", "#ff00ff00", XmlAttributeValue.class);
    checkAnnotationColor(annotation, new Color(0, 255, 0));
}
Also used : XmlAttributeValue(com.intellij.psi.xml.XmlAttributeValue) Annotation(com.intellij.lang.annotation.Annotation)

Example 88 with Annotation

use of com.intellij.lang.annotation.Annotation in project android by JetBrains.

the class AndroidColorAnnotatorTest method testColorReferenceInXml2.

public void testColorReferenceInXml2() {
    // Reference to a color from a layout file
    Annotation annotation = findAnnotation("res/layout/color_test.xml", "@color/color2", XmlAttributeValue.class);
    checkAnnotationColor(annotation, new Color(0x303F9F));
}
Also used : Annotation(com.intellij.lang.annotation.Annotation)

Example 89 with Annotation

use of com.intellij.lang.annotation.Annotation in project intellij-plugins by JetBrains.

the class JstdConfigFileAnnotator method annotateDocument.

private static void annotateDocument(@NotNull YAMLDocument yamlDocument, @NotNull final AnnotationHolder holder) {
    final YAMLValue value = yamlDocument.getTopLevelValue();
    if (!(value instanceof YAMLMapping)) {
        holder.createErrorAnnotation(yamlDocument, "Expected mapping");
        return;
    }
    final Collection<YAMLKeyValue> keyValues = ((YAMLMapping) value).getKeyValues();
    markStrangeSymbols(yamlDocument, holder);
    BasePathInfo basePathInfo = new BasePathInfo(yamlDocument);
    annotateBasePath(basePathInfo, holder);
    final Set<String> visitedKeys = Sets.newHashSet();
    for (YAMLKeyValue keyValue : keyValues) {
        String keyText = keyValue.getKeyText();
        if (keyValue.getKey() == null) {
            holder.createErrorAnnotation(keyValue.getFirstChild(), "Expected key");
            continue;
        }
        if (!JstdConfigFileUtils.isTopLevelKey(keyValue)) {
            holder.createErrorAnnotation(keyValue.getKey(), "Unexpected key '" + keyText + "'");
        } else if (!visitedKeys.add(keyText)) {
            holder.createErrorAnnotation(keyValue.getKey(), "Duplicated '" + keyText + "' key");
        } else if (JstdConfigFileUtils.isTopLevelKeyWithInnerFileSequence(keyValue)) {
            annotateKeyValueWithInnerFileSequence(keyValue, holder, basePathInfo.getBasePath());
        }
    }
    if (!visitedKeys.contains("test")) {
        Annotation annotation = holder.createWeakWarningAnnotation(yamlDocument, "JsTestDriver configuration file should have 'test:' section");
        annotation.registerFix(new AddTestSectionAction());
    }
}
Also used : Annotation(com.intellij.lang.annotation.Annotation)

Example 90 with Annotation

use of com.intellij.lang.annotation.Annotation in project intellij-plugins by JetBrains.

the class ActionScriptConstructorChecker method checkMissedConstructor.

public void checkMissedConstructor(@NotNull JSClass jsClass) {
    if (jsClass.isInterface())
        return;
    final JSFunction nontrivialSuperClassConstructor = getNontrivialSuperClassConstructor(jsClass);
    if (nontrivialSuperClassConstructor == null) {
        return;
    }
    final PsiElement place = getPlaceForNamedElementProblem(jsClass);
    Annotation annotation = myProblemReporter.registerGenericError(place, JSBundle.message("javascript.validation.message.missed.super.constructor.call"));
    annotation.registerFix(JSFixFactory.getInstance().addConstructorAndSuperInvocationFix(jsClass, nontrivialSuperClassConstructor));
}
Also used : PsiElement(com.intellij.psi.PsiElement) Annotation(com.intellij.lang.annotation.Annotation)

Aggregations

Annotation (com.intellij.lang.annotation.Annotation)97 PsiElement (com.intellij.psi.PsiElement)24 ASTNode (com.intellij.lang.ASTNode)22 TextRange (com.intellij.openapi.util.TextRange)19 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)15 Project (com.intellij.openapi.project.Project)11 NotNull (org.jetbrains.annotations.NotNull)10 PsiFile (com.intellij.psi.PsiFile)8 GrModifierFix (org.jetbrains.plugins.groovy.codeInspection.bugs.GrModifierFix)6 HighlightDisplayLevel (com.intellij.codeHighlighting.HighlightDisplayLevel)4 Editor (com.intellij.openapi.editor.Editor)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 GrModifierList (org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList)4 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)3 HighlightSeverity (com.intellij.lang.annotation.HighlightSeverity)3 PsiReference (com.intellij.psi.PsiReference)3 IElementType (com.intellij.psi.tree.IElementType)3 IncorrectOperationException (com.intellij.util.IncorrectOperationException)3 Nullable (org.jetbrains.annotations.Nullable)3 HbCloseBlockMustache (com.dmarcotte.handlebars.psi.HbCloseBlockMustache)2