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);
}
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();
}
}
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);
}
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()]);
}
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()]);
}
Aggregations