use of org.eclipse.ltk.internal.core.refactoring.RefactoringSessionReader in project che by eclipse.
the class RefactoringHistoryManager method getCachedSession.
/**
* Returns the cached refactoring session descriptor.
*
* @param store
* the file store of the descriptor
* @param projectName
* project name, or <code>null</code> for the workspace
* @param input
* the input stream where to read the descriptor
* @return the cached refactoring session descriptor
* @throws CoreException
* if an error occurs while reading the session
*/
private RefactoringSessionDescriptor getCachedSession(final IFileStore store, String projectName, final InputStream input) throws CoreException {
if (store.equals(fCachedStore) && fCachedDescriptor != null)
return fCachedDescriptor;
final RefactoringSessionDescriptor descriptor;
try {
descriptor = new RefactoringSessionReader(false, projectName).readSession(new InputSource(input));
fCachedDescriptor = descriptor;
fCachedStore = store;
return descriptor;
} catch (CoreException e) {
throw new CoreException(new MultiStatus(RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.REFACTORING_HISTORY_IO_ERROR, new IStatus[] { e.getStatus() }, Messages.format(RefactoringCoreMessages.RefactoringHistoryManager_error_reading_file, BasicElementLabels.getURLPart(store.toURI().toString())), null));
}
}
use of org.eclipse.ltk.internal.core.refactoring.RefactoringSessionReader in project che by eclipse.
the class RefactoringHistoryService method readRefactoringHistory.
/**
* {@inheritDoc}
*/
public RefactoringHistory readRefactoringHistory(final InputStream stream, final int flags) throws CoreException {
Assert.isNotNull(stream);
Assert.isTrue(flags >= RefactoringDescriptor.NONE);
final List list = new ArrayList();
final RefactoringSessionDescriptor descriptor = new RefactoringSessionReader(false, null).readSession(new InputSource(stream));
if (descriptor != null) {
final RefactoringDescriptor[] descriptors = descriptor.getRefactorings();
if (flags > RefactoringDescriptor.NONE) {
for (int index = 0; index < descriptors.length; index++) {
final int current = descriptors[index].getFlags();
if ((current | flags) == current)
list.add(descriptors[index]);
}
} else
list.addAll(Arrays.asList(descriptors));
}
final RefactoringDescriptorProxy[] proxies = new RefactoringDescriptorProxy[list.size()];
for (int index = 0; index < list.size(); index++) proxies[index] = new RefactoringDescriptorProxyAdapter((RefactoringDescriptor) list.get(index));
return new RefactoringHistoryImplementation(proxies);
}
use of org.eclipse.ltk.internal.core.refactoring.RefactoringSessionReader 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();
}
}
Aggregations