@Override public String[] getStepDescriptions() { if (isEnabled(CleanUpConstants.ADD_MISSING_METHODES)) return new String[] { MultiFixMessages.UnimplementedCodeCleanUp_AddUnimplementedMethods_description }; if (isEnabled(MAKE_TYPE_ABSTRACT)) return new String[] { MultiFixMessages.UnimplementedCodeCleanUp_MakeAbstract_description }; return null; }
@Override public String[] getStepDescriptions() { if (isEnabled(CleanUpConstants.ADD_MISSING_METHODES)) return new String[] { MultiFixMessages.UnimplementedCodeCleanUp_AddUnimplementedMethods_description }; if (isEnabled(MAKE_TYPE_ABSTRACT)) return new String[] { MultiFixMessages.UnimplementedCodeCleanUp_MakeAbstract_description }; return null; }
@Override public boolean canFix(ICompilationUnit compilationUnit, IProblemLocation problem) { int id= problem.getProblemId(); if (id == IProblem.AbstractMethodMustBeImplemented || id == IProblem.EnumConstantMustImplementAbstractMethod) return isEnabled(CleanUpConstants.ADD_MISSING_METHODES) || isEnabled(MAKE_TYPE_ABSTRACT); return false; }
@Override public boolean canFix(ICompilationUnit compilationUnit, IProblemLocation problem) { int id= problem.getProblemId(); if (id == IProblem.AbstractMethodMustBeImplemented || id == IProblem.EnumConstantMustImplementAbstractMethod) return isEnabled(CleanUpConstants.ADD_MISSING_METHODES) || isEnabled(MAKE_TYPE_ABSTRACT); return false; }
@Override protected ICleanUpFix createFix(CompilationUnit unit, IProblemLocation[] problems) throws CoreException { IProblemLocation[] problemLocations= filter(problems, new int[] { IProblem.AbstractMethodMustBeImplemented, IProblem.EnumConstantMustImplementAbstractMethod }); return UnimplementedCodeFix.createCleanUp(unit, isEnabled(CleanUpConstants.ADD_MISSING_METHODES), isEnabled(MAKE_TYPE_ABSTRACT), problemLocations); }
@Override protected ICleanUpFix createFix(CompilationUnit unit, IProblemLocation[] problems) throws CoreException { IProblemLocation[] problemLocations= filter(problems, new int[] { IProblem.AbstractMethodMustBeImplemented, IProblem.EnumConstantMustImplementAbstractMethod }); return UnimplementedCodeFix.createCleanUp(unit, isEnabled(CleanUpConstants.ADD_MISSING_METHODES), isEnabled(MAKE_TYPE_ABSTRACT), problemLocations); }
@Override public int computeNumberOfFixes(CompilationUnit compilationUnit) { if (!isEnabled(CleanUpConstants.ADD_MISSING_METHODES) && !isEnabled(MAKE_TYPE_ABSTRACT)) return 0; IProblemLocation[] locations= filter(convertProblems(compilationUnit.getProblems()), new int[] { IProblem.AbstractMethodMustBeImplemented, IProblem.EnumConstantMustImplementAbstractMethod }); HashSet<ASTNode> types= new HashSet<>(); for (int i= 0; i < locations.length; i++) { ASTNode type= UnimplementedCodeFix.getSelectedTypeNode(compilationUnit, locations[i]); if (type != null) { types.add(type); } } return types.size(); }
@Override public int computeNumberOfFixes(CompilationUnit compilationUnit) { if (!isEnabled(CleanUpConstants.ADD_MISSING_METHODES) && !isEnabled(MAKE_TYPE_ABSTRACT)) return 0; IProblemLocation[] locations= filter(convertProblems(compilationUnit.getProblems()), new int[] { IProblem.AbstractMethodMustBeImplemented, IProblem.EnumConstantMustImplementAbstractMethod }); HashSet<ASTNode> types= new HashSet<>(); for (int i= 0; i < locations.length; i++) { ASTNode type= UnimplementedCodeFix.getSelectedTypeNode(compilationUnit, locations[i]); if (type != null) { types.add(type); } } return types.size(); }
@Override public String getPreview() { StringBuffer buf= new StringBuffer(); if (isEnabled(MAKE_TYPE_ABSTRACT)) { buf.append("public abstract class Face implements IFace {\n"); //$NON-NLS-1$ } else { buf.append("public class Face implements IFace {\n"); //$NON-NLS-1$ } if (isEnabled(CleanUpConstants.ADD_MISSING_METHODES)) { boolean createComments= Boolean.valueOf(PreferenceConstants.getPreference(PreferenceConstants.CODEGEN_ADD_COMMENTS, null)).booleanValue(); if (createComments) buf.append(indent(getOverridingMethodComment(), " ")); //$NON-NLS-1$ buf.append(" @Override\n"); //$NON-NLS-1$ buf.append(" public void method() {\n"); //$NON-NLS-1$ buf.append(indent(getMethodBody(), " ")); //$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(); if (isEnabled(MAKE_TYPE_ABSTRACT)) { buf.append("public abstract class Face implements IFace {\n"); //$NON-NLS-1$ } else { buf.append("public class Face implements IFace {\n"); //$NON-NLS-1$ } if (isEnabled(CleanUpConstants.ADD_MISSING_METHODES)) { boolean createComments= Boolean.valueOf(PreferenceConstants.getPreference(PreferenceConstants.CODEGEN_ADD_COMMENTS, null)).booleanValue(); if (createComments) buf.append(indent(getOverridingMethodComment(), " ")); //$NON-NLS-1$ buf.append(" @Override\n"); //$NON-NLS-1$ buf.append(" public void method() {\n"); //$NON-NLS-1$ buf.append(indent(getMethodBody(), " ")); //$NON-NLS-1$ buf.append(" }\n"); //$NON-NLS-1$ } buf.append("}\n"); //$NON-NLS-1$ return buf.toString(); }
@Override protected ICleanUpFix createFix(CompilationUnit unit) throws CoreException { IProblemLocation[] problemLocations= convertProblems(unit.getProblems()); problemLocations= filter(problemLocations, new int[] { IProblem.AbstractMethodMustBeImplemented, IProblem.EnumConstantMustImplementAbstractMethod }); return UnimplementedCodeFix.createCleanUp(unit, isEnabled(CleanUpConstants.ADD_MISSING_METHODES), isEnabled(MAKE_TYPE_ABSTRACT), problemLocations); }
@Override protected ICleanUpFix createFix(CompilationUnit unit) throws CoreException { IProblemLocation[] problemLocations= convertProblems(unit.getProblems()); problemLocations= filter(problemLocations, new int[] { IProblem.AbstractMethodMustBeImplemented, IProblem.EnumConstantMustImplementAbstractMethod }); return UnimplementedCodeFix.createCleanUp(unit, isEnabled(CleanUpConstants.ADD_MISSING_METHODES), isEnabled(MAKE_TYPE_ABSTRACT), problemLocations); }