/** * {@inheritDoc} */ public boolean requireAST(ICompilationUnit unit) throws CoreException { boolean usePrentheses= isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES); if (!usePrentheses) return false; return isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS) || isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_NEVER); }
public IFix createFix(CompilationUnit compilationUnit) throws CoreException { 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)); }
@Override public String getPreview() { StringBuffer buf= new StringBuffer(); if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS)) { buf.append("boolean b= (((i > 0) && (i < 10)) || (i == 50));\n"); //$NON-NLS-1$ } else if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_NEVER)) { buf.append("boolean b= i > 0 && i < 10 || i == 50;\n"); //$NON-NLS-1$ } else { buf.append("boolean b= (i > 0 && i < 10 || i == 50);\n"); //$NON-NLS-1$ } return buf.toString(); }
@Override public String[] getStepDescriptions() { List<String> result= new ArrayList<>(); if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS)) result.add(MultiFixMessages.ExpressionsCleanUp_addParanoiac_description); if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_NEVER)) result.add(MultiFixMessages.ExpressionsCleanUp_removeUnnecessary_description); return result.toArray(new String[result.size()]); }
@Override public String getPreview() { StringBuilder buf= new StringBuilder(); if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS)) { buf.append("boolean b= (((i > 0) && (i < 10)) || (i == 50));\n"); //$NON-NLS-1$ } else if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_NEVER)) { buf.append("boolean b= i > 0 && i < 10 || i == 50;\n"); //$NON-NLS-1$ } else { buf.append("boolean b= (i > 0 && i < 10 || i == 50);\n"); //$NON-NLS-1$ } return buf.toString(); }
public String getPreview() { StringBuffer buf= new StringBuffer(); if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS)) { buf.append("boolean b= (((i > 0) && (i < 10)) || (i == 50));\n"); //$NON-NLS-1$ } else if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_NEVER)) { buf.append("boolean b= i > 0 && i < 10 || i == 50;\n"); //$NON-NLS-1$ } else { buf.append("boolean b= (i > 0 && i < 10 || i == 50);\n"); //$NON-NLS-1$ } return buf.toString(); }
/** * {@inheritDoc} */ public String[] getDescriptions() { List result= new ArrayList(); if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS)) result.add(MultiFixMessages.ExpressionsCleanUp_addParanoiac_description); if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_NEVER)) result.add(MultiFixMessages.ExpressionsCleanUp_removeUnnecessary_description); return (String[])result.toArray(new String[result.size()]); }
@Override public String[] getStepDescriptions() { List<String> result= new ArrayList<>(); if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS)) result.add(MultiFixMessages.ExpressionsCleanUp_addParanoiac_description); if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_NEVER)) result.add(MultiFixMessages.ExpressionsCleanUp_removeUnnecessary_description); return result.toArray(new String[result.size()]); }
@Override 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)); }
@Override 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} */ public boolean canFix(CompilationUnit compilationUnit, IProblemLocation problem) throws CoreException { if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS)) { IFix fix= ExpressionsFix.createAddParanoidalParenthesisFix(compilationUnit, new ASTNode[] {problem.getCoveredNode(compilationUnit)}); if (fix != null) return true; } if (isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES) && isEnabled(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_NEVER)) { IFix fix= ExpressionsFix.createRemoveUnnecessaryParenthesisFix(compilationUnit, new ASTNode[] {problem.getCoveredNode(compilationUnit)}); if (fix != null) return true; } return false; }