KickJava   Java API By Example, From Geeks To Geeks.

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


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
24 import org.netbeans.api.gsf.annotations.CheckForNull;
25 import org.netbeans.api.gsf.annotations.NonNull;
26 import org.netbeans.api.gsf.annotations.Nullable;
27 import org.netbeans.api.lexer.Language;
28 import org.netbeans.api.lexer.TokenId;
29
30
31 /**
32  * Lexical information for a given language.
33  *
34  * @author <a HREF="mailto:tor.norbye@sun.com">Tor Norbye</a>
35  */

36 public interface GsfLanguage {
37     /**
38      * <p>Return the prefix used for line comments in this language, or null if this language
39      * does not have a line comment. As an example, a Java scanner would return <code>//</code>,
40      * a Ruby scanner would return <code>#</code>, a Visual Basic scanner would return <code>'</code>, etc.
41      * </p>
42      */

43     @CheckForNull
44     String JavaDoc getLineCommentPrefix();
45     
46     /**
47      * <p>Return true iff the given character is considered to be an identifier character. This
48      * is used for example when the user double clicks in the editor to select a "word" or identifier
49      * by checking to the left and to the right of the caret position and selecting until a character
50      * is not considered an identifier char by the scanner.
51      * </p>
52      * <p>
53      * For a language like Java, just return Character.isJavaIdentifierPart(). For something like
54      * Ruby, we also want to include "@" and "$" such that double clicking on a global variable
55      * for example will include the global prefix "$".
56      */

57     boolean isIdentifierChar(char c);
58     
59     /**
60      * <p>Return the Lexer Language associated with this scanner
61      *</p>
62      */

63     @NonNull
64     Language getLexerLanguage();
65
66     /**
67      * <p>Return a set of token types that are relevant to the lexer for this language.
68      * "Relevant" here
69      * means that it's a TokenType that will ever be passed in by the scanner to the
70      * {@link TokenResult}.</p>
71      * <p>
72      * Technically, it's a List, not a Set. The list of TokenTypes will be used for
73      * example in the color and font chooser for the editor, such that users can customize
74      * the appearance of source text. The order of the tokens in the list will be used
75      * in the TokenType list in the editor style chooser.
76      * </p>
77      * <p>
78      * If a language returns null or an empty List, <b>all</b> known TokenTypes will be
79      * offered to the user. To avoid this, return only tokens that are relevant to this
80      * language.
81      * </p>
82      * <p>
83      * You are strongly encouraged to use existing {@link DefaultTokenType} tokens when
84      * possible, such that user's existing color customizations will apply.
85      * </p>
86      * <p>
87      * You should also register a code fragment sample in the layer
88      * (at <code>OptionsDialog/PreviewExamples/</code><i>mime/type/</i>) and this code
89      * sample should try to use as many of the tokens pertaining to the language such
90      * that users can see the effect of customizing the various token types.
91      * </p>
92      * @todo Make this into a Map interface that is called just once instead.
93      */

94     @CheckForNull
95     List JavaDoc<? extends TokenId> getRelevantTokenTypes();
96 }
97
Popular Tags