use of org.eclipse.ltk.core.refactoring.RefactoringDescriptor in project che by eclipse.
the class RefactoringHistoryService method writeRefactoringDescriptors.
/**
* {@inheritDoc}
*/
public void writeRefactoringDescriptors(final RefactoringDescriptorProxy[] proxies, final OutputStream stream, final int flags, final boolean time, IProgressMonitor monitor) throws CoreException {
Assert.isNotNull(proxies);
Assert.isNotNull(stream);
Assert.isTrue(flags >= RefactoringDescriptor.NONE);
if (monitor == null)
monitor = new NullProgressMonitor();
try {
//$NON-NLS-1$
monitor.beginTask("", 100 * proxies.length);
connect();
final List list = new ArrayList(proxies.length);
for (int index = 0; index < proxies.length; index++) {
final RefactoringDescriptor descriptor = proxies[index].requestDescriptor(new SubProgressMonitor(monitor, 100));
if (descriptor != null) {
final int current = descriptor.getFlags();
if ((current | flags) == current)
list.add(descriptor);
}
}
final RefactoringDescriptor[] descriptors = new RefactoringDescriptor[list.size()];
list.toArray(descriptors);
RefactoringHistoryManager.writeRefactoringSession(stream, new RefactoringSessionDescriptor(descriptors, IRefactoringSerializationConstants.CURRENT_VERSION, null), time);
} finally {
disconnect();
}
}
use of org.eclipse.ltk.core.refactoring.RefactoringDescriptor in project che by eclipse.
the class RefactoringHistoryManager method readRefactoringDescriptors.
/**
* Reads default refactoring descriptors from the specified input stream.
*
* @param stream
* the input stream where to read from
* @param collection
* the list of descriptors read from the history
* @param monitor
* the progress monitor to use
* @throws CoreException
* if an error occurs while reading the descriptors
*/
private static void readRefactoringDescriptors(final InputStream stream, final Collection collection, final IProgressMonitor monitor) throws CoreException {
try {
monitor.beginTask(RefactoringCoreMessages.RefactoringHistoryService_retrieving_history, 1);
final RefactoringDescriptor[] results = new RefactoringSessionReader(true, null).readSession(new InputSource(new BufferedInputStream(stream))).getRefactorings();
for (int index = 0; index < results.length; index++) collection.add(results[index]);
} finally {
monitor.done();
}
}
use of org.eclipse.ltk.core.refactoring.RefactoringDescriptor 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