Search in sources :

Example 1 with DefaultConfigurationOption

use of com.github.javaparser.printer.configuration.DefaultConfigurationOption in project drools by kiegroup.

the class ConstraintPrintVisitor method printArguments.

public void printArguments(final NodeList<Expression> args, final Void arg) {
    printer.print("(");
    if (!isNullOrEmpty(args)) {
        boolean columnAlignParameters = (args.size() > 1) && configuration.get(new DefaultConfigurationOption(DefaultPrinterConfiguration.ConfigOption.COLUMN_ALIGN_PARAMETERS)).map(ConfigurationOption::asBoolean).orElse(false);
        if (columnAlignParameters) {
            printer.indentWithAlignTo(printer.getCursor().column);
        }
        for (final Iterator<Expression> i = args.iterator(); i.hasNext(); ) {
            final Expression e = i.next();
            e.accept(this, arg);
            if (i.hasNext()) {
                printer.print(",");
                if (columnAlignParameters) {
                    printer.println();
                } else {
                    printer.print(" ");
                }
            }
        }
        if (columnAlignParameters) {
            printer.unindent();
        }
    }
    printer.print(")");
}
Also used : DefaultConfigurationOption(com.github.javaparser.printer.configuration.DefaultConfigurationOption) Expression(com.github.javaparser.ast.expr.Expression) ListCreationLiteralExpression(org.drools.mvel.parser.ast.expr.ListCreationLiteralExpression) DrlxExpression(org.drools.mvel.parser.ast.expr.DrlxExpression) MapCreationLiteralExpression(org.drools.mvel.parser.ast.expr.MapCreationLiteralExpression) ConfigurationOption(com.github.javaparser.printer.configuration.ConfigurationOption) DefaultConfigurationOption(com.github.javaparser.printer.configuration.DefaultConfigurationOption)

Example 2 with DefaultConfigurationOption

use of com.github.javaparser.printer.configuration.DefaultConfigurationOption in project drools by kiegroup.

the class JavaParserCompiler method createPrettyPrinter.

private static DefaultPrettyPrinter createPrettyPrinter() {
    DefaultPrinterConfiguration config = new DefaultPrinterConfiguration();
    config.addOption(new DefaultConfigurationOption(DefaultPrinterConfiguration.ConfigOption.COLUMN_ALIGN_PARAMETERS, true));
    config.addOption(new DefaultConfigurationOption(DefaultPrinterConfiguration.ConfigOption.COLUMN_ALIGN_FIRST_METHOD_CHAIN, true));
    return new DefaultPrettyPrinter(config);
}
Also used : DefaultConfigurationOption(com.github.javaparser.printer.configuration.DefaultConfigurationOption) DefaultPrettyPrinter(com.github.javaparser.printer.DefaultPrettyPrinter) DefaultPrinterConfiguration(com.github.javaparser.printer.configuration.DefaultPrinterConfiguration)

Example 3 with DefaultConfigurationOption

use of com.github.javaparser.printer.configuration.DefaultConfigurationOption in project drools by kiegroup.

the class AbstractDTAnalysisTest method debugAnalysis.

protected static void debugAnalysis(DTAnalysis analysis) {
    if (!LOG.isDebugEnabled()) {
        return;
    }
    StringBuilder sbGaps = new StringBuilder("\nGaps:\n");
    for (Hyperrectangle gap : analysis.getGaps()) {
        sbGaps.append(gap.toString());
        sbGaps.append("\n");
    }
    LOG.debug(sbGaps.toString());
    DefaultPrinterConfiguration printConfig = new DefaultPrinterConfiguration();
    printConfig.addOption(new DefaultConfigurationOption(DefaultPrinterConfiguration.ConfigOption.COLUMN_ALIGN_PARAMETERS, true));
    printConfig.addOption(new DefaultConfigurationOption(DefaultPrinterConfiguration.ConfigOption.COLUMN_ALIGN_FIRST_METHOD_CHAIN, true));
    Expression printGaps = DTAnalysisMeta.printGaps(analysis);
    LOG.debug("\n" + printGaps.toString(printConfig));
    StringBuilder sbOverlaps = new StringBuilder("\nOverlaps:\n");
    for (Overlap overlap : analysis.getOverlaps()) {
        sbOverlaps.append(overlap.toString());
        sbOverlaps.append("\n");
    }
    LOG.debug(sbOverlaps.toString());
    Expression printOverlaps = DTAnalysisMeta.printOverlaps(analysis);
    LOG.debug("\n" + printOverlaps.toString(printConfig));
}
Also used : DefaultConfigurationOption(com.github.javaparser.printer.configuration.DefaultConfigurationOption) Expression(com.github.javaparser.ast.expr.Expression) Hyperrectangle(org.kie.dmn.validation.dtanalysis.model.Hyperrectangle) DefaultPrinterConfiguration(com.github.javaparser.printer.configuration.DefaultPrinterConfiguration) Overlap(org.kie.dmn.validation.dtanalysis.model.Overlap)

Aggregations

DefaultConfigurationOption (com.github.javaparser.printer.configuration.DefaultConfigurationOption)3 Expression (com.github.javaparser.ast.expr.Expression)2 DefaultPrinterConfiguration (com.github.javaparser.printer.configuration.DefaultPrinterConfiguration)2 DefaultPrettyPrinter (com.github.javaparser.printer.DefaultPrettyPrinter)1 ConfigurationOption (com.github.javaparser.printer.configuration.ConfigurationOption)1 DrlxExpression (org.drools.mvel.parser.ast.expr.DrlxExpression)1 ListCreationLiteralExpression (org.drools.mvel.parser.ast.expr.ListCreationLiteralExpression)1 MapCreationLiteralExpression (org.drools.mvel.parser.ast.expr.MapCreationLiteralExpression)1 Hyperrectangle (org.kie.dmn.validation.dtanalysis.model.Hyperrectangle)1 Overlap (org.kie.dmn.validation.dtanalysis.model.Overlap)1