KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > gsf > Language


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 package org.netbeans.modules.gsf;
20
21 import javax.swing.Action JavaDoc;
22 import org.netbeans.api.gsf.*;
23 import org.netbeans.api.gsf.Completable;
24 import org.netbeans.api.gsf.DeclarationFinder;
25 import org.netbeans.api.gsf.InstantRenamer;
26 import org.netbeans.api.gsf.Parser;
27 import org.netbeans.api.gsf.GsfLanguage;
28 import org.netbeans.api.gsf.annotations.CheckForNull;
29 import org.netbeans.api.gsf.annotations.NonNull;
30 import org.netbeans.api.gsf.BracketCompletion;
31 import org.netbeans.api.gsf.Formatter;
32 import org.netbeans.api.gsf.Indexer;
33 import org.netbeans.api.gsf.StructureScanner;
34 import org.netbeans.spi.palette.PaletteController;
35
36
37 /**
38  * @todo Should languages get to declared "priorities"? In case there are
39  * overlaps in extensions that is.
40  * @todo Can I devise a way where one language can "extend" another?
41  * For example, the Jackpot Rule language should simply be the Java language
42  * with a couple of simple changes.
43  * @todo Add LanguageVersion list property. For example, for Java, they could be
44  * JDK 1.4, 5.0, 6.0. This would be exposed as a property somewhere (perhaps
45  * on a project basis) and would be used by plugins to drive parser specific
46  * info. Similarly for JavaScript I have multiple language versions - 1.0 through 1.6
47  * in the case of Rhino (corresponding to different JavaScript/EcmaScript versions).
48  * @todo Add a "Line Comment Prefix" property for languages (e.g. "//" for Java, "#" for ksh,
49  * etc. which can be used to drive the availability and implementation of the Comment
50  * (Shift + Meta + T) feature (and uncomment, Shift + Meta + D).
51  *
52  * @author <a HREF="mailto:tor.norbye@sun.com">Tor Norbye</a>
53  */

54 public interface Language {
55     /** Return the display-name (user visible, and localized) name of this language.
56      * It should be brief (one or two words). For example "Java", "C++", "Groovy",
57      * "Visual Basic", etc.
58      */

59     @NonNull
60     String JavaDoc getDisplayName();
61
62     /** Return the mime-type of this language. For example text/x-java.
63      */

64     @NonNull
65     String JavaDoc getMimeType();
66
67     /** Return the set of common file extensions used for source files in this
68      * type of language. It should not include the dot.
69      * For example, for Java it would be { "java" }. For C++ it might
70      * be { "cpp", "cc", "c++", "cxx" }. The first item in the array will be
71      * considered the "primary" extension that will be used when creating new
72      * files etc.
73      */

74     String JavaDoc[] getExtensions();
75
76     /** Return a scanner (lexical analyzer, tokenizer) for use with this language.
77      * @todo Clarify whether clients should cache instances of this or if it will
78      * be called only once and management done by the IDE
79      */

80     @CheckForNull
81     GsfLanguage getGsfLanguage();
82
83     /** Return a parser for use with this language. A parser is optional (in which
84      * case getParser() may return null) but in that case a lot of functionality
85      * will be disabled for this language.
86      * @todo Clarify whether clients should cache instances of this or if it will
87      * be called only once and management done by the IDE
88      */

89     @CheckForNull
90     Parser getParser();
91
92     /** Return Actions that will be provided in the editor context menu for this language.
93      */

94     Action JavaDoc[] getEditorActions();
95
96     /** Return an icon to be used for files of this language type.
97      * @see org.openide.util.Utilities#loadImage
98      */

99
100     //public Image getIcon();
101

102     /** Hmmmm this is a bit rough. The path would have to be relative to some resource...
103      * I guess it would be relative to the specific plugin language class?
104      * Example: "com/foo/bar/javascript.gif"
105      * @todo More documentation here, or revise API entirely
106      */

107     String JavaDoc getIconBase();
108
109     /**
110      * Get a code completion handler, if any
111      */

112     @CheckForNull
113     Completable getCompletionProvider();
114
115     /**
116      * Get a rename helper, if any, for instant renaming
117      */

118     @CheckForNull
119     InstantRenamer getInstantRenamer();
120
121     /**
122      * Get a Declaration finder, if any, for resolving declarations for a given identifier
123      */

124     @CheckForNull
125     DeclarationFinder getDeclarationFinder();
126     
127     /**
128      * Get an Formatter, if any, for helping indent and reformat code
129      */

130     @CheckForNull
131     Formatter getFormatter();
132     
133     /**
134      * Get a BracketCompletion helper, if any, for helping with bracket completion
135      */

136     @CheckForNull
137     BracketCompletion getBracketCompletion();
138     
139     /**
140      * Get an associated palette controller, if any
141      */

142     @CheckForNull
143     PaletteController getPalette();
144
145     /**
146      * Get an associated indexer, if any
147      */

148     @CheckForNull
149     Indexer getIndexer();
150     
151     /**
152      * Get a structure scanner which produces navigation/outline contents
153      */

154     @CheckForNull
155     StructureScanner getStructure();
156 }
157
Popular Tags