Beispiel #1
0
  private boolean processingSingleFile(final File f) throws IOException, InterruptedException {
    if (OptionFlags.getInstance().isVerbose()) {
      this.log("Processing " + f.getAbsolutePath());
    }
    final SourceFileReader sourceFileReader =
        new SourceFileReader(
            new Defines(),
            f,
            option.getOutputDir(),
            option.getConfig(),
            option.getCharset(),
            option.getFileFormatOption());

    if (option.isCheckOnly()) {
      return sourceFileReader.hasError();
    }
    if (executorService == null) {
      return doFile(f, sourceFileReader);
    }

    executorService.submit(
        new Callable<Boolean>() {
          public Boolean call() throws Exception {
            return doFile(f, sourceFileReader);
          }
        });

    return false;
  }
Beispiel #2
0
 public void setFormat(String s) {
   if ("xmi".equalsIgnoreCase(s)) {
     option.setFileFormat(FileFormat.XMI_STANDARD);
   }
   if ("xmi:argo".equalsIgnoreCase(s)) {
     option.setFileFormat(FileFormat.XMI_ARGO);
   }
   if ("xmi:start".equalsIgnoreCase(s)) {
     option.setFileFormat(FileFormat.XMI_STAR);
   }
   if ("eps".equalsIgnoreCase(s)) {
     option.setFileFormat(FileFormat.EPS);
   }
   if ("pdf".equalsIgnoreCase(s)) {
     option.setFileFormat(FileFormat.PDF);
   }
   if ("latex".equalsIgnoreCase(s)) {
     option.setFileFormat(FileFormat.LATEX);
   }
   if ("eps:text".equalsIgnoreCase(s)) {
     option.setFileFormat(FileFormat.EPS_TEXT);
   }
   if ("svg".equalsIgnoreCase(s)) {
     option.setFileFormat(FileFormat.SVG);
   }
   if ("txt".equalsIgnoreCase(s)) {
     option.setFileFormat(FileFormat.ATXT);
   }
   if ("utxt".equalsIgnoreCase(s)) {
     option.setFileFormat(FileFormat.UTXT);
   }
 }
Beispiel #3
0
 public void setNbThread(String s) {
   if (s != null && s.matches("\\d+")) {
     option.setNbThreads(Integer.parseInt(s));
     final int nbThreads = option.getNbThreads();
     this.executorService = Executors.newFixedThreadPool(nbThreads);
   }
   if ("auto".equalsIgnoreCase(s)) {
     option.setNbThreads(Option.defaultNbThreads());
     final int nbThreads = option.getNbThreads();
     this.executorService = Executors.newFixedThreadPool(nbThreads);
   }
 }
Beispiel #4
0
 public void setConfig(String s) {
   try {
     option.initConfig(s);
   } catch (IOException e) {
     log("Error reading " + s);
   }
 }
Beispiel #5
0
  private String getRegexpPattern(String ext) {
    final Pattern p = Pattern.compile("\\w+");
    final Matcher m = p.matcher(ext);
    final StringBuilder filePattern = new StringBuilder("(?i)^.*\\.(");

    while (m.find()) {
      final String value = m.group();
      if (filePattern.toString().endsWith("(") == false) {
        filePattern.append("|");
      }
      filePattern.append(value);
    }
    if (filePattern.toString().endsWith("(") == false) {
      filePattern.append(")$");
      return filePattern.toString();
    }
    return Option.getPattern();
  }
Beispiel #6
0
 private boolean doFile(final File f, final SourceFileReader sourceFileReader)
     throws IOException, InterruptedException {
   final Collection<GeneratedImage> result = sourceFileReader.getGeneratedImages();
   boolean error = false;
   for (GeneratedImage g : result) {
     if (OptionFlags.getInstance().isVerbose()) {
       myLog(g + " " + g.getDescription());
     }
     nbFiles.addAndGet(1);
     if (g.lineErrorRaw() != -1) {
       error = true;
     }
   }
   if (error) {
     myLog("Error: " + f.getCanonicalPath());
   }
   if (error && option.isFailfastOrFailfast2()) {
     return true;
   }
   return false;
 }
Beispiel #7
0
 public void setCheckOnly(String s) {
   final boolean flag =
       "true".equalsIgnoreCase(s) || "yes".equalsIgnoreCase(s) || "on".equalsIgnoreCase(s);
   option.setCheckOnly(flag);
 }
Beispiel #8
0
 public void setFailFast2(String s) {
   final boolean flag =
       "true".equalsIgnoreCase(s) || "yes".equalsIgnoreCase(s) || "on".equalsIgnoreCase(s);
   option.setFailfast2(flag);
 }
Beispiel #9
0
 public void setCharset(String s) {
   option.setCharset(s);
 }
Beispiel #10
0
 public void setOutput(String s) {
   option.setOutputDir(new File(s));
 }
Beispiel #11
0
 private boolean fileToProcess(String name) {
   return name.matches(Option.getPattern());
 }
Beispiel #12
0
 private void eventuallyFailfast(final File error) throws IOException {
   if (error != null && option.isFailfastOrFailfast2()) {
     this.log("Error in file " + error.getCanonicalPath());
     throw new BuildException("Error in file " + error.getCanonicalPath());
   }
 }