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

项目:che    文件:ExtractTempRefactoring.java   
@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();
  }
}
项目:Eclipse-Postfix-Code-Completion    文件:ExtractTempRefactoring.java   
private final ExtractLocalDescriptor createRefactoringDescriptor() {
    final Map<String, String> arguments= new HashMap<String, String>();
    String project= null;
    IJavaProject javaProject= fCu.getJavaProject();
    if (javaProject != null)
        project= javaProject.getElementName();
    final String description= Messages.format(RefactoringCoreMessages.ExtractTempRefactoring_descriptor_description_short, BasicElementLabels.getJavaElementName(fTempName));
    final String expression= ASTNodes.asString(fSelectedExpression.getAssociatedExpression());
    final String header= Messages.format(RefactoringCoreMessages.ExtractTempRefactoring_descriptor_description, new String[] { BasicElementLabels.getJavaElementName(fTempName), BasicElementLabels.getJavaCodeString(expression)});
    final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header);
    comment.addSetting(Messages.format(RefactoringCoreMessages.ExtractTempRefactoring_name_pattern, BasicElementLabels.getJavaElementName(fTempName)));
    final BodyDeclaration decl= (BodyDeclaration) ASTNodes.getParent(fSelectedExpression.getAssociatedExpression(), BodyDeclaration.class);
    if (decl instanceof MethodDeclaration) {
        final IMethodBinding method= ((MethodDeclaration) decl).resolveBinding();
        final String label= method != null ? BindingLabelProvider.getBindingLabel(method, JavaElementLabels.ALL_FULLY_QUALIFIED) : BasicElementLabels.getJavaElementName('{' + JavaElementLabels.ELLIPSIS_STRING + '}');
        comment.addSetting(Messages.format(RefactoringCoreMessages.ExtractTempRefactoring_destination_pattern, label));
    }
    comment.addSetting(Messages.format(RefactoringCoreMessages.ExtractTempRefactoring_expression_pattern, BasicElementLabels.getJavaCodeString(expression)));
    if (fReplaceAllOccurrences)
        comment.addSetting(RefactoringCoreMessages.ExtractTempRefactoring_replace_occurrences);
    if (fDeclareFinal)
        comment.addSetting(RefactoringCoreMessages.ExtractTempRefactoring_declare_final);
    final ExtractLocalDescriptor descriptor= RefactoringSignatureDescriptorFactory.createExtractLocalDescriptor(project, description, comment.asString(), arguments, RefactoringDescriptor.NONE);
    arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fCu));
    arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, fTempName);
    arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, new Integer(fSelectionStart).toString() + " " + new Integer(fSelectionLength).toString()); //$NON-NLS-1$
    arguments.put(ATTRIBUTE_REPLACE, Boolean.valueOf(fReplaceAllOccurrences).toString());
    arguments.put(ATTRIBUTE_FINAL, Boolean.valueOf(fDeclareFinal).toString());
    return descriptor;
}
项目:Eclipse-Postfix-Code-Completion    文件:ExtractTempRefactoring.java   
@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();
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ExtractTempRefactoring.java   
private final ExtractLocalDescriptor createRefactoringDescriptor() {
    final Map<String, String> arguments= new HashMap<String, String>();
    String project= null;
    IJavaProject javaProject= fCu.getJavaProject();
    if (javaProject != null)
        project= javaProject.getElementName();
    final String description= Messages.format(RefactoringCoreMessages.ExtractTempRefactoring_descriptor_description_short, BasicElementLabels.getJavaElementName(fTempName));
    final String expression= ASTNodes.asString(fSelectedExpression.getAssociatedExpression());
    final String header= Messages.format(RefactoringCoreMessages.ExtractTempRefactoring_descriptor_description, new String[] { BasicElementLabels.getJavaElementName(fTempName), BasicElementLabels.getJavaCodeString(expression)});
    final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header);
    comment.addSetting(Messages.format(RefactoringCoreMessages.ExtractTempRefactoring_name_pattern, BasicElementLabels.getJavaElementName(fTempName)));
    final BodyDeclaration decl= (BodyDeclaration) ASTNodes.getParent(fSelectedExpression.getAssociatedExpression(), BodyDeclaration.class);
    if (decl instanceof MethodDeclaration) {
        final IMethodBinding method= ((MethodDeclaration) decl).resolveBinding();
        final String label= method != null ? BindingLabelProvider.getBindingLabel(method, JavaElementLabels.ALL_FULLY_QUALIFIED) : BasicElementLabels.getJavaElementName('{' + JavaElementLabels.ELLIPSIS_STRING + '}');
        comment.addSetting(Messages.format(RefactoringCoreMessages.ExtractTempRefactoring_destination_pattern, label));
    }
    comment.addSetting(Messages.format(RefactoringCoreMessages.ExtractTempRefactoring_expression_pattern, BasicElementLabels.getJavaCodeString(expression)));
    if (fReplaceAllOccurrences)
        comment.addSetting(RefactoringCoreMessages.ExtractTempRefactoring_replace_occurrences);
    if (fDeclareFinal)
        comment.addSetting(RefactoringCoreMessages.ExtractTempRefactoring_declare_final);
    final ExtractLocalDescriptor descriptor= RefactoringSignatureDescriptorFactory.createExtractLocalDescriptor(project, description, comment.asString(), arguments, RefactoringDescriptor.NONE);
    arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fCu));
    arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, fTempName);
    arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, new Integer(fSelectionStart).toString() + " " + new Integer(fSelectionLength).toString()); //$NON-NLS-1$
    arguments.put(ATTRIBUTE_REPLACE, Boolean.valueOf(fReplaceAllOccurrences).toString());
    arguments.put(ATTRIBUTE_FINAL, Boolean.valueOf(fDeclareFinal).toString());
    return descriptor;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ExtractTempRefactoring.java   
@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();
    }
}
项目:che    文件:ExtractTempRefactoring.java   
private final ExtractLocalDescriptor createRefactoringDescriptor() {
  final Map<String, String> arguments = new HashMap<String, String>();
  String project = null;
  IJavaProject javaProject = fCu.getJavaProject();
  if (javaProject != null) project = javaProject.getElementName();
  final String description =
      Messages.format(
          RefactoringCoreMessages.ExtractTempRefactoring_descriptor_description_short,
          BasicElementLabels.getJavaElementName(fTempName));
  final String expression = ASTNodes.asString(fSelectedExpression.getAssociatedExpression());
  final String header =
      Messages.format(
          RefactoringCoreMessages.ExtractTempRefactoring_descriptor_description,
          new String[] {
            BasicElementLabels.getJavaElementName(fTempName),
            BasicElementLabels.getJavaCodeString(expression)
          });
  final JDTRefactoringDescriptorComment comment =
      new JDTRefactoringDescriptorComment(project, this, header);
  comment.addSetting(
      Messages.format(
          RefactoringCoreMessages.ExtractTempRefactoring_name_pattern,
          BasicElementLabels.getJavaElementName(fTempName)));
  final BodyDeclaration decl =
      (BodyDeclaration)
          ASTNodes.getParent(
              fSelectedExpression.getAssociatedExpression(), BodyDeclaration.class);
  if (decl instanceof MethodDeclaration) {
    final IMethodBinding method = ((MethodDeclaration) decl).resolveBinding();
    final String label =
        method != null
            ? BindingLabelProvider.getBindingLabel(method, JavaElementLabels.ALL_FULLY_QUALIFIED)
            : BasicElementLabels.getJavaElementName(
                '{' + JavaElementLabels.ELLIPSIS_STRING + '}');
    comment.addSetting(
        Messages.format(
            RefactoringCoreMessages.ExtractTempRefactoring_destination_pattern, label));
  }
  comment.addSetting(
      Messages.format(
          RefactoringCoreMessages.ExtractTempRefactoring_expression_pattern,
          BasicElementLabels.getJavaCodeString(expression)));
  if (fReplaceAllOccurrences)
    comment.addSetting(RefactoringCoreMessages.ExtractTempRefactoring_replace_occurrences);
  if (fDeclareFinal)
    comment.addSetting(RefactoringCoreMessages.ExtractTempRefactoring_declare_final);
  final ExtractLocalDescriptor descriptor =
      RefactoringSignatureDescriptorFactory.createExtractLocalDescriptor(
          project, description, comment.asString(), arguments, RefactoringDescriptor.NONE);
  arguments.put(
      JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT,
      JavaRefactoringDescriptorUtil.elementToHandle(project, fCu));
  arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, fTempName);
  arguments.put(
      JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION,
      new Integer(fSelectionStart).toString()
          + " "
          + new Integer(fSelectionLength).toString()); // $NON-NLS-1$
  arguments.put(ATTRIBUTE_REPLACE, Boolean.valueOf(fReplaceAllOccurrences).toString());
  arguments.put(ATTRIBUTE_FINAL, Boolean.valueOf(fDeclareFinal).toString());
  return descriptor;
}
项目:che    文件:RefactoringSignatureDescriptorFactory.java   
public static ExtractLocalDescriptor createExtractLocalDescriptor() {
  return new ExtractLocalDescriptor();
}
项目:che    文件:RefactoringSignatureDescriptorFactory.java   
public static ExtractLocalDescriptor createExtractLocalDescriptor(
    String project, String description, String comment, Map arguments, int flags) {
  return new ExtractLocalDescriptor(project, description, comment, arguments, flags);
}