@Override
 public ICleanUpFix createFix(final CleanUpContext context) throws CoreException {
   if (context.getAST() == null) return null;
   if (context.getCompilationUnit() == null) return null;
   // return new SorterCleanUpFix(context);
   return null;
 }
  /** {@inheritDoc} */
  public ICleanUpFix createFix(CleanUpContext context) throws CoreException {
    CompilationUnit compilationUnit = context.getAST();
    if (compilationUnit == null) return null;

    boolean usePrentheses = isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES);
    if (!usePrentheses) return null;

    return ExpressionsFix.createCleanUp(
        compilationUnit,
        isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS),
        isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_NEVER));
  }
  /** {@inheritDoc} */
  @Override
  public ICleanUpFix createFix(CleanUpContext context) throws CoreException {
    CompilationUnit compilationUnit = context.getAST();
    if (compilationUnit == null) return null;

    boolean convertForLoops =
        isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED);

    return ConvertLoopFix.createCleanUp(
        compilationUnit,
        convertForLoops,
        convertForLoops,
        isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL)
            && isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_LOCAL_VARIABLES));
  }
  @Override
  public ICleanUpFix createFix(CleanUpContext context) throws CoreException {
    ICompilationUnit unit = context.getCompilationUnit();

    if (!(unit instanceof GroovyCompilationUnit)) {
      return null;
    }

    GroovyCompilationUnit gunit = (GroovyCompilationUnit) unit;
    char[] contents = gunit.getContents();
    ITextSelection sel = new TextSelection(0, contents.length);
    IDocument doc = new Document(new String(contents));
    boolean isIndentOnly = kind == FormatKind.INDENT_ONLY;
    IFormatterPreferences preferences = new FormatterPreferences(gunit);

    DefaultGroovyFormatter formatter =
        new DefaultGroovyFormatter(sel, doc, preferences, isIndentOnly);
    TextEdit edit = formatter.format();

    return new TextEditFix(edit, gunit, "Format groovy source code.");
  }