001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.cnd.editor.shell;
043:
044: import java.util.HashMap;
045: import org.netbeans.editor.BaseTokenCategory;
046: import org.netbeans.editor.BaseTokenID;
047: import org.netbeans.editor.TokenID;
048: import org.netbeans.editor.BaseImageTokenID;
049: import org.netbeans.editor.TokenContext;
050: import org.netbeans.editor.TokenContextPath;
051:
052: /**
053: * Shell token-context defines token-ids and token-categories
054: * used in Shells.
055: *
056: */
057:
058: public class ShellTokenContext extends TokenContext {
059:
060: private static int id = 1;
061:
062: // Token category
063: public static final int TC_FIRST_ID = id;
064:
065: public static final BaseTokenCategory TC_MACROS = new BaseTokenCategory(
066: "macros", id++); // NOI18N
067: public static final BaseTokenCategory TC_MACRO_OPERATORS = new BaseTokenCategory(
068: "macro-operators", id++); // NOI18N
069: public static final BaseTokenCategory TC_RULES = new BaseTokenCategory(
070: "rules", id++); // NOI18N
071: public static final BaseTokenCategory TC_GLOBAL = new BaseTokenCategory(
072: "global-special-characters", id++); // NOI18N
073: public static final BaseTokenCategory TC_TARGET = new BaseTokenCategory(
074: "targets", id++); // NOI18N
075: public static final BaseTokenCategory TC_ERRORS = new BaseTokenCategory(
076: "errors", id++); // NOI18N
077:
078: public static final int TC_LAST_ID = id - 1;
079:
080: //other literals [no category]
081:
082: public static final int NO_CAT_FIRST_ID = id;
083:
084: public static final BaseTokenID IDENTIFIER = new BaseTokenID(
085: "identifier", id++); // NOI18N
086: public static final BaseTokenID WHITESPACE = new BaseTokenID(
087: "whitespace", id++); // NOI18N
088: public static final BaseTokenID LINE_COMMENT = new BaseTokenID(
089: "line-comment", id++); // NOI18N
090: public static final BaseTokenID SHELL_COMMAND = new BaseTokenID(
091: "shell-command", id++); // NOI18N
092: public static final BaseTokenID STRING_LITERAL = new BaseTokenID(
093: "string-literal", id++); // NOI18N
094:
095: public static final int NO_CAT_LAST_ID = id - 1;
096:
097: //Macros
098:
099: public static final int MACRO_FIRST_ID = id;
100:
101: public static final BaseTokenID MACRO_LITERAL = new BaseTokenID(
102: "macro-literal", id++, TC_MACROS); // NOI18N
103: public static final BaseImageTokenID MACRO_DOLLAR = new BaseImageTokenID(
104: "dollar", id++, TC_MACROS, "$"); // NOI18N
105: public static final BaseImageTokenID MACRO_DOLAR_REFERENCE = new BaseImageTokenID(
106: "dollar-reference", id++, TC_MACROS, "$$"); // NOI18N
107: public static final BaseImageTokenID MACRO_ESCAPED_DOLLAR = new BaseImageTokenID(
108: "escaped-currency", id++, TC_MACROS, "\\$"); // NOI18N
109: public static final BaseImageTokenID MACRO_LPAREN = new BaseImageTokenID(
110: "left-paran", id++, TC_MACROS, "("); // NOI18N
111: public static final BaseImageTokenID MACRO_RPAREN = new BaseImageTokenID(
112: "right-paran", id++, TC_MACROS, ")"); // NOI18N
113: public static final BaseImageTokenID MACRO_LBRACE = new BaseImageTokenID(
114: "left-brace", id++, TC_MACROS, "{"); // NOI18N
115: public static final BaseImageTokenID MACRO_RBRACE = new BaseImageTokenID(
116: "right-brace", id++, TC_MACROS, "}"); // NOI18N
117: public static final BaseImageTokenID MACRO_COMMAND_SUBSTITUTE = new BaseImageTokenID(
118: "command substitute", id++, TC_MACROS, ":sh"); // NOI18N
119: public static final BaseImageTokenID MACRO_DYN_TARGET_BASENAME = new BaseImageTokenID(
120: "target-basename", id++, TC_MACROS, "$*"); // NOI18N
121: public static final BaseImageTokenID MACRO_DYN_DEPENDENCY_FILENAME = new BaseImageTokenID(
122: "dependency-filename", id++, TC_MACROS, "$<"); // NOI18N
123: public static final BaseImageTokenID MACRO_DYN_CURRENTTARGET = new BaseImageTokenID(
124: "current-target", id++, TC_MACROS, "$@"); // NOI18N
125: public static final BaseImageTokenID MACRO_DYN_DEPENDENCY_LIST = new BaseImageTokenID(
126: "dependency-list", id++, TC_MACROS, "$?"); // NOI18N
127: public static final BaseImageTokenID MACRO_DYN_LIBRARYNAME = new BaseImageTokenID(
128: "library-name", id++, TC_MACROS, "$%"); // NOI18N
129:
130: public static final int MACRO_LAST_ID = id - 1;
131:
132: //macro operators
133: public static final int MACRO_OPERATORS_FIRST_ID = id;
134:
135: public static final BaseImageTokenID MACRO_OP_EQUALS = new BaseImageTokenID(
136: "equals", id++, TC_MACRO_OPERATORS, "="); // NOI18N
137: public static final BaseImageTokenID MACRO_OP_APPEND = new BaseImageTokenID(
138: "append", id++, TC_MACRO_OPERATORS, "+="); // NOI18N
139: public static final BaseImageTokenID MACRO_OP_CONDITIONAL = new BaseImageTokenID(
140: "conditional", id++, TC_MACRO_OPERATORS, ":="); // NOI18N
141: public static final int MACRO_OPERATORS_LAST_ID = id - 1;
142:
143: //rules
144: public static final int RULES_FIRST_ID = id;
145:
146: public static final BaseImageTokenID RULES_PLUS = new BaseImageTokenID(
147: "plus", id++, TC_RULES, "+"); // NOI18N
148: public static final BaseImageTokenID RULES_MINUS = new BaseImageTokenID(
149: "minus", id++, TC_RULES, "-"); // NOI18N
150: public static final BaseImageTokenID RULES_AT = new BaseImageTokenID(
151: "at", id++, TC_RULES, "@"); // NOI18N
152: public static final BaseImageTokenID RULES_QUESTION_MARK = new BaseImageTokenID(
153: "question-mark", id++, TC_RULES, "?"); // NOI18N
154: public static final BaseImageTokenID RULES_EXCLAMATION = new BaseImageTokenID(
155: "exclamation", id++, TC_RULES, "!"); // NOI18N
156:
157: public static final int RULES_LAST_ID = id - 1;
158:
159: //global special characters
160:
161: public static final int GLOBAL_FIRST_ID = id;
162:
163: /**SC_POUND in here is just a place holder to show that it is a special character
164: * the syntax highlighting for exclamations are handled in LINE_COMMENT
165: */
166: public static final BaseImageTokenID GLOBAL_POUND = new BaseImageTokenID(
167: "pound", id++, TC_GLOBAL, "#"); // NOI18N
168: public static final BaseImageTokenID GLOBAL_INCLUDE = new BaseImageTokenID(
169: "include", id++, TC_GLOBAL); // NOI18N
170:
171: public static final int GLOBAL_LAST_ID = id - 1;
172:
173: //targets and dependencies
174:
175: public static final int TARGET_FIRST_ID = id;
176:
177: public static final BaseImageTokenID TARGET_COLON = new BaseImageTokenID(
178: "colon", id++, TC_TARGET, ":"); // NOI18N
179: public static final BaseImageTokenID TARGET_DOUBLE_COLON = new BaseImageTokenID(
180: "double-colon", id++, TC_TARGET, "::"); // NOI18N
181: public static final BaseImageTokenID TARGET_PERCENT = new BaseImageTokenID(
182: "percent", id++, TC_TARGET, "%"); // NOI18N
183:
184: public static final BaseImageTokenID TARGET_DEFAULT = new BaseImageTokenID(
185: ".DEFAULT", id++, TC_TARGET); // NOI18N
186: public static final BaseImageTokenID TARGET_DONE = new BaseImageTokenID(
187: ".DONE", id++, TC_TARGET); // NOI18N
188: public static final BaseImageTokenID TARGET_FAILED = new BaseImageTokenID(
189: ".FAILED", id++, TC_TARGET); // NOI18N
190: public static final BaseImageTokenID TARGET_GETPOSIX = new BaseImageTokenID(
191: ".GET_POSIX", id++, TC_TARGET); // NOI18N
192: public static final BaseImageTokenID TARGET_IGNORE = new BaseImageTokenID(
193: ".IGNORE", id++, TC_TARGET); // NOI18N
194: public static final BaseImageTokenID TARGET_INIT = new BaseImageTokenID(
195: ".INIT", id++, TC_TARGET); // NOI18N
196: public static final BaseImageTokenID TARGET_KEEPSTATE = new BaseImageTokenID(
197: ".KEEP_STATE", id++, TC_TARGET); // NOI18N
198: public static final BaseImageTokenID TARGET_KEEPSTATEFILE = new BaseImageTokenID(
199: ".KEEP_STATE_FILE", id++, TC_TARGET); // NOI18N
200: public static final BaseImageTokenID TARGET_MAKEVERSION = new BaseImageTokenID(
201: ".MAKE_VERSION", id++, TC_TARGET); // NOI18N
202: public static final BaseImageTokenID TARGET_NOPARALLEL = new BaseImageTokenID(
203: ".NO_PARALLEL", id++, TC_TARGET); // NOI18N
204: public static final BaseImageTokenID TARGET_PARALLEL = new BaseImageTokenID(
205: ".PARALLEL", id++, TC_TARGET); // NOI18N
206: public static final BaseImageTokenID TARGET_POSIX = new BaseImageTokenID(
207: ".POSIX", id++, TC_TARGET); // NOI18N
208: public static final BaseImageTokenID TARGET_PRECIOUS = new BaseImageTokenID(
209: ".PRECIOUS", id++, TC_TARGET); // NOI18N
210: public static final BaseImageTokenID TARGET_SCCSGET = new BaseImageTokenID(
211: ".SCCS_GET", id++, TC_TARGET); // NOI18N
212: public static final BaseImageTokenID TARGET_SCCSGETPOSIX = new BaseImageTokenID(
213: ".SCCS_GET_POSIX", id++, TC_TARGET); // NOI18N
214: public static final BaseImageTokenID TARGET_SILENT = new BaseImageTokenID(
215: ".SILENT", id++, TC_TARGET); // NOI18N
216: public static final BaseImageTokenID TARGET_SUFFIXES = new BaseImageTokenID(
217: ".SUFFIXES", id++, TC_TARGET); // NOI18N
218: public static final BaseImageTokenID TARGET_WAIT = new BaseImageTokenID(
219: ".WAIT", id++, TC_TARGET); // NOI18N
220:
221: public static final int TARGET_LAST_ID = id - 1;
222:
223: // errors
224:
225: public static final int ERR_FIRST_ID = id;
226:
227: public static final BaseTokenID ERR_INCOMPLETE_MACRO_LITERAL = new BaseTokenID(
228: "incomplete-macro-literal", id++, TC_ERRORS); // NOI18N
229:
230: public static final int ERR_LAST_ID = id;
231:
232: // Context instance declaration
233: public static final ShellTokenContext context = new ShellTokenContext();
234:
235: public static final TokenContextPath contextPath = context
236: .getContextPath();
237:
238: private ShellTokenContext() {
239: super ("shell-"); // NOI18N
240:
241: try {
242: addDeclaredTokenIDs();
243: } catch (Exception e) {
244: if (Boolean.getBoolean("netbeans.debug.exceptions")) { //NOI18N
245: e.printStackTrace();
246: }
247: }
248:
249: }
250:
251: }
|