1 11 package org.eclipse.jdt.internal.ui.fix; 12 13 import java.util.Map ; 14 15 import org.eclipse.core.runtime.Assert; 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.core.runtime.IProgressMonitor; 18 19 import org.eclipse.ltk.core.refactoring.RefactoringStatus; 20 21 import org.eclipse.jdt.core.ICompilationUnit; 22 import org.eclipse.jdt.core.IJavaProject; 23 import org.eclipse.jdt.core.compiler.IProblem; 24 import org.eclipse.jdt.core.dom.CompilationUnit; 25 26 import org.eclipse.jdt.internal.corext.fix.CleanUpConstants; 27 import org.eclipse.jdt.internal.corext.fix.IFix; 28 29 public abstract class AbstractCleanUp implements ICleanUp { 30 31 private Map fOptions; 32 private final boolean fCanReinitialize; 33 34 public AbstractCleanUp() { 35 this(null); 36 } 37 38 public AbstractCleanUp(Map options) { 39 fOptions= options; 40 fCanReinitialize= options == null; 41 } 42 43 protected int getNumberOfProblems(IProblem[] problems, int problemId) { 44 int result= 0; 45 for (int i= 0; i < problems.length; i++) { 46 if (problems[i].getID() == problemId) 47 result++; 48 } 49 return result; 50 } 51 52 55 public RefactoringStatus checkPreConditions(IJavaProject project, ICompilationUnit[] compilationUnits, IProgressMonitor monitor) throws CoreException { 56 if (monitor != null) 57 monitor.done(); 58 return new RefactoringStatus(); 59 } 60 61 64 public RefactoringStatus checkPostConditions(IProgressMonitor monitor) throws CoreException { 65 if (monitor != null) 66 monitor.done(); 67 return new RefactoringStatus(); 69 } 70 71 74 public void initialize(Map settings) throws CoreException { 75 if (fCanReinitialize) 76 fOptions= settings; 77 } 78 79 protected boolean isEnabled(String key) { 80 Assert.isNotNull(key); 81 82 Object value= fOptions.get(key); 83 return CleanUpConstants.TRUE == value || CleanUpConstants.TRUE.equals(value); 84 } 85 86 89 public boolean needsFreshAST(CompilationUnit compilationUnit) { 90 return false; 91 } 92 93 96 public IFix createFix(ICompilationUnit unit) throws CoreException { 97 return null; 98 } 99 } 100 | Popular Tags |