use of org.eclipse.xtext.ui.refactoring.impl.DefaultRefactoringDocumentProvider.EditorDocument in project xtext-eclipse by eclipse.
the class RefactoringDocumentProviderTest method testCleanEditorDocument.
@Test
public void testCleanEditorDocument() throws Exception {
XtextEditor editor = openEditor(testFile);
assertFalse(editor.isDirty());
IRefactoringDocument cleanDocument = createAndCheckDocument(testFile);
assertTrue(cleanDocument instanceof EditorDocument);
IXtextDocument editorDocument = editor.getDocument();
assertEquals(editorDocument, ((EditorDocument) cleanDocument).getDocument());
assertEquals(TEST_FILE_CONTENT, cleanDocument.getOriginalContents());
Change change = cleanDocument.createChange(CHANGE_NAME, textEdit);
assertTrue(change instanceof EditorDocumentChange);
assertEquals(TEST_FILE_NAME + " - " + TEST_PROJECT, change.getName());
assertEquals(editor, ((EditorDocumentChange) change).getEditor());
assertTrue(((EditorDocumentChange) change).isDoSave());
Change undoChange = checkEdit(cleanDocument, textEdit);
assertNotNull(undoChange);
IRefactoringDocument dirtyDocument = createAndCheckDocument(testFile);
assertTrue(cleanDocument instanceof EditorDocument);
assertEquals(editorDocument, ((EditorDocument) dirtyDocument).getDocument());
}
use of org.eclipse.xtext.ui.refactoring.impl.DefaultRefactoringDocumentProvider.EditorDocument in project xtext-eclipse by eclipse.
the class RefactoringDocumentProviderTest method testDirtyEditorDocument.
@Test
public void testDirtyEditorDocument() throws Exception {
XtextEditor editor = openEditor(testFile);
editor.getDocument().replace(0, 0, " ");
editor.getDocument().replace(0, 1, "");
assertTrue(editor.isDirty());
IRefactoringDocument cleanDocument = createAndCheckDocument(testFile);
assertTrue(cleanDocument instanceof EditorDocument);
IXtextDocument editorDocument = editor.getDocument();
assertEquals(editorDocument, ((EditorDocument) cleanDocument).getDocument());
assertEquals(TEST_FILE_CONTENT, cleanDocument.getOriginalContents());
Change change = cleanDocument.createChange(CHANGE_NAME, textEdit);
assertTrue(change instanceof EditorDocumentChange);
assertEquals(TEST_FILE_NAME + " - " + TEST_PROJECT, change.getName());
assertEquals(editor, ((EditorDocumentChange) change).getEditor());
assertFalse(((EditorDocumentChange) change).isDoSave());
Change undoChange = checkEdit(cleanDocument, textEdit);
assertNotNull(undoChange);
IRefactoringDocument dirtyDocument = createAndCheckDocument(testFile);
assertTrue(cleanDocument instanceof EditorDocument);
assertEquals(editorDocument, ((EditorDocument) dirtyDocument).getDocument());
}
Aggregations