Search in sources :

Example 1 with Status

use of org.jetbrains.plugins.groovy.dsl.DslActivationStatus.Status in project intellij-community by JetBrains.

the class GroovyDslAnnotator method annotate.

@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder holder) {
    if (!(psiElement instanceof GroovyFile))
        return;
    final GroovyFile groovyFile = (GroovyFile) psiElement;
    if (!GrFileIndexUtil.isGroovySourceFile(groovyFile))
        return;
    final VirtualFile vfile = groovyFile.getVirtualFile();
    if (!GdslUtil.GDSL_FILTER.value(vfile))
        return;
    final DslActivationStatus.Status status = GroovyDslFileIndex.getStatus(vfile);
    if (status == ACTIVE)
        return;
    final String message = status == MODIFIED ? "DSL descriptor file has been changed and isn't currently executed." : "DSL descriptor file has been disabled due to a processing error.";
    final Annotation annotation = holder.createWarningAnnotation(psiElement, message);
    annotation.setFileLevelAnnotation(true);
    if (status == ERROR) {
        final String error = GroovyDslFileIndex.getError(vfile);
        if (error != null) {
            annotation.registerFix(GroovyQuickFixFactory.getInstance().createInvestigateFix(error));
        }
    }
    annotation.registerFix(new ActivateFix(vfile));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Status(org.jetbrains.plugins.groovy.dsl.DslActivationStatus.Status) GroovyFile(org.jetbrains.plugins.groovy.lang.psi.GroovyFile) Annotation(com.intellij.lang.annotation.Annotation)

Aggregations

Annotation (com.intellij.lang.annotation.Annotation)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Status (org.jetbrains.plugins.groovy.dsl.DslActivationStatus.Status)1 GroovyFile (org.jetbrains.plugins.groovy.lang.psi.GroovyFile)1