Search in sources :

Example 11 with RefactoringChangeDescriptor

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

the class InlineTempRefactoring method createChange.

//----- changes
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
    try {
        pm.beginTask(RefactoringCoreMessages.InlineTempRefactoring_preview, 2);
        final Map<String, String> arguments = new HashMap<String, String>();
        String project = null;
        IJavaProject javaProject = fCu.getJavaProject();
        if (javaProject != null)
            project = javaProject.getElementName();
        final IVariableBinding binding = getVariableDeclaration().resolveBinding();
        String text = null;
        final IMethodBinding method = binding.getDeclaringMethod();
        if (method != null)
            text = BindingLabelProvider.getBindingLabel(method, JavaElementLabels.ALL_FULLY_QUALIFIED);
        else
            text = BasicElementLabels.getJavaElementName('{' + JavaElementLabels.ELLIPSIS_STRING + '}');
        final String description = Messages.format(RefactoringCoreMessages.InlineTempRefactoring_descriptor_description_short, BasicElementLabels.getJavaElementName(binding.getName()));
        final String header = Messages.format(RefactoringCoreMessages.InlineTempRefactoring_descriptor_description, new String[] { BindingLabelProvider.getBindingLabel(binding, JavaElementLabels.ALL_FULLY_QUALIFIED), text });
        final JDTRefactoringDescriptorComment comment = new JDTRefactoringDescriptorComment(project, this, header);
        comment.addSetting(Messages.format(RefactoringCoreMessages.InlineTempRefactoring_original_pattern, BindingLabelProvider.getBindingLabel(binding, JavaElementLabels.ALL_FULLY_QUALIFIED)));
        final InlineLocalVariableDescriptor descriptor = RefactoringSignatureDescriptorFactory.createInlineLocalVariableDescriptor(project, description, comment.asString(), arguments, RefactoringDescriptor.NONE);
        arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fCu));
        arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, String.valueOf(fSelectionStart) + ' ' + String.valueOf(fSelectionLength));
        CompilationUnitRewrite cuRewrite = new CompilationUnitRewrite(fCu, fASTRoot);
        inlineTemp(cuRewrite);
        removeTemp(cuRewrite);
        final CompilationUnitChange result = cuRewrite.createChange(RefactoringCoreMessages.InlineTempRefactoring_inline, false, new SubProgressMonitor(pm, 1));
        result.setDescriptor(new RefactoringChangeDescriptor(descriptor));
        return result;
    } finally {
        pm.done();
    }
}
Also used : IMethodBinding(org.eclipse.jdt.core.dom.IMethodBinding) CompilationUnitRewrite(org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite) IJavaProject(org.eclipse.jdt.core.IJavaProject) HashMap(java.util.HashMap) InlineLocalVariableDescriptor(org.eclipse.jdt.core.refactoring.descriptors.InlineLocalVariableDescriptor) IVariableBinding(org.eclipse.jdt.core.dom.IVariableBinding) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) JDTRefactoringDescriptorComment(org.eclipse.jdt.internal.corext.refactoring.JDTRefactoringDescriptorComment) CompilationUnitChange(org.eclipse.jdt.core.refactoring.CompilationUnitChange) RefactoringChangeDescriptor(org.eclipse.ltk.core.refactoring.RefactoringChangeDescriptor)

Example 12 with RefactoringChangeDescriptor

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

the class ExtractTempRefactoring method createChange.

@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
    try {
        pm.beginTask(RefactoringCoreMessages.ExtractTempRefactoring_checking_preconditions, 1);
        ExtractLocalDescriptor descriptor = createRefactoringDescriptor();
        fChange.setDescriptor(new RefactoringChangeDescriptor(descriptor));
        return fChange;
    } finally {
        pm.done();
    }
}
Also used : ExtractLocalDescriptor(org.eclipse.jdt.core.refactoring.descriptors.ExtractLocalDescriptor) RefactoringChangeDescriptor(org.eclipse.ltk.core.refactoring.RefactoringChangeDescriptor)

Example 13 with RefactoringChangeDescriptor

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

the class ExtractConstantRefactoring method createChange.

@Override
public Change createChange(IProgressMonitor monitor) throws CoreException {
    ExtractConstantDescriptor descriptor = createRefactoringDescriptor();
    fChange.setDescriptor(new RefactoringChangeDescriptor(descriptor));
    return fChange;
}
Also used : ExtractConstantDescriptor(org.eclipse.jdt.core.refactoring.descriptors.ExtractConstantDescriptor) RefactoringChangeDescriptor(org.eclipse.ltk.core.refactoring.RefactoringChangeDescriptor)

Aggregations

RefactoringChangeDescriptor (org.eclipse.ltk.core.refactoring.RefactoringChangeDescriptor)13 JDTRefactoringDescriptorComment (org.eclipse.jdt.internal.corext.refactoring.JDTRefactoringDescriptorComment)4 HashMap (java.util.HashMap)3 CompilationUnitChange (org.eclipse.jdt.core.refactoring.CompilationUnitChange)3 IJavaProject (org.eclipse.jdt.core.IJavaProject)2 ITypeBinding (org.eclipse.jdt.core.dom.ITypeBinding)2 RenameJavaElementDescriptor (org.eclipse.jdt.core.refactoring.descriptors.RenameJavaElementDescriptor)2 DynamicValidationStateChange (org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange)2 CompositeChange (org.eclipse.ltk.core.refactoring.CompositeChange)2 RenameResourceChange (org.eclipse.ltk.core.refactoring.resource.RenameResourceChange)2 TextEdit (org.eclipse.text.edits.TextEdit)2 IProject (org.eclipse.core.resources.IProject)1 IResource (org.eclipse.core.resources.IResource)1 IResourceChangeEvent (org.eclipse.core.resources.IResourceChangeEvent)1 IResourceChangeListener (org.eclipse.core.resources.IResourceChangeListener)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)1 ASTNode (org.eclipse.jdt.core.dom.ASTNode)1 BodyDeclaration (org.eclipse.jdt.core.dom.BodyDeclaration)1