Ejemplo n.º 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;
  }
Ejemplo n.º 2
0
 public void define(String name, String value) {
   values.put(name, value);
   if (name.equalsIgnoreCase("graphviz_dot")) {
     OptionFlags.getInstance()
         .setDotExecutable(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(value));
   }
 }
Ejemplo n.º 3
0
 private void addSimpleDirectory(File dir) {
   if (OptionFlags.getInstance().isWord()) {
     addSimpleDirectory(dir, "(?i)^.*_extr\\d+\\.txt$");
   } else {
     addSimpleDirectory(dir, option.getPattern());
   }
 }
Ejemplo n.º 4
0
 private AbstractPSystem executeOneLine(
     AbstractPSystem sys, UmlSource source, final IteratorCounter2 it) {
   final CommandControl commandControl = isValid2(it);
   if (commandControl == CommandControl.NOT_OK) {
     final ErrorUml err =
         new ErrorUml(
             ErrorUmlType.SYNTAX_ERROR, "Syntax Error?", it.currentNum(), it.peek().getLocation());
     if (OptionFlags.getInstance().isUseSuggestEngine()) {
       final SuggestEngine engine = new SuggestEngine(source, this);
       final SuggestEngineResult result = engine.tryToSuggest(sys);
       if (result.getStatus() == SuggestEngineStatus.ONE_SUGGESTION) {
         err.setSuggest(result);
       }
     }
     sys = new PSystemError(source, err, null);
   } else if (commandControl == CommandControl.OK_PARTIAL) {
     final IteratorCounter2 saved = it.cloneMe();
     final CommandExecutionResult result = manageMultiline2(it, sys);
     if (result.isOk() == false) {
       sys =
           new PSystemError(
               source,
               new ErrorUml(
                   ErrorUmlType.EXECUTION_ERROR,
                   result.getError(),
                   it.currentNum() - 1,
                   saved.next().getLocation()),
               null);
     }
   } else if (commandControl == CommandControl.OK) {
     final CharSequence line = it.next();
     final BlocLines lines = BlocLines.single(line);
     Command cmd = getFirstCommandOkForLines(lines);
     final CommandExecutionResult result = sys.executeCommand(cmd, lines);
     if (result.isOk() == false) {
       sys =
           new PSystemError(
               source,
               new ErrorUml(
                   ErrorUmlType.EXECUTION_ERROR,
                   result.getError(),
                   it.currentNum() - 1,
                   ((CharSequence2) line).getLocation()),
               result.getDebugLines());
     }
     if (result.getNewDiagram() != null) {
       sys = result.getNewDiagram();
     }
   } else {
     assert false;
   }
   return sys;
 }
Ejemplo n.º 5
0
  public final PSystem createPSystem(final List<String> strings)
      throws IOException, InterruptedException {

    final List<PSystemFactory> factories = new ArrayList<PSystemFactory>();
    factories.add(new SequenceDiagramFactory());
    factories.add(new ClassDiagramFactory());
    factories.add(new ActivityDiagramFactory());
    factories.add(new ActivityDiagramFactory2());
    factories.add(new UsecaseDiagramFactory());
    factories.add(new ComponentDiagramFactory());
    factories.add(new StateDiagramFactory());
    factories.add(new ActivityDiagramFactory2());
    factories.add(new CompositeDiagramFactory());
    factories.add(new ObjectDiagramFactory());
    factories.add(new PostIdDiagramFactory());
    factories.add(new PrintSkinFactory());
    factories.add(new PSystemVersionFactory());
    factories.add(new PSystemDotFactory(DiagramType.DOT));
    factories.add(new PSystemDotFactory(DiagramType.UML));
    factories.add(new PSystemDitaaFactory(DiagramType.DITAA));
    factories.add(new PSystemDitaaFactory(DiagramType.UML));
    factories.add(new PSystemSudokuFactory());
    factories.add(new PSystemEggFactory());
    factories.add(new PSystemRIPFactory());
    factories.add(new PSystemLostFactory());
    factories.add(new PSystemPathFactory());
    factories.add(new PSystemOregonFactory());
    factories.add(new PSystemProjectFactory());

    final UmlSource umlSource = new UmlSource(strings);
    final DiagramType diagramType = umlSource.getDiagramType();
    final List<PSystemError> errors = new ArrayList<PSystemError>();
    for (PSystemFactory systemFactory : factories) {
      if (diagramType != systemFactory.getDiagramType()) {
        continue;
      }
      final PSystem sys = new PSystemSingleBuilder(umlSource, systemFactory).getPSystem();
      if (isOk(sys)) {
        return sys;
      }
      errors.add((PSystemError) sys);
    }

    final PSystemError err = merge(errors);
    if (OptionFlags.getInstance().isQuiet() == false) {
      err.print(System.err);
    }
    return err;
  }
Ejemplo n.º 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;
 }
Ejemplo n.º 7
0
 public void setOverwrite(String s) {
   final boolean flag =
       "true".equalsIgnoreCase(s) || "yes".equalsIgnoreCase(s) || "on".equalsIgnoreCase(s);
   OptionFlags.getInstance().setOverwrite(flag);
 }
Ejemplo n.º 8
0
 public void setSuggestEngine(String s) {
   OptionFlags.getInstance()
       .setUseSuggestEngine(
           "true".equalsIgnoreCase(s) || "yes".equalsIgnoreCase(s) || "on".equalsIgnoreCase(s));
 }
Ejemplo n.º 9
0
 public void setGraphvizDot(String s) {
   OptionFlags.getInstance().setDotExecutable(s);
 }
Ejemplo n.º 10
0
 public void setVerbose(String s) {
   if ("true".equalsIgnoreCase(s)) {
     OptionFlags.getInstance().setVerbose(true);
   }
 }
Ejemplo n.º 11
0
 public void setKeepTmpFiles(String s) {
   if ("true".equalsIgnoreCase(s)) {
     OptionFlags.getInstance().setKeepTmpFiles(true);
   }
 }
Ejemplo n.º 12
0
 private static void exit() throws InterruptedException {
   if (OptionFlags.getInstance().isSystemExit()) {
     System.exit(0);
   }
   throw new InterruptedException("exit");
 }