KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > api > gsf > Completable


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.api.gsf;
21
22 import java.util.List JavaDoc;
23 import org.netbeans.api.gsf.CompletionProposal;
24 import org.netbeans.api.gsf.CompilationInfo;
25 import org.netbeans.api.gsf.Element;
26 import org.netbeans.api.gsf.HtmlFormatter;
27
28
29 /**
30  * Provide code completion for this language. This implementation
31  * is responsible for all the analysis around the given caret offset.
32  * A code completion provider should be smart and for example limit
33  * alternatives not just by the given identifier prefix at the caret offset,
34  * but also by the surrounding context; for example, if we're doing
35  * code completion inside an expression that is part of a {@code return}
36  * statement, the types should be limited by the return type of the current
37  * method, and so on.
38  *
39  * A default SPI implementation is available that will perform some of this
40  * analysis assuming it's applied to a parse tree using the other SPI default
41  * implementation classes.
42  *
43  * @todo Rename me to CodeCompletion or CompletionProvider or Completer or something like that
44  * @todo Instead of passing in caseSensitive, should I pass in a Comparator which should be used
45  * for determining eligibility? That way it's completely insulated from the clients
46  *
47  * @author Tor Norbye
48  */

49 public interface Completable {
50     /**
51      * @todo Pass in the completion type? (Smart versus documentation etc.)
52      * @todo Pass in the line offsets? Nah, just make the completion provider figure those out.
53      */

54     List JavaDoc<CompletionProposal> complete(CompilationInfo info, int caretOffset, String JavaDoc prefix,
55         boolean caseSensitive, HtmlFormatter formatter);
56     
57     /**
58      * Return the HTML documentation for the given program element (returned in CompletionProposals
59      * by the complete method)
60      */

61     String JavaDoc document(CompilationInfo info, Element element);
62     
63     /**
64      * Compute the prefix to be used for completion at the given caretOffset
65      */

66     String JavaDoc getPrefix(CompilationInfo info, int caretOffset);
67     
68     // TODO:
69
// processKey action stuff from GsfCompletionItem to handle "(", "." etc.
70
}
71
Popular Tags