Package com.google.devtools.moe.client.editors

Examples of com.google.devtools.moe.client.editors.Editor


  @Override
  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());

    Codebase editedCodebase = editor.edit(codebaseToEdit, context, editOp.term.options);

    AppContext.RUN.ui.popTaskAndPersist(editTask, editedCodebase.getPath());
    return editedCodebase.copyWithExpression(this);
  }
View Full Code Here


  }

  public void testParseAndEvaluate() throws Exception {
    IMocksControl control = EasyMock.createControl();
    CodebaseCreator cc = control.createMock(CodebaseCreator.class);
    Editor e = control.createMock(Editor.class);
    Editor translatorEditor = control.createMock(Editor.class);

    File firstDir = new File("/first");
    File secondDir = new File("/second");
    File finalDir = new File("/final");

    TranslatorPath tPath = new TranslatorPath("foo", "public");
    Translator t = new ForwardTranslator(ImmutableList.<TranslatorStep>of(
        new TranslatorStep("quux", translatorEditor)));
   
    ProjectContext context = ProjectContext.builder()
        .withRepositories(ImmutableMap.of("foo", new Repository("foo", null, cc, null)))
        .withTranslators(ImmutableMap.of(tPath, t))
        .withEditors(ImmutableMap.of("bar", e)).build();

    Codebase firstCb = new Codebase(new File("/first"), "foo",
        new RepositoryExpression(new Term("foo", EMPTY_MAP)));
   
    Codebase secondCb = new Codebase(new File("/second"), "public",
        new RepositoryExpression(new Term("foo2", EMPTY_MAP)));
   
    Codebase finalCb = new Codebase(new File("/final"), "public",
        new RepositoryExpression(new Term("foo3", EMPTY_MAP)));

    expect(cc.create(EMPTY_MAP)).andReturn(firstCb);
    expect(translatorEditor.edit(firstCb, context, EMPTY_MAP)).andReturn(secondCb);
    expect(e.getDescription()).andReturn("");
    expect(e.edit(secondCb, context, EMPTY_MAP)).andReturn(finalCb);

    control.replay();
    Codebase c = Parser.parseExpression("foo>public|bar").createCodebase(context);
View Full Code Here

TOP

Related Classes of com.google.devtools.moe.client.editors.Editor

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.