Search in sources :

Example 6 with JavaRenameProcessor

use of org.eclipse.jdt.internal.corext.refactoring.rename.JavaRenameProcessor in project xtext-eclipse by eclipse.

the class CombinedJvmJdtRenameProcessor method createChange.

@Override
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
    SubMonitor monitor = SubMonitor.convert(pm, jvmElements2jdtProcessors.size() + 1);
    CompositeChange compositeChange = new CompositeChange(getProcessorName());
    compositeChange.add(super.createChange(monitor.newChild(1)));
    for (JavaRenameProcessor processor : jvmElements2jdtProcessors.values()) {
        if (monitor.isCanceled()) {
            throw new OperationCanceledException();
        }
        compositeChange.add(processor.createChange(monitor.newChild(1)));
    }
    return compositeChange;
}
Also used : OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SubMonitor(org.eclipse.core.runtime.SubMonitor) JavaRenameProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.JavaRenameProcessor) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange)

Example 7 with JavaRenameProcessor

use of org.eclipse.jdt.internal.corext.refactoring.rename.JavaRenameProcessor in project xtext-eclipse by eclipse.

the class CombinedJvmJdtRenameProcessor method checkInitialConditions.

@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
    SubMonitor monitor = SubMonitor.convert(pm, jvmElements2jdtProcessors.size() + 1);
    RefactoringStatus status = super.checkInitialConditions(monitor.newChild(1));
    for (JavaRenameProcessor processor : jvmElements2jdtProcessors.values()) {
        if (monitor.isCanceled()) {
            throw new OperationCanceledException();
        }
        status.merge(processor.checkInitialConditions(monitor.newChild(1)));
    }
    return status;
}
Also used : OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SubMonitor(org.eclipse.core.runtime.SubMonitor) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) JavaRenameProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.JavaRenameProcessor)

Example 8 with JavaRenameProcessor

use of org.eclipse.jdt.internal.corext.refactoring.rename.JavaRenameProcessor in project xtext-eclipse by eclipse.

the class CombinedJvmJdtRenameProcessor method initialize.

@Override
public boolean initialize(final IRenameElementContext renameElementContext) {
    Assert.isLegal(renameElementContext instanceof CombinedJvmJdtRenameContext);
    if (!super.initialize(renameElementContext))
        return false;
    jvmElements2jdtProcessors = newHashMap();
    for (Map.Entry<URI, IJavaElement> jvm2javaElement : ((CombinedJvmJdtRenameContext) renameElementContext).getJvm2JavaElements().entrySet()) {
        JavaRenameProcessor jdtRenameProcessor = jdtRefactoringFactory.createRenameProcessor(jvm2javaElement.getValue());
        if (jdtRenameProcessor != null) {
            jvmElements2jdtProcessors.put(jvm2javaElement.getKey(), jdtRenameProcessor);
        } else {
            return false;
        }
    }
    return true;
}
Also used : IJavaElement(org.eclipse.jdt.core.IJavaElement) JavaRenameProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.JavaRenameProcessor) Map(java.util.Map) URI(org.eclipse.emf.common.util.URI)

Example 9 with JavaRenameProcessor

use of org.eclipse.jdt.internal.corext.refactoring.rename.JavaRenameProcessor in project xtext-xtend by eclipse.

the class AbstractXtendRenameRefactoringTest method createXtendRenameRefactoring.

protected ProcessorBasedRefactoring createXtendRenameRefactoring(final XtextEditor editor, final int offset, String newName) {
    IRenameElementContext renameElementContext = createRenameElementContext(editor, offset);
    ProcessorBasedRefactoring renameRefactoring = renameRefactoringProvider.getRenameRefactoring(renameElementContext);
    RefactoringProcessor processor = renameRefactoring.getProcessor();
    if (processor instanceof AbstractRenameProcessor)
        ((AbstractRenameProcessor) processor).setNewName(newName);
    else if (processor instanceof JavaRenameProcessor)
        ((JavaRenameProcessor) processor).setNewElementName(newName);
    return renameRefactoring;
}
Also used : CompositeRefactoringProcessor(org.eclipse.xtext.common.types.ui.refactoring.participant.CompositeRefactoringProcessor) RefactoringProcessor(org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor) AbstractRenameProcessor(org.eclipse.xtext.ui.refactoring.impl.AbstractRenameProcessor) IRenameElementContext(org.eclipse.xtext.ui.refactoring.ui.IRenameElementContext) JavaRenameProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.JavaRenameProcessor) ProcessorBasedRefactoring(org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring)

Aggregations

JavaRenameProcessor (org.eclipse.jdt.internal.corext.refactoring.rename.JavaRenameProcessor)9 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)4 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)3 SubMonitor (org.eclipse.core.runtime.SubMonitor)3 RenameRefactoring (org.eclipse.ltk.core.refactoring.participants.RenameRefactoring)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Map (java.util.Map)2 CoreException (org.eclipse.core.runtime.CoreException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 URI (org.eclipse.emf.common.util.URI)2 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)2 RenameCompilationUnitProcessor (org.eclipse.jdt.internal.corext.refactoring.rename.RenameCompilationUnitProcessor)2 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)2 PerformRefactoringOperation (org.eclipse.ltk.core.refactoring.PerformRefactoringOperation)2 RefactoringStatusEntry (org.eclipse.ltk.core.refactoring.RefactoringStatusEntry)2 ProcessorBasedRefactoring (org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring)2 RefactoringProcessor (org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor)2 PartInitException (org.eclipse.ui.PartInitException)2 CompositeRefactoringProcessor (org.eclipse.xtext.common.types.ui.refactoring.participant.CompositeRefactoringProcessor)2 AbstractRenameProcessor (org.eclipse.xtext.ui.refactoring.impl.AbstractRenameProcessor)2