Darkyenus / glsl4idea

A GLSL language plugin for IntelliJ IDEA
GNU Lesser General Public License v3.0
100 stars 30 forks source link

com.intellij.diagnostic.PluginException: Element: class glslplugin.lang.parser.GLSLFile #GLSL because: different providers #179

Open hamoid opened 1 year ago

hamoid commented 1 year ago

Describe the bug The IDE is complaining about exceptions with the GLSL plugin.

com.intellij.diagnostic.PluginException: Element: class glslplugin.lang.parser.GLSLFile #GLSL  because: different providers: com.intellij.psi.SingleRootFileViewProvider{vFile=jar:///home/funpro/.local/share/JetBrains/IdeaIC2023.1/GLSL4Idea/lib/GLSL4Idea-1.24.jar!/glsl/builtin.glsl, vFileId=1267040, content=VirtualFileContent{size=97756}, eventSystemEnabled=true}(5ee6b4b3); com.intellij.psi.SingleRootFileViewProvider{vFile=jar:///home/funpro/.local/share/JetBrains/IdeaIC2023.1/GLSL4Idea/lib/GLSL4Idea-1.24.jar!/glsl/builtin.glsl, vFileId=1267040, content=VirtualFileContent{size=97756}, eventSystemEnabled=true}(765a03b5)
invalidated at: see attachment [Plugin: GLSL]
    at com.intellij.diagnostic.PluginProblemReporterImpl.createPluginExceptionByClass(PluginProblemReporterImpl.java:23)
    at com.intellij.diagnostic.PluginException.createByClass(PluginException.java:99)
    at com.intellij.psi.util.PsiUtilCore.ensureValid(PsiUtilCore.java:482)
    at com.intellij.psi.impl.source.PsiFileImpl.loadTreeElement(PsiFileImpl.java:192)
    at com.intellij.psi.impl.source.PsiFileImpl.calcTreeElement(PsiFileImpl.java:734)
    at com.intellij.psi.impl.source.PsiFileImpl.getNode(PsiFileImpl.java:937)
    at com.intellij.psi.impl.source.PsiFileImpl.getFirstChild(PsiFileImpl.java:744)
    at glslplugin.lang.parser.GLSLFile.processDeclarations(GLSLFile.java:69)
    at glslplugin.lang.parser.GLSLFile.processDeclarations(GLSLFile.java:85)
    at com.intellij.psi.util.PsiTreeUtil.treeWalkUp(PsiTreeUtil.java:1257)
    at glslplugin.lang.elements.expressions.GLSLVariableExpression$VariableWalkResult.walkPossibleReferences(GLSLVariableExpression.java:117)
    at glslplugin.lang.elements.expressions.GLSLVariableExpression$VariableReference.resolve(GLSLVariableExpression.java:105)
    at glslplugin.annotation.impl.VariableTypeHighlightAnnotation.annotate(VariableTypeHighlightAnnotation.java:21)
    at glslplugin.annotation.impl.VariableTypeHighlightAnnotation.annotate(VariableTypeHighlightAnnotation.java:17)
    at glslplugin.annotation.Annotator.annotateGeneric(Annotator.java:46)
    at glslplugin.annotation.GLSLAnnotator.annotate(GLSLAnnotator.java:81)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.runAnnotators(DefaultHighlightVisitor.java:130)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.visit(DefaultHighlightVisitor.java:107)
        ...

To Reproduce

            @Language("GLSL")
            val glsl = """
                #version 450
                layout(local_size_x=1) in;
                layout(rgba32f) uniform writeonly image2DArray writeTex;
                uniform int numLayers;
                void main() {
                    vec4 pink = vec4(1.0, 0.753, 0.796, 1.0);
                    for (int layer=0; layer<numLayers; layer++) {
                        ivec3 coords = ivec3(gl_GlobalInvocationID.x, 
                                             gl_GlobalInvocationID.y, 
                                             layer);
                        float alpha = sin(coords.x * 0.1 + layer) * 0.5 + 0.5;
                        imageStore(writeTex, coords, pink * alpha);
                    }
                }
                """.trimIndent()

I don't know if it's the cause, but the first line with layout is highlighted as an error, with the tooltip Unable to parse external declaration.

Expected behavior No errors

Screenshots image

Versions

Additional context GLSL code is a compute shader.

hamoid commented 1 year ago

Trying the code above today in a different file I do not get the error. I will investigate what is the actual trigger.