KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > fix > CommentFormatCleanUp


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.ui.fix;
12
13 import java.util.HashMap JavaDoc;
14 import java.util.Map JavaDoc;
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 JavaDoc 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 JavaDoc preferences= new HashMap JavaDoc(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     /**
54      * {@inheritDoc}
55      */

56     public IFix createFix(CompilationUnit compilationUnit) throws CoreException {
57         return null;
58     }
59     
60     /**
61      * {@inheritDoc}
62      */

63     public boolean requireAST(ICompilationUnit unit) throws CoreException {
64         return false;
65     }
66     
67     /**
68      * {@inheritDoc}
69      */

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 JavaDoc getRequiredOptions() {
78         return null;
79     }
80     
81     /**
82      * {@inheritDoc}
83      */

84     public String JavaDoc[] getDescriptions() {
85         return null;
86     }
87     
88     public String JavaDoc getPreview() {
89         StringBuffer JavaDoc buf= new StringBuffer JavaDoc();
90         buf.append("/**\n"); //$NON-NLS-1$
91
buf.append(" *A Javadoc comment\n"); //$NON-NLS-1$
92
buf.append("* @since 2007\n"); //$NON-NLS-1$
93
buf.append(" */\n"); //$NON-NLS-1$
94

95         return buf.toString();
96     }
97     
98     /**
99      * {@inheritDoc}
100      */

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