@Test public void testNoMainMethod() throws Exception { final String original = "int a = 1; void foo() { }"; final TranslationUnit tu = ParseHelper.parse(original); final List<GlobalVariableDeclToExprReductionOpportunity> ops = GlobalVariableDeclToExprReductionOpportunities .findOpportunities(MakeShaderJobFromFragmentShader.make(tu), new ReducerContext(false, ShadingLanguageVersion.ESSL_100, new RandomWrapper(0), new IdGenerator())); assertTrue(ops.isEmpty()); }
static List<GlobalVariableDeclToExprReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); }
GlobalVariableDeclToExprReductionOpportunities extends ReductionOpportunitiesBase<GlobalVariableDeclToExprReductionOpportunity> { static List<GlobalVariableDeclToExprReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } }
GlobalVariableDeclToExprReductionOpportunities extends ReductionOpportunitiesBase<GlobalVariableDeclToExprReductionOpportunity> { static List<GlobalVariableDeclToExprReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  GlobalVariableDeclToExprReductionOpportunities(TranslationUnit tu,
                                                        ReducerContext context); }
GlobalVariableDeclToExprReductionOpportunities extends ReductionOpportunitiesBase<GlobalVariableDeclToExprReductionOpportunity> { static List<GlobalVariableDeclToExprReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  GlobalVariableDeclToExprReductionOpportunities(TranslationUnit tu,
                                                        ReducerContext context); @Override void visitVariablesDeclaration(VariablesDeclaration variablesDeclaration); @Override void visitFunctionDefinition(FunctionDefinition functionDefinition); }
GlobalVariableDeclToExprReductionOpportunities extends ReductionOpportunitiesBase<GlobalVariableDeclToExprReductionOpportunity> { static List<GlobalVariableDeclToExprReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  GlobalVariableDeclToExprReductionOpportunities(TranslationUnit tu,
                                                        ReducerContext context); @Override void visitVariablesDeclaration(VariablesDeclaration variablesDeclaration); @Override void visitFunctionDefinition(FunctionDefinition functionDefinition);  }