KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > core > syntax > deprecated > JspTagSyntax


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.modules.web.core.syntax.deprecated;
21
22 import org.netbeans.modules.web.core.syntax.*;
23 import org.netbeans.editor.Syntax;
24 import org.netbeans.editor.TokenID;
25 import org.openide.ErrorManager;
26
27 /**
28 * Syntax class for JSP tags. It is not meant to be used by itself, but as one of syntaxes with
29 * MultiSyntax. Recognizes JSP tags, comments and directives. Does not recognize scriptlets,
30 * expressions and declarations, which should be rocognized by the master syntax, as expressions
31 * can appear embedded in a JSP tag. Moreover, they all share Java syntax.
32 *
33 * @author Petr Jiricka
34 * @version 1.00
35 * @deprecated Use JSP Lexer instead
36 */

37
38 public class JspTagSyntax extends Syntax {
39
40     // Internal states
41
// general
42
private static final int ISI_ERROR = 1; // when the fragment does not start with <
43
private static final int ISA_LT = 2; // after '<' char
44
// tags and directives
45
private static final int ISI_TAG = 3; // inside JSP tag
46
private static final int ISI_DIR = 4; // inside JSP directive
47
private static final int ISP_TAG = 5; // after JSP tag
48
private static final int ISP_DIR = 6; // after JSP directive
49
private static final int ISI_TAG_I_WS = 7; // inside JSP tag after whitespace
50
private static final int ISI_DIR_I_WS = 8; // inside JSP directive after whitespace
51
private static final int ISI_ENDTAG = 9; // inside end JSP tag
52
private static final int ISI_TAG_ATTR = 10; // inside tag attribute
53
private static final int ISI_DIR_ATTR = 11; // inside directive attribute
54
private static final int ISP_TAG_EQ = 12; // just after '=' in tag
55
private static final int ISP_DIR_EQ = 13; // just after '=' in directive
56
private static final int ISI_TAG_STRING = 14; // inside string (value - "") in tag
57
private static final int ISI_DIR_STRING = 15; // inside string (value - "") in directive
58
private static final int ISI_TAG_STRING_B = 16; // inside string (value - "") after backslash in tag
59
private static final int ISI_DIR_STRING_B = 17; // inside string (value - "") after backslash in directive
60
private static final int ISI_TAG_STRING2 = 18; // inside string (value - '') in tag
61
private static final int ISI_DIR_STRING2 = 19; // inside string (value - '') in directive
62
private static final int ISI_TAG_STRING2_B = 20; // inside string (value - '') after backslash in tag
63
private static final int ISI_DIR_STRING2_B = 21; // inside string (value - '') after backslash in directive
64
private static final int ISA_ENDSLASH = 22; // after ending '/' in JSP tag
65
private static final int ISA_ENDPC = 23; // after ending '%' in JSP directive
66
// comments (+directives)
67
private static final int ISA_LT_PC = 24; // after '<%' (comment or directive)
68
private static final int ISI_JSP_COMMENT = 25; // after <%-
69

70     private static final int ISI_JSP_COMMENT_M = 26; // inside JSP comment after -
71
private static final int ISI_JSP_COMMENT_MM = 27; // inside JSP comment after --
72
private static final int ISI_JSP_COMMENT_MMP = 28; // inside JSP comment after --%
73
// end state
74
static final int ISA_END_JSP = 29; // JSP fragment has finished and control
75
// should be returned to master syntax
76
// more errors
77
private static final int ISI_TAG_ERROR = 30; // error in tag, can be cleared by > or \n
78
private static final int ISI_DIR_ERROR = 31; // error in directive, can be cleared by %>, \n, \t or space
79
private static final int ISI_DIR_ERROR_P = 32; // error in directive after %, can be cleared by > or \n
80

81     private static final int ISA_LT_PC_AT = 33; // after '<%@' (directive)
82
private static final int ISA_LT_SLASH = 34; // after '</' sequence
83
private static final int ISA_LT_PC_DASH = 35; // after <%- ;not comment yet
84

85   
86     public JspTagSyntax() {
87         tokenContextPath = JspTagTokenContext.contextPath;
88     }
89
90     public boolean isIdentifierPart(char ch) {
91         return Character.isJavaIdentifierPart(ch);
92     }
93
94     protected TokenID parseToken() {
95         char actChar;
96         int _state; //help state
97

98         while(offset < stopOffset) {
99             actChar = buffer[offset];
100             //System.out.println("JspTagSyntax: offset: " + offset + " actchar: '" + actChar
101
// + "' state: " + getStateName(state));
102
switch (state) {
103                 case INIT:
104                     switch (actChar) {
105                         case '\n':
106                             offset++;
107                             return JspTagTokenContext.EOL;
108                         case '<':
109                             state = ISA_LT;
110                             break;
111                         default:
112                             state = ISI_ERROR;
113                             break;
114                     }
115                     break;
116
117                 case ISA_LT:
118                     if (Character.isLetter(actChar) ||
119                         (actChar == '_')
120                     ) { // possible tag begining
121
state = ISI_TAG;
122                         return JspTagTokenContext.SYMBOL;
123                     }
124
125                     switch (actChar) {
126                         case '/':
127                             state = ISA_LT_SLASH;
128                             break;
129                         case '\n':
130                             state = ISI_TAG_ERROR;
131                             return JspTagTokenContext.SYMBOL;
132                         case '%':
133                             state = ISA_LT_PC;
134                             break;
135                         default:
136                             state = ISI_TAG_ERROR;
137                             break;
138                     }
139                     break;
140           
141                 case ISA_LT_SLASH:
142                     if (Character.isLetter(actChar) ||
143                         (actChar == '_')) {
144                         //possible end tag beginning
145
//offset++;
146
state = ISI_ENDTAG;
147                         return JspTagTokenContext.SYMBOL;
148                     }
149                     
150                     //everyting alse is an error
151
state = ISI_TAG_ERROR;
152                     break;
153                     
154                 case ISI_TAG:
155                 case ISI_DIR:
156                     if (!(Character.isLetter(actChar) ||
157                           Character.isDigit(actChar) ||
158                           (actChar == '_') ||
159                           (actChar == '-') ||
160                           (actChar == ':') ||
161                           (actChar == '.'))
162                     ) { // not alpha
163
if (actChar == '<'){
164                             _state = state;
165                             state = ISA_END_JSP;
166                             return ((_state == ISI_TAG) ? JspTagTokenContext.TAG : JspDirectiveTokenContext.TAG);//TODO - parser
167
}
168                         _state = state;
169                         state = ((state == ISI_TAG) ? ISP_TAG : ISP_DIR);
170                         return ((_state == ISI_TAG) ? JspTagTokenContext.TAG : JspDirectiveTokenContext.TAG); //TODO - parser
171
}
172                     break;
173
174                 case ISP_TAG:
175                 case ISP_DIR:
176                     if (Character.isLetter(actChar) ||
177                         (actChar == '_')
178                     ) {
179                         state = ((state == ISP_TAG) ? ISI_TAG_ATTR : ISI_DIR_ATTR);
180                         break;
181                     }
182                     switch (actChar) {
183                         case '\n':
184                             if (offset == tokenOffset) { // no char
185
offset++;
186                                 return ((state == ISP_TAG) ? JspTagTokenContext.EOL : JspDirectiveTokenContext.EOL );//TODO - parser
187
} else { // return string first
188
return ((state == ISP_TAG) ? JspTagTokenContext.TAG : JspDirectiveTokenContext.TAG );//TODO - parser
189
}
190                         case '>': // for tags
191
if (state == ISP_TAG) {
192                                 if (offset == tokenOffset) { // no char
193
offset++;
194                                     state = ISA_END_JSP;
195                                     return JspTagTokenContext.SYMBOL;
196                                 }
197                                 else { // return string first
198
return JspTagTokenContext.TAG;
199                                 }
200                             }
201                             else { // directive
202
//state = ISI_DIR_ERROR;
203
//commented out to minimize errors during the process of writing directives
204
break;
205                             }
206                         case '/': // for tags
207
if (state == ISP_TAG) {
208                                 if (offset == tokenOffset) { // no char
209
state = ISA_ENDSLASH;
210                                     break;
211                                 }
212                                 else { // return string first
213
return JspTagTokenContext.TAG;
214                                 }
215                             }
216                             else { // directive
217
//state = ISI_DIR_ERROR;
218
//commented out to minimize errors during the process of writing directives
219
break;
220                             }
221                         case '%': // for directives
222
if (state == ISP_DIR) {
223                                 if (offset == tokenOffset) { // no char
224
state = ISA_ENDPC;
225                                     break;
226                                 }
227                                 else { // return string first
228
return JspDirectiveTokenContext.TAG;
229                                 }
230                             }
231                             else { // tag
232
state = ISI_TAG_ERROR;
233                                 break;
234                             }
235                         case '=':
236                             offset++;
237                             _state = state;
238                             state = ((state == ISP_TAG) ? ISP_TAG_EQ : ISP_DIR_EQ);
239                             return ((_state == ISP_TAG) ? JspTagTokenContext.SYMBOL : JspDirectiveTokenContext.SYMBOL);//TODO - parser
240
case ' ':
241                         case '\t':
242                             state = ((state == ISP_TAG) ? ISI_TAG_I_WS : ISI_DIR_I_WS);
243                             break;
244                         case '<': // assume that this is the start of the next tag
245
_state = state;
246                             state=ISA_END_JSP;
247                             return ((_state == ISP_TAG) ? JspTagTokenContext.TAG : JspDirectiveTokenContext.TAG );//TODO - parser
248
default: //numbers or illegal symbols
249
state = ((state == ISP_TAG) ? ISI_TAG_ERROR : ISI_DIR_ERROR);
250                             break;
251                     }
252                     break;
253           
254                 case ISI_TAG_I_WS:
255                 case ISI_DIR_I_WS:
256                     switch (actChar) {
257                         case ' ':
258                         case '\t':
259                             break;
260                         case '<':
261                             _state = state;
262                             state = ISA_END_JSP;
263                             return ((_state == ISI_TAG_I_WS) ? JspTagTokenContext.TAG : JspDirectiveTokenContext.TAG);//TODO - parser
264
default:
265                             _state = state;
266                             state = ((state == ISI_TAG_I_WS) ? ISP_TAG : ISP_DIR);
267                             return ((_state == ISI_TAG_I_WS) ? JspTagTokenContext.WHITESPACE : JspDirectiveTokenContext.WHITESPACE );//TODO - parser
268
}
269                     break;
270
271                 case ISI_ENDTAG:
272                     if (!(Character.isLetter(actChar) ||
273                           Character.isDigit(actChar) ||
274                           (actChar == '_') ||
275                           (actChar == '-') ||
276                           (actChar == ':'))
277                     ) { // not alpha
278
state = ISP_TAG;
279                         return JspTagTokenContext.TAG;
280                     }
281                     break;
282
283                 case ISI_TAG_ATTR:
284                 case ISI_DIR_ATTR:
285                     if (!(Character.isLetter(actChar) ||
286                           Character.isDigit(actChar) ||
287                           (actChar == '_') ||
288                           (actChar == ':') ||
289                           (actChar == '-'))
290                     ) { // not alpha or '-' (http-equiv)
291
_state = state;
292                         state = ((state == ISI_TAG_ATTR) ? ISP_TAG : ISP_DIR);
293                         return ((_state == ISI_TAG_ATTR) ? JspTagTokenContext.ATTRIBUTE : JspDirectiveTokenContext.ATTRIBUTE);//TODO - parser
294
}
295                     break;
296
297                 case ISP_TAG_EQ:
298                 case ISP_DIR_EQ:
299                     switch (actChar) {
300                         case '\n':
301                             if (offset == tokenOffset) { // no char
302
offset++;
303                                 return ((state == ISP_TAG_EQ) ? JspTagTokenContext.EOL : JspDirectiveTokenContext.EOL );//TODO - parser
304
} else { // return string first
305
return ((state == ISP_TAG_EQ) ? JspTagTokenContext.ATTR_VALUE : JspDirectiveTokenContext.ATTR_VALUE );//TODO - parser
306
}
307                         case '"':
308                             state = ((state == ISP_TAG_EQ) ? ISI_TAG_STRING : ISI_DIR_STRING);
309                             break;
310                         case '\'':
311                             state = ((state == ISP_TAG_EQ) ? ISI_TAG_STRING2 : ISI_DIR_STRING2);
312                             break;
313                         case ' ':
314                         case '\t':
315                             // don't change the state
316
break;
317                         default:
318                             _state = state;
319                             state = ((state == ISP_TAG_EQ) ? ISP_TAG : ISP_DIR);
320                             return ((_state == ISP_TAG_EQ) ? JspTagTokenContext.ATTR_VALUE : JspDirectiveTokenContext.ATTR_VALUE );//TODO - parser
321
}
322                     break;
323
324                 case ISI_TAG_STRING:
325                 case ISI_DIR_STRING:
326                 case ISI_TAG_STRING2:
327                 case ISI_DIR_STRING2:
328                     if ((actChar == '"') && ((state == ISI_TAG_STRING) || (state == ISI_DIR_STRING))) {
329                         offset++;
330                         _state = state;
331                         state = ((state == ISI_TAG_STRING) ? ISP_TAG : ISP_DIR);
332                         return ((_state == ISI_TAG_STRING) ? JspTagTokenContext.ATTR_VALUE : JspDirectiveTokenContext.ATTR_VALUE );//TODO - parser
333
}
334           
335                     if ((actChar == '\'') && ((state == ISI_TAG_STRING2) || (state == ISI_DIR_STRING2))) {
336                         offset++;
337                         _state = state;
338                         state = ((state == ISI_TAG_STRING2) ? ISP_TAG : ISP_DIR);
339                         return ((_state == ISI_TAG_STRING2) ? JspTagTokenContext.ATTR_VALUE : JspDirectiveTokenContext.ATTR_VALUE );//TODO - parser
340
}
341
342                     switch (actChar) {
343                         case '\\':
344                             switch (state) {
345                                 case ISI_TAG_STRING:
346                                     state = ISI_TAG_STRING_B;
347                                     break;
348                                 case ISI_DIR_STRING:
349                                     state = ISI_DIR_STRING_B;
350                                     break;
351                                 case ISI_TAG_STRING2:
352                                     state = ISI_TAG_STRING2_B;
353                                     break;
354                                 case ISI_DIR_STRING2:
355                                     state = ISI_DIR_STRING2_B;
356                                     break;
357                             }
358                             break;
359                         case '\n':
360                             if (offset == tokenOffset) { // no char
361
offset++;
362                                 return (((state == ISI_TAG_STRING) || (state == ISI_TAG_STRING2)) ? JspTagTokenContext.EOL : JspDirectiveTokenContext.EOL );//TODO - parser
363

364                             } else { // return string first
365
return (((state == ISI_TAG_STRING) || (state == ISI_TAG_STRING2)) ? JspTagTokenContext.ATTR_VALUE : JspDirectiveTokenContext.ATTR_VALUE );//TODO - parser
366
}
367                     }
368                     break;
369
370                 case ISI_TAG_STRING_B:
371                 case ISI_DIR_STRING_B:
372                 case ISI_TAG_STRING2_B:
373                 case ISI_DIR_STRING2_B:
374                     switch (actChar) {
375                         case '"':
376                         case '\'':
377                         case '\\':
378                             break;
379                         default:
380                             offset--;
381                             break;
382                     }
383                     switch (state) {
384                         case ISI_TAG_STRING_B:
385                             state = ISI_TAG_STRING;
386                             break;
387                         case ISI_DIR_STRING_B:
388                             state = ISI_DIR_STRING;
389                             break;
390                         case ISI_TAG_STRING2_B:
391                             state = ISI_TAG_STRING2;
392                             break;
393                         case ISI_DIR_STRING2_B:
394                             state = ISI_DIR_STRING2;
395                             break;
396                     }
397                     break;
398
399                 case ISA_ENDSLASH:
400                     switch (actChar) {
401                         case '>':
402                             offset++;
403                             state = ISA_END_JSP;
404                             return JspTagTokenContext.SYMBOL;
405                         case '\n':
406                             state = ISI_TAG_ERROR;
407                             return JspTagTokenContext.SYMBOL;
408                         default:
409                             state = ISP_TAG;
410                             return JspTagTokenContext.SYMBOL;
411                     }
412                     //break; not reached
413

414                 case ISA_ENDPC:
415                     switch (actChar) {
416                         case '>':
417                             offset++;
418                             state = ISA_END_JSP;
419                             return JspDirectiveTokenContext.SYMBOL;
420                         case '\n':
421                             state = ISI_DIR_ERROR;
422                             return JspDirectiveTokenContext.SYMBOL;
423                         default:
424                             state = ISP_DIR;
425                             return JspDirectiveTokenContext.SYMBOL;
426                     }
427                     //break; not reached
428

429                 case ISA_LT_PC:
430                     switch (actChar) {
431                         case '@':
432                             offset++;
433                             state = ISA_LT_PC_AT;
434                             return JspDirectiveTokenContext.SYMBOL;
435                         case '-':
436                             state = ISA_LT_PC_DASH;
437                             break;
438                         default: // just cut it, because this will be recognized
439
// by master syntax as a Java scriptlet/expression/declaration
440
state = ISA_END_JSP;
441                             return JspTagTokenContext.SYMBOL;
442                     }
443                     break;
444           
445                 case ISA_LT_PC_DASH:
446                     switch(actChar) {
447                         case '-':
448                             state = ISI_JSP_COMMENT;
449                             break;
450                         default:
451                             offset++;
452                             state = ISA_END_JSP;
453                             return JspDirectiveTokenContext.TEXT;
454                     }
455                     break;
456                     
457                 // JSP states
458
case ISI_JSP_COMMENT:
459                     switch (actChar) {
460                         case '\n':
461                             if (offset == tokenOffset) { // no char
462
offset++;
463                                 return JspTagTokenContext.EOL;
464                             } else { // return block comment first
465
return JspTagTokenContext.COMMENT;
466                             }
467                         case '-':
468                             state = ISI_JSP_COMMENT_M;
469                             break;
470                     }
471                     break;
472           
473                 case ISI_JSP_COMMENT_M:
474                     switch (actChar) {
475                         case '\n':
476                             state = ISI_JSP_COMMENT;
477                             if (offset == tokenOffset) { // no char
478
offset++;
479                                 return JspTagTokenContext.EOL;
480                             } else { // return block comment first
481
return JspTagTokenContext.COMMENT;
482                             }
483                         case '-':
484                             state = ISI_JSP_COMMENT_MM;
485                             break;
486                         default:
487                             state = ISI_JSP_COMMENT;
488                             break;
489                     }
490                     break;
491           
492                 case ISI_JSP_COMMENT_MM:
493                     switch (actChar) {
494                         case '\n':
495                             state = ISI_JSP_COMMENT;
496                             if (offset == tokenOffset) { // no char
497
offset++;
498                                 return JspTagTokenContext.EOL;
499                             } else { // return block comment first
500
return JspTagTokenContext.COMMENT;
501                             }
502                         case '%':
503                             state = ISI_JSP_COMMENT_MMP;
504                             break;
505                         case '-':
506                             state = ISI_JSP_COMMENT_MM;
507                             break;
508                         default:
509                             state = ISI_JSP_COMMENT;
510                             break;
511                     }
512                     break;
513           
514                 case ISI_JSP_COMMENT_MMP:
515                     switch (actChar) {
516                         case '\n':
517                             state = ISI_JSP_COMMENT;
518                             if (offset == tokenOffset) { // no char
519
offset++;
520                                 return JspTagTokenContext.EOL;
521                             } else { // return block comment first
522
return JspTagTokenContext.COMMENT;
523                             }
524                         case '>':
525                             state = ISA_END_JSP;
526                             offset++;
527                             return JspTagTokenContext.COMMENT;
528                         default:
529                             state = ISI_JSP_COMMENT;
530                             break;
531                     }
532                     break;
533           
534                 case ISI_ERROR:
535                     switch (actChar) {
536                         case '\n':
537                             state = INIT;
538                             return JspTagTokenContext.ERROR;
539                         case '<':
540                             state = ISA_LT;
541                             return JspTagTokenContext.ERROR;
542                     }
543                     break;
544           
545                 case ISI_TAG_ERROR:
546                     switch (actChar) {
547                         case '\n':
548                             if (offset == tokenOffset) { // no char
549
offset++;
550                                 state = ISI_TAG_I_WS;
551                                 return JspTagTokenContext.EOL;
552                             } else { // return error first
553
return JspTagTokenContext.ERROR;
554                             }
555                         case '>':
556                             state = ISI_TAG_I_WS;
557                             return JspTagTokenContext.ERROR;
558                         case ' ':
559                         case '\t':
560                             state = ISI_TAG;
561                             return JspTagTokenContext.ERROR;
562                             
563                     }
564                     break;
565           
566                 case ISI_DIR_ERROR:
567                     switch (actChar) {
568                         case '\n':
569                             if (offset == tokenOffset) { // no char
570
offset++;
571                                 state = ISI_DIR_I_WS;
572                                 return JspDirectiveTokenContext.EOL;
573                             } else { // return error first
574
return JspDirectiveTokenContext.ERROR;
575                             }
576                         case '%':
577                             state = ISI_TAG;
578                             return JspDirectiveTokenContext.ERROR;
579                         case '\t':
580                         case ' ':
581                             state = ISI_DIR_I_WS;
582                             return JspDirectiveTokenContext.ERROR;
583                     }
584                     break;
585           
586                 case ISI_DIR_ERROR_P:
587                     switch (actChar) {
588                         case '\n':
589                             if (offset == tokenOffset) { // no char
590
offset++;
591                                 state = ISI_DIR_I_WS;
592                                 return JspDirectiveTokenContext.EOL;
593                             } else { // return error first
594
return JspDirectiveTokenContext.ERROR;
595                             }
596                         case '>':
597                             offset--;
598                             state = ISI_DIR_I_WS;
599                             return JspDirectiveTokenContext.ERROR;
600                     }
601                     break;
602           
603                 case ISA_END_JSP:
604                     if (offset == tokenOffset) {
605                         offset++;
606                         return JspTagTokenContext.AFTER_UNEXPECTED_LT;
607                     }
608                     else {
609                         return JspTagTokenContext.TEXT;
610                     }
611                     //break;
612

613                 // added states
614
case ISA_LT_PC_AT:
615                     if (Character.isLetter(actChar) ||
616                         (actChar == '_')
617                     ) { // the directive starts
618
state = ISI_DIR;
619                         return JspDirectiveTokenContext.TAG;
620                     }
621
622                     switch (actChar) {
623                         case '\n':
624                             if (offset == tokenOffset) { // no char
625
offset++;
626                                 return JspDirectiveTokenContext.EOL;
627                             }
628                             else {
629                                 return JspDirectiveTokenContext.TAG;
630                             }
631                     }
632                     break;
633           
634             }
635       
636             ++offset;
637         } // end of while(offset...)
638

639         // At this stage there's no more text in the scanned buffer.
640
// Scanner first checks whether this is completely the last
641
// available buffer.
642

643         if (lastBuffer) {
644             switch(state) {
645                 case ISI_ERROR:
646                 case ISI_TAG_ERROR:
647                     return JspTagTokenContext.ERROR;
648                 case ISI_DIR_ERROR:
649                 case ISI_DIR_ERROR_P:
650                     return JspDirectiveTokenContext.ERROR;
651                 case ISA_LT:
652                 case ISA_LT_SLASH:
653                 case ISA_ENDSLASH:
654                 case ISP_TAG_EQ:
655                     return JspTagTokenContext.SYMBOL;
656                 case ISA_LT_PC:
657                 case ISA_LT_PC_DASH:
658                 case ISA_ENDPC:
659                 case ISP_DIR_EQ:
660                     return JspDirectiveTokenContext.SYMBOL;
661                 case ISI_TAG:
662                 case ISI_ENDTAG:
663                     return JspTagTokenContext.TAG;
664                 case ISI_DIR:
665                     return JspDirectiveTokenContext.TAG;
666                 case ISP_TAG:
667                 case ISI_TAG_I_WS:
668                     return JspTagTokenContext.TAG;
669                 case ISP_DIR:
670                 case ISI_DIR_I_WS:
671                 case ISA_LT_PC_AT:
672                     return JspDirectiveTokenContext.TAG;
673                 case ISI_TAG_ATTR:
674                     return JspTagTokenContext.ATTRIBUTE;
675                 case ISI_DIR_ATTR:
676                     return JspDirectiveTokenContext.ATTRIBUTE;
677                 case ISI_TAG_STRING:
678                 case ISI_TAG_STRING_B:
679                 case ISI_TAG_STRING2:
680                 case ISI_TAG_STRING2_B:
681                     return JspTagTokenContext.ATTR_VALUE;
682                 case ISI_DIR_STRING:
683                 case ISI_DIR_STRING_B:
684                 case ISI_DIR_STRING2:
685                 case ISI_DIR_STRING2_B:
686                     return JspDirectiveTokenContext.ATTR_VALUE;
687                 case ISI_JSP_COMMENT:
688                 case ISI_JSP_COMMENT_M:
689                 case ISI_JSP_COMMENT_MM:
690                 case ISI_JSP_COMMENT_MMP:
691                     return JspTagTokenContext.COMMENT;
692                 case ISA_END_JSP:
693                     return JspTagTokenContext.TEXT;
694                 default:
695                     ErrorManager.getDefault ().notify (
696                         ErrorManager.INFORMATIONAL,
697                         new Exception JavaDoc("Unhandled state : " + getStateName(state)) // NOI18N
698
);
699             }
700         }
701
702         // At this stage there's no more text in the scanned buffer, but
703
// this buffer is not the last so the scan will continue on another buffer.
704
// The scanner tries to minimize the amount of characters
705
// that will be prescanned in the next buffer.
706

707         // pending
708

709         //Following code has been commented out because it may produce incomplete tokens
710
//when the parse buffer end falls somewhere inside a token. In such a case
711
//an incomplete token is created - the token ends at the offset of the parse buffer.
712
//Although this approach may save some machine time due to syntax prescan minimalization,
713
//it can and in fact does cause problems in a code which relies on tokens
714
//to be compact (e.g. code completion - see issue #47165).
715
/*switch(state) {
716             case ISI_ERROR:
717             case ISI_TAG_ERROR:
718             case ISI_DIR_ERROR:
719             case ISI_DIR_ERROR_P:
720                 return JspTagTokenContext.ERROR;
721             case ISA_LT:
722             case ISA_LT_PC:
723             // case ISA_ENDSLASH: // it is important to keep '/>' token complete
724             case ISA_ENDPC:
725             case ISP_TAG_EQ:
726             case ISP_DIR_EQ:
727                 return JspTagTokenContext.SYMBOL;
728             case ISI_TAG:
729             case ISI_DIR:
730             case ISI_ENDTAG:
731                 return JspTagTokenContext.TAG;
732             case ISP_TAG:
733             case ISP_DIR:
734             case ISI_TAG_I_WS:
735             case ISI_DIR_I_WS:
736             case ISA_LT_PC_AT:
737                 return JspTagTokenContext.TAG;
738             case ISI_TAG_ATTR:
739             case ISI_DIR_ATTR:
740                 return JspTagTokenContext.ATTRIBUTE;
741             case ISI_TAG_STRING:
742             case ISI_DIR_STRING:
743             case ISI_TAG_STRING_B:
744             case ISI_DIR_STRING_B:
745             case ISI_TAG_STRING2:
746             case ISI_DIR_STRING2:
747             case ISI_TAG_STRING2_B:
748             case ISI_DIR_STRING2_B:
749                 return JspTagTokenContext.ATTR_VALUE;
750             case ISI_JSP_COMMENT:
751             case ISI_JSP_COMMENT_M:
752             case ISI_JSP_COMMENT_MM:
753             case ISI_JSP_COMMENT_MMP:
754                 return JspTagTokenContext.COMMENT;
755             case ISA_END_JSP:
756                 return JspTagTokenContext.TEXT;
757         }
758 */

759         return null;
760
761     }
762
763
764     public String JavaDoc getStateName(int stateNumber) {
765         switch(stateNumber) {
766             case ISI_ERROR : return "jsptag_ISI_ERROR"; // NOI18N
767
case ISA_LT : return "jsptag_ISA_LT"; // NOI18N
768
case ISI_TAG : return "jsptag_ISI_TAG"; // NOI18N
769
case ISI_DIR : return "jsptag_ISI_DIR"; // NOI18N
770
case ISP_TAG : return "jsptag_ISP_TAG"; // NOI18N
771
case ISP_DIR : return "jsptag_ISP_DIR"; // NOI18N
772
case ISI_TAG_I_WS : return "jsptag_ISI_TAG_I_WS"; // NOI18N
773
case ISI_DIR_I_WS : return "jsptag_ISI_DIR_I_WS"; // NOI18N
774
case ISI_ENDTAG : return "jsptag_ISI_ENDTAG"; // NOI18N
775
case ISI_TAG_ATTR : return "jsptag_ISI_TAG_ATTR"; // NOI18N
776
case ISI_DIR_ATTR : return "jsptag_ISI_DIR_ATTR"; // NOI18N
777
case ISP_TAG_EQ : return "jsptag_ISP_TAG_EQ"; // NOI18N
778
case ISP_DIR_EQ : return "jsptag_ISP_DIR_EQ"; // NOI18N
779
case ISI_TAG_STRING : return "jsptag_ISI_TAG_STRING"; // NOI18N
780
case ISI_DIR_STRING : return "jsptag_ISI_DIR_STRING"; // NOI18N
781
case ISI_TAG_STRING_B : return "jsptag_ISI_TAG_STRING_B"; // NOI18N
782
case ISI_DIR_STRING_B : return "jsptag_ISI_DIR_STRING_B"; // NOI18N
783
case ISI_TAG_STRING2 : return "jsptag_ISI_TAG_STRING2"; // NOI18N
784
case ISI_DIR_STRING2 : return "jsptag_ISI_DIR_STRING2"; // NOI18N
785
case ISI_TAG_STRING2_B : return "jsptag_ISI_TAG_STRING2_B"; // NOI18N
786
case ISI_DIR_STRING2_B : return "jsptag_ISI_DIR_STRING2_B"; // NOI18N
787
case ISA_ENDSLASH : return "jsptag_ISA_ENDSLASH"; // NOI18N
788
case ISA_ENDPC : return "jsptag_ISA_ENDPC"; // NOI18N
789
case ISA_LT_PC : return "jsptag_ISA_LT_PC"; // NOI18N
790
case ISI_JSP_COMMENT : return "jsptag_ISI_JSP_COMMENT"; // NOI18N
791
case ISI_JSP_COMMENT_M : return "jsptag_ISI_JSP_COMMENT_M"; // NOI18N
792
case ISI_JSP_COMMENT_MM : return "jsptag_ISI_JSP_COMMENT_MM"; // NOI18N
793
case ISI_JSP_COMMENT_MMP : return "jsptag_ISI_JSP_COMMENT_MMP"; // NOI18N
794
case ISA_END_JSP : return "jsptag_ISA_END_JSP"; // NOI18N
795
case ISI_TAG_ERROR : return "jsptag_ISI_TAG_ERROR"; // NOI18N
796
case ISI_DIR_ERROR : return "jsptag_ISI_DIR_ERROR"; // NOI18N
797
case ISI_DIR_ERROR_P : return "jsptag_ISI_DIR_ERROR_P"; // NOI18N
798
case ISA_LT_PC_AT : return "jsptag_ISA_LT_PC_AT"; // NOI18N
799
default:
800                 return super.getStateName(stateNumber);
801         }
802     }
803
804 }
805
806
Popular Tags