@Test public void testGetUniformDeclaration() throws Exception { final String shader = "uniform float a, b;" + "uniform int;" + "void main()" + "{" + " float c = a;" + " float d = b;" + "}"; final TranslationUnit translationUnit = ParseHelper.parse(shader, ShaderKind.FRAGMENT); final VariablesDeclaration variablesDeclaration = translationUnit.getUniformDeclaration("a"); assertEquals(variablesDeclaration.getDeclInfos().get(0).getName(), "a"); assertEquals(variablesDeclaration.getDeclInfos().get(1).getName(), "b"); final VariablesDeclaration variablesDeclaration2 = translationUnit.getUniformDeclaration("b"); assertEquals(variablesDeclaration2.getDeclInfos().get(0).getName(), "a"); assertEquals(variablesDeclaration2.getDeclInfos().get(1).getName(), "b"); }
public VariablesDeclaration getUniformDeclaration(String name) { return getGlobalVariablesDeclarations().stream() .filter(variablesDeclaration -> variablesDeclaration.getBaseType().hasQualifier(TypeQualifier.UNIFORM) && variablesDeclaration.getDeclInfos().stream() .anyMatch(variableDecl -> variableDecl.getName().equals(name))).findAny().get(); }
TranslationUnit implements IAstNode { public VariablesDeclaration getUniformDeclaration(String name) { return getGlobalVariablesDeclarations().stream() .filter(variablesDeclaration -> variablesDeclaration.getBaseType().hasQualifier(TypeQualifier.UNIFORM) && variablesDeclaration.getDeclInfos().stream() .anyMatch(variableDecl -> variableDecl.getName().equals(name))).findAny().get(); } }
TranslationUnit implements IAstNode { public VariablesDeclaration getUniformDeclaration(String name) { return getGlobalVariablesDeclarations().stream() .filter(variablesDeclaration -> variablesDeclaration.getBaseType().hasQualifier(TypeQualifier.UNIFORM) && variablesDeclaration.getDeclInfos().stream() .anyMatch(variableDecl -> variableDecl.getName().equals(name))).findAny().get(); } TranslationUnit(ShaderKind shaderKind,
                         Optional<ShadingLanguageVersion> shadingLanguageVersion,
                         List<Declaration> topLevelDeclarations);  TranslationUnit(Optional<ShadingLanguageVersion> shadingLanguageVersion,
                         List<Declaration> topLevelDeclarations); }
TranslationUnit implements IAstNode { public VariablesDeclaration getUniformDeclaration(String name) { return getGlobalVariablesDeclarations().stream() .filter(variablesDeclaration -> variablesDeclaration.getBaseType().hasQualifier(TypeQualifier.UNIFORM) && variablesDeclaration.getDeclInfos().stream() .anyMatch(variableDecl -> variableDecl.getName().equals(name))).findAny().get(); } TranslationUnit(ShaderKind shaderKind,
                         Optional<ShadingLanguageVersion> shadingLanguageVersion,
                         List<Declaration> topLevelDeclarations);  TranslationUnit(Optional<ShadingLanguageVersion> shadingLanguageVersion,
                         List<Declaration> topLevelDeclarations); boolean hasMainFunction(); FunctionDefinition getMainFunction(); ShaderKind getShaderKind(); void setShaderKind(ShaderKind shaderKind); List<Declaration> getTopLevelDeclarations(); boolean hasShadingLanguageVersion(); ShadingLanguageVersion getShadingLanguageVersion(); void setShadingLanguageVersion(ShadingLanguageVersion shadingLanguageVersion); void setTopLevelDeclarations(List<Declaration> topLevelDeclarations); @Override void accept(IAstVisitor visitor); void addDeclaration(Declaration decl); void addDeclarationBefore(Declaration newDecl, Declaration existingDecl); void updateTopLevelDeclaration(Declaration newDecl, Declaration existingDecl); void removeTopLevelDeclaration(int index); void removeTopLevelDeclaration(Declaration declaration); @Override TranslationUnit clone(); List<VariableDeclInfo> getGlobalVarDeclInfos(); List<VariablesDeclaration> getGlobalVariablesDeclarations(); List<VariablesDeclaration> getUniformDecls(); VariablesDeclaration getUniformDeclaration(String name); boolean hasUniformDeclaration(String name); List<StructDefinitionType> getStructDefinitions(); StructDefinitionType getStructDefinition(StructNameType type); }
TranslationUnit implements IAstNode { public VariablesDeclaration getUniformDeclaration(String name) { return getGlobalVariablesDeclarations().stream() .filter(variablesDeclaration -> variablesDeclaration.getBaseType().hasQualifier(TypeQualifier.UNIFORM) && variablesDeclaration.getDeclInfos().stream() .anyMatch(variableDecl -> variableDecl.getName().equals(name))).findAny().get(); } TranslationUnit(ShaderKind shaderKind,
                         Optional<ShadingLanguageVersion> shadingLanguageVersion,
                         List<Declaration> topLevelDeclarations);  TranslationUnit(Optional<ShadingLanguageVersion> shadingLanguageVersion,
                         List<Declaration> topLevelDeclarations); boolean hasMainFunction(); FunctionDefinition getMainFunction(); ShaderKind getShaderKind(); void setShaderKind(ShaderKind shaderKind); List<Declaration> getTopLevelDeclarations(); boolean hasShadingLanguageVersion(); ShadingLanguageVersion getShadingLanguageVersion(); void setShadingLanguageVersion(ShadingLanguageVersion shadingLanguageVersion); void setTopLevelDeclarations(List<Declaration> topLevelDeclarations); @Override void accept(IAstVisitor visitor); void addDeclaration(Declaration decl); void addDeclarationBefore(Declaration newDecl, Declaration existingDecl); void updateTopLevelDeclaration(Declaration newDecl, Declaration existingDecl); void removeTopLevelDeclaration(int index); void removeTopLevelDeclaration(Declaration declaration); @Override TranslationUnit clone(); List<VariableDeclInfo> getGlobalVarDeclInfos(); List<VariablesDeclaration> getGlobalVariablesDeclarations(); List<VariablesDeclaration> getUniformDecls(); VariablesDeclaration getUniformDeclaration(String name); boolean hasUniformDeclaration(String name); List<StructDefinitionType> getStructDefinitions(); StructDefinitionType getStructDefinition(StructNameType type);  }