1 11 package org.eclipse.jdt.internal.ui.fix; 12 13 import java.util.HashMap ; 14 import java.util.Map ; 15 16 import org.eclipse.core.runtime.CoreException; 17 18 import org.eclipse.jdt.core.ICompilationUnit; 19 import org.eclipse.jdt.core.dom.CompilationUnit; 20 import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; 21 22 import org.eclipse.jdt.internal.corext.fix.CleanUpConstants; 23 import org.eclipse.jdt.internal.corext.fix.IFix; 24 25 import org.eclipse.jdt.ui.text.java.IProblemLocation; 26 27 public class CommentFormatCleanUp extends AbstractCleanUp { 28 29 public CommentFormatCleanUp(Map options) { 30 super(options); 31 } 32 33 public CommentFormatCleanUp() { 34 super(); 35 } 36 37 public IFix createFix(ICompilationUnit compilationUnit) throws CoreException { 38 if (compilationUnit == null) 39 return null; 40 41 if (!isEnabled(CleanUpConstants.FORMAT_SOURCE_CODE)) 42 return null; 43 44 HashMap preferences= new HashMap (compilationUnit.getJavaProject().getOptions(true)); 45 46 boolean singleLineComment= DefaultCodeFormatterConstants.TRUE.equals(preferences.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT)); 47 boolean blockComment= DefaultCodeFormatterConstants.TRUE.equals(preferences.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT)); 48 boolean javaDoc= DefaultCodeFormatterConstants.TRUE.equals(preferences.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT)); 49 50 return CommentFormatFix.createCleanUp(compilationUnit, singleLineComment, blockComment, javaDoc, preferences); 51 } 52 53 56 public IFix createFix(CompilationUnit compilationUnit) throws CoreException { 57 return null; 58 } 59 60 63 public boolean requireAST(ICompilationUnit unit) throws CoreException { 64 return false; 65 } 66 67 70 public IFix createFix(CompilationUnit compilationUnit, IProblemLocation[] problems) throws CoreException { 71 if (compilationUnit == null) 72 return null; 73 74 return null; 75 } 76 77 public Map getRequiredOptions() { 78 return null; 79 } 80 81 84 public String [] getDescriptions() { 85 return null; 86 } 87 88 public String getPreview() { 89 StringBuffer buf= new StringBuffer (); 90 buf.append("/**\n"); buf.append(" *A Javadoc comment\n"); buf.append("* @since 2007\n"); buf.append(" */\n"); 95 return buf.toString(); 96 } 97 98 101 public int maximalNumberOfFixes(CompilationUnit compilationUnit) { 102 return -1; 103 } 104 105 public boolean canFix(CompilationUnit compilationUnit, IProblemLocation problem) throws CoreException { 106 return false; 107 } 108 109 } 110 | Popular Tags |