示例#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();
  }
示例#2
0
 protected void smudge(ITextEditor... editors) throws BadLocationException {
   for (ITextEditor editor : editors) {
     IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
     document.replace(document.getLength(), 0, " ");
     if (editor instanceof XtextEditor) {
       waitForReconciler((XtextEditor) editor);
     }
     waitForDisplay();
     assertTrue(editor.isDirty());
   }
 }