Exemplo n.º 1
0
  protected void renameFooToFooBar(final XtextEditor contextEditor) throws Exception {
    contextEditor.getEditorSite().getPage().activate(contextEditor);
    waitForDisplay();
    IXtextDocument document = contextEditor.getDocument();
    final int offset = document.get().indexOf("foo");
    contextEditor.selectAndReveal(offset, 3);

    EvaluationContext evaluationContext = new EvaluationContext(null, new Object());
    evaluationContext.addVariable(ISources.ACTIVE_EDITOR_NAME, contextEditor);
    ExecutionEvent executionEvent = new ExecutionEvent(null, newHashMap(), null, evaluationContext);
    renameElementHandler.execute(executionEvent);
    //		syncUtil.totalSync(refactoringPreferences.isSaveAllBeforeRefactoring());
    //		IRenameElementContext context = document.readOnly(new IUnitOfWork<IRenameElementContext,
    // XtextResource>() {
    //			public IRenameElementContext exec(XtextResource state) throws Exception {
    //				EObject target = eObjectAtOffsetHelper.resolveElementAt(state, offset);
    //				return renameContextFactory.createRenameElementContext(target, contextEditor, new
    // TextSelection(offset,
    //						3), state);
    //			}
    //		});
    //		controller.initialize(context);
    //		waitForDisplay();
    //		controller.startRefactoring(RefactoringType.LINKED_EDITING);
    //		waitForDisplay();
    pressKeys(contextEditor, "fooBar\n");
    waitForDisplay();
    waitForReconciler(fooEditor);
    waitForReconciler(barEditor);
    waitForDisplay();
  }