Search in sources :

Example 6 with ProcessorBasedRefactoring

use of org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring in project xtext-xtend by eclipse.

the class JavaRefactoringIntegrationTest 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)

Example 7 with ProcessorBasedRefactoring

use of org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring in project xtext-xtend by eclipse.

the class JavaRefactoringIntegrationTest method renameXtendElement.

protected void renameXtendElement(final XtextEditor editor, final int offset, final String newName, final int allowedSeverity) throws Exception {
    syncUtil.totalSync(false);
    new WorkspaceModifyOperation() {

        @Override
        protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
            ProcessorBasedRefactoring renameRefactoring = createXtendRenameRefactoring(editor, offset, newName);
            assertTrue("Refactoring not applicable", renameRefactoring.isApplicable());
            RefactoringStatus status = renameRefactoring.checkAllConditions(new NullProgressMonitor());
            assertTrue(status.toString(), status.getSeverity() <= allowedSeverity);
            Change change = renameRefactoring.createChange(new NullProgressMonitor());
            change.perform(new NullProgressMonitor());
        }
    }.run(new NullProgressMonitor());
    syncUtil.totalSync(false);
    assertTrue(compositeRefactoringProcessorAccess.isDisposed());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) Change(org.eclipse.ltk.core.refactoring.Change) ProcessorBasedRefactoring(org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 8 with ProcessorBasedRefactoring

use of org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring in project xtext-xtend by eclipse.

the class JavaRefactoringIntegrationTest method renameXtendElementWithError.

protected RefactoringStatus renameXtendElementWithError(final XtextEditor editor, final int offset, String newName) throws Exception {
    syncUtil.totalSync(false);
    ProcessorBasedRefactoring renameRefactoring = createXtendRenameRefactoring(editor, offset, newName);
    RefactoringStatus status = renameRefactoring.checkAllConditions(new NullProgressMonitor());
    assertFalse("Expected an error", status.isOK());
    return status;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) ProcessorBasedRefactoring(org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring)

Example 9 with ProcessorBasedRefactoring

use of org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring in project xtext-xtend by eclipse.

the class AbstractXtendRenameRefactoringTest method renameXtendElement.

protected void renameXtendElement(final XtextEditor editor, final int offset, final String newName, final int allowedSeverity, IProgressMonitor monitor) throws Exception {
    syncUtil.totalSync(false);
    new WorkspaceModifyOperation() {

        @Override
        protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
            ProcessorBasedRefactoring renameRefactoring = createXtendRenameRefactoring(editor, offset, newName);
            assertTrue("Refactoring not applicable", renameRefactoring.isApplicable());
            RefactoringStatus status = renameRefactoring.checkAllConditions(monitor);
            assertTrue(status.toString(), status.getSeverity() <= allowedSeverity);
            Change change = renameRefactoring.createChange(monitor);
            change.perform(monitor);
        }
    }.run(monitor);
    syncUtil.totalSync(false);
    assertTrue(compositeRefactoringProcessorAccess.isDisposed());
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) Change(org.eclipse.ltk.core.refactoring.Change) ProcessorBasedRefactoring(org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 10 with ProcessorBasedRefactoring

use of org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring in project xtext-xtend by eclipse.

the class AbstractXtendRenameRefactoringTest method renameXtendElementWithError.

protected RefactoringStatus renameXtendElementWithError(final XtextEditor editor, final int offset, String newName, IProgressMonitor monitor) throws Exception {
    syncUtil.totalSync(false);
    ProcessorBasedRefactoring renameRefactoring = createXtendRenameRefactoring(editor, offset, newName);
    RefactoringStatus status = renameRefactoring.checkAllConditions(monitor);
    assertFalse("Expected an error", status.isOK());
    return status;
}
Also used : RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) ProcessorBasedRefactoring(org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring)

Aggregations

ProcessorBasedRefactoring (org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring)13 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)8 CoreException (org.eclipse.core.runtime.CoreException)4 IMethod (org.eclipse.jdt.core.IMethod)3 Change (org.eclipse.ltk.core.refactoring.Change)3 Refactoring (org.eclipse.ltk.core.refactoring.Refactoring)3 RefactoringProcessor (org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor)3 IRenameElementContext (org.eclipse.xtext.ui.refactoring.ui.IRenameElementContext)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)2 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)2 IType (org.eclipse.jdt.core.IType)2 JavaRenameProcessor (org.eclipse.jdt.internal.corext.refactoring.rename.JavaRenameProcessor)2 ChangeSignatureProcessor (org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureProcessor)2 WorkspaceModifyOperation (org.eclipse.ui.actions.WorkspaceModifyOperation)2 CompositeRefactoringProcessor (org.eclipse.xtext.common.types.ui.refactoring.participant.CompositeRefactoringProcessor)2 AbstractRenameProcessor (org.eclipse.xtext.ui.refactoring.impl.AbstractRenameProcessor)2 ArrayList (java.util.ArrayList)1