use of org.eclipse.ltk.internal.core.refactoring.RefactoringSessionTransformer in project che by eclipse.
the class RefactoringHistoryManager method transformDescriptor.
/**
* Transforms the specified refactoring descriptor into a DOM node.
*
* @param descriptor
* the descriptor to transform
* @param projects
* <code>true</code> to include project information,
* <code>false</code> otherwise
* @return the DOM node representing the refactoring descriptor
* @throws CoreException
* if an error occurs while transforming the descriptor
*/
private static Document transformDescriptor(final RefactoringDescriptor descriptor, final boolean projects) throws CoreException {
final RefactoringSessionTransformer transformer = new RefactoringSessionTransformer(projects);
try {
transformer.beginSession(null, IRefactoringSerializationConstants.CURRENT_VERSION);
try {
final String id = descriptor.getID();
transformer.beginRefactoring(id, descriptor.getTimeStamp(), descriptor.getProject(), descriptor.getDescription(), descriptor.getComment(), descriptor.getFlags());
final Map arguments = getArgumentMap(descriptor);
if (arguments != null) {
checkArgumentMap(arguments);
for (final Iterator iterator = arguments.entrySet().iterator(); iterator.hasNext(); ) {
final Map.Entry entry = (Entry) iterator.next();
transformer.createArgument((String) entry.getKey(), (String) entry.getValue());
}
}
} finally {
transformer.endRefactoring();
}
} finally {
transformer.endSession();
}
return transformer.getResult();
}
use of org.eclipse.ltk.internal.core.refactoring.RefactoringSessionTransformer in project che by eclipse.
the class RefactoringHistoryManager method writeRefactoringSession.
/**
* Writes refactoring session descriptor to the specified output stream.
*
* @param stream
* the output stream where to write to
* @param descriptor
* the refactoring session descriptors to write
* @param stamps
* <code>true</code> to write time stamps as well,
* <code>false</code> otherwise
* @throws CoreException
* if an error occurs while writing the refactoring session
* descriptor
*/
public static void writeRefactoringSession(final OutputStream stream, final RefactoringSessionDescriptor descriptor, final boolean stamps) throws CoreException {
final RefactoringSessionTransformer transformer = new RefactoringSessionTransformer(true);
final RefactoringDescriptor[] descriptors = descriptor.getRefactorings();
try {
transformer.beginSession(descriptor.getComment(), descriptor.getVersion());
for (int index = 0; index < descriptors.length; index++) {
final RefactoringDescriptor current = descriptors[index];
if (current != null) {
try {
long stamp = stamps ? current.getTimeStamp() : -1;
transformer.beginRefactoring(current.getID(), stamp, current.getProject(), current.getDescription(), current.getComment(), current.getFlags());
final Map arguments = getArgumentMap(current);
if (arguments != null) {
checkArgumentMap(arguments);
for (final Iterator iterator = arguments.entrySet().iterator(); iterator.hasNext(); ) {
final Map.Entry entry = (Entry) iterator.next();
transformer.createArgument((String) entry.getKey(), (String) entry.getValue());
}
}
} finally {
transformer.endRefactoring();
}
}
}
} finally {
transformer.endSession();
}
final Document result = transformer.getResult();
writeNode(stream, result);
}
Aggregations