Search in sources :

Example 1 with RefactoringDescriptorProxy

use of org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy in project che by eclipse.

the class RefactoringHistoryImplementation method removeAll.

/**
	 * {@inheritDoc}
	 */
public RefactoringHistory removeAll(final RefactoringHistory history) {
    final Set existing = new LinkedHashSet(Arrays.asList(fDescriptorProxies));
    final Set other = new HashSet(Arrays.asList(history.getDescriptors()));
    existing.removeAll(other);
    final RefactoringDescriptorProxy[] proxies = new RefactoringDescriptorProxy[existing.size()];
    existing.toArray(proxies);
    return new RefactoringHistoryImplementation(proxies);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) RefactoringDescriptorProxy(org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 2 with RefactoringDescriptorProxy

use of org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy in project che by eclipse.

the class RefactoringHistoryManager method readRefactoringHistory.

/**
	 * Reads the refactoring history from disk.
	 *
	 * @param start
	 *            the start time stamp, inclusive
	 * @param end
	 *            the end time stamp, inclusive
	 * @param monitor
	 *            the progress monitor to use
	 * @return the refactoring history
	 */
RefactoringHistory readRefactoringHistory(final long start, final long end, final IProgressMonitor monitor) {
    try {
        monitor.beginTask(RefactoringCoreMessages.RefactoringHistoryService_retrieving_history, 200);
        final Set set = new HashSet();
        try {
            if (fHistoryStore.fetchInfo(EFS.NONE, new SubProgressMonitor(monitor, 20, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)).exists())
                readRefactoringDescriptorProxies(fHistoryStore, fProjectName, set, start, end, new SubProgressMonitor(monitor, 80), RefactoringCoreMessages.RefactoringHistoryService_retrieving_history);
            final IFileStore store = EFS.getLocalFileSystem().getStore(RefactoringCorePlugin.getDefault().getStateLocation()).getChild(RefactoringHistoryService.NAME_HISTORY_FOLDER).getChild(RefactoringHistoryService.NAME_WORKSPACE_PROJECT);
            if (store.fetchInfo(EFS.NONE, new SubProgressMonitor(monitor, 20, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)).exists())
                readRefactoringDescriptorProxies(store, null, set, start, end, new SubProgressMonitor(monitor, 80), RefactoringCoreMessages.RefactoringHistoryService_retrieving_history);
        } catch (CoreException exception) {
            RefactoringCorePlugin.log(exception);
        }
        final RefactoringDescriptorProxy[] proxies = new RefactoringDescriptorProxy[set.size()];
        set.toArray(proxies);
        return new RefactoringHistoryImplementation(proxies);
    } finally {
        monitor.done();
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) CoreException(org.eclipse.core.runtime.CoreException) RefactoringDescriptorProxy(org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy) IFileStore(org.eclipse.core.filesystem.IFileStore) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) HashSet(java.util.HashSet)

Example 3 with RefactoringDescriptorProxy

use of org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy 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 4 with RefactoringDescriptorProxy

use of org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy in project che by eclipse.

the class RefactoringHistoryManager method readRefactoringDescriptorProxies.

/**
	 * Reads refactoring descriptor proxies from the specified input stream.
	 * <p>
	 * The refactoring descriptor proxies are returned in no particular order.
	 * </p>
	 *
	 * @param stream
	 *            the input stream where to read from
	 * @param project
	 *            the name of the project, or <code>null</code> for the
	 *            workspace
	 * @param start
	 *            the start time stamp, inclusive
	 * @param end
	 *            the end time stamp, inclusive
	 * @return An array of refactoring descriptor proxies
	 * @throws IOException
	 *             if an input/output error occurs
	 */
public static RefactoringDescriptorProxy[] readRefactoringDescriptorProxies(final InputStream stream, final String project, final long start, final long end) throws IOException {
    final List list = new ArrayList();
    final BufferedReader reader = new BufferedReader(new InputStreamReader(stream, IRefactoringSerializationConstants.OUTPUT_ENCODING));
    while (reader.ready()) {
        final String line = reader.readLine();
        if (line != null) {
            final int index = line.indexOf(DELIMITER_COMPONENT);
            if (index > 0) {
                try {
                    final long stamp = new Long(line.substring(0, index)).longValue();
                    if (stamp >= start && stamp <= end)
                        list.add(new DefaultRefactoringDescriptorProxy(unescapeString(line.substring(index + 1)), project, stamp));
                } catch (NumberFormatException exception) {
                // Just skip
                }
            }
        }
    }
    return (RefactoringDescriptorProxy[]) list.toArray(new RefactoringDescriptorProxy[list.size()]);
}
Also used : InputStreamReader(java.io.InputStreamReader) RefactoringDescriptorProxy(org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy) ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) List(java.util.List) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList)

Example 5 with RefactoringDescriptorProxy

use of org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy in project che by eclipse.

the class AbstractRefactoringHistoryResourceMapping method getProjects.

/**
	 * {@inheritDoc}
	 */
public final IProject[] getProjects() {
    final Set set = new HashSet();
    final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    final RefactoringDescriptorProxy[] proxies = fRefactoringHistory.getDescriptors();
    for (int index = 0; index < proxies.length; index++) {
        final String name = proxies[index].getProject();
        if (//$NON-NLS-1$
        name != null && !"".equals(name))
            set.add(root.getProject(name));
    }
    return (IProject[]) set.toArray(new IProject[set.size()]);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) RefactoringDescriptorProxy(org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy) IProject(org.eclipse.core.resources.IProject) HashSet(java.util.HashSet)

Aggregations

RefactoringDescriptorProxy (org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy)14 HashSet (java.util.HashSet)10 Set (java.util.Set)10 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)9 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 ArrayList (java.util.ArrayList)4 IFileStore (org.eclipse.core.filesystem.IFileStore)4 BufferedInputStream (java.io.BufferedInputStream)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 Iterator (java.util.Iterator)3 NodeList (org.w3c.dom.NodeList)3 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 IProject (org.eclipse.core.resources.IProject)2 IPath (org.eclipse.core.runtime.IPath)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2