private static MethodAnalysisResults analyzeLambda(MetamodelUtil metamodel, String className, String methodName, String methodSignature) { try { // Open up the corresponding class to analyze PathAnalysisFactory pathAnalysisFactory = new PathAnalysisFactory( new MethodChecker(metamodel)); TransformationClassAnalyzer classAnalyzer = new TransformationClassAnalyzer(className); MethodAnalysisResults analysis = classAnalyzer.analyzeLambdaMethod(methodName, methodSignature, pathAnalysisFactory); PathAnalysisSimplifier.cleanAndSimplify(analysis, Collections.emptyMap(), Collections.emptyMap(), false); return analysis; } catch (IOException e) { e.printStackTrace(); return null; } catch (AnalyzerException e) { e.printStackTrace(); return null; } }
public <U> ColumnExpressions<U> apply(List<Table<?>> fromTables) { try { SymbExToColumns translator = new SymbExToColumns(metamodel, new SelectFromWhereLambdaArgumentHandler(lambda, fromTables)); // TODO: Handle this case by translating things to use SELECT CASE if (lambda.symbolicAnalysis.paths.size() > 1) return null; ColumnExpressions<U> returnExpr = (ColumnExpressions<U>)translator.transform(PathAnalysisSimplifier.simplify(lambda.symbolicAnalysis.paths.get(0).getReturnValue(), Collections.emptyMap(), Collections.emptyMap(), false)); return returnExpr; } catch (TypedValueVisitorException e) { e.printStackTrace(); throw new IllegalArgumentException("Could not create query from lambda", e); } }
for (TypedValue val: PathAnalysisSimplifier.simplifyBooleans(path.getConditions(), comparisonMethods, comparisonStaticMethods, isAllEqualsConverted))
TypedValue returnVal = PathAnalysisSimplifier.simplifyBoolean(path.getReturnValue(), Collections.emptyMap(), Collections.emptyMap(), false); ColumnExpressions<?> returnColumns = translator.transform(returnVal); if (!returnColumns.isSingleColumn()) throw new IllegalArgumentException("Where lambda should only return a single column of data");
.simplifyBoolean(path.getReturnValue(), config.getComparisonMethods(), config.getComparisonStaticMethods(), config.isAllEqualsSafe); if (returnVal instanceof ConstantValue.BooleanConstant)
protected <U> ColumnExpressions<U> simplifyAndTranslatePathToColumns(LambdaAnalysis lambda, int pathIdx, SymbExToColumns translator, SymbExPassDown passdown) throws TypedValueVisitorException { return (ColumnExpressions<U>)PathAnalysisSimplifier .simplify(lambda.symbolicAnalysis.paths.get(pathIdx).getReturnValue(), config.getComparisonMethods(), config.getComparisonStaticMethods(), config.isAllEqualsSafe) .visit(translator, passdown); }
private static MethodAnalysisResults analyzeLambdaClass(Class<?> lambdaClass, MetamodelUtil metamodel, LambdaAsClassAnalysisConfig lambdaAsClass, ClassLoader alternateClassLoader, boolean isObjectEqualsSafe, boolean isAllEqualsSafe, boolean isCollectionContainsSafe) throws IOException, AnalyzerException { // Open up the corresponding class to analyze TransformationClassAnalyzer classAnalyzer = new TransformationClassAnalyzer(lambdaClass.getName(), alternateClassLoader); Method matchingMethod = lambdaAsClass.findLambdaMethod(lambdaClass); if (matchingMethod == null) throw new AnalyzerException(null, "Could not find a lambda method with the expected name in the class"); PathAnalysisFactory pathAnalysisFactory = new PathAnalysisFactory( metamodel.getMethodChecker(isObjectEqualsSafe, isAllEqualsSafe, isCollectionContainsSafe)); MethodAnalysisResults analysis = classAnalyzer.analyzeLambdaMethod(matchingMethod.getName(), Type.getMethodDescriptor(matchingMethod), pathAnalysisFactory); PathAnalysisSimplifier.cleanAndSimplify(analysis, metamodel.getComparisonMethods(isObjectEqualsSafe), metamodel.getComparisonStaticMethods(isObjectEqualsSafe), isAllEqualsSafe); return analysis; }
PathAnalysis path = where.symbolicAnalysis.paths.get(n); TypedValue returnVal = PathAnalysisSimplifier.simplifyBoolean(path.getReturnValue(), Collections.emptyMap(), Collections.emptyMap(), false); ColumnExpressions<?> returnColumns = translator.transform(returnVal); if (!returnColumns.isSingleColumn()) {
.simplify(lambda.symbolicAnalysis.paths.get(0).getReturnValue(), config.getComparisonMethods(), config.getComparisonStaticMethods(), config.isAllEqualsSafe) .visit(translator, passdown);
private static MethodAnalysisResults analyzeLambda(MetamodelUtil metamodel, ClassLoader alternateClassLoader, boolean isObjectEqualsSafe, boolean isAllEqualsSafe, boolean isCollectionContainsSafe, String className, String methodName, String methodSignature) throws IOException, AnalyzerException { // Open up the corresponding class to analyze PathAnalysisFactory pathAnalysisFactory = new PathAnalysisFactory( metamodel.getMethodChecker(isObjectEqualsSafe, isAllEqualsSafe, isCollectionContainsSafe)); TransformationClassAnalyzer classAnalyzer = new TransformationClassAnalyzer(className, alternateClassLoader); MethodAnalysisResults analysis = classAnalyzer.analyzeLambdaMethod(methodName, methodSignature, pathAnalysisFactory); PathAnalysisSimplifier.cleanAndSimplify(analysis, metamodel.getComparisonMethods(isObjectEqualsSafe), metamodel.getComparisonStaticMethods(isObjectEqualsSafe), isAllEqualsSafe); return analysis; }
.simplify(joinLambda.symbolicAnalysis.paths.get(0).getReturnValue(), config.getComparisonMethods(), config.getComparisonStaticMethods(), config.isAllEqualsSafe) .visit(translator, passdown);
private static MethodAnalysisResults analyzeLambda(MetamodelUtil metamodel, String className, String methodName, String methodSignature) { try { // Open up the corresponding class to analyze PathAnalysisFactory pathAnalysisFactory = new PathAnalysisFactory( new MethodChecker(metamodel)); TransformationClassAnalyzer classAnalyzer = new TransformationClassAnalyzer(className); MethodAnalysisResults analysis = classAnalyzer.analyzeLambdaMethod(methodName, methodSignature, pathAnalysisFactory); PathAnalysisSimplifier.cleanAndSimplify(analysis, Collections.emptyMap(), Collections.emptyMap(), false); return analysis; } catch (IOException e) { e.printStackTrace(); return null; } catch (AnalyzerException e) { e.printStackTrace(); return null; } }
.simplify(lambda.symbolicAnalysis.paths.get(0).getReturnValue(), config.getComparisonMethods(), config.getComparisonStaticMethods(), config.isAllEqualsSafe) .visit(translator, passdown);
.simplify(lambda.symbolicAnalysis.paths.get(0).getReturnValue(), config.getComparisonMethods(), config.getComparisonStaticMethods(), config.isAllEqualsSafe) .visit(translator, passdown);
public <U> ColumnExpressions<U> apply(List<Table<?>> fromTables) { try { SymbExToColumns translator = new SymbExToColumns(metamodel, new SelectFromWhereLambdaArgumentHandler(lambda, fromTables)); // TODO: Handle this case by translating things to use SELECT CASE if (lambda.symbolicAnalysis.paths.size() > 1) return null; ColumnExpressions<U> returnExpr = (ColumnExpressions<U>)translator.transform(PathAnalysisSimplifier.simplify(lambda.symbolicAnalysis.paths.get(0).getReturnValue(), Collections.emptyMap(), Collections.emptyMap(), false)); return returnExpr; } catch (TypedValueVisitorException e) { e.printStackTrace(); throw new IllegalArgumentException("Could not create query from lambda", e); } }