public IFix createFix(ICompilationUnit compilationUnit) throws CoreException { if (compilationUnit == null) return null; boolean removeWhitespaces= isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES); return CodeFormatFix.createCleanUp(compilationUnit, isEnabled(CleanUpConstants.FORMAT_SOURCE_CODE), removeWhitespaces && isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_ALL), removeWhitespaces && isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_IGNORE_EMPTY)); }
@Override public String[] getStepDescriptions() { ArrayList<String> result= new ArrayList<>(); if (isEnabled(CleanUpConstants.FORMAT_SOURCE_CODE)) result.add(MultiFixMessages.CodeFormatCleanUp_description); if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES)) { if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_ALL)) { result.add(MultiFixMessages.CodeFormatCleanUp_RemoveTrailingAll_description); } else if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_IGNORE_EMPTY)) { result.add(MultiFixMessages.CodeFormatCleanUp_RemoveTrailingNoEmpty_description); } } if (isEnabled(CleanUpConstants.FORMAT_CORRECT_INDENTATION)) result.add(MultiFixMessages.CodeFormatCleanUp_correctIndentation_description); return result.toArray(new String[result.size()]); }
@Override public String[] getStepDescriptions() { ArrayList<String> result= new ArrayList<>(); if (isEnabled(CleanUpConstants.FORMAT_SOURCE_CODE)) result.add(MultiFixMessages.CodeFormatCleanUp_description); if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES)) { if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_ALL)) { result.add(MultiFixMessages.CodeFormatCleanUp_RemoveTrailingAll_description); } else if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_IGNORE_EMPTY)) { result.add(MultiFixMessages.CodeFormatCleanUp_RemoveTrailingNoEmpty_description); } } if (isEnabled(CleanUpConstants.FORMAT_CORRECT_INDENTATION)) result.add(MultiFixMessages.CodeFormatCleanUp_correctIndentation_description); return result.toArray(new String[result.size()]); }
/** * {@inheritDoc} */ public String[] getDescriptions() { ArrayList result= new ArrayList(); if (isEnabled(CleanUpConstants.FORMAT_SOURCE_CODE)) result.add(MultiFixMessages.CodeFormatCleanUp_description); if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES)) { if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_ALL)) { result.add(MultiFixMessages.CodeFormatCleanUp_RemoveTrailingAll_description); } else if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_IGNORE_EMPTY)) { result.add(MultiFixMessages.CodeFormatCleanUp_RemoveTrailingNoEmpty_description); } } return (String[])result.toArray(new String[result.size()]); }
@Override public ICleanUpFix createFix(CleanUpContext context) throws CoreException { ICompilationUnit compilationUnit= context.getCompilationUnit(); if (compilationUnit == null) return null; IRegion[] regions; if (context instanceof MultiLineCleanUpContext) { regions= ((MultiLineCleanUpContext)context).getRegions(); } else { regions= null; } boolean removeWhitespaces= isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES); return CodeFormatFix.createCleanUp(compilationUnit, regions, isEnabled(CleanUpConstants.FORMAT_SOURCE_CODE), removeWhitespaces && isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_ALL), removeWhitespaces && isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_IGNORE_EMPTY), isEnabled(CleanUpConstants.FORMAT_CORRECT_INDENTATION)); }
@Override public ICleanUpFix createFix(CleanUpContext context) throws CoreException { ICompilationUnit compilationUnit= context.getCompilationUnit(); if (compilationUnit == null) return null; IRegion[] regions; if (context instanceof MultiLineCleanUpContext) { regions= ((MultiLineCleanUpContext)context).getRegions(); } else { regions= null; } boolean removeWhitespaces= isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES); return CodeFormatFix.createCleanUp(compilationUnit, regions, isEnabled(CleanUpConstants.FORMAT_SOURCE_CODE), removeWhitespaces && isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_ALL), removeWhitespaces && isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_IGNORE_EMPTY), isEnabled(CleanUpConstants.FORMAT_CORRECT_INDENTATION)); }
public String getPreview() { StringBuffer buf= new StringBuffer(); buf.append("public class Engine {\n"); //$NON-NLS-1$ buf.append(" public void start() {}\n"); //$NON-NLS-1$ if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES) && isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_ALL)) { buf.append("\n"); //$NON-NLS-1$ } else { buf.append(" \n"); //$NON-NLS-1$ } if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES)) { buf.append(" public\n"); //$NON-NLS-1$ } else { buf.append(" public \n"); //$NON-NLS-1$ } buf.append(" void stop() {\n"); //$NON-NLS-1$ buf.append(" }\n"); //$NON-NLS-1$ buf.append("}\n"); //$NON-NLS-1$ return buf.toString(); }
@Override public String getPreview() { StringBuilder buf= new StringBuilder(); buf.append("/**\n"); //$NON-NLS-1$ buf.append(" *A Javadoc comment\n"); //$NON-NLS-1$ buf.append("* @since 2007\n"); //$NON-NLS-1$ buf.append(" */\n"); //$NON-NLS-1$ buf.append("public class Engine {\n"); //$NON-NLS-1$ buf.append(" public void start() {}\n"); //$NON-NLS-1$ if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES) && isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_ALL)) { buf.append("\n"); //$NON-NLS-1$ } else { buf.append(" \n"); //$NON-NLS-1$ } if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES)) { buf.append(" public\n"); //$NON-NLS-1$ } else { buf.append(" public \n"); //$NON-NLS-1$ } buf.append(" void stop() {\n"); //$NON-NLS-1$ buf.append(" }\n"); //$NON-NLS-1$ buf.append("}\n"); //$NON-NLS-1$ return buf.toString(); } }
@Override public String getPreview() { StringBuffer buf= new StringBuffer(); buf.append("/**\n"); //$NON-NLS-1$ buf.append(" *A Javadoc comment\n"); //$NON-NLS-1$ buf.append("* @since 2007\n"); //$NON-NLS-1$ buf.append(" */\n"); //$NON-NLS-1$ buf.append("public class Engine {\n"); //$NON-NLS-1$ buf.append(" public void start() {}\n"); //$NON-NLS-1$ if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES) && isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_ALL)) { buf.append("\n"); //$NON-NLS-1$ } else { buf.append(" \n"); //$NON-NLS-1$ } if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES)) { buf.append(" public\n"); //$NON-NLS-1$ } else { buf.append(" public \n"); //$NON-NLS-1$ } buf.append(" void stop() {\n"); //$NON-NLS-1$ buf.append(" }\n"); //$NON-NLS-1$ buf.append("}\n"); //$NON-NLS-1$ return buf.toString(); } }