void report(IvyXmlWriter xw) {
   xw.begin("COVERAGE");
   for (MethodCountData mcd : method_data.values()) {
     mcd.report(xw);
   }
   xw.end("COVERAGE");
 }
 /** ***************************************************************************** */
 void saveProject() {
   try {
     File f1 = new File(base_directory, ".pyproject");
     IvyXmlWriter xw = new IvyXmlWriter(f1);
     outputXml(xw);
     xw.close();
   } catch (IOException e) {
     PybaseMain.logE("Problem writing project file", e);
   }
 }
  /** ***************************************************************************** */
  private void loadFiles(String pfx, File dir, boolean reload) {
    File[] fls = dir.listFiles(new SourceFilter());

    if (fls != null) {
      for (File f : fls) {
        if (f.isDirectory()) {
          String nm = f.getName();
          String opfx = pfx;
          if (pfx == null) pfx = nm;
          else pfx += "." + nm;
          loadFiles(pfx, f, reload);
          pfx = opfx;
        } else {
          String mnm = f.getName();
          int idx = mnm.lastIndexOf(".");
          if (idx >= 0) mnm = mnm.substring(0, idx);
          if (pfx != null) mnm = pfx + "." + mnm;
          IFileData fd = PybaseFileManager.getFileManager().getNewFileData(f, mnm, this);
          ISemanticData isd = parse_data.get(fd);
          if (reload) {
            // fd.reload();
            isd = null;
          }
          all_files.add(fd);
          if (isd == null) {
            ISemanticData sd = parseFile(fd);
            if (sd != null) {
              System.err.println("PYBASE: PARSE YIELDS: " + sd.getRootNode());
              IvyXmlWriter xw = PybaseMain.getPybaseMain().beginMessage("FILEERROR");
              xw.field("PROJECT", sd.getProject().getName());
              xw.field("FILE", fd.getFile().getPath());
              xw.begin("MESSAGES");
              for (PybaseMessage m : sd.getMessages()) {
                try {
                  System.err.println("PYBASE: PARSE ERROR: " + m);
                  PybaseUtil.outputProblem(m, sd, xw);
                } catch (Throwable t) {
                  PybaseMain.logE("Pybase error message: ", t);
                }
              }
              xw.end("MESSAGES");
              PybaseMain.getPybaseMain().finishMessage(xw);
            }
          }
        }
      }
    }
  }
 void outputXml(IvyXmlWriter xw) {
   xw.begin("PROJECT");
   xw.field("NAME", project_name);
   xw.field("BASE", base_directory.getPath());
   if (python_interpreter != null) {
     xw.textElement("EXE", python_interpreter.getExecutable().getPath());
   }
   for (IPathSpec ps : project_paths) {
     ps.outputXml(xw);
   }
   for (IFileSpec fs : project_files) {
     fs.outputXml(xw);
   }
   pybase_prefs.outputXml(xw, false);
   xw.end("PROJECT");
 }
 private void outputDelta(IvyXmlWriter xw, String act, IFileData ifd) {
   xw.begin("DELTA");
   xw.field("KIND", act);
   xw.begin("RESOURCE");
   xw.field("TYPE", "FILE");
   xw.field("PROJECT", project_name);
   xw.field("LOCATION", ifd.getFile().getAbsolutePath());
   xw.end("RESOURCE");
   xw.end("DELTA");
 }
 void report(IvyXmlWriter xw) {
   xw.begin("BLOCK");
   xw.field("ID", block_index);
   xw.field("START", start_line);
   xw.field("END", end_line);
   xw.field("COUNT", enter_count);
   for (Map.Entry<Integer, Integer> ent : branch_counts.entrySet()) {
     xw.begin("BRANCH");
     xw.field("TOBLOCK", ent.getKey());
     xw.field("COUNT", ent.getValue());
     xw.end("BRANCH");
   }
   xw.end("BLOCK");
 }
 void report(IvyXmlWriter xw) {
   xw.begin("METHOD");
   xw.field("NAME", method_name);
   xw.field("START", start_line);
   xw.field("END", end_line);
   xw.field("COUNT", called_count);
   xw.field("TOP", top_count);
   for (Map.Entry<String, Integer> ent : calls_counts.entrySet()) {
     xw.begin("CALLS");
     xw.field("NAME", ent.getKey());
     xw.field("COUNT", ent.getValue());
     xw.end("CALLS");
   }
   for (BlockCountData bcd : block_data.values()) {
     bcd.report(xw);
   }
   xw.end("METHOD");
 }
  /** ***************************************************************************** */
  void createModule(String name, String cnts, IvyXmlWriter xw) throws PybaseException {
    File fil = findModuleFile(name);

    try {
      FileWriter fw = new FileWriter(fil);
      fw.write(cnts);
      fw.close();
    } catch (IOException e) {
      throw new PybaseException("Problem writing new module code", e);
    }

    if (xw != null) {
      xw.begin("FILE");
      xw.field("PATH", fil.getAbsolutePath());
      xw.end();
    }

    build(true, false);
  }
 /** ***************************************************************************** */
 synchronized void shortReport(IvyXmlWriter xw) {
   xw.begin("TEST");
   xw.field("NAME", test_name);
   xw.field("STATUS", test_status);
   xw.field("STATE", test_state);
   xw.field("CLASS", class_name);
   if (test_class != null) xw.field("TCLASS", test_class);
   xw.field("METHOD", method_name);
   xw.end("TEST");
 }
  void outputProject(boolean files, boolean paths, boolean clss, boolean opts, IvyXmlWriter xw) {
    if (xw == null) return;

    xw.begin("PROJECT");
    xw.field("NAME", project_name);
    xw.field("PATH", base_directory.getPath());
    xw.field("WORKSPACE", project_manager.getWorkSpaceDirectory().getPath());
    if (python_interpreter != null) {
      xw.textElement("EXE", python_interpreter.getExecutable().getPath());
    }

    if (paths) {
      for (IPathSpec ps : project_paths) {
        ps.outputXml(xw);
      }
    }
    if (files) {
      for (IFileSpec fs : project_files) {
        fs.outputXml(xw);
      }
    }

    if (opts) pybase_prefs.outputXml(xw, true);

    xw.end("PROJECT");
  }
  synchronized void longReport(IvyXmlWriter xw) {
    xw.begin("TEST");
    xw.field("NAME", test_name);
    xw.field("STATUS", test_status);
    xw.field("STATE", test_state);
    xw.field("CLASS", class_name);
    if (test_class != null) xw.field("TCLASS", test_class);
    xw.field("METHOD", method_name);

    if (fail_message != null) {
      xw.cdataElement("EXCEPTION", fail_message);
      xw.cdataElement("TRACE", fail_trace);
    }

    if (count_data != null) count_data.report(xw);

    for (String s : annotation_types) {
      xw.textElement("ANNOT", s);
    }

    xw.end("TEST");
  }
  /** ***************************************************************************** */
  void findPackage(String name, IvyXmlWriter xw) {
    File dir = null;
    String[] comps = name.split("\\.");
    for (IPathSpec ps : project_paths) {
      if (!ps.isUser()) continue;
      File f = ps.getOSFile(base_directory);
      if (!f.exists()) continue;
      for (int i = 0; i < comps.length; ++i) {
        f = new File(f, comps[i]);
      }
      if (f.exists()) {
        dir = new File(f, comps[comps.length - 1]);
        break;
      }
    }

    if (dir != null && xw != null) {
      xw.begin("PACKAGE");
      xw.field("NAME", name);
      xw.field("PATH", dir.getAbsolutePath());
      xw.end("PACKAGE");
    }
  }