KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > javadoc > DocSuggester


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.tasklist.javadoc;
21
22 import java.util.List JavaDoc;
23 import org.netbeans.modules.tasklist.javadoc.ext.JavaDocOpenProjectsScanner;
24 import org.openide.loaders.DataObject;
25 import org.openide.loaders.DataObjectNotFoundException;
26 import org.netbeans.modules.tasklist.client.SuggestionManager;
27 import org.netbeans.modules.tasklist.providers.DocumentSuggestionProvider;
28 import org.netbeans.modules.tasklist.providers.SuggestionContext;
29 import org.netbeans.modules.tasklist.javadoc.ext.JavadocProxy;
30 import org.openide.filesystems.FileObject;
31
32
33 /**
34  * This class lists the javadoc errors for the current document/class
35  * <p>
36  *
37  * @todo Add Confirmation panels
38  *
39  * @todo Look at performance. Rewrite the ListModel stuff.
40  * Or find a way to reuse the javadoc module AutoCommenter directly.
41  *
42  * @todo Handle the case where a formal parameter has been renamed
43  * better. Instead of offering one action to delete the
44  * javadoc and another to add for the new name, have some kind
45  * of rename-mapping. For example, the confirmation dialog
46  * could ask you to select among existing items instead (where
47  * I list undocumented parameters)
48  *
49  * @todo Try to position the cursor better: if you double click on a
50  * "@param is missing description" error, don't go to the front of
51  * the javadoc comment - go to the line with the particular @param!
52  *
53  * @todo Even though I list javadoc errors as separate suggestions,
54  * the fixer will apply ALL suggestions for the same method in
55  * on operation. This means the user doesn't get to select one
56  * and not all of the suggestions. This should be fixed, but requires
57  * some rearchitecting of the autoCorrect function in auto-commenter.
58  * Short term, I should at least remove the other suggestions after
59  * fix!
60  *
61  * @author Tor Norbye
62  * @author tl
63  */

64 public final class DocSuggester extends DocumentSuggestionProvider {
65     public static final String JavaDoc TYPE = "nb-javadoc-errors"; // NOI18N
66

67     /** The list of tasks we're currently showing in the tasklist */
68     private List JavaDoc showingTasks = null;
69     
70     static {
71         Thread JavaDoc t = new Thread JavaDoc(new JavaDocOpenProjectsScanner());
72         t.setPriority(Thread.MIN_PRIORITY);
73         t.setDaemon(true);
74         t.start();
75     }
76     
77     public String JavaDoc getType() {
78         return TYPE;
79     }
80     
81     public List JavaDoc scan(final SuggestionContext env) {
82
83         if (SuggestionManager.getDefault().isEnabled(TYPE)) {
84             FileObject fo = env.getFileObject();
85             DataObject dobj;
86             try {
87                 dobj = DataObject.find(fo);
88             } catch (DataObjectNotFoundException e) {
89                 return null;
90             }
91             return JavadocProxy.findErrors(dobj);
92         } else {
93             return null;
94         }
95     }
96
97 }
98
Popular Tags