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; }
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); } }
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); } }
public void setConfig(String s) { try { option.initConfig(s); } catch (IOException e) { log("Error reading " + s); } }
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(); }
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; }
public void setCheckOnly(String s) { final boolean flag = "true".equalsIgnoreCase(s) || "yes".equalsIgnoreCase(s) || "on".equalsIgnoreCase(s); option.setCheckOnly(flag); }
public void setFailFast2(String s) { final boolean flag = "true".equalsIgnoreCase(s) || "yes".equalsIgnoreCase(s) || "on".equalsIgnoreCase(s); option.setFailfast2(flag); }
public void setCharset(String s) { option.setCharset(s); }
public void setOutput(String s) { option.setOutputDir(new File(s)); }
private boolean fileToProcess(String name) { return name.matches(Option.getPattern()); }
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()); } }