use of org.eclipse.ltk.core.refactoring.TextFileChange in project jbosstools-hibernate by jbosstools.
the class HibernateJPARefactoring method createChange.
@Override
public Change createChange(IProgressMonitor pm) {
// $NON-NLS-1$
final CompositeChange cc = new CompositeChange("");
for (int i = 0; i < changes.size(); i++) {
ChangeStructure cs = changes.get(i);
final String change_name = cs.path.toString();
TextFileChange change = new TextFileChange(change_name, (IFile) cs.icu.getResource());
change.setSaveMode(TextFileChange.LEAVE_DIRTY);
change.setEdit(cs.textEdit);
cs.change = change;
cc.add(change);
}
cc.markAsSynthetic();
return cc;
}
use of org.eclipse.ltk.core.refactoring.TextFileChange in project erlide_eclipse by erlang.
the class ChangedFile method createChanges.
/**
* Creates <code>Change</code> objects from the original and the modified source.
*
* @return the created <code>Change</code> object which typically instance of
* <code>TextFileChange</code>
* @throws IOException
* if an exception occurs while accessing the source file
*/
public Change createChanges(final IFile file) throws IOException {
IFile eclipseRep;
if (file == null) {
eclipseRep = findEclipseRepresentation(oldPath);
} else {
eclipseRep = file;
}
final TextFileChange change = new TextFileChange(oldPath, eclipseRep);
// change.setSaveMode(TextFileChange.FORCE_SAVE);
final File tf = new File(oldPath);
final List<TextEdit> edits = ChangesetMaker.createEdits(tf, newFileContent);
final MultiTextEdit multiEdit = new MultiTextEdit();
if (!edits.isEmpty()) {
for (final TextEdit edit : edits) {
multiEdit.addChild(edit);
}
change.setEdit(multiEdit);
return change;
}
return null;
}
Aggregations