A whole lot of code formatting, unused import removal and other readability fixes.

Syntax checking should now stop from generating errors with passed jME3 built-in vars. Those variables are only accepted used with "in" or "uniform".

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9346 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
dan..om 13 years ago
parent cd010fa5e7
commit 690915870c
  1. 4
      sdk/jme3-glsl-support/nbproject/project.properties
  2. 27
      sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/GlslCompletionProvider.java
  3. 25
      sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/GlslShaderFileObserver.java
  4. 62
      sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/GlslVocabularyManager.java
  5. 48
      sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslFragmentShaderDataObject.java
  6. 39
      sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslGeometryShaderDataObject.java
  7. 48
      sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/dataobject/GlslVertexShaderDataObject.java
  8. 1
      sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/glsl/GLSL_130.nbs
  9. 166
      sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/glsl/Glsl.java
  10. 24
      sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/lexer/Glsl.java
  11. 176
      sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/lexer/GlslLexer.java
  12. 119
      sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/lexer/GlslTokenId.java
  13. 52
      sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/vocabulary/GLSLElementDescriptor.java
  14. 15
      sdk/jme3-glsl-support/src/net/java/nboglpack/glsleditor/vocabulary/GLSLVocabulary.java

@ -2,5 +2,5 @@ javac.compilerargs=-Xlint -Xlint:-serial
javac.source=1.5
license.file=license.txt
nbm.homepage=http://kenai.com/projects/netbeans-opengl-pack
nbm.module.author=Mathias Henze, Michael Bien
spec.version.base=3.0.0
nbm.module.author=Mathias Henze, Michael Bien, Dany Rioux
spec.version.base=3.0.1.0

@ -23,7 +23,6 @@ import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.net.URL;
import java.util.Iterator;
import java.util.Map;
import net.java.nboglpack.glsleditor.dataobject.GlslFragmentShaderDataLoader;
import net.java.nboglpack.glsleditor.dataobject.GlslGeometryShaderDataLoader;
import net.java.nboglpack.glsleditor.dataobject.GlslVertexShaderDataLoader;
@ -31,7 +30,6 @@ import net.java.nboglpack.glsleditor.glsl.Glsl;
import net.java.nboglpack.glsleditor.vocabulary.GLSLElementDescriptor;
import org.netbeans.spi.editor.completion.support.CompletionUtilities;
/**
* Completion provider for the OpenGL Shading Language editor.
*
@ -41,7 +39,6 @@ import org.netbeans.spi.editor.completion.support.CompletionUtilities;
public class GlslCompletionProvider implements CompletionProvider {
private static final ErrorManager LOGGER = ErrorManager.getDefault().getInstance(GlslCompletionProvider.class.getName());
private final String mimeType;
private GlslCompletionProvider(String mimeType) {
@ -56,19 +53,18 @@ public class GlslCompletionProvider implements CompletionProvider {
return 0;
}
public static GlslCompletionProvider createVSCompletionProvider(){
public static GlslCompletionProvider createVSCompletionProvider() {
return new GlslCompletionProvider(GlslVertexShaderDataLoader.REQUIRED_MIME);
}
public static GlslCompletionProvider createGSCompletionProvider(){
public static GlslCompletionProvider createGSCompletionProvider() {
return new GlslCompletionProvider(GlslGeometryShaderDataLoader.REQUIRED_MIME);
}
public static GlslCompletionProvider createFSCompletionProvider(){
public static GlslCompletionProvider createFSCompletionProvider() {
return new GlslCompletionProvider(GlslFragmentShaderDataLoader.REQUIRED_MIME);
}
private static class GlslCompletionQuery extends AsyncCompletionQuery {
private GlslVocabularyManager vocabulary;
@ -99,7 +95,7 @@ public class GlslCompletionProvider implements CompletionProvider {
}
// add user declared functions first
synchronized(Glsl.declaredFunctions) {
synchronized (Glsl.declaredFunctions) {
Set<Entry<String, GLSLElementDescriptor>> entrySet = Glsl.declaredFunctions.entrySet();
for (Entry<String, GLSLElementDescriptor> entry : entrySet) {
@ -126,8 +122,9 @@ public class GlslCompletionProvider implements CompletionProvider {
GLSLElementDescriptor[] elements = vocabulary.getDesc(name);
if (elements != null) {
for (GLSLElementDescriptor element : elements)
for (GLSLElementDescriptor element : elements) {
completionResultSet.addItem(new GlslCompletionItem(name, element, prefix, pos));
}
}
}
@ -141,14 +138,11 @@ public class GlslCompletionProvider implements CompletionProvider {
private GLSLElementDescriptor content;
private int carretPosition = 0;
private String prefix;
private String leftText;
private String rightText;
private String ARGUMENTS_COLOR = "<font color=#b28b00>";
private String BUILD_IN_VAR_COLOR = "<font color=#ce7b00>";
private String KEYWORD_COLOR = "<font color=#000099>";
private int priority;
public GlslCompletionItem(String key, GLSLElementDescriptor content, String prefix, int carretPosition) {
@ -224,8 +218,8 @@ public class GlslCompletionProvider implements CompletionProvider {
Completion.get().hideAll();
// replace prefix with key
try {
component.getDocument().remove(carretPosition-prefix.length(), prefix.length());
component.getDocument().insertString(carretPosition-prefix.length(), key, null);
component.getDocument().remove(carretPosition - prefix.length(), prefix.length());
component.getDocument().insertString(carretPosition - prefix.length(), key, null);
} catch (BadLocationException e) {
LOGGER.notify(e);
}
@ -252,6 +246,7 @@ public class GlslCompletionProvider implements CompletionProvider {
}
return new AsyncCompletionTask(new AsyncCompletionQuery() {
private GlslDocItem item = new GlslDocItem(key, content);
protected void query(CompletionResultSet completionResultSet, Document document, int i) {
@ -291,14 +286,14 @@ public class GlslCompletionProvider implements CompletionProvider {
StringBuilder sb = new StringBuilder();
sb.append("<code>");
if(content.type != null) {
if (content.type != null) {
sb.append(content.type);
sb.append(" ");
}
sb.append("<b>");
sb.append(item);
sb.append("</b>");
if(content.arguments != null) {
if (content.arguments != null) {
sb.append(content.arguments);
}
sb.append("</code><p>");

@ -4,12 +4,9 @@ package net.java.nboglpack.glsleditor;
* Created on 26. March 2007, 00:49
*
*/
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
//import net.java.nboglpack.glslcompiler.GLSLCompilerService;
import org.openide.loaders.DataObject;
import org.openide.util.Lookup;
import org.openide.util.RequestProcessor;
/**
@ -18,16 +15,17 @@ import org.openide.util.RequestProcessor;
*/
public class GlslShaderFileObserver implements DocumentListener {
private final DataObject observedDao;
private final static RequestProcessor RP = new RequestProcessor("compiler");
private final RequestProcessor.Task compilerTask;
private boolean runOnDocUpdate = true;
private int compileDelay = 500;
private final DataObject observedDao;
private final static RequestProcessor RP = new RequestProcessor("compiler");
private final RequestProcessor.Task compilerTask;
private boolean runOnDocUpdate = true;
private int compileDelay = 500;
public GlslShaderFileObserver(DataObject dao) {
observedDao = dao;
compilerTask = RP.create(new Runnable() {
public void run() {
// GLSLCompilerService compiler = Lookup.getDefault().lookup(GLSLCompilerService.class);
// compiler.compileShader(new DataObject[] {observedDao}, false);
@ -36,20 +34,22 @@ public class GlslShaderFileObserver implements DocumentListener {
compilerTask.setPriority(Thread.MIN_PRIORITY);
}
// DocumentListener
public void insertUpdate(DocumentEvent arg0) {
if(runOnDocUpdate)
if (runOnDocUpdate) {
runCompileTask();
}
}
public void removeUpdate(DocumentEvent arg0) {
if(runOnDocUpdate)
if (runOnDocUpdate) {
runCompileTask();
}
}
public void changedUpdate(DocumentEvent arg0) {
}
public final void runCompileTask() {
compilerTask.schedule(compileDelay);
}
@ -61,5 +61,4 @@ public class GlslShaderFileObserver implements DocumentListener {
public void setRunOnDocUpdate(boolean runOnDocUpdate) {
this.runOnDocUpdate = runOnDocUpdate;
}
}

@ -4,7 +4,6 @@
* Created on 12. Februar 2006, 03:37
*
*/
package net.java.nboglpack.glsleditor;
import java.io.InputStream;
@ -31,34 +30,36 @@ import org.openide.filesystems.FileUtil;
*/
public class GlslVocabularyManager {
private static final ErrorManager LOGGER = ErrorManager.getDefault().getInstance(GlslVocabularyManager.class.getName());
private static final HashMap<String, GlslVocabularyManager> instances = new HashMap<String, GlslVocabularyManager>();
private static GLSLVocabulary vocabulary = null;
private final String mimetype;
private final Set<String> keySet;
private final Map<String, GLSLElementDescriptor[]> vocabularyExtention;
private static final ErrorManager LOGGER = ErrorManager.getDefault().getInstance(GlslVocabularyManager.class.getName());
private static final HashMap<String, GlslVocabularyManager> instances = new HashMap<String, GlslVocabularyManager>();
private static GLSLVocabulary vocabulary = null;
private final String mimetype;
private final Set<String> keySet;
private final Map<String, GLSLElementDescriptor[]> vocabularyExtention;
/** Creates a new instance of GlslVocabularyManager */
/**
* Creates a new instance of GlslVocabularyManager
*/
private GlslVocabularyManager(String mimetype) {
if( !mimetype.equals(GlslFragmentShaderDataLoader.REQUIRED_MIME)
&& !mimetype.equals(GlslVertexShaderDataLoader.REQUIRED_MIME)
&& !mimetype.equals(GlslGeometryShaderDataLoader.REQUIRED_MIME)) {
throw new IllegalArgumentException(mimetype+" is no GLSL mime type");
if (!mimetype.equals(GlslFragmentShaderDataLoader.REQUIRED_MIME)
&& !mimetype.equals(GlslVertexShaderDataLoader.REQUIRED_MIME)
&& !mimetype.equals(GlslGeometryShaderDataLoader.REQUIRED_MIME)) {
throw new IllegalArgumentException(mimetype + " is no GLSL mime type");
}
this.mimetype = mimetype;
if(vocabulary == null)
if (vocabulary == null) {
loadVocabulary();
}
if(mimetype.equals(GlslFragmentShaderDataLoader.REQUIRED_MIME)) {
if (mimetype.equals(GlslFragmentShaderDataLoader.REQUIRED_MIME)) {
vocabularyExtention = vocabulary.fragmentShaderVocabulary;
}else if(mimetype.equals(GlslVertexShaderDataLoader.REQUIRED_MIME)) {
} else if (mimetype.equals(GlslVertexShaderDataLoader.REQUIRED_MIME)) {
vocabularyExtention = vocabulary.vertexShaderVocabulary;
}else {
} else {
vocabularyExtention = vocabulary.geometryShaderVocabulary;
}
@ -68,9 +69,8 @@ public class GlslVocabularyManager {
private final Set<String> mainSet = vocabulary.mainVocabulary.keySet();
private final Set<String> extSet = vocabularyExtention.keySet();
public Iterator<String> iterator() {
return new Iterator<String>(){
return new Iterator<String>() {
Iterator<String> mainIt = mainSet.iterator();
Iterator<String> extIt = extSet.iterator();
@ -80,23 +80,22 @@ public class GlslVocabularyManager {
}
public String next() {
if(mainIt.hasNext())
if (mainIt.hasNext()) {
return mainIt.next();
else
} else {
return extIt.next();
}
}
public void remove() {
throw new UnsupportedOperationException("Not supported yet.");
}
};
}
public int size() {
return mainSet.size()+extSet.size();
return mainSet.size() + extSet.size();
}
};
}
@ -105,9 +104,9 @@ public class GlslVocabularyManager {
GlslVocabularyManager instance = instances.get(mimetype);
if(instance == null) {
if (instance == null) {
instance = new GlslVocabularyManager(mimetype);
instances.put(mimetype,instance);
instances.put(mimetype, instance);
}
return instance;
@ -115,7 +114,7 @@ public class GlslVocabularyManager {
private void loadVocabulary() {
FileObject vocabularyfile = FileUtil.getConfigFile("Editors/"+mimetype+"/vocabulary.xml");
FileObject vocabularyfile = FileUtil.getConfigFile("Editors/" + mimetype + "/vocabulary.xml");
if (vocabularyfile != null) {
@ -130,7 +129,7 @@ public class GlslVocabularyManager {
JAXBContext jc = JAXBContext.newInstance("net.java.nboglpack.glsleditor.vocabulary", this.getClass().getClassLoader());
Unmarshaller unmarshaller = jc.createUnmarshaller();
vocabulary = (GLSLVocabulary)unmarshaller.unmarshal(is);
vocabulary = (GLSLVocabulary) unmarshaller.unmarshal(is);
} catch (Exception ex) {
@ -140,7 +139,7 @@ public class GlslVocabularyManager {
} finally {
if(is != null) {
if (is != null) {
try {
is.close();
} catch (Exception e) {
@ -162,11 +161,10 @@ public class GlslVocabularyManager {
GLSLElementDescriptor[] desc = vocabulary.mainVocabulary.get(key);
if(desc == null)
if (desc == null) {
desc = vocabularyExtention.get(key);
}
return desc;
}
}

@ -13,39 +13,20 @@ import org.openide.nodes.Node;
import org.openide.text.CloneableEditorSupport;
import org.openide.text.DataEditorSupport;
public class GlslFragmentShaderDataObject extends MultiDataObject {
private final GlslShaderFileObserver observer;
private final GlslShaderFileObserver observer;
public GlslFragmentShaderDataObject(FileObject pf, GlslFragmentShaderDataLoader loader) throws DataObjectExistsException, IOException {
super(pf, loader);
CookieSet cookies = getCookieSet();
observer= new GlslShaderFileObserver(this);
observer = new GlslShaderFileObserver(this);
final CloneableEditorSupport support= DataEditorSupport.create(this, getPrimaryEntry(), cookies);
final CloneableEditorSupport support = DataEditorSupport.create(this, getPrimaryEntry(), cookies);
support.addPropertyChangeListener(
new PropertyChangeListener(){
public void propertyChange(PropertyChangeEvent event) {
if("document".equals(event.getPropertyName())){
if(event.getNewValue()!=null)
{
support.getDocument().addDocumentListener(observer);
observer.runCompileTask();
}
else if(event.getOldValue()!=null)
{
// cylab: I think this is never called.
// But I don't know if unregistering the observer makes any difference...
((Document)event.getOldValue()).removeDocumentListener(observer);
}
}
}
}
);
new PropertyChangeListenerImpl(support));
cookies.add((Node.Cookie) support);
}
@ -54,4 +35,25 @@ public class GlslFragmentShaderDataObject extends MultiDataObject {
return new GlslFragmentShaderDataNode(this);
}
private class PropertyChangeListenerImpl implements PropertyChangeListener {
private final CloneableEditorSupport support;
public PropertyChangeListenerImpl(CloneableEditorSupport support) {
this.support = support;
}
public void propertyChange(PropertyChangeEvent event) {
if ("document".equals(event.getPropertyName())) {
if (event.getNewValue() != null) {
support.getDocument().addDocumentListener(observer);
observer.runCompileTask();
} else if (event.getOldValue() != null) {
// cylab: I think this is never called.
// But I don't know if unregistering the observer makes any difference...
((Document) event.getOldValue()).removeDocumentListener(observer);
}
}
}
}
}

@ -14,7 +14,6 @@ import org.openide.text.CloneableEditorSupport;
import org.openide.util.Lookup;
import org.openide.text.DataEditorSupport;
/**
* @author Michael Bien
*/
@ -30,21 +29,7 @@ public class GlslGeometryShaderDataObject extends MultiDataObject {
observer = new GlslShaderFileObserver(this);
final CloneableEditorSupport support = DataEditorSupport.create(this, getPrimaryEntry(), cookies);
support.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if ("document".equals(event.getPropertyName())) {
if (event.getNewValue() != null) {
support.getDocument().addDocumentListener(observer);
observer.runCompileTask();
} else if (event.getOldValue() != null) {
// cylab: I think this is never called.
// But I don't know if unregistering the observer makes any difference...
((Document) event.getOldValue()).removeDocumentListener(observer);
}
}
}
});
support.addPropertyChangeListener(new PropertyChangeListenerImpl(support));
cookies.add((Node.Cookie) support);
}
@ -57,4 +42,26 @@ public class GlslGeometryShaderDataObject extends MultiDataObject {
public Lookup getLookup() {
return getCookieSet().getLookup();
}
private class PropertyChangeListenerImpl implements PropertyChangeListener {
private final CloneableEditorSupport support;
public PropertyChangeListenerImpl(CloneableEditorSupport support) {
this.support = support;
}
public void propertyChange(PropertyChangeEvent event) {
if ("document".equals(event.getPropertyName())) {
if (event.getNewValue() != null) {
support.getDocument().addDocumentListener(observer);
observer.runCompileTask();
} else if (event.getOldValue() != null) {
// cylab: I think this is never called.
// But I don't know if unregistering the observer makes any difference...
((Document) event.getOldValue()).removeDocumentListener(observer);
}
}
}
}
}

@ -1,6 +1,5 @@
package net.java.nboglpack.glsleditor.dataobject;
import net.java.nboglpack.glsleditor.GlslShaderFileObserver;
import net.java.nboglpack.glsleditor.GlslShaderFileObserver;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@ -16,34 +15,17 @@ import org.openide.text.DataEditorSupport;
public class GlslVertexShaderDataObject extends MultiDataObject {
private GlslShaderFileObserver observer;
private GlslShaderFileObserver observer;
public GlslVertexShaderDataObject(FileObject pf, GlslVertexShaderDataLoader loader) throws DataObjectExistsException, IOException {
super(pf, loader);
CookieSet cookies = getCookieSet();
observer= new GlslShaderFileObserver(this);
observer = new GlslShaderFileObserver(this);
final CloneableEditorSupport support= DataEditorSupport.create(this, getPrimaryEntry(), cookies);
final CloneableEditorSupport support = DataEditorSupport.create(this, getPrimaryEntry(), cookies);
support.addPropertyChangeListener(
new PropertyChangeListener(){
public void propertyChange(PropertyChangeEvent event) {
if("document".equals(event.getPropertyName())){
if(event.getNewValue()!=null)
{
support.getDocument().addDocumentListener(observer);
observer.runCompileTask();
}
else if(event.getOldValue()!=null)
{
// cylab: I think this is never called.
// But I don't know if unregistering the observer makes any difference...
((Document)event.getOldValue()).removeDocumentListener(observer);
}
}
}
}
);
new PropertyChangeListenerImpl(support));
cookies.add((Node.Cookie) support);
}
@ -51,4 +33,26 @@ public class GlslVertexShaderDataObject extends MultiDataObject {
protected Node createNodeDelegate() {
return new GlslVertexShaderDataNode(this);
}
private class PropertyChangeListenerImpl implements PropertyChangeListener {
private final CloneableEditorSupport support;
public PropertyChangeListenerImpl(CloneableEditorSupport support) {
this.support = support;
}
public void propertyChange(PropertyChangeEvent event) {
if ("document".equals(event.getPropertyName())) {
if (event.getNewValue() != null) {
support.getDocument().addDocumentListener(observer);
observer.runCompileTask();
} else if (event.getOldValue() != null) {
// cylab: I think this is never called.
// But I don't know if unregistering the observer makes any difference...
((Document) event.getOldValue()).removeDocumentListener(observer);
}
}
}
}
}

@ -284,6 +284,7 @@ global_identifier_list = global_declared_identifier [array_index] (<COMMA> globa
global_declared_identifier = <IDENTIFIER>;
global_preprocessor = <PREPROCESSOR>;
field_declaration = ("in" | "uniform") type_specifier_or_identifier <BUILD_IN_VAR> ;
field_declaration = global_type_qualifier struct_declaration;
field_declaration = global_type_qualifier global_type_declaration [assignment2];

@ -4,7 +4,6 @@
* Created on 24.09.2007, 00:46:53
*
*/
package net.java.nboglpack.glsleditor.glsl;
import java.util.HashMap;
@ -28,19 +27,19 @@ import org.netbeans.api.lexer.TokenUtilities;
*/
public final class Glsl {
private final static String KEYWORD_FONT_COLOR = "<font color=808080>";
public final static Map<String, GLSLElementDescriptor> declaredFunctions = new HashMap<String, GLSLElementDescriptor>();
private final static String KEYWORD_FONT_COLOR = "<font color=808080>";
public final static Map<String, GLSLElementDescriptor> declaredFunctions = new HashMap<String, GLSLElementDescriptor>();
private Glsl() {}
private Glsl() {
}
/**
/**
* Assembles a human readable String containing the declaraton of a function.
* Asumes that the current token of the SyntaxContext represents the function name.
*/
public static final String createFunctionDeclarationString(SyntaxContext context) {
AbstractDocument document = (AbstractDocument)context.getDocument();
AbstractDocument document = (AbstractDocument) context.getDocument();
StringBuilder sb = new StringBuilder();
@ -55,51 +54,58 @@ public final class Glsl {
sb.append("<html>");
int moved = 0;
while(sequence.movePrevious() && isIgnoredToken(sequence.token()))
while (sequence.movePrevious() && isIgnoredToken(sequence.token())) {
moved++;
}
String type = sequence.token().toString();
while(moved-- >= 0)
while (moved-- >= 0) {
sequence.moveNext();
}
// append function name
sb.append(sequence.token().text());
while(!TokenUtilities.equals(sequence.token().text(), "("))
while (!TokenUtilities.equals(sequence.token().text(), "(")) {
sequence.moveNext();
}
sb.append("(");
Token token;
boolean first = true;
while(sequence.moveNext() && !TokenUtilities.equals(sequence.token().text(), ")")) {
while (sequence.moveNext() && !TokenUtilities.equals(sequence.token().text(), ")")) {
token = sequence.token();
if(!isIgnoredToken(token)) {
if (!isIgnoredToken(token)) {
if(first) {
if (first) {
sb.append(KEYWORD_FONT_COLOR);
}else if(token.id() != GlslTokenId.COMMA && token.id() != GlslTokenId.BRACKET && token.id() != GlslTokenId.INTEGER_LITERAL) {
} else if (token.id() != GlslTokenId.COMMA && token.id() != GlslTokenId.BRACKET && token.id() != GlslTokenId.INTEGER_LITERAL) {
sb.append(" ");
}
if(!TokenUtilities.equals(token.text(), "void")) {
if (!TokenUtilities.equals(token.text(), "void")) {
moved = 0;
while(sequence.moveNext() && isIgnoredToken(sequence.token()))
while (sequence.moveNext() && isIgnoredToken(sequence.token())) {
moved++;
}
if(sequence.token().id() == GlslTokenId.COMMA || TokenUtilities.equals(sequence.token().text(), ")"))
if (sequence.token().id() == GlslTokenId.COMMA || TokenUtilities.equals(sequence.token().text(), ")")) {
sb.append("</font>");
}
while(moved-- >= 0)
while (moved-- >= 0) {
sequence.movePrevious();
}
sb.append(token.text());
if(token.id() == GlslTokenId.COMMA)
if (token.id() == GlslTokenId.COMMA) {
sb.append(KEYWORD_FONT_COLOR);
}
}
first = false;
@ -109,7 +115,7 @@ public final class Glsl {
sb.append("</font>)");
if(!"void".equals(type)) {
if (!"void".equals(type)) {
sb.append(" : ");
sb.append(KEYWORD_FONT_COLOR);
sb.append(type);
@ -118,7 +124,7 @@ public final class Glsl {
sb.append("</html>");
} finally {
document.readUnlock();
document.readUnlock();
}
return sb.toString();
@ -130,7 +136,7 @@ public final class Glsl {
*/
public static final String createFieldDeclarationString(SyntaxContext context) {
AbstractDocument document = (AbstractDocument)context.getDocument();
AbstractDocument document = (AbstractDocument) context.getDocument();
StringBuilder sb = new StringBuilder();
@ -152,53 +158,55 @@ public final class Glsl {
// read forward
int moved = 0;
Token token;
while( sequence.moveNext()
while (sequence.moveNext()
&& sequence.token().id() != GlslTokenId.SEMICOLON
&& sequence.token().id() != GlslTokenId.COMMA
&& sequence.token().id() != GlslTokenId.EQ ) {
&& sequence.token().id() != GlslTokenId.EQ) {
token = sequence.token();
if(!isIgnoredToken(token))
if (!isIgnoredToken(token)) {
sb.append(token);
}
moved++;
}
while(moved-- >= 0)
while (moved-- >= 0) {
sequence.movePrevious();
}
// read backwards throw the declaration
boolean skipToken = false;
while( sequence.movePrevious()
while (sequence.movePrevious()
&& sequence.token().id() != GlslTokenId.SEMICOLON
&& sequence.token().id() != GlslTokenId.END_OF_LINE ) {
&& sequence.token().id() != GlslTokenId.END_OF_LINE) {
token = sequence.token();
if(!isIgnoredToken(token)) {
if (!isIgnoredToken(token)) {
// we have a struct declaration; skip everything between { }
if(token.id() == GlslTokenId.BRACE && TokenUtilities.equals(token.text(), "}")) {
if (token.id() == GlslTokenId.BRACE && TokenUtilities.equals(token.text(), "}")) {
movePreviousUntil(sequence, GlslTokenId.BRACE, "}", "{");
continue;
}
// skip token in case of an comma seperated identifier list
if(skipToken) {
if( token.id() == GlslTokenId.BRACKET
&& TokenUtilities.equals(token.text(), "]") ) {
if (skipToken) {
if (token.id() == GlslTokenId.BRACKET
&& TokenUtilities.equals(token.text(), "]")) {
movePreviousUntil(sequence, GlslTokenId.BRACKET, "]", "[");
skipToken = false;
}else {
} else {
skipToken = false;
}
continue;
}
if(token.id() == GlslTokenId.COMMA) {
if (token.id() == GlslTokenId.COMMA) {
skipToken = true;
continue;
}
if(!TokenUtilities.equals(token.text(), "struct")) {
if (!TokenUtilities.equals(token.text(), "struct")) {
sb.insert(insertIndex, token.text());
sb.insert(insertIndex, " ");
}
@ -215,27 +223,31 @@ public final class Glsl {
return sb.toString();
}
public static final String createPreprocessorString(SyntaxContext context) {
ASTNode node = (ASTNode)context.getASTPath().getLeaf();
ASTNode node = (ASTNode) context.getASTPath().getLeaf();
List<ASTItem> children = node.getChildren();
String str = null;
for (ASTItem item : children)
if (isTokenType(item, GlslTokenId.PREPROCESSOR.name()))
str = ((ASTToken)item).getIdentifier();
for (ASTItem item : children) {
if (isTokenType(item, GlslTokenId.PREPROCESSOR.name())) {
str = ((ASTToken) item).getIdentifier();
}
}
for(int i = 0; i < str.length(); i++) {
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if(c != '#' && !Character.isWhitespace(c))
for(int j = str.length()-1; j > i; j--)
if(!Character.isWhitespace(str.charAt(j)))
return str.substring(i, j+1);
if (c != '#' && !Character.isWhitespace(c)) {
for (int j = str.length() - 1; j > i; j--) {
if (!Character.isWhitespace(str.charAt(j))) {
return str.substring(i, j + 1);
}
}
}
}
@ -243,16 +255,16 @@ public final class Glsl {
}
/**
* called from withen GLSL_*.nbs each time the document has been modified.
* Called from withen GLSL_*.nbs each time the document has been modified.
*/
public static void process(SyntaxContext context) {
AbstractDocument document = (AbstractDocument)context.getDocument();
try{
AbstractDocument document = (AbstractDocument) context.getDocument();
try {
document.readLock();
// remember all declared funktions for auto completion
synchronized(declaredFunctions) {
// remember all declared functions for auto-completion
synchronized (declaredFunctions) {
declaredFunctions.clear();
}
@ -262,28 +274,29 @@ public final class Glsl {
for (ASTItem declarationItem : declaration.getChildren()) {
if(isNode(declarationItem, "function")) {
if (isNode(declarationItem, "function")) {
List<ASTItem> functionItems = declarationItem.getChildren();
if(functionItems.size() < 3)
if (functionItems.size() < 3) {
break;
}
ASTItem nameToken = functionItems.get(0);
if(isTokenType(nameToken, GlslTokenId.FUNCTION.name())) {
if (isTokenType(nameToken, GlslTokenId.FUNCTION.name())) {
// determine return type
StringBuilder returnType = new StringBuilder();
for (ASTItem typeItem : declaration.getChildren()) {
if(isNode(typeItem, "function"))
if (isNode(typeItem, "function")) {
break;
}
if(typeItem instanceof ASTNode) {
returnType.append(((ASTNode)typeItem).getAsText().trim());
}else if(typeItem instanceof ASTToken) {
if (typeItem instanceof ASTNode) {
returnType.append(((ASTNode) typeItem).getAsText().trim());
} else if (typeItem instanceof ASTToken) {
final ASTToken t = (ASTToken) typeItem;
returnType.append(t.getIdentifier().trim());
}
@ -295,8 +308,9 @@ public final class Glsl {
name.append("(");
ASTItem parameterList = functionItems.get(2);
if(isNode(parameterList, "parameter_declaration_list"))
name.append(((ASTNode)parameterList).getAsText());
if (isNode(parameterList, "parameter_declaration_list")) {
name.append(((ASTNode) parameterList).getAsText());
}
name.append(")");
GLSLElementDescriptor elementDesc = new GLSLElementDescriptor(
@ -308,7 +322,7 @@ public final class Glsl {
name.insert(0, ((ASTToken) nameToken).getIdentifier());
synchronized(declaredFunctions) {
synchronized (declaredFunctions) {
declaredFunctions.put(name.toString(), elementDesc);
}
@ -319,43 +333,41 @@ public final class Glsl {
}
}
}
}finally{
} finally {
document.readUnlock();
}
}
private static final void movePreviousUntil(TokenSequence sequence, GlslTokenId id, String countToken, String stopToken) {
private static void movePreviousUntil(TokenSequence sequence, GlslTokenId id, String countToken, String stopToken) {
int counter = 1;
while(sequence.movePrevious() && counter > 0) {
if(sequence.token().id() == id) {
if(TokenUtilities.equals(sequence.token().text(), stopToken)) {
while (sequence.movePrevious() && counter > 0) {
if (sequence.token().id() == id) {
if (TokenUtilities.equals(sequence.token().text(), stopToken)) {
counter--;
}else if(TokenUtilities.equals(sequence.token().text(), countToken)){
} else if (TokenUtilities.equals(sequence.token().text(), countToken)) {
counter++;
}
}
}
}
private static final boolean isIgnoredToken(Token token) {
return token.id() == GlslTokenId.WHITESPACE
private static boolean isIgnoredToken(Token token) {
return token.id() == GlslTokenId.WHITESPACE
|| token.id() == GlslTokenId.COMMENT
|| token.id() == GlslTokenId.PREPROCESSOR;
}
private static final boolean isNode(ASTItem item, String nodeToken) {
return item != null && item instanceof ASTNode && ((ASTNode)item).getNT().equals(nodeToken);
private static boolean isNode(ASTItem item, String nodeToken) {
return item != null && item instanceof ASTNode && ((ASTNode) item).getNT().equals(nodeToken);
}
private static final boolean isToken(ASTItem item, String id) {
return item != null && item instanceof ASTToken && ((ASTToken)item).getIdentifier().equals(id);
private static boolean isToken(ASTItem item, String id) {
return item != null && item instanceof ASTToken && ((ASTToken) item).getIdentifier().equals(id);
}
private static final boolean isTokenType(ASTItem item, String type) {
private static boolean isTokenType(ASTItem item, String type) {
return item != null && item instanceof ASTToken && ((ASTToken) item).getTypeName().equals(type);
}
}

@ -4,7 +4,6 @@
* Created on 19.08.2007, 18:25:24
*
*/
package net.java.nboglpack.glsleditor.lexer;
import java.util.Collection;
@ -24,15 +23,14 @@ import org.netbeans.spi.lexer.LexerRestartInfo;
*/
public class Glsl extends LanguageHierarchy<GlslTokenId> {
public static final Glsl VERTEX_LANGUAGE = new Glsl(GlslVertexShaderDataLoader.REQUIRED_MIME);
public static final Glsl GEOMETRY_LANGUAGE = new Glsl(GlslGeometryShaderDataLoader.REQUIRED_MIME);
public static final Glsl FRAGMENT_LANGUAGE = new Glsl(GlslFragmentShaderDataLoader.REQUIRED_MIME);
private final String mimeType;
public static final Glsl VERTEX_LANGUAGE = new Glsl(GlslVertexShaderDataLoader.REQUIRED_MIME);
public static final Glsl GEOMETRY_LANGUAGE = new Glsl(GlslGeometryShaderDataLoader.REQUIRED_MIME);
public static final Glsl FRAGMENT_LANGUAGE = new Glsl(GlslFragmentShaderDataLoader.REQUIRED_MIME);
private final String mimeType;
private Glsl(String mimeType) {
this.mimeType = mimeType;
}
private Glsl(String mimeType) {
this.mimeType = mimeType;
}
@Override
protected String mimeType() {
@ -49,13 +47,15 @@ public class Glsl extends LanguageHierarchy<GlslTokenId> {
return new GlslLexer(info, GlslVocabularyManager.getInstance(mimeType()));
}
public static Language<GlslTokenId> vertexLanguage(){
public static Language<GlslTokenId> vertexLanguage() {
return VERTEX_LANGUAGE.language();
}
public static Language<GlslTokenId> fragmentLanguage(){
public static Language<GlslTokenId> fragmentLanguage() {
return FRAGMENT_LANGUAGE.language();
}
public static Language<GlslTokenId> geometryLanguage(){
public static Language<GlslTokenId> geometryLanguage() {
return GEOMETRY_LANGUAGE.language();
}
}

@ -4,7 +4,6 @@
* Created on 19.08.2007, 18:31:16
*
*/
package net.java.nboglpack.glsleditor.lexer;
import net.java.nboglpack.glsleditor.GlslVocabularyManager;
@ -15,33 +14,29 @@ import org.netbeans.spi.lexer.LexerInput;
import org.netbeans.spi.lexer.LexerRestartInfo;
import org.netbeans.spi.lexer.TokenFactory;
/**
* Lexer for the OpenGL Shading Language.
* @author Michael Bien
*/
public class GlslLexer implements Lexer<GlslTokenId> {
private final LexerInput input;
private final TokenFactory<GlslTokenId> factory;
private final GlslVocabularyManager manager;
private final StringBuilder stringBuilder;
private final LexerInput input;
private final TokenFactory<GlslTokenId> factory;
private final GlslVocabularyManager manager;
private final StringBuilder stringBuilder;
public GlslLexer(LexerRestartInfo<GlslTokenId> info, GlslVocabularyManager manager) {
this.input = info.input();
this.factory = info.tokenFactory();
this.manager = manager;
this.stringBuilder = new StringBuilder();
}
public GlslLexer(LexerRestartInfo<GlslTokenId> info, GlslVocabularyManager manager) {
this.input = info.input();
this.factory = info.tokenFactory();
this.manager = manager;
this.stringBuilder = new StringBuilder();
}
@SuppressWarnings("fallthrough")
public Token<GlslTokenId> nextToken() {
int character = input.read();
switch(character) {
switch (character) {
case '(':
case ')':
return factory.createToken(GlslTokenId.PAREN);
@ -64,76 +59,76 @@ public class GlslLexer implements Lexer<GlslTokenId> {
case '~':
return factory.createToken(GlslTokenId.TILDE);
case '*':
if(input.read() == '=') {
if (input.read() == '=') {
return factory.createToken(GlslTokenId.MUL_ASSIGN);
}else{
} else {
input.backup(1);
return factory.createToken(GlslTokenId.STAR);
}
case '%':
if(input.read() == '=') {
if (input.read() == '=') {
return factory.createToken(GlslTokenId.MOD_ASSIGN);
}else{
} else {
input.backup(1);
return factory.createToken(GlslTokenId.PERCENT);
}
case '!':
if(input.read() == '=') {
if (input.read() == '=') {
return factory.createToken(GlslTokenId.NE);
}else{
} else {
input.backup(1);
return factory.createToken(GlslTokenId.BANG);
}
case '=':
if(input.read() == '=') {
if (input.read() == '=') {
return factory.createToken(GlslTokenId.EQEQ);
}else{
} else {
input.backup(1);
return factory.createToken(GlslTokenId.EQ);
}
case '^':
switch(input.read()) {
case('^'):
switch (input.read()) {
case ('^'):
return factory.createToken(GlslTokenId.CARETCARET);
case('='):
case ('='):
return factory.createToken(GlslTokenId.XOR_ASSIGN);
default:
input.backup(1);
return factory.createToken(GlslTokenId.CARET);
}
case '+':
switch(input.read()) {
case('+'):
switch (input.read()) {
case ('+'):
return factory.createToken(GlslTokenId.PLUSPLUS);
case('='):
case ('='):
return factory.createToken(GlslTokenId.ADD_ASSIGN);
default:
input.backup(1);
return factory.createToken(GlslTokenId.PLUS);
}
case '-':
switch(input.read()) {
case('-'):
switch (input.read()) {
case ('-'):
return factory.createToken(GlslTokenId.MINUSMINUS);
case('='):
case ('='):
return factory.createToken(GlslTokenId.SUB_ASSIGN);
default:
input.backup(1);
return factory.createToken(GlslTokenId.MINUS);
}
case '&':
switch(input.read()) {
case('&'):
switch (input.read()) {
case ('&'):
return factory.createToken(GlslTokenId.AMPAMP);
case('='):
case ('='):
return factory.createToken(GlslTokenId.AND_ASSIGN);
default:
input.backup(1);
return factory.createToken(GlslTokenId.AMP);
}
case '|':
switch(input.read()) {
case('|'):
switch (input.read()) {
case ('|'):
return factory.createToken(GlslTokenId.BARBAR);
case ('='):
return factory.createToken(GlslTokenId.OR_ASSIGN);
@ -142,30 +137,30 @@ public class GlslLexer implements Lexer<GlslTokenId> {
return factory.createToken(GlslTokenId.BAR);
}
case '<':
switch(input.read()) {
case('<'):
if(input.read() == '=') {
switch (input.read()) {
case ('<'):
if (input.read() == '=') {
return factory.createToken(GlslTokenId.LEFT_BITSHIFT_ASSIGN);
}else{
} else {
input.backup(1);
return factory.createToken(GlslTokenId.LEFT_BITSHIFT);
}
case('='):
case ('='):
return factory.createToken(GlslTokenId.LE);
default:
input.backup(1);
return factory.createToken(GlslTokenId.LEFT_ANGLE);
}
case '>':
switch(input.read()) {
case('>'):
if(input.read() == '=') {
switch (input.read()) {
case ('>'):
if (input.read() == '=') {
return factory.createToken(GlslTokenId.RIGHT_BITSHIFT_ASSIGN);
}else{
} else {
input.backup(1);
return factory.createToken(GlslTokenId.RIGHT_BITSHIFT);
}
case('='):
case ('='):
return factory.createToken(GlslTokenId.GE);
default:
input.backup(1);
@ -173,14 +168,14 @@ public class GlslLexer implements Lexer<GlslTokenId> {
}
case '/':
int c = input.read();
if(c == '/') {
if (c == '/') {
readRemainingLine();
return factory.createToken(GlslTokenId.COMMENT);
}else if(c == '*') {
} else if (c == '*') {
return tokenizeMLComment();
}else if(c == '=') {
} else if (c == '=') {
return factory.createToken(GlslTokenId.DIV_ASSIGN);
}else{
} else {
input.backup(1);
return factory.createToken(GlslTokenId.SLASH);
}
@ -189,24 +184,25 @@ public class GlslLexer implements Lexer<GlslTokenId> {
return factory.createToken(GlslTokenId.PREPROCESSOR);
case ' ':
case '\t':
do{
do {
character = input.read();
}while(character == ' ' || character == '\t');
} while (character == ' ' || character == '\t');
input.backup(1);
return factory.createToken(GlslTokenId.WHITESPACE);
case '\r':
input.consumeNewline();
case LexerInput.EOF:
if(input.readLength() == 0)
if (input.readLength() == 0) {
return null;
}
case '\n':
return factory.createToken(GlslTokenId.END_OF_LINE);
default:
if(Character.isDigit(character)) {
if (Character.isDigit(character)) {
return tokenizeNumber();
}else if(Character.isUnicodeIdentifierStart(character)) {
} else if (Character.isUnicodeIdentifierStart(character)) {
return tokenizeName();
}else{
} else {
return factory.createToken(GlslTokenId.error);
}
}
@ -214,11 +210,11 @@ public class GlslLexer implements Lexer<GlslTokenId> {
}
@SuppressWarnings("fallthrough")
private final void readRemainingLine() {
private void readRemainingLine() {
int character = input.read();
while(character != LexerInput.EOF) {
while (character != LexerInput.EOF) {
switch (character) {
case '\r':
input.consumeNewline();
@ -231,12 +227,12 @@ public class GlslLexer implements Lexer<GlslTokenId> {
}
private final Token<GlslTokenId> tokenizeMLComment() {
private Token<GlslTokenId> tokenizeMLComment() {
int character = input.read();
while(character != LexerInput.EOF) {
if(character == '*' && input.read() == '/') {
while (character != LexerInput.EOF) {
if (character == '*' && input.read() == '/') {
return factory.createToken(GlslTokenId.ML_COMMENT);
}
character = input.read();
@ -245,67 +241,68 @@ public class GlslLexer implements Lexer<GlslTokenId> {
}
private final Token<GlslTokenId> tokenizeNumber() {
private Token<GlslTokenId> tokenizeNumber() {
int character;
do{
do {
character = input.read();
}while(Character.isDigit(character));
} while (Character.isDigit(character));
if(character == '.') {
if (character == '.') {
do{
do {
character = input.read();
}while(Character.isDigit(character));
} while (Character.isDigit(character));
if(character != 'f' && character != 'F')
if (character != 'f' && character != 'F') {
input.backup(1);
}
return factory.createToken(GlslTokenId.FLOAT_LITERAL);
}else{
} else {
if(character != 'u' && character != 'U')
if (character != 'u' && character != 'U') {
input.backup(1);
}
// input.backup(1);
return factory.createToken(GlslTokenId.INTEGER_LITERAL);
}
}
private final Token<GlslTokenId> tokenizeName() {
private Token<GlslTokenId> tokenizeName() {
if(stringBuilder.length() > 0)
if (stringBuilder.length() > 0) {
stringBuilder.delete(0, stringBuilder.length());
}
// backup everything read
input.backup(input.readLength());
// assamble token
char c;
while(Character.isUnicodeIdentifierPart(c = ((char)input.read())))
while (Character.isUnicodeIdentifierPart(c = ((char) input.read()))) {
stringBuilder.append(c);
}
if(stringBuilder.length() > 0)
if (stringBuilder.length() > 0) {
input.backup(1);
}
// categorise token
GLSLElementDescriptor[] desc = manager.getDesc(stringBuilder.toString());
if(desc != null) {
if(desc[0].category != null) {
if(desc[0].category == GLSLElementDescriptor.Category.BUILD_IN_FUNC)
if (desc != null) {
if (desc[0].category != null) {
if (desc[0].category == GLSLElementDescriptor.Category.BUILD_IN_FUNC) {
return factory.createToken(GlslTokenId.BUILD_IN_FUNC);
if(desc[0].category == GLSLElementDescriptor.Category.BUILD_IN_VAR)
}
if (desc[0].category == GLSLElementDescriptor.Category.BUILD_IN_VAR) {
return factory.createToken(GlslTokenId.BUILD_IN_VAR);
}
return factory.createToken(GlslTokenId.KEYWORD);
}
}
@ -313,7 +310,7 @@ public class GlslLexer implements Lexer<GlslTokenId> {
int tokenEnd = input.readLength();
int character = input.read();
while(true) {
while (true) {
switch (character) {
case ' ':
case '\t':
@ -322,10 +319,10 @@ public class GlslLexer implements Lexer<GlslTokenId> {
character = input.read();
break;
case '(':
input.backup(input.readLength()-tokenEnd);
input.backup(input.readLength() - tokenEnd);
return factory.createToken(GlslTokenId.FUNCTION);
default:
input.backup(input.readLength()-tokenEnd);
input.backup(input.readLength() - tokenEnd);
return factory.createToken(GlslTokenId.IDENTIFIER);
}
}
@ -339,5 +336,4 @@ public class GlslLexer implements Lexer<GlslTokenId> {
public void release() {
}
}

@ -15,73 +15,72 @@ import org.netbeans.api.lexer.TokenId;
*/
public enum GlslTokenId implements TokenId {
IDENTIFIER("glsl-name"),
INTEGER_LITERAL("glsl-literal"),
FLOAT_LITERAL("glsl-literal"),
FUNCTION("glsl-function"),
KEYWORD("glsl-keyword"),
BUILD_IN_FUNC("glsl-build-in-func"),
BUILD_IN_VAR("glsl-build-in-var"),
COMMENT("glsl-comment"),
ML_COMMENT("glsl-comment"),
IDENTIFIER("glsl-name"),
INTEGER_LITERAL("glsl-literal"),
FLOAT_LITERAL("glsl-literal"),
FUNCTION("glsl-function"),
KEYWORD("glsl-keyword"),
BUILD_IN_FUNC("glsl-build-in-func"),
BUILD_IN_VAR("glsl-build-in-var"),
COMMENT("glsl-comment"),
ML_COMMENT("glsl-comment"),
PAREN("glsl-paren"),
BRACE("glsl-brace"),
BRACKET("glsl-bracket"),
LEFT_ANGLE("glsl-angle"),
RIGHT_ANGLE("glsl-angle"),
PAREN("glsl-paren"),
BRACE("glsl-brace"),
BRACKET("glsl-bracket"),
LEFT_ANGLE("glsl-angle"),
RIGHT_ANGLE("glsl-angle"),
SEMICOLON("glsl-separator"),
COMMA("glsl-separator"),
DOT("glsl-separator"),
COLON("glsl-separator"),
SEMICOLON("glsl-separator"),
COMMA("glsl-separator"),
DOT("glsl-separator"),
COLON("glsl-separator"),
PERCENT("glsl-operation"),
STAR("glsl-operation"),
TILDE("glsl-operation"),
QUESTION("glsl-operation"),
BANG("glsl-operation"),
SLASH("glsl-operation"),
LEFT_BITSHIFT("glsl-operation"),
RIGHT_BITSHIFT("glsl-operation"),
PLUS("glsl-operation"),
PLUSPLUS("glsl-operation"),
MINUS("glsl-operation"),
MINUSMINUS("glsl-operation"),
AMP("glsl-operation"),
AMPAMP("glsl-operation"),
EQ("glsl-operation"),
EQEQ("glsl-operation"),
NE("glsl-operation"),
LE("glsl-operation"),
GE("glsl-operation"),
BAR("glsl-operation"),
BARBAR("glsl-operation"),
CARET("glsl-operation"),
CARETCARET("glsl-operation"),
ADD_ASSIGN("glsl-operation"),
SUB_ASSIGN("glsl-operation"),
MUL_ASSIGN("glsl-operation"),
DIV_ASSIGN("glsl-operation"),
AND_ASSIGN("glsl-operation"),
OR_ASSIGN("glsl-operation"),
XOR_ASSIGN("glsl-operation"),
MOD_ASSIGN("glsl-operation"),
LEFT_BITSHIFT_ASSIGN("glsl-operation"),
RIGHT_BITSHIFT_ASSIGN("glsl-operation"),
PERCENT("glsl-operation"),
STAR("glsl-operation"),
TILDE("glsl-operation"),
QUESTION("glsl-operation"),
BANG("glsl-operation"),
SLASH("glsl-operation"),
LEFT_BITSHIFT("glsl-operation"),
RIGHT_BITSHIFT("glsl-operation"),
PLUS("glsl-operation"),
PLUSPLUS("glsl-operation"),
MINUS("glsl-operation"),
MINUSMINUS("glsl-operation"),
AMP("glsl-operation"),
AMPAMP("glsl-operation"),
EQ("glsl-operation"),
EQEQ("glsl-operation"),
NE("glsl-operation"),
LE("glsl-operation"),
GE("glsl-operation"),
BAR("glsl-operation"),
BARBAR("glsl-operation"),
CARET("glsl-operation"),
CARETCARET("glsl-operation"),
ADD_ASSIGN("glsl-operation"),
SUB_ASSIGN("glsl-operation"),
MUL_ASSIGN("glsl-operation"),
DIV_ASSIGN("glsl-operation"),
AND_ASSIGN("glsl-operation"),
OR_ASSIGN("glsl-operation"),
XOR_ASSIGN("glsl-operation"),
MOD_ASSIGN("glsl-operation"),
LEFT_BITSHIFT_ASSIGN("glsl-operation"),
RIGHT_BITSHIFT_ASSIGN("glsl-operation"),
WHITESPACE("glsl-whitespace"),
END_OF_LINE("glsl-end-of-line"),
PREPROCESSOR("glsl-preprocessor"),
WHITESPACE("glsl-whitespace"),
END_OF_LINE("glsl-end-of-line"),
PREPROCESSOR("glsl-preprocessor"),
error("glsl-error");
error("glsl-error");
private final String primaryCategory;
private final String primaryCategory;
private GlslTokenId(String primaryCategory) {
this.primaryCategory = primaryCategory;
}
private GlslTokenId(String primaryCategory) {
this.primaryCategory = primaryCategory;
}
public String primaryCategory() {
return primaryCategory;

@ -16,41 +16,43 @@ import javax.xml.bind.annotation.XmlType;
*/
public class GLSLElementDescriptor {
@XmlType
@XmlEnum(String.class)
public enum Category { BUILD_IN_FUNC, BUILD_IN_VAR, USER_FUNC, JUMP, ITERATION, SELECTION, QUALIFIER, TYPE, KEYWORD }
@XmlType
@XmlEnum(String.class)
public enum Category {
BUILD_IN_FUNC, BUILD_IN_VAR, USER_FUNC, JUMP, ITERATION, SELECTION, QUALIFIER, TYPE, KEYWORD
}
@XmlElement
public final Category category;
@XmlElement
public final Category category;
@XmlElement(required = true)
public final String tooltip;
@XmlElement(required = true)
public final String tooltip;
@XmlElement(required = true)
public final String doc;
@XmlElement(required = true)
public final String doc;
@XmlElement(required = true)
public final String arguments;
@XmlElement(required = true)
public final String arguments;
@XmlElement(required = true)
public final String type;
@XmlElement(required = true)
public final String type;
/*bean constructor, fields are directly injected*/
/**
* Bean constructor, fields are directly injected.
*/
public GLSLElementDescriptor() {
category = Category.KEYWORD;
tooltip = null;
doc = null;
arguments = null;
type = null;
category = Category.KEYWORD;
tooltip = null;
doc = null;
arguments = null;
type = null;
}
public GLSLElementDescriptor(Category category, String tooltip, String doc, String arguments, String type) {
this.category = category;
this.tooltip = tooltip;
this.doc = doc;
this.category = category;
this.tooltip = tooltip;
this.doc = doc;
this.arguments = arguments;
this.type = type;
this.type = type;
}
}

@ -16,18 +16,15 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class GLSLVocabulary {
public final HashMap<String, GLSLElementDescriptor[]> mainVocabulary;
public final HashMap<String, GLSLElementDescriptor[]> fragmentShaderVocabulary;
public final HashMap<String, GLSLElementDescriptor[]> vertexShaderVocabulary;
public final HashMap<String, GLSLElementDescriptor[]> geometryShaderVocabulary;
public final HashMap<String, GLSLElementDescriptor[]> mainVocabulary;
public final HashMap<String, GLSLElementDescriptor[]> fragmentShaderVocabulary;
public final HashMap<String, GLSLElementDescriptor[]> vertexShaderVocabulary;
public final HashMap<String, GLSLElementDescriptor[]> geometryShaderVocabulary;
public GLSLVocabulary() {
mainVocabulary = new HashMap<String, GLSLElementDescriptor[]>();
vertexShaderVocabulary = new HashMap<String, GLSLElementDescriptor[]>();
mainVocabulary = new HashMap<String, GLSLElementDescriptor[]>();
vertexShaderVocabulary = new HashMap<String, GLSLElementDescriptor[]>();
fragmentShaderVocabulary = new HashMap<String, GLSLElementDescriptor[]>();
geometryShaderVocabulary = new HashMap<String, GLSLElementDescriptor[]>();
}
}

Loading…
Cancel
Save