コード例 #1
0
  public void visitFunctionDescr(final FunctionDescr functionDescr) {
    this.template = new String();
    final String parameterTemplate =
        processParameters(functionDescr.getParameterNames(), functionDescr.getParameterTypes());

    this.template =
        "<function return-type=\""
            + functionDescr.getReturnType()
            + "\" name=\""
            + functionDescr.getName()
            + "\">"
            + XmlDumper.eol
            + parameterTemplate
            + "<body>"
            + XmlDumper.eol
            + functionDescr.getText()
            + XmlDumper.eol
            + "</body>"
            + XmlDumper.eol
            + "</function>"
            + XmlDumper.eol;
  }
コード例 #2
0
ファイル: ClipsShell.java プロジェクト: ryanzhang/drools
  public void functionHandler(FunctionDescr functionDescr) {
    // for now all functions are in MAIN
    // setModuleName( functionDescr );
    functionDescr.setNamespace("MAIN");
    Appendable builder = new StringBuilderAppendable();

    // strip lead/trailing quotes
    String name = functionDescr.getName().trim();
    if (name.charAt(0) == '"') {
      name = name.substring(1);
    }

    if (name.charAt(name.length() - 1) == '"') {
      name = name.substring(0, name.length() - 1);
    }
    builder.append("function " + name + "(");

    for (int i = 0, length = functionDescr.getParameterNames().size(); i < length; i++) {
      builder.append(functionDescr.getParameterNames().get(i));
      if (i < length - 1) {
        builder.append(", ");
      }
    }

    builder.append(") {\n");
    // TODO: fix this
    //        List list = (List) functionDescr.getBody();
    //        for ( Iterator it = list.iterator(); it.hasNext(); ) {
    //            FunctionHandlers.dump( (LispForm) it.next(),
    //                                   builder,
    //                                   true );
    //        }
    builder.append("}");

    System.out.println("mvel expr:" + builder.toString());

    functionDescr.setText(builder.toString());
    functionDescr.setDialect("clips");

    PackageDescr pkgDescr = createPackageDescr(functionDescr.getNamespace());
    pkgDescr.addFunction(functionDescr);

    this.packageBuilder.addPackage(pkgDescr);
  }
コード例 #3
0
ファイル: FunctionError.java プロジェクト: rapidan/droolsjbpm
 private String createMessage(String message) {
   StringBuilder detail = new StringBuilder();
   if (object instanceof CompilationProblem[]) {
     CompilationProblem[] cp = (CompilationProblem[]) object;
     this.errorLines = new int[cp.length];
     for (int i = 0; i < cp.length; i++) {
       this.errorLines[i] =
           cp[i].getStartLine()
               - this.functionDescr.getOffset()
               + this.getFunctionDescr().getLine()
               - 1;
       detail.append(this.functionDescr.getName());
       detail.append(" (line:");
       detail.append(this.errorLines[i]);
       detail.append("): ");
       detail.append(cp[i].getMessage());
       detail.append("\n");
     }
   } else {
     this.errorLines = new int[0];
   }
   return "[ " + functionDescr.getName() + " : " + message + "\n" + detail.toString() + " ]";
 }