Java 类org.eclipse.jdt.core.refactoring.descriptors.InlineLocalVariableDescriptor 实例源码

项目:Eclipse-Postfix-Code-Completion    文件:InlineTempRefactoring.java   
@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();
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:InlineTempRefactoring.java   
@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();
    }
}
项目:che    文件:InlineTempRefactoring.java   
@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();
  }
}
项目:che    文件:RefactoringSignatureDescriptorFactory.java   
public static InlineLocalVariableDescriptor createInlineLocalVariableDescriptor() {
  return new InlineLocalVariableDescriptor();
}
项目:che    文件:RefactoringSignatureDescriptorFactory.java   
public static InlineLocalVariableDescriptor createInlineLocalVariableDescriptor(
    String project, String description, String comment, Map arguments, int flags) {
  return new InlineLocalVariableDescriptor(project, description, comment, arguments, flags);
}