Lines 1-127
Link Here
|
1 |
/* |
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* |
4 |
* Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. |
5 |
* |
6 |
* Oracle and Java are registered trademarks of Oracle and/or its affiliates. |
7 |
* Other names may be trademarks of their respective owners. |
8 |
* |
9 |
* The contents of this file are subject to the terms of either the GNU |
10 |
* General Public License Version 2 only ("GPL") or the Common |
11 |
* Development and Distribution License("CDDL") (collectively, the |
12 |
* "License"). You may not use this file except in compliance with the |
13 |
* License. You can obtain a copy of the License at |
14 |
* http://www.netbeans.org/cddl-gplv2.html |
15 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the |
16 |
* specific language governing permissions and limitations under the |
17 |
* License. When distributing the software, include this License Header |
18 |
* Notice in each file and include the License file at |
19 |
* nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this |
20 |
* particular file as subject to the "Classpath" exception as provided |
21 |
* by Oracle in the GPL Version 2 section of the License file that |
22 |
* accompanied this code. If applicable, add the following below the |
23 |
* License Header, with the fields enclosed by brackets [] replaced by |
24 |
* your own identifying information: |
25 |
* "Portions Copyrighted [year] [name of copyright owner]" |
26 |
* |
27 |
* Contributor(s): |
28 |
* |
29 |
* The Original Software is NetBeans. The Initial Developer of the Original |
30 |
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2009 Sun |
31 |
* Microsystems, Inc. All Rights Reserved. |
32 |
* |
33 |
* If you wish your version of this file to be governed by only the CDDL |
34 |
* or only the GPL Version 2, indicate your decision by adding |
35 |
* "[Contributor] elects to include this software in this distribution |
36 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a |
37 |
* single choice of license, a recipient has the option to distribute |
38 |
* your version of this file under either the CDDL, the GPL Version 2 or |
39 |
* to extend the choice of license to its licensees as provided above. |
40 |
* However, if you add GPL Version 2 code and therefore, elected the GPL |
41 |
* Version 2 license, then the option applies only if the new code is |
42 |
* made subject to such option by the copyright holder. |
43 |
*/ |
44 |
|
45 |
package org.netbeans.modules.db.sql.editor; |
46 |
|
47 |
import java.util.logging.Level; |
48 |
import java.util.logging.Logger; |
49 |
import org.netbeans.editor.BaseTokenCategory; |
50 |
import org.netbeans.editor.BaseTokenID; |
51 |
import org.netbeans.editor.TokenContext; |
52 |
import org.netbeans.editor.TokenContextPath; |
53 |
|
54 |
/** |
55 |
* SQL token-context defines token-ids and token-categories |
56 |
* used in SQL language. |
57 |
* |
58 |
* @author Jesse Beaumont based on code by Miloslav Metelka |
59 |
*/ |
60 |
|
61 |
public class SQLTokenContext extends TokenContext { |
62 |
|
63 |
// Numeric-ids for token categories |
64 |
public static final int ERRORS_ID = 0; // errors |
65 |
|
66 |
// Numeric-ids for token-ids |
67 |
public static final int WHITESPACE_ID = ERRORS_ID + 1; // inside white space |
68 |
public static final int LINE_COMMENT_ID = WHITESPACE_ID + 1; // inside line comment -- |
69 |
public static final int BLOCK_COMMENT_ID = LINE_COMMENT_ID + 1; // inside block comment /* ... */ |
70 |
public static final int STRING_ID = BLOCK_COMMENT_ID + 1; // inside string constant |
71 |
public static final int INCOMPLETE_STRING_ID = STRING_ID + 1; // inside string constant after ' |
72 |
public static final int IDENTIFIER_ID = INCOMPLETE_STRING_ID + 1; // inside identifier |
73 |
public static final int OPERATOR_ID = IDENTIFIER_ID + 1; // slash char |
74 |
public static final int INVALID_COMMENT_END_ID = OPERATOR_ID + 1; // after '0' |
75 |
public static final int INT_LITERAL_ID = INVALID_COMMENT_END_ID + 1; // integer number |
76 |
public static final int DOUBLE_LITERAL_ID = INT_LITERAL_ID + 1; // double number |
77 |
public static final int DOT_ID = DOUBLE_LITERAL_ID + 1; // after '.' |
78 |
public static final int KEYWORD_ID = DOT_ID + 1; |
79 |
|
80 |
// Token categories |
81 |
public static final BaseTokenCategory ERRORS = |
82 |
new BaseTokenCategory("errors", ERRORS_ID); // NOI18N |
83 |
|
84 |
// Token-ids |
85 |
public static final BaseTokenID WHITESPACE = |
86 |
new BaseTokenID( "whitespace", WHITESPACE_ID ); // NOI18N |
87 |
public static final BaseTokenID LINE_COMMENT = |
88 |
new BaseTokenID( "line-comment", LINE_COMMENT_ID ); // NOI18N |
89 |
public static final BaseTokenID BLOCK_COMMENT = |
90 |
new BaseTokenID( "block-comment", BLOCK_COMMENT_ID ); // NOI18N |
91 |
public static final BaseTokenID STRING = |
92 |
new BaseTokenID( "string-literal", STRING_ID ); // NOI18N |
93 |
public static final BaseTokenID INCOMPLETE_STRING = |
94 |
new BaseTokenID( "incomplete-string-literal", INCOMPLETE_STRING_ID, ERRORS ); // NOI18N |
95 |
public static final BaseTokenID IDENTIFIER = |
96 |
new BaseTokenID( "identifier", IDENTIFIER_ID ); // NOI18N |
97 |
public static final BaseTokenID OPERATOR = |
98 |
new BaseTokenID( "operator", OPERATOR_ID ); // NOI18N |
99 |
public static final BaseTokenID INVALID_COMMENT_END = |
100 |
new BaseTokenID( "invalid-comment-end", INVALID_COMMENT_END_ID, ERRORS ); // NOI18N |
101 |
public static final BaseTokenID INT_LITERAL = |
102 |
new BaseTokenID( "int-literal", INT_LITERAL_ID ); // NOI18N |
103 |
public static final BaseTokenID DOUBLE_LITERAL = |
104 |
new BaseTokenID( "double-literal", DOUBLE_LITERAL_ID ); // NOI18N |
105 |
public static final BaseTokenID DOT = |
106 |
new BaseTokenID( "dot", DOT_ID ); // NOI18N |
107 |
public static final BaseTokenID KEYWORD = |
108 |
new BaseTokenID( "keyword", KEYWORD_ID ); // NOI18N |
109 |
|
110 |
// Context instance declaration |
111 |
public static final SQLTokenContext context = new SQLTokenContext(); |
112 |
public static final TokenContextPath contextPath = context.getContextPath(); |
113 |
|
114 |
/** |
115 |
* Constructs a new SQLTokenContext |
116 |
*/ |
117 |
private SQLTokenContext() { |
118 |
super("sql-"); // NOI18N |
119 |
|
120 |
try { |
121 |
addDeclaredTokenIDs(); |
122 |
} catch (Exception e) { |
123 |
Logger.getLogger (SQLTokenContext.class.getName ()).log (Level.INFO, e.getLocalizedMessage (), e); |
124 |
} |
125 |
|
126 |
} |
127 |
} |