private boolean requireAST() { boolean useBlocks= isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS); if (!useBlocks) return false; return isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS) || isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER) || isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW); }
private boolean requireAST() { boolean useBlocks= isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS); if (!useBlocks) return false; return isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS) || isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER) || isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW); }
/** * {@inheritDoc} */ public boolean requireAST(ICompilationUnit unit) throws CoreException { boolean useBlocks= isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS); if (!useBlocks) return false; return isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS) || isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER) || isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW); }
@Override public String[] getStepDescriptions() { List<String> result= new ArrayList<>(); if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS)) result.add(MultiFixMessages.CodeStyleMultiFix_ConvertSingleStatementInControlBodeyToBlock_description); if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER)) result.add(MultiFixMessages.ControlStatementsCleanUp_RemoveUnnecessaryBlocks_description); if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW)) result.add(MultiFixMessages.ControlStatementsCleanUp_RemoveUnnecessaryBlocksWithReturnOrThrow_description); return result.toArray(new String[result.size()]); }
@Override public String[] getStepDescriptions() { List<String> result= new ArrayList<>(); if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS)) result.add(MultiFixMessages.CodeStyleMultiFix_ConvertSingleStatementInControlBodeyToBlock_description); if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER)) result.add(MultiFixMessages.ControlStatementsCleanUp_RemoveUnnecessaryBlocks_description); if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW)) result.add(MultiFixMessages.ControlStatementsCleanUp_RemoveUnnecessaryBlocksWithReturnOrThrow_description); return result.toArray(new String[result.size()]); }
/** * {@inheritDoc} */ public IFix createFix(CompilationUnit compilationUnit) throws CoreException { if (compilationUnit == null) return null; boolean useBlocks= isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS); if (!useBlocks) return null; return ControlStatementsFix.createCleanUp(compilationUnit, isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS), isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER), isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW)); }
/** * {@inheritDoc} */ public String[] getDescriptions() { List result= new ArrayList(); if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS)) result.add(MultiFixMessages.CodeStyleMultiFix_ConvertSingleStatementInControlBodeyToBlock_description); if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER)) result.add(MultiFixMessages.ControlStatementsCleanUp_RemoveUnnecessaryBlocks_description); if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW)) result.add(MultiFixMessages.ControlStatementsCleanUp_RemoveUnnecessaryBlocksWithReturnOrThrow_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 useBlocks= isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS); if (!useBlocks) return null; return ControlStatementsFix.createCleanUp(compilationUnit, isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS), isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER), isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW)); }
@Override public ICleanUpFix createFix(CleanUpContext context) throws CoreException { CompilationUnit compilationUnit= context.getAST(); if (compilationUnit == null) return null; boolean useBlocks= isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS); if (!useBlocks) return null; return ControlStatementsFix.createCleanUp(compilationUnit, isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS), isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER), isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW)); }
public String getPreview() { StringBuffer buf= new StringBuffer(); if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS)) { buf.append("if (obj == null) {\n"); //$NON-NLS-1$ buf.append(" throw new IllegalArgumentException();\n"); //$NON-NLS-1$ buf.append(" return;\n"); //$NON-NLS-1$ buf.append("}\n"); //$NON-NLS-1$ } else if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER)){ buf.append("if (obj == null)\n"); //$NON-NLS-1$ buf.append(" throw new IllegalArgumentException();\n"); //$NON-NLS-1$ buf.append(" return;\n"); //$NON-NLS-1$ buf.append("\n"); //$NON-NLS-1$ } else if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW)) { buf.append("if (obj == null)\n"); //$NON-NLS-1$ buf.append(" throw new IllegalArgumentException();\n"); //$NON-NLS-1$
StringBuffer buf= new StringBuffer(); if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS)) { buf.append("if (obj == null) {\n"); //$NON-NLS-1$ buf.append(" throw new IllegalArgumentException();\n"); //$NON-NLS-1$ buf.append(" return;\n"); //$NON-NLS-1$ buf.append("}\n"); //$NON-NLS-1$ } else if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER)){ buf.append("if (obj == null)\n"); //$NON-NLS-1$ buf.append(" throw new IllegalArgumentException();\n"); //$NON-NLS-1$ buf.append(" return;\n"); //$NON-NLS-1$ buf.append("\n"); //$NON-NLS-1$ } else if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW)) { buf.append("if (obj == null)\n"); //$NON-NLS-1$ buf.append(" throw new IllegalArgumentException();\n"); //$NON-NLS-1$
StringBuilder buf= new StringBuilder(); if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS)) { buf.append("if (obj == null) {\n"); //$NON-NLS-1$ buf.append(" throw new IllegalArgumentException();\n"); //$NON-NLS-1$ buf.append(" return;\n"); //$NON-NLS-1$ buf.append("}\n"); //$NON-NLS-1$ } else if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER)){ buf.append("if (obj == null)\n"); //$NON-NLS-1$ buf.append(" throw new IllegalArgumentException();\n"); //$NON-NLS-1$ buf.append(" return;\n"); //$NON-NLS-1$ buf.append("\n"); //$NON-NLS-1$ } else if (isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS) && isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW)) { buf.append("if (obj == null)\n"); //$NON-NLS-1$ buf.append(" throw new IllegalArgumentException();\n"); //$NON-NLS-1$