use of org.eclipse.xtext.ui.refactoring2.ReplaceFileContentChange in project xtext-eclipse by eclipse.
the class ChangeConverter method _handleReplacements.
protected void _handleReplacements(final IEmfResourceChange change) {
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
final Procedure0 _function = () -> {
try {
final IFile file = this.resourceUriConverter.toFile(change.getResource().getURI());
boolean _canWrite = this.canWrite(file);
boolean _not = (!_canWrite);
if (_not) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("Affected file \'");
IPath _fullPath = file.getFullPath();
_builder.append(_fullPath);
_builder.append("\' is read-only");
this.issues.add(RefactoringIssueAcceptor.Severity.ERROR, _builder.toString());
}
this.checkDerived(file);
change.getResource().save(outputStream, null);
final byte[] newContent = outputStream.toByteArray();
String _lastSegment = change.getOldURI().lastSegment();
final ReplaceFileContentChange ltkChange = new ReplaceFileContentChange(_lastSegment, file, newContent);
this.addChange(ltkChange);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
};
TryWithResource.tryWith(outputStream, _function);
}
Aggregations