Package com.google.devtools.moe.client.codebase

Examples of com.google.devtools.moe.client.codebase.CodebaseCreationError


    if (options.get("referenceFromCodebase") != null) {
      try {
        refFrom =
            Parser.parseExpression(options.get("referenceFromCodebase")).createCodebase(context);
      } catch (ParseError e) {
        throw new CodebaseCreationError("Couldn't parse referenceFromCodebase '"
            + options.get("referenceFromCodebase") + "': " + e);
      }
      // Discard the "default" reference from-codebase, i.e. the top of the forward-trans stack.
      forwardTranslationStack.pop();
    } else {
View Full Code Here


          "refTo", "Pushing to forward-translation stack: " + options.get("referenceToCodebase"));
      refTo = Parser.parseExpression(options.get("referenceToCodebase")).createCodebase(context);
      forwardTransStack.push(refTo);
      AppContext.RUN.ui.popTaskAndPersist(task, refTo.getPath());
    } catch (ParseError e) {
      throw new CodebaseCreationError("Couldn't parse in translation: " + e);
    }

    // This Expression is used only for informative output.
    Expression forwardEditExp = refTo.getExpression();
    for (TranslatorStep forwardStep : forwardSteps) {
View Full Code Here

  public Codebase createCodebase(ProjectContext context) throws CodebaseCreationError {
    Codebase codebaseToEdit = exToEdit.createCodebase(context);
    String editorName = editOp.term.identifier;
    Editor editor = context.editors.get(editorName);
    if (editor == null) {
      throw new CodebaseCreationError("no editor " + editorName);
    }

    Ui.Task editTask = AppContext.RUN.ui.pushTask(
        "edit",
        "Editing " + codebaseToEdit.getPath() + " with editor " + editor.getDescription());
View Full Code Here

    if (repositoryName.equals("file")) {
      cc = new FileCodebaseCreator();
    } else {
      Repository repo = context.repositories.get(repositoryName);
      if (repo == null) {
        throw new CodebaseCreationError("no repository " + repositoryName);
      }
      cc = repo.codebaseCreator;
    }

    Ui.Task createTask = AppContext.RUN.ui.pushTask(
View Full Code Here

    String toProjectSpace = translateOp.term.identifier;
    TranslatorPath path = new TranslatorPath(
        codebaseToTranslate.getProjectSpace(), toProjectSpace);
    Translator translator = context.translators.get(path);
    if (translator == null) {
      throw new CodebaseCreationError(
          String.format("Could not find translator from project space \"%s\" to \"%s\"",
                        codebaseToTranslate.getProjectSpace(), toProjectSpace));
    }

    Ui.Task translateTask = AppContext.RUN.ui.pushTask(
View Full Code Here

    Utils.checkKeys(options, ImmutableSet.of(PATH_OPTION, PROJECT_SPACE_OPTION));

    // Get the source path to the file/directory described in the options list.
    String source = options.get(PATH_OPTION);
    if (Strings.isNullOrEmpty(source)) {
      throw new CodebaseCreationError(
        String.format("Please specify the mandatory '%s' option for the FileCodebaseCreator",
                      PATH_OPTION));
    }

    // Create the codebase instance.
View Full Code Here

   * @throws CodebaseCreationError
   */
  public static File getCodebasePath(File sourceFile) throws CodebaseCreationError {
    // Check whether the specified path is valid.
    if (!AppContext.RUN.fileSystem.exists(sourceFile)) {
      throw new CodebaseCreationError(
            String.format("The specified codebase path \"%s\" does not exist.", sourceFile));
    }

    try {
      // Get the target path based upon whether we are dealing with a directory or a file.
      if (AppContext.RUN.fileSystem.isDirectory(sourceFile)) {
        // If it is a directory, make a copy and return the path of the copy.
        File destFile = AppContext.RUN.fileSystem.getTemporaryDirectory("file_codebase_copy_");
        Utils.copyDirectory(sourceFile, destFile);
        return destFile;
      } else if (AppContext.RUN.fileSystem.isFile(sourceFile)) {
        // If it is a file, assume that it is an archive and try to extract it.
        File extractedArchive = Utils.expandToDirectory(sourceFile);
        if (extractedArchive != null) {
          return extractedArchive;
        }
      }
    } catch (CommandException exception) {
      throw new CodebaseCreationError(
        String.format("Could not extract archive: '%s' %s", sourceFile, exception.getMessage()));
    } catch (IOException exception) {
      throw new CodebaseCreationError(
        String.format("Could not extract archive '%s': %s", sourceFile, exception.getMessage()));
    }

    // If we did not return a codebase-path by now, we have no way of handling it.
    throw new CodebaseCreationError(
        String.format("The '%s'-option of a FileCodebaseCreator must specify either a directory " +
                    "or a .tar/.tar.gz-archive", PATH_OPTION));
  }
View Full Code Here

TOP

Related Classes of com.google.devtools.moe.client.codebase.CodebaseCreationError

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.