/** * {@inheritDoc} */ public boolean requireAST(ICompilationUnit unit) throws CoreException { return isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED); }
/** * {@inheritDoc} */ public IFix createFix(CompilationUnit compilationUnit) throws CoreException { 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 String[] getStepDescriptions() { List<String> result= new ArrayList<>(); if (isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED)) result.add(MultiFixMessages.Java50CleanUp_ConvertToEnhancedForLoop_description); return result.toArray(new String[result.size()]); }
@Override public String[] getStepDescriptions() { List<String> result= new ArrayList<>(); if (isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED)) result.add(MultiFixMessages.Java50CleanUp_ConvertToEnhancedForLoop_description); return result.toArray(new String[result.size()]); }
/** * {@inheritDoc} */ public String[] getDescriptions() { List result= new ArrayList(); if (isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED)) result.add(MultiFixMessages.Java50CleanUp_ConvertToEnhancedForLoop_description); return (String[])result.toArray(new String[result.size()]); }
@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 { 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 CleanUpRequirements getRequirements() { return new CleanUpRequirements(isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED), false, false, null); }
@Override public String getPreview() { StringBuffer buf= new StringBuffer(); if (isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED)) { buf.append("for (int element : ids) {\n"); //$NON-NLS-1$ buf.append(" double value= element / 2; \n"); //$NON-NLS-1$ buf.append(" System.out.println(value);\n"); //$NON-NLS-1$ buf.append("}\n"); //$NON-NLS-1$ } else { buf.append("for (int i = 0; i < ids.length; i++) {\n"); //$NON-NLS-1$ buf.append(" double value= ids[i] / 2; \n"); //$NON-NLS-1$ buf.append(" System.out.println(value);\n"); //$NON-NLS-1$ buf.append("}\n"); //$NON-NLS-1$ } return buf.toString(); } }
@Override public CleanUpRequirements getRequirements() { return new CleanUpRequirements(isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED), false, false, null); }
public String getPreview() { StringBuffer buf= new StringBuffer(); if (isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED)) { buf.append("for (int element : ids) {\n"); //$NON-NLS-1$ buf.append(" double value= element / 2; \n"); //$NON-NLS-1$ buf.append(" System.out.println(value);\n"); //$NON-NLS-1$ buf.append("}\n"); //$NON-NLS-1$ } else { buf.append("for (int i = 0; i < ids.length; i++) {\n"); //$NON-NLS-1$ buf.append(" double value= ids[i] / 2; \n"); //$NON-NLS-1$ buf.append(" System.out.println(value);\n"); //$NON-NLS-1$ buf.append("}\n"); //$NON-NLS-1$ } return buf.toString(); }
@Override public String getPreview() { StringBuilder buf= new StringBuilder(); if (isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED)) { buf.append("for (int element : ids) {\n"); //$NON-NLS-1$ buf.append(" double value= element / 2; \n"); //$NON-NLS-1$ buf.append(" System.out.println(value);\n"); //$NON-NLS-1$ buf.append("}\n"); //$NON-NLS-1$ } else { buf.append("for (int i = 0; i < ids.length; i++) {\n"); //$NON-NLS-1$ buf.append(" double value= ids[i] / 2; \n"); //$NON-NLS-1$ buf.append(" System.out.println(value);\n"); //$NON-NLS-1$ buf.append("}\n"); //$NON-NLS-1$ } return buf.toString(); } }