Search in sources :

Example 6 with RefactoringDescriptor

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

the class RenameTypeTest method helper3_fail.

private void helper3_fail(String oldName, String newName, boolean updateSimilar, boolean updateTextual, boolean updateRef, int matchStrategy) throws JavaModelException, CoreException, IOException, Exception {
    RefactoringDescriptor descriptor = initWithAllOptions(oldName, oldName, newName, updateRef, updateTextual, updateSimilar, null, matchStrategy);
    Assert.assertNotNull("was supposed to fail", performRefactoring(descriptor));
}
Also used : RefactoringDescriptor(org.eclipse.ltk.core.refactoring.RefactoringDescriptor)

Example 7 with RefactoringDescriptor

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

the class RenameTypeTest method helper3.

private void helper3(String oldName, String newName, boolean updateRef, boolean updateTextual, boolean updateSimilar, String nonJavaFiles) throws JavaModelException, CoreException, IOException, Exception {
    RefactoringDescriptor descriptor = initWithAllOptions(oldName, oldName, newName, updateRef, updateTextual, updateSimilar, nonJavaFiles, RenamingNameSuggestor.STRATEGY_EMBEDDED);
    Refactoring ref = createRefactoring(descriptor);
    RefactoringStatus status = performRefactoring(ref);
    Assert.assertNull("was supposed to pass", status);
    checkResultInClass(newName);
    checkMappedSimilarElementsExist(ref);
}
Also used : RefactoringDescriptor(org.eclipse.ltk.core.refactoring.RefactoringDescriptor) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) Refactoring(org.eclipse.ltk.core.refactoring.Refactoring) RenameRefactoring(org.eclipse.ltk.core.refactoring.participants.RenameRefactoring)

Example 8 with RefactoringDescriptor

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

the class RenameTypeTest method helper3_inner.

private void helper3_inner(String oldName, String oldInnerName, String newName, String innerNewName, boolean updateRef, boolean updateTextual, boolean updateSimilar, String nonJavaFiles) throws JavaModelException, CoreException, IOException, Exception {
    RefactoringDescriptor descriptor = initWithAllOptions(oldName, oldInnerName, innerNewName, updateRef, updateTextual, updateSimilar, nonJavaFiles, RenamingNameSuggestor.STRATEGY_EMBEDDED);
    Refactoring ref = createRefactoring(descriptor);
    Assert.assertNull("was supposed to pass", performRefactoring(ref));
    checkResultInClass(newName);
    checkMappedSimilarElementsExist(ref);
}
Also used : RefactoringDescriptor(org.eclipse.ltk.core.refactoring.RefactoringDescriptor) Refactoring(org.eclipse.ltk.core.refactoring.Refactoring) RenameRefactoring(org.eclipse.ltk.core.refactoring.participants.RenameRefactoring)

Example 9 with RefactoringDescriptor

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

the class RefactoringHistoryManager method requestDescriptor.

/**
	 * Requests the resolved refactoring descriptor associated with the given
	 * proxy.
	 *
	 * @param proxy
	 *            the refactoring descriptor proxy
	 * @param monitor
	 *            the progress monitor to use
	 * @return the associated refactoring descriptor, or <code>null</code>
	 */
RefactoringDescriptor requestDescriptor(final RefactoringDescriptorProxy proxy, final IProgressMonitor monitor) {
    try {
        monitor.beginTask(RefactoringCoreMessages.RefactoringHistoryService_resolving_information, 2);
        final long stamp = proxy.getTimeStamp();
        if (stamp >= 0) {
            InputStream input = null;
            try {
                final IFileStore folder = fHistoryStore.getFileStore(stampToPath(stamp));
                final IFileStore file = folder.getChild(RefactoringHistoryService.NAME_HISTORY_FILE);
                if (file.fetchInfo(EFS.NONE, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)).exists()) {
                    input = new BufferedInputStream(file.openInputStream(EFS.NONE, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)));
                    final RefactoringSessionDescriptor descriptor = getCachedSession(file, fProjectName, input);
                    if (descriptor != null) {
                        final RefactoringDescriptor[] descriptors = descriptor.getRefactorings();
                        for (int index = 0; index < descriptors.length; index++) {
                            final RefactoringDescriptor refactoringDescriptor = descriptors[index];
                            if (refactoringDescriptor.getTimeStamp() == stamp) {
                                return refactoringDescriptor;
                            }
                        }
                    }
                }
            } catch (CoreException exception) {
                RefactoringCorePlugin.log(exception);
            } finally {
                try {
                    if (input != null)
                        input.close();
                } catch (IOException exception) {
                    RefactoringCorePlugin.log(exception);
                }
            }
        }
    } finally {
        monitor.done();
    }
    return null;
}
Also used : RefactoringDescriptor(org.eclipse.ltk.core.refactoring.RefactoringDescriptor) CoreException(org.eclipse.core.runtime.CoreException) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) IFileStore(org.eclipse.core.filesystem.IFileStore) IOException(java.io.IOException) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) RefactoringSessionDescriptor(org.eclipse.ltk.core.refactoring.RefactoringSessionDescriptor)

Example 10 with RefactoringDescriptor

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

the class RefactoringHistorySerializer method processHistoryNotification.

/**
	 * Processes the history event.
	 *
	 * @param store
	 *            the file store
	 * @param event
	 *            the history event
	 * @param name
	 *            the project name, or <code>null</code>
	 * @throws CoreException
	 *             if an error occurs
	 */
private void processHistoryNotification(final IFileStore store, final RefactoringHistoryEvent event, final String name) throws CoreException {
    final RefactoringDescriptorProxy proxy = event.getDescriptor();
    final int type = event.getEventType();
    final RefactoringHistoryManager manager = new RefactoringHistoryManager(store, name);
    final NullProgressMonitor monitor = new NullProgressMonitor();
    if (type == RefactoringHistoryEvent.PUSHED || type == RefactoringHistoryEvent.ADDED) {
        final RefactoringDescriptor descriptor = proxy.requestDescriptor(monitor);
        if (descriptor != null)
            manager.addRefactoringDescriptor(descriptor, type == RefactoringHistoryEvent.ADDED, monitor);
    } else if (type == RefactoringHistoryEvent.POPPED)
        manager.removeRefactoringDescriptors(new RefactoringDescriptorProxy[] { proxy }, monitor, RefactoringCoreMessages.RefactoringHistoryService_updating_history);
}
Also used : RefactoringDescriptor(org.eclipse.ltk.core.refactoring.RefactoringDescriptor) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) RefactoringDescriptorProxy(org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy)

Aggregations

RefactoringDescriptor (org.eclipse.ltk.core.refactoring.RefactoringDescriptor)13 RefactoringSessionDescriptor (org.eclipse.ltk.core.refactoring.RefactoringSessionDescriptor)4 ArrayList (java.util.ArrayList)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 BufferedInputStream (java.io.BufferedInputStream)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 CoreException (org.eclipse.core.runtime.CoreException)2 ListenerList (org.eclipse.core.runtime.ListenerList)2 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)2 Refactoring (org.eclipse.ltk.core.refactoring.Refactoring)2 RefactoringDescriptorProxy (org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy)2 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)2 RenameRefactoring (org.eclipse.ltk.core.refactoring.participants.RenameRefactoring)2 RefactoringSessionReader (org.eclipse.ltk.internal.core.refactoring.RefactoringSessionReader)2 DefaultRefactoringDescriptor (org.eclipse.ltk.internal.core.refactoring.history.DefaultRefactoringDescriptor)2 InputSource (org.xml.sax.InputSource)2 SAXParseException (org.xml.sax.SAXParseException)2