darkyenus / glsl4idea Goto Github PK
View Code? Open in Web Editor NEWA GLSL language plugin for IntelliJ IDEA
License: GNU Lesser General Public License v3.0
A GLSL language plugin for IntelliJ IDEA
License: GNU Lesser General Public License v3.0
#version 330
struct S { int x; };
void main() {
int i; // correctly parsed
S s; // correctly parsed
}
out int i; // correctly parsed
out S s; // parse error
Currently we just ignore the contents of all directives. #define
should be able to actually define tokens to be expanded into another list of tokens. Ideally this would do function-like macros as well as variables, but variables only would be a good start.
The semicolon errors with "Expected a type specifier."
layout(points) in;
layout(line_strip, max_vertices = 6) out;
In version 1.7 on CLion 1.0.1, the following code snippet:
#ifdef GL_ES
precision mediump float;
precision mediump vec2;
precision mediump vec4;
precision mediump sampler2D;
#endif // GL_ES
gets improperly highlighted for vec2 and vec4, as per the attached screenshot.
I suspect this happens on more types, but I didn't do any further tests. Adding precision markers to vec2/vec4 types seems to be legal according to section 4.5.2 of the specifications.
Currently preprocessor conditionals are just ignored - everything in them is parsed as usual regardless of whether the condition is true. This would lead to parser errors in a bunch of different ways.
There are already unused files for this in resources/environment.
In GLSL 4.5, there's: uint
, double
, uvec[234]
, dvec[234]
, dmat[234]x[234]
, and a bunch of new opaque types. It'd be good to support these.
The parser makes no attempt to parse switch statements. They end up parsed as a function call, a missing semicolon and then a compound statement.
Relevant Piglit testcases:
fail/switch-case-duplicated.vert
fail/switch-case-empty-end.vert
fail/switch-case-in-int.vert
fail/switch-case-uniform-int.vert
fail/switch-default-duplicated.vert
fail/switch-expression-const-float.vert
fail/switch-expression-const-ivec2.vert
fail/switch-expression-const-vec2.vert
fail/switch-expression-in-float.vert
fail/switch-expression-in-vec2.vert
fail/switch-expression-uniform-float.vert
fail/switch-expression-uniform-vec2.vert
fail/switch-expression-var-float.vert
fail/switch-expression-var-vec2.vert
fail/switch.frag
fail/switch-nested-case.vert
fail/switch-nested-default.vert
fail/switch-uint-vs-int.vert
pass/switch-case-const-int-expression.vert
pass/switch-case-const-int.vert
pass/switch-case-fallthrough.vert
pass/switch-case-statement.vert
pass/switch-default.vert
pass/switch-expression-const-int.vert
pass/switch-expression-in-int.vert
pass/switch-expression-uniform-int.vert
pass/switch-expression-var-int.vert
pass/switch-nested-break.vert
pass/switch-nested-loop.vert
pass/switch-nested-switch.vert
For built in and known types and methods
The following warning is invalid:
#ifdef DEFINE_F
int f() { return 3; }
#endif // warning: unreachable expression
#extension extension_name : enable
Load the corresponding environment file with types and mehods.
gl_Position.x = -1.f + 4.f * (gl_VertexID & 1);
gl_Position.y = -1.f + 2.f * (gl_VertexID & 2);
gl_Position.zw = vec2(1.f);
I'm not savy with building plugin jar, could you please provide some basic instructions?
Thanks
Show only when relevant and change icon/make clickable?
If a Java file contains an error, then that file and its parent packages will have a red error squiggle in the project tree viewer (and on the breadcrumb menu at the top). This isn't the case for GLSL files. I can't find what needs to be implemented to do this.
OSX Yosemite 10.10.2
IntelliJ IDEA 14.1
Build #IU-141.177, built on March 23, 2015
JRE: 1.6.0_65-b14-466.1-11M4716 x86_64
JVM: Java HotSpot(TM) 64-Bit Server VM by Apple Inc.
Plugin 'GLSL' failed to initialize and will be disabled. Please restart IntelliJ IDEA.
com.intellij.diagnostic.PluginException: glslplugin/components/GLSLTemplatesLoader : Unsupported major.minor version 51.0 [Plugin: GLSL]
...
51.0 is java 1.7; it can't be run on 1.6, JDK 1.6 is required on OSX - It is possible to run IDEA on jdk 7/8 but with issues. Please provide version compiled for 1.6.
Currently, the line:
vec2 v; v.xx = vec2(1.0);
is considered valid.
Relevant piglit shaders:
fail/swizzle2.frag
I've tried installing both of the precompiled versions of this plugin, but the GLSL files I have remain unhighlighted. The older version of this plugin on the Jetbrains repository does activate properly, but it's impossible to configure it so it looks good with the Darkula theme.
I'm running on CLion 1.0
https://www.opengl.org/wiki/Interface_Block_%28GLSL%29
uniform UniformBlock {
mat4 projection, modelview;
float near, far;
} matrices, moreMatrices[3];
buffer ShaderStorageBlock {
mat4 projection;
}; // no identifier - names are in global scope
struct Struct {
int x;
} // correctly highlighted as a missing semicolon error
uniform Block {
int x;
} // no parse errors generated
At some point we're going to have to recognise the version and stage of a GLSL file. I know it's somehow possible to add those little drop-down menus to the bottom right of the IDE (eg. the Git plugin does it for the current branch, plus there's one for line endings and charset). I think it'd be good to detect it and populate menus down there so they can be manually changed if needed. I have no idea how to do this.
I get the following error on my Mac when trying to enable the GLSL plugin. I'm not sure if the error is related to AppCode or to the GLSL plugin.
Error message:
Plugin 'GLSL' failed to initialize and will be disabled. Please restart AppCode.
java.lang.NoSuchMethodError: com.intellij.ide.fileTemplates.FileTemplateManager.getDefaultInstance()Lcom/intellij/ide/fileTemplates/FileTemplateManager;
at glslplugin.components.GLSLTemplatesLoader.initComponent(GLSLTemplatesLoader.java:39)
at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter$1.getComponentInstance(ComponentManagerImpl.java:567)
at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter.getComponentInstance(ComponentManagerImpl.java:609)
at com.intellij.util.pico.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:236)
at com.intellij.util.pico.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:223)
at com.intellij.util.pico.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:210)
at org.picocontainer.alternatives.AbstractDelegatingMutablePicoContainer.getComponentInstance(AbstractDelegatingMutablePicoContainer.java:75)
at com.intellij.openapi.components.impl.ComponentManagerImpl.createComponent(ComponentManagerImpl.java:124)
at com.intellij.openapi.application.impl.ApplicationImpl.createComponent(ApplicationImpl.java:358)
at com.intellij.openapi.components.impl.ComponentManagerImpl.a(ComponentManagerImpl.java:115)
at com.intellij.openapi.components.impl.ComponentManagerImpl.init(ComponentManagerImpl.java:86)
at com.intellij.openapi.components.impl.stores.ApplicationStoreImpl.load(ApplicationStoreImpl.java:110)
at com.intellij.openapi.application.impl.ApplicationImpl.load(ApplicationImpl.java:511)
at com.intellij.openapi.application.impl.ApplicationImpl.load(ApplicationImpl.java:493)
at com.intellij.idea.IdeaApplication.run(IdeaApplication.java:158)
at com.intellij.idea.MainImpl$1$1$1.run(MainImpl.java:66)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:715)
at java.awt.EventQueue.access$400(EventQueue.java:82)
at java.awt.EventQueue$2.run(EventQueue.java:676)
at java.awt.EventQueue$2.run(EventQueue.java:674)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:685)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:364)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Example:
vec2 a = vec2(1.0).xy;
xy
Result:
java.lang.ClassCastException: com.intellij.psi.impl.source.tree.LeafPsiElement cannot be cast to glslplugin.lang.elements.GLSLIdentifier
at glslplugin.intentions.vectorcomponents.VectorComponentsIntention$1$1.run(VectorComponentsIntention.java:84)
at com.intellij.openapi.application.RunResult.run(RunResult.java:38)
at com.intellij.openapi.command.WriteCommandAction$2$1.run(WriteCommandAction.java:114)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:937)
at com.intellij.openapi.command.WriteCommandAction$2.run(WriteCommandAction.java:111)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:124)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:99)
at com.intellij.openapi.command.WriteCommandAction.performWriteCommandAction(WriteCommandAction.java:108)
at com.intellij.openapi.command.WriteCommandAction.execute(WriteCommandAction.java:80)
at glslplugin.intentions.vectorcomponents.VectorComponentsIntention$1.run(VectorComponentsIntention.java:87)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:715)
at java.awt.EventQueue.access$400(EventQueue.java:82)
at java.awt.EventQueue$2.run(EventQueue.java:676)
at java.awt.EventQueue$2.run(EventQueue.java:674)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:685)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:734)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:569)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:382)
In our engine we use a preprocessor, which allows us to use #include "filename.glsl"
in shaders. The syntax is the same as the ARB_shading_language_include extension.
In order for this extension (and, my real reason to suggest this, our codebase) to be supported in terms of tokens, it's necessary to lex string literals. This should be very easy as they contain no special characters or escaping. Parser support isn't required, as they're only valid in preprocessor directives which already just eat all the tokens until the end of the line.
Are there any plans to upload the plugin to JetBrains' repository? Given that you got the official blessing from the original authors to carry over development I think the next logical step would be to upload an updated version. Not even JetBrains employees are aware of this version it seems, according to https://youtrack.jetbrains.com/issue/CPP-1536 - and there is definitely the request for such a thing, now that it works under CLion too. Now that more GLES functionalities are covered, I know for sure that I wouldn't mind having this available on Android Studio too :)
For example
in.anything
puts parser into infinite loop and hangs Intellij which has to be force quit.
Generally, it is not very robust and syntax error tolerant. Next test cases:
void while
void main() {
}
Two consecutive operators
void in() {}
and other keyword-named functions
Using AppCode 3.1 (139.1402) and GLSL plugin 1.8 I receive the following error after enabling the GSLS plugin and re-starting AppCode:
Plugin 'GLSL' failed to initialize and will be disabled. Please restart AppCode.
java.lang.NoSuchMethodError: com.intellij.ide.fileTemplates.FileTemplateManager.getDefaultInstance()Lcom/intellij/ide/fileTemplates/FileTemplateManager;
at glslplugin.components.GLSLTemplatesLoader.initComponent(GLSLTemplatesLoader.java:39)
at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter$1.getComponentInstance(ComponentManagerImpl.java:567)
at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter.getComponentInstance(ComponentManagerImpl.java:609)
at com.intellij.util.pico.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:236)
at com.intellij.util.pico.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:223)
at com.intellij.util.pico.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:210)
at org.picocontainer.alternatives.AbstractDelegatingMutablePicoContainer.getComponentInstance(AbstractDelegatingMutablePicoContainer.java:75)
at com.intellij.openapi.components.impl.ComponentManagerImpl.createComponent(ComponentManagerImpl.java:124)
at com.intellij.openapi.application.impl.ApplicationImpl.createComponent(ApplicationImpl.java:358)
at com.intellij.openapi.components.impl.ComponentManagerImpl.a(ComponentManagerImpl.java:115)
at com.intellij.openapi.components.impl.ComponentManagerImpl.init(ComponentManagerImpl.java:86)
at com.intellij.openapi.components.impl.stores.ApplicationStoreImpl.load(ApplicationStoreImpl.java:110)
at com.intellij.openapi.application.impl.ApplicationImpl.load(ApplicationImpl.java:511)
at com.intellij.openapi.application.impl.ApplicationImpl.load(ApplicationImpl.java:493)
at com.intellij.idea.IdeaApplication.run(IdeaApplication.java:158)
at com.intellij.idea.MainImpl$1$1$1.run(MainImpl.java:66)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:715)
at java.awt.EventQueue.access$400(EventQueue.java:82)
at java.awt.EventQueue$2.run(EventQueue.java:676)
at java.awt.EventQueue$2.run(EventQueue.java:674)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:685)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:364)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
As per subject, I've tried to rebuild the plugin from source following the given instructions, but it seems like CLion's Platform SDK is missing a few things that this plugin needs.
Here's the compilation report (with the latest version from the repo):
glsl4idea/src/glslplugin/components/GLSLCompiler.java Error:(24, 37) java: package com.intellij.openapi.compiler does not exist Error:(25, 37) java: package com.intellij.openapi.compiler does not exist Error:(26, 37) java: package com.intellij.openapi.compiler does not exist Error:(27, 37) java: package com.intellij.openapi.compiler does not exist Error:(39, 38) java: cannot find symbol symbol: class TranslatingCompiler Error:(46, 42) java: cannot find symbol symbol: class CompileScope location: class glslplugin.components.GLSLCompiler Error:(52, 62) java: cannot find symbol symbol: class CompileContext location: class glslplugin.components.GLSLCompiler Error:(57, 25) java: cannot find symbol symbol: class CompileContext location: class glslplugin.components.GLSLCompiler Error:(57, 97) java: cannot find symbol symbol: class OutputSink location: class glslplugin.components.GLSLCompiler Error:(86, 42) java: cannot find symbol symbol: class OutputItem location: class glslplugin.components.GLSLCompiler Error:(76, 16) java: cannot find symbol symbol: class OutputItem location: class glslplugin.components.GLSLCompiler.ExitResult Error:(107, 17) java: cannot find symbol symbol: class CompileContext location: class glslplugin.components.GLSLCompiler.GLSLCompileAction Error:(110, 34) java: cannot find symbol symbol: class CompileContext location: class glslplugin.components.GLSLCompiler.GLSLCompileAction Error:(45, 5) java: method does not override or implement a method from a supertype Error:(51, 5) java: method does not override or implement a method from a supertype Error:(56, 5) java: method does not override or implement a method from a supertype Error:(78, 24) java: cannot find symbol symbol: class OutputItem location: class glslplugin.components.GLSLCompiler.ExitResult Error:(122, 36) java: cannot find symbol symbol: variable CompilerMessageCategory location: class glslplugin.components.GLSLCompiler.GLSLCompileAction glsl4idea/src/glslplugin/actions/GLSLDeduceExpressionTypeAction.java Error:(24, 41) java: cannot find symbol symbol: class DataKeys location: package com.intellij.openapi.actionSystem Error:(33, 29) java: cannot find symbol symbol: class PsiUtil location: package com.intellij.psi.util Error:(80, 41) java: cannot find symbol symbol: variable DataKeys location: class glslplugin.actions.GLSLDeduceExpressionTypeAction Error:(119, 40) java: cannot find symbol symbol: variable DataKeys location: class glslplugin.actions.GLSLDeduceExpressionTypeAction Error:(120, 41) java: cannot find symbol symbol: variable DataKeys location: class glslplugin.actions.GLSLDeduceExpressionTypeAction Error:(129, 26) java: cannot find symbol symbol: variable PsiUtil location: class glslplugin.actions.GLSLDeduceExpressionTypeAction glsl4idea/src/glslplugin/structureview/GLSLStructureViewFactory.java Error:(34, 52) java: is not abstract and does not override abstract method createStructureViewModel(com.intellij.openapi.editor.Editor) in com.intellij.ide.structureView.TreeBasedStructureViewBuilder
I'll see if I can fix some of those, hopefully without breaking the plugin in IDEA.
https://www.opengl.org/wiki/Layout_Qualifier_%28GLSL%29
layout(binding = 0, std140) uniform mat4 matrixFromBuffer;
Needs constant expression analysis first
That is, code after return/break/continue/discard should be striked-out or something
Via JOGL or stripped down LWJGL?
While working with a 430 core comp shader I noticed a couple of incorrect syntax checks.
image2d
and framebuffer
is marked with Expected '{'
layout(binding = 0, rgba32f) uniform image2D framebuffer;
const box boxes[] = {
/* The ground */
{vec3(-5.0, -0.1, -5.0), vec3(5.0, 0.0, 5.0)},
/* Box in the middle */
{vec3(-0.5, 0.0, -0.5), vec3(0.5, 1.0, 0.5)}
};
Samples from a recent LWJGL Ray trace tutorial.
Syntax validates with the Reference Compiler
Function calls are seemingly all getting parsed as constructors, which means they're all doing type conversions to struct types which don't exist.
int f();
void main() {
int x = f(); // error: can't assign 'f' to 'int'
vec3 x = normalize(vec3(1.f)); // error: can't assign 'normalize' to 'vec3'
}
If I use 'Right click › New › GLSL Shader', and enter 'Shader.vert', it creates a new file called 'Shader.vert.glsl'. It still recognises it as a GLSL file, but I then have to manually rename it to 'Shader.vert'.
As per subject, here's an example that triggers a syntax error:
#define DUMMY
attribute DUMMY vec4 vector;
yields a "Missing ';' after declaration" at the beginning of vec4
error.
Removing <lang.psiStructureViewFactory language="GLSL" implementationClass="glslplugin.structureview.GLSLStructureViewFactory"/>
from plugin.xml doesn't seem to change anything, and that is the only entry point. What does it actually do then? Do we need it?
Doing a git bisect
, it looks like this was caused by me in ed947af. Whoops.
I am not able to install the Plugin in Intellij 13.
I get the message that the plugin is not compatible with the current version.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.