Search in sources :

Example 1 with RefactoringSessionReader

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));
    }
}
Also used : InputSource(org.xml.sax.InputSource) RefactoringSessionReader(org.eclipse.ltk.internal.core.refactoring.RefactoringSessionReader) CoreException(org.eclipse.core.runtime.CoreException) MultiStatus(org.eclipse.core.runtime.MultiStatus) RefactoringSessionDescriptor(org.eclipse.ltk.core.refactoring.RefactoringSessionDescriptor)

Example 2 with RefactoringSessionReader

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);
}
Also used : RefactoringDescriptor(org.eclipse.ltk.core.refactoring.RefactoringDescriptor) InputSource(org.xml.sax.InputSource) RefactoringSessionReader(org.eclipse.ltk.internal.core.refactoring.RefactoringSessionReader) RefactoringDescriptorProxy(org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy) ArrayList(java.util.ArrayList) List(java.util.List) ListenerList(org.eclipse.core.runtime.ListenerList) ArrayList(java.util.ArrayList) RefactoringSessionDescriptor(org.eclipse.ltk.core.refactoring.RefactoringSessionDescriptor)

Example 3 with RefactoringSessionReader

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();
    }
}
Also used : RefactoringDescriptor(org.eclipse.ltk.core.refactoring.RefactoringDescriptor) InputSource(org.xml.sax.InputSource) RefactoringSessionReader(org.eclipse.ltk.internal.core.refactoring.RefactoringSessionReader) BufferedInputStream(java.io.BufferedInputStream)

Aggregations

RefactoringSessionReader (org.eclipse.ltk.internal.core.refactoring.RefactoringSessionReader)3 InputSource (org.xml.sax.InputSource)3 RefactoringDescriptor (org.eclipse.ltk.core.refactoring.RefactoringDescriptor)2 RefactoringSessionDescriptor (org.eclipse.ltk.core.refactoring.RefactoringSessionDescriptor)2 BufferedInputStream (java.io.BufferedInputStream)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CoreException (org.eclipse.core.runtime.CoreException)1 ListenerList (org.eclipse.core.runtime.ListenerList)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1 RefactoringDescriptorProxy (org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy)1