Search in sources :

Example 1 with RenameElementProcessor

use of org.eclipse.xtext.ui.refactoring.impl.RenameElementProcessor in project xtext-xtend by eclipse.

the class XtendJdtRenameParticipantProcessor method isXtendRename.

/**
 * @return true, if the triggering refactoring targets an Xtend element.
 */
protected boolean isXtendRename() {
    JdtRenameParticipant jdtRenameParticipant = ((JvmModelJdtRenameParticipantContext) getRenameElementContext()).getJdtRenameParticipant();
    RefactoringProcessor triggeringProcessor = jdtRenameParticipant.getProcessor().getRefactoring().getProcessor();
    if (triggeringProcessor instanceof RenameElementProcessor) {
        EClass targetElementEClass = ((RenameElementProcessor) triggeringProcessor).getRenameElementContext().getTargetElementEClass();
        return targetElementEClass.getEPackage() == XtendPackage.eINSTANCE;
    }
    return false;
}
Also used : EClass(org.eclipse.emf.ecore.EClass) JdtRenameParticipant(org.eclipse.xtext.common.types.ui.refactoring.participant.JdtRenameParticipant) JvmModelJdtRenameParticipantContext(org.eclipse.xtext.xbase.ui.jvmmodel.refactoring.JvmModelJdtRenameParticipantContext) RefactoringProcessor(org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor) RenameElementProcessor(org.eclipse.xtext.ui.refactoring.impl.RenameElementProcessor)

Example 2 with RenameElementProcessor

use of org.eclipse.xtext.ui.refactoring.impl.RenameElementProcessor in project xtext-xtend by eclipse.

the class RefactoringIntegrationTest method doRename.

protected void doRename(EObject targetElement, String newName) throws Exception {
    URI targetElementURI = EcoreUtil.getURI(targetElement);
    RenameElementProcessor processor = processorProvider.get();
    processor.initialize(new IRenameElementContext.Impl(targetElementURI, targetElement.eClass(), null, null, null));
    processor.setNewName(newName);
    RefactoringStatus initialStatus = processor.checkInitialConditions(new NullProgressMonitor());
    assertTrue(initialStatus.isOK());
    RefactoringStatus finalStatus = processor.checkFinalConditions(new NullProgressMonitor(), null);
    assertTrue(finalStatus.toString(), finalStatus.isOK());
    final Change change = processor.createChange(new NullProgressMonitor());
    assertNotNull(change);
    new WorkspaceModifyOperation() {

        @Override
        protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
            change.perform(monitor);
        }
    }.run(null);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) Change(org.eclipse.ltk.core.refactoring.Change) URI(org.eclipse.emf.common.util.URI) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IRenameElementContext(org.eclipse.xtext.ui.refactoring.ui.IRenameElementContext) RenameElementProcessor(org.eclipse.xtext.ui.refactoring.impl.RenameElementProcessor)

Aggregations

RenameElementProcessor (org.eclipse.xtext.ui.refactoring.impl.RenameElementProcessor)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 URI (org.eclipse.emf.common.util.URI)1 EClass (org.eclipse.emf.ecore.EClass)1 Change (org.eclipse.ltk.core.refactoring.Change)1 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)1 RefactoringProcessor (org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor)1 WorkspaceModifyOperation (org.eclipse.ui.actions.WorkspaceModifyOperation)1 JdtRenameParticipant (org.eclipse.xtext.common.types.ui.refactoring.participant.JdtRenameParticipant)1 IRenameElementContext (org.eclipse.xtext.ui.refactoring.ui.IRenameElementContext)1 JvmModelJdtRenameParticipantContext (org.eclipse.xtext.xbase.ui.jvmmodel.refactoring.JvmModelJdtRenameParticipantContext)1