initial implementation
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / DocumentElementParser.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler;
12
13 import net.sourceforge.phpdt.core.compiler.CharOperation;
14 import net.sourceforge.phpdt.core.compiler.IProblem;
15 import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit;
16 import net.sourceforge.phpdt.internal.compiler.parser.UnitParser;
17 import net.sourceforge.phpdt.internal.compiler.problem.AbortCompilation;
18 import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter;
19 import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
20
21 import org.eclipse.core.runtime.CoreException;
22
23
24 /*
25  * A document element parser extracts structural information
26  * from a piece of source, providing detailed source positions info.
27  *
28  * also see @IDocumentElementRequestor
29  *
30  * The structural investigation includes:
31  * - the package statement
32  * - import statements
33  * - top-level types: package member, member types (member types of member types...)
34  * - fields
35  * - methods
36  *
37  * Any (parsing) problem encountered is also provided.
38  */
39 public class DocumentElementParser extends UnitParser {
40         IDocumentElementRequestor requestor;
41         private int localIntPtr;
42         private int lastFieldEndPosition;
43         private int lastFieldBodyEndPosition;   
44         private int typeStartPosition;
45         private long selectorSourcePositions;
46         private int typeDims;
47         private int extendsDim;
48         private int declarationSourceStart;
49
50         /* int[] stack for storing javadoc positions */
51         int[][] intArrayStack;
52         int intArrayPtr;
53         
54 //      CompilerOptions options;
55         
56 public DocumentElementParser(
57         final IDocumentElementRequestor requestor, 
58         IProblemFactory problemFactory) {
59 //      CompilerOptions options) {
60         super(new ProblemReporter(
61                 DefaultErrorHandlingPolicies.exitAfterAllProblems(), 
62 //              options, 
63                 problemFactory) {
64                 public void record(IProblem problem, CompilationResult unitResult) {
65                         requestor.acceptProblem(problem);
66                 }
67         });
68 //      false,
69 //      options.sourceLevel >= CompilerOptions.JDK1_4);
70         this.requestor = requestor;
71         intArrayStack = new int[30][];
72 //      this.options = options;
73 }
74
75 /**
76  *
77  * INTERNAL USE-ONLY
78  */
79 //protected void adjustInterfaceModifiers() {
80 //      intStack[intPtr - 2] |= AccInterface;
81 //}
82 /*
83  * Will clear the comment stack when looking
84  * for a potential JavaDoc which might contain @deprecated.
85  *
86  * Additionally, before investigating for @deprecated, retrieve the positions
87  * of the JavaDoc comments so as to notify requestor with them.
88  */
89 //public void checkAnnotation() {
90 //
91 //      /* persisting javadoc positions */
92 //      pushOnIntArrayStack(this.getJavaDocPositions());
93 //      boolean deprecated = false;
94 //      int lastAnnotationIndex = -1;
95 //      int commentPtr = scanner.commentPtr;
96 //
97 //      //since jdk1.2 look only in the last java doc comment...
98 //      nextComment : for (lastAnnotationIndex = scanner.commentPtr; lastAnnotationIndex >= 0; lastAnnotationIndex--){
99 //              //look for @deprecated into the first javadoc comment preceeding the declaration
100 //              int commentSourceStart = scanner.commentStarts[lastAnnotationIndex];
101 //              // javadoc only (non javadoc comment have negative end positions.)
102 //              if (modifiersSourceStart != -1 && modifiersSourceStart < commentSourceStart) {
103 //                      continue nextComment;
104 //              }
105 //              if (scanner.commentStops[lastAnnotationIndex] < 0) {
106 //                      continue nextComment;
107 //              }
108 //              int commentSourceEnd = scanner.commentStops[lastAnnotationIndex] - 1; //stop is one over
109 //              char[] comment = scanner.source;
110 //
111 //              deprecated =
112 //                      checkDeprecation(
113 //                              commentSourceStart,
114 //                              commentSourceEnd,
115 //                              comment);
116 //              break nextComment;
117 //      }
118 //      if (deprecated) {
119 //              checkAndSetModifiers(AccDeprecated);
120 //      }
121 //      // modify the modifier source start to point at the first comment
122 //      if (commentPtr >= 0) {
123 //              declarationSourceStart = scanner.commentStarts[0];
124 //      }
125 //}
126 /**
127  *
128  * INTERNAL USE-ONLY
129  */
130 //protected void consumeClassBodyDeclaration() {
131 //      // ClassBodyDeclaration ::= Diet Block
132 //      //push an Initializer
133 //      //optimize the push/pop
134 //
135 //      super.consumeClassBodyDeclaration();
136 //      Initializer initializer = (Initializer) astStack[astPtr];
137 //      requestor.acceptInitializer(
138 //              initializer.declarationSourceStart,
139 //              initializer.declarationSourceEnd,
140 //              intArrayStack[intArrayPtr--], 
141 //              0,
142 //              modifiersSourceStart, 
143 //              initializer.block.sourceStart,
144 //              initializer.block.sourceEnd);
145 //}
146 ///**
147 // *
148 // * INTERNAL USE-ONLY
149 // */
150 //protected void consumeClassDeclaration() {
151 //      super.consumeClassDeclaration();
152 //      // we know that we have a TypeDeclaration on the top of the astStack
153 //      if (isLocalDeclaration()) {
154 //              // we ignore the local variable declarations
155 //              return;
156 //      }
157 //      requestor.exitClass(endStatementPosition, // '}' is the end of the body 
158 //       ((TypeDeclaration) astStack[astPtr]).declarationSourceEnd);
159 //}
160 ///**
161 // *
162 // * INTERNAL USE-ONLY
163 // */
164 //protected void consumeClassHeader() {
165 //      //ClassHeader ::= $empty
166 //      super.consumeClassHeader();
167 //      if (isLocalDeclaration()) {
168 //              // we ignore the local variable declarations
169 //              intArrayPtr--;
170 //              return;
171 //      }
172 //      TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr];
173 //      TypeReference[] superInterfaces = typeDecl.superInterfaces;
174 //      char[][] interfaceNames = null;
175 //      int[] interfaceNameStarts = null;
176 //      int[] interfaceNameEnds = null;
177 //      if (superInterfaces != null) {
178 //              int superInterfacesLength = superInterfaces.length;
179 //              interfaceNames = new char[superInterfacesLength][];
180 //              interfaceNameStarts = new int[superInterfacesLength];
181 //              interfaceNameEnds = new int[superInterfacesLength];
182 //              for (int i = 0; i < superInterfacesLength; i++) {
183 //                      TypeReference superInterface = superInterfaces[i];
184 //                      interfaceNames[i] = CharOperation.concatWith(superInterface.getTypeName(), '.'); 
185 //                      interfaceNameStarts[i] = superInterface.sourceStart;
186 //                      interfaceNameEnds[i] = superInterface.sourceEnd;
187 //              }
188 //      }
189 //      // flush the comments related to the class header
190 //      scanner.commentPtr = -1;
191 //      TypeReference superclass = typeDecl.superclass;
192 //      if (superclass == null) {
193 //              requestor.enterClass(
194 //                      typeDecl.declarationSourceStart, 
195 //                      intArrayStack[intArrayPtr--], 
196 //                      typeDecl.modifiers, 
197 //                      typeDecl.modifiersSourceStart, 
198 //                      typeStartPosition, 
199 //                      typeDecl.name, 
200 //                      typeDecl.sourceStart, 
201 //                      typeDecl.sourceEnd, 
202 //                      null, 
203 //                      -1, 
204 //                      -1, 
205 //                      interfaceNames, 
206 //                      interfaceNameStarts, 
207 //                      interfaceNameEnds, 
208 //                      scanner.currentPosition - 1); 
209 //      } else {
210 //              requestor.enterClass(
211 //                      typeDecl.declarationSourceStart, 
212 //                      intArrayStack[intArrayPtr--], 
213 //                      typeDecl.modifiers, 
214 //                      typeDecl.modifiersSourceStart, 
215 //                      typeStartPosition, 
216 //                      typeDecl.name, 
217 //                      typeDecl.sourceStart, 
218 //                      typeDecl.sourceEnd, 
219 //                      CharOperation.concatWith(superclass.getTypeName(), '.'), 
220 //                      superclass.sourceStart, 
221 //                      superclass.sourceEnd, 
222 //                      interfaceNames, 
223 //                      interfaceNameStarts, 
224 //                      interfaceNameEnds, 
225 //                      scanner.currentPosition - 1); 
226 //
227 //      }
228 //}
229 //protected void consumeClassHeaderName() {
230 //      // ClassHeaderName ::= Modifiersopt 'class' 'Identifier'
231 //      TypeDeclaration typeDecl;
232 //      if (nestedMethod[nestedType] == 0) {
233 //              if (nestedType != 0) {
234 //                      typeDecl = new MemberTypeDeclaration(this.compilationUnit.compilationResult);
235 //              } else {
236 //                      typeDecl = new TypeDeclaration(this.compilationUnit.compilationResult);
237 //              }
238 //      } else {
239 //              // Record that the block has a declaration for local types
240 //              typeDecl = new LocalTypeDeclaration(this.compilationUnit.compilationResult);
241 //              markEnclosingMemberWithLocalType();
242 //              blockReal();
243 //      }
244 //
245 //      //highlight the name of the type
246 //      long pos = identifierPositionStack[identifierPtr];
247 //      typeDecl.sourceEnd = (int) pos;
248 //      typeDecl.sourceStart = (int) (pos >>> 32);
249 //      typeDecl.name = identifierStack[identifierPtr--];
250 //      identifierLengthPtr--;
251 //
252 //      //compute the declaration source too
253 //      // 'class' and 'interface' push an int position
254 //      typeStartPosition = typeDecl.declarationSourceStart = intStack[intPtr--];
255 //      intPtr--;
256 //      int declarationSourceStart = intStack[intPtr--];
257 //      typeDecl.modifiersSourceStart = intStack[intPtr--];
258 //      typeDecl.modifiers = intStack[intPtr--];
259 //      if (typeDecl.declarationSourceStart > declarationSourceStart) {
260 //              typeDecl.declarationSourceStart = declarationSourceStart;
261 //      }
262 //      typeDecl.bodyStart = typeDecl.sourceEnd + 1;
263 //      pushOnAstStack(typeDecl);
264 //}
265 ///**
266 // *
267 // * INTERNAL USE-ONLY
268 // */
269 //protected void consumeCompilationUnit() {
270 //      // CompilationUnit ::= EnterCompilationUnit PackageDeclarationopt ImportDeclarationsopt
271 //      requestor.exitCompilationUnit(scanner.source.length - 1);
272 //}
273 /**
274  *
275  * INTERNAL USE-ONLY
276  */
277 //protected void consumeConstructorDeclaration() {
278 //      // ConstructorDeclaration ::= ConstructorHeader ConstructorBody
279 //      super.consumeConstructorDeclaration();
280 //      if (isLocalDeclaration()) {
281 //              // we ignore the local variable declarations
282 //              return;
283 //      }
284 //      ConstructorDeclaration cd = (ConstructorDeclaration) astStack[astPtr];
285 //      requestor.exitConstructor(endStatementPosition, cd.declarationSourceEnd);
286 //}
287 ///**
288 // *
289 // * INTERNAL USE-ONLY
290 // */
291 //protected void consumeConstructorHeader() {
292 //      // ConstructorHeader ::= ConstructorHeaderName MethodHeaderParameters MethodHeaderThrowsClauseopt
293 //      super.consumeConstructorHeader();
294 //      if (isLocalDeclaration()) {
295 //              // we ignore the local variable declarations
296 //              intArrayPtr--;
297 //              return;
298 //      }
299 //      ConstructorDeclaration cd = (ConstructorDeclaration) astStack[astPtr];
300 //      Argument[] arguments = cd.arguments;
301 //      char[][] argumentTypes = null;
302 //      char[][] argumentNames = null;
303 //      int[] argumentTypeStarts = null;
304 //      int[] argumentTypeEnds = null;
305 //      int[] argumentNameStarts = null;
306 //      int[] argumentNameEnds = null;
307 //      if (arguments != null) {
308 //              int argumentLength = arguments.length;
309 //              argumentTypes = new char[argumentLength][];
310 //              argumentNames = new char[argumentLength][];
311 //              argumentNameStarts = new int[argumentLength];
312 //              argumentNameEnds = new int[argumentLength];
313 //              argumentTypeStarts = new int[argumentLength];
314 //              argumentTypeEnds = new int[argumentLength];
315 //              for (int i = 0; i < argumentLength; i++) {
316 //                      Argument argument = arguments[i];
317 //                      TypeReference argumentType = argument.type;
318 //                      argumentTypes[i] = returnTypeName(argumentType);
319 //                      argumentNames[i] = argument.name;
320 //                      argumentNameStarts[i] = argument.sourceStart;
321 //                      argumentNameEnds[i] = argument.sourceEnd;
322 //                      argumentTypeStarts[i] = argumentType.sourceStart;
323 //                      argumentTypeEnds[i] = argumentType.sourceEnd;
324 //              }
325 //      }
326 //      TypeReference[] thrownExceptions = cd.thrownExceptions;
327 //      char[][] exceptionTypes = null;
328 //      int[] exceptionTypeStarts = null;
329 //      int[] exceptionTypeEnds = null;
330 //      if (thrownExceptions != null) {
331 //              int thrownExceptionLength = thrownExceptions.length;
332 //              exceptionTypes = new char[thrownExceptionLength][];
333 //              exceptionTypeStarts = new int[thrownExceptionLength];
334 //              exceptionTypeEnds = new int[thrownExceptionLength];
335 //              for (int i = 0; i < thrownExceptionLength; i++) {
336 //                      TypeReference exception = thrownExceptions[i];
337 //                      exceptionTypes[i] = CharOperation.concatWith(exception.getTypeName(), '.');
338 //                      exceptionTypeStarts[i] = exception.sourceStart;
339 //                      exceptionTypeEnds[i] = exception.sourceEnd;
340 //              }
341 //      }
342 //      requestor
343 //              .enterConstructor(
344 //                      cd.declarationSourceStart, 
345 //                      intArrayStack[intArrayPtr--], 
346 //                      cd.modifiers,
347 //                      cd.modifiersSourceStart, 
348 //                      cd.selector, 
349 //                      cd.sourceStart, 
350 //                      (int) (selectorSourcePositions & 0xFFFFFFFFL), 
351 //                      // retrieve the source end of the name
352 //                      argumentTypes, 
353 //                      argumentTypeStarts, 
354 //                      argumentTypeEnds, 
355 //                      argumentNames, 
356 //                      argumentNameStarts, 
357 //                      argumentNameEnds, 
358 //                      rParenPos, 
359 //                      // right parenthesis
360 //                      exceptionTypes, 
361 //                      exceptionTypeStarts, 
362 //                      exceptionTypeEnds, 
363 //                      scanner.currentPosition - 1); 
364 //}
365 //protected void consumeConstructorHeaderName() {
366 //      // ConstructorHeaderName ::=  Modifiersopt 'Identifier' '('
367 //      ConstructorDeclaration cd = new ConstructorDeclaration(this.compilationUnit.compilationResult);
368 //
369 //      //name -- this is not really revelant but we do .....
370 //      cd.selector = identifierStack[identifierPtr];
371 //      selectorSourcePositions = identifierPositionStack[identifierPtr--];
372 //      identifierLengthPtr--;
373 //
374 //      //modifiers
375 //      cd.declarationSourceStart = intStack[intPtr--];
376 //      cd.modifiersSourceStart = intStack[intPtr--];
377 //      cd.modifiers = intStack[intPtr--];
378 //
379 //      //highlight starts at the selector starts
380 //      cd.sourceStart = (int) (selectorSourcePositions >>> 32);
381 //      pushOnAstStack(cd);
382 //
383 //      cd.sourceEnd = lParenPos;
384 //      cd.bodyStart = lParenPos + 1;
385 //}
386 //protected void consumeDefaultModifiers() {
387 //      checkAnnotation(); // might update modifiers with AccDeprecated
388 //      pushOnIntStack(modifiers); // modifiers
389 //      pushOnIntStack(-1);
390 //      pushOnIntStack(
391 //              declarationSourceStart >= 0 ? declarationSourceStart : scanner.startPosition); 
392 //      resetModifiers();
393 //}
394 //protected void consumeDiet() {
395 //      // Diet ::= $empty
396 //      super.consumeDiet();
397 //      /* persisting javadoc positions
398 //       * Will be consume in consumeClassBodyDeclaration
399 //       */
400 //      pushOnIntArrayStack(this.getJavaDocPositions());        
401 //}
402 ///**
403 // *
404 // * INTERNAL USE-ONLY
405 // */
406 //protected void consumeEnterCompilationUnit() {
407 //      // EnterCompilationUnit ::= $empty
408 //      requestor.enterCompilationUnit();
409 //}
410 ///**
411 // *
412 // * INTERNAL USE-ONLY
413 // */
414 //protected void consumeEnterVariable() {
415 //      // EnterVariable ::= $empty
416 //      boolean isLocalDeclaration = isLocalDeclaration();
417 //      if (!isLocalDeclaration && (variablesCounter[nestedType] != 0)) {
418 //              requestor.exitField(lastFieldBodyEndPosition, lastFieldEndPosition);
419 //      }
420 //      char[] name = identifierStack[identifierPtr];
421 //      long namePosition = identifierPositionStack[identifierPtr--];
422 //      int extendedTypeDimension = intStack[intPtr--];
423 //
424 //      AbstractVariableDeclaration declaration;
425 //      if (nestedMethod[nestedType] != 0) {
426 //              // create the local variable declarations
427 //              declaration = 
428 //                      new LocalDeclaration(null, name, (int) (namePosition >>> 32), (int) namePosition); 
429 //      } else {
430 //              // create the field declaration
431 //              declaration = 
432 //                      new FieldDeclaration(null, name, (int) (namePosition >>> 32), (int) namePosition); 
433 //      }
434 //      identifierLengthPtr--;
435 //      TypeReference type;
436 //      int variableIndex = variablesCounter[nestedType];
437 //      int typeDim = 0;
438 //      if (variableIndex == 0) {
439 //              // first variable of the declaration (FieldDeclaration or LocalDeclaration)
440 //              if (nestedMethod[nestedType] != 0) {
441 //                      // local declaration
442 //                      declaration.declarationSourceStart = intStack[intPtr--];
443 //                      declaration.modifiersSourceStart = intStack[intPtr--];
444 //                      declaration.modifiers = intStack[intPtr--];
445 //                      type = getTypeReference(typeDim = intStack[intPtr--]); // type dimension
446 //                      pushOnAstStack(type);
447 //              } else {
448 //                      // field declaration
449 //                      type = getTypeReference(typeDim = intStack[intPtr--]); // type dimension
450 //                      pushOnAstStack(type);
451 //                      declaration.declarationSourceStart = intStack[intPtr--];
452 //                      declaration.modifiersSourceStart = intStack[intPtr--];
453 //                      declaration.modifiers = intStack[intPtr--];
454 //              }
455 //      } else {
456 //              type = (TypeReference) astStack[astPtr - variableIndex];
457 //              typeDim = type.dimensions();
458 //              AbstractVariableDeclaration previousVariable = 
459 //                      (AbstractVariableDeclaration) astStack[astPtr]; 
460 //              declaration.declarationSourceStart = previousVariable.declarationSourceStart;
461 //              declaration.modifiers = previousVariable.modifiers;
462 //              declaration.modifiersSourceStart = previousVariable.modifiersSourceStart;
463 //      }
464 //
465 //      localIntPtr = intPtr;
466 //
467 //      if (extendedTypeDimension == 0) {
468 //              declaration.type = type;
469 //      } else {
470 //              int dimension = typeDim + extendedTypeDimension;
471 //              //on the identifierLengthStack there is the information about the type....
472 //              int baseType;
473 //              if ((baseType = identifierLengthStack[identifierLengthPtr + 1]) < 0) {
474 //                      //it was a baseType
475 //                      declaration.type = TypeReference.baseTypeReference(-baseType, dimension);
476 //                      declaration.type.sourceStart = type.sourceStart;
477 //                      declaration.type.sourceEnd = type.sourceEnd;
478 //              } else {
479 //                      declaration.type = this.copyDims(type, dimension);
480 //              }
481 //      }
482 //      variablesCounter[nestedType]++;
483 //      nestedMethod[nestedType]++;
484 //      pushOnAstStack(declaration);
485 //
486 //      int[] javadocPositions = intArrayStack[intArrayPtr];
487 //      if (!isLocalDeclaration) {
488 //              requestor
489 //                      .enterField(
490 //                              declaration.declarationSourceStart, 
491 //                              javadocPositions, 
492 //                              declaration.modifiers, 
493 //                              declaration.modifiersSourceStart, 
494 //                              returnTypeName(declaration.type), 
495 //                              type.sourceStart, 
496 //                              type.sourceEnd, 
497 //                              typeDims, 
498 //                              name, 
499 //                              (int) (namePosition >>> 32), 
500 //                              (int) namePosition, 
501 //                              extendedTypeDimension, 
502 //                              extendedTypeDimension == 0 ? -1 : endPosition); 
503 //      }
504 //}
505 ///**
506 // *
507 // * INTERNAL USE-ONLY
508 // */
509 //protected void consumeExitVariableWithInitialization() {
510 //      // ExitVariableWithInitialization ::= $empty
511 //      // the scanner is located after the comma or the semi-colon.
512 //      // we want to include the comma or the semi-colon
513 //      super.consumeExitVariableWithInitialization();
514 //      nestedMethod[nestedType]--;     
515 //      lastFieldEndPosition = scanner.currentPosition - 1;
516 //      lastFieldBodyEndPosition =      ((AbstractVariableDeclaration) astStack[astPtr]).initialization.sourceEnd;
517 //}
518 //protected void consumeExitVariableWithoutInitialization() {
519 //      // ExitVariableWithoutInitialization ::= $empty
520 //      // do nothing by default
521 //      super.consumeExitVariableWithoutInitialization();
522 //      nestedMethod[nestedType]--;     
523 //      lastFieldEndPosition = scanner.currentPosition - 1;
524 //      lastFieldBodyEndPosition = scanner.startPosition - 1;
525 //}
526 ///**
527 // *
528 // * INTERNAL USE-ONLY
529 // */
530 //protected void consumeFieldDeclaration() {
531 //      // See consumeLocalVariableDeclarationDefaultModifier() in case of change: duplicated code
532 //      // FieldDeclaration ::= Modifiersopt Type VariableDeclarators ';'
533 //      // the super.consumeFieldDeclaration will reinitialize the variableCounter[nestedType]  
534 //      int variableIndex = variablesCounter[nestedType];
535 //      super.consumeFieldDeclaration();
536 //      intArrayPtr--;
537 //      if (isLocalDeclaration())
538 //              return;
539 //      if (variableIndex != 0) {
540 //              requestor.exitField(lastFieldBodyEndPosition, lastFieldEndPosition);
541 //      }
542 //}
543 //protected void consumeFormalParameter() {
544 //      // FormalParameter ::= Type VariableDeclaratorId ==> false
545 //      // FormalParameter ::= Modifiers Type VariableDeclaratorId ==> true
546 //      /*
547 //      astStack : 
548 //      identifierStack : type identifier
549 //      intStack : dim dim
550 //       ==>
551 //      astStack : Argument
552 //      identifierStack :  
553 //      intStack :  
554 //      */
555 //
556 //      identifierLengthPtr--;
557 //      char[] name = identifierStack[identifierPtr];
558 //      long namePositions = identifierPositionStack[identifierPtr--];
559 //      TypeReference type = getTypeReference(intStack[intPtr--] + intStack[intPtr--]);
560 //      intPtr -= 3;
561 //      Argument arg = 
562 //              new Argument(
563 //                      name, 
564 //                      namePositions, 
565 //                      type, 
566 //                      intStack[intPtr + 1]); // modifiers
567 //      pushOnAstStack(arg);
568 //      intArrayPtr--;
569 //}
570 ///**
571 // *
572 // * INTERNAL USE-ONLY
573 // */
574 //protected void consumeInterfaceDeclaration() {
575 //      super.consumeInterfaceDeclaration();
576 //      // we know that we have a TypeDeclaration on the top of the astStack
577 //      if (isLocalDeclaration()) {
578 //              // we ignore the local variable declarations
579 //              return;
580 //      }
581 //      requestor.exitInterface(endStatementPosition, // the '}' is the end of the body
582 //       ((TypeDeclaration) astStack[astPtr]).declarationSourceEnd);
583 //}
584 ///**
585 // *
586 // * INTERNAL USE-ONLY
587 // */
588 //protected void consumeInterfaceHeader() {
589 //      //InterfaceHeader ::= $empty
590 //      super.consumeInterfaceHeader();
591 //      if (isLocalDeclaration()) {
592 //              // we ignore the local variable declarations
593 //              intArrayPtr--;
594 //              return;
595 //      }
596 //      TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr];
597 //      TypeReference[] superInterfaces = typeDecl.superInterfaces;
598 //      char[][] interfaceNames = null;
599 //      int[] interfaceNameStarts = null;
600 //      int[] interfacenameEnds = null;
601 //      int superInterfacesLength = 0;
602 //      if (superInterfaces != null) {
603 //              superInterfacesLength = superInterfaces.length;
604 //              interfaceNames = new char[superInterfacesLength][];
605 //              interfaceNameStarts = new int[superInterfacesLength];
606 //              interfacenameEnds = new int[superInterfacesLength];
607 //      }
608 //      if (superInterfaces != null) {
609 //              for (int i = 0; i < superInterfacesLength; i++) {
610 //                      TypeReference superInterface = superInterfaces[i];
611 //                      interfaceNames[i] = CharOperation.concatWith(superInterface.getTypeName(), '.'); 
612 //                      interfaceNameStarts[i] = superInterface.sourceStart;
613 //                      interfacenameEnds[i] = superInterface.sourceEnd;
614 //              }
615 //      }
616 //      // flush the comments related to the interface header
617 //      scanner.commentPtr = -1;
618 //      requestor.enterInterface(
619 //              typeDecl.declarationSourceStart, 
620 //              intArrayStack[intArrayPtr--], 
621 //              typeDecl.modifiers, 
622 //              typeDecl.modifiersSourceStart, 
623 //              typeStartPosition, 
624 //              typeDecl.name, 
625 //              typeDecl.sourceStart, 
626 //              typeDecl.sourceEnd, 
627 //              interfaceNames, 
628 //              interfaceNameStarts, 
629 //              interfacenameEnds, 
630 //              scanner.currentPosition - 1); 
631 //}
632 //protected void consumeInterfaceHeaderName() {
633 //      // InterfaceHeaderName ::= Modifiersopt 'interface' 'Identifier'
634 //      TypeDeclaration typeDecl;
635 //      if (nestedMethod[nestedType] == 0) {
636 //              if (nestedType != 0) {
637 //                      typeDecl = new MemberTypeDeclaration(this.compilationUnit.compilationResult);
638 //              } else {
639 //                      typeDecl = new TypeDeclaration(this.compilationUnit.compilationResult);
640 //              }
641 //      } else {
642 //              // Record that the block has a declaration for local types
643 //              typeDecl = new LocalTypeDeclaration(this.compilationUnit.compilationResult);
644 //              markEnclosingMemberWithLocalType();
645 //              blockReal();
646 //      }
647 //
648 //      //highlight the name of the type
649 //      long pos = identifierPositionStack[identifierPtr];
650 //      typeDecl.sourceEnd = (int) pos;
651 //      typeDecl.sourceStart = (int) (pos >>> 32);
652 //      typeDecl.name = identifierStack[identifierPtr--];
653 //      identifierLengthPtr--;
654 //
655 //      //compute the declaration source too
656 //      // 'class' and 'interface' push an int position
657 //      typeStartPosition = typeDecl.declarationSourceStart = intStack[intPtr--];
658 //      intPtr--;
659 //      int declarationSourceStart = intStack[intPtr--];
660 //      typeDecl.modifiersSourceStart = intStack[intPtr--];
661 //      typeDecl.modifiers = intStack[intPtr--];
662 //      if (typeDecl.declarationSourceStart > declarationSourceStart) {
663 //              typeDecl.declarationSourceStart = declarationSourceStart;
664 //      }
665 //      typeDecl.bodyStart = typeDecl.sourceEnd + 1;
666 //      pushOnAstStack(typeDecl);
667 //}
668 ///**
669 // *
670 // * INTERNAL USE-ONLY
671 // */
672 //protected void consumeLocalVariableDeclaration() {
673 //      // See consumeLocalVariableDeclarationDefaultModifier() in case of change: duplicated code
674 //      // FieldDeclaration ::= Modifiersopt Type VariableDeclarators ';'
675 //
676 //      super.consumeLocalVariableDeclaration();
677 //      intArrayPtr--;
678 //}
679 ///**
680 // *
681 // * INTERNAL USE-ONLY
682 // */
683 //protected void consumeMethodDeclaration(boolean isNotAbstract) {
684 //      // MethodDeclaration ::= MethodHeader MethodBody
685 //      // AbstractMethodDeclaration ::= MethodHeader ';'
686 //      super.consumeMethodDeclaration(isNotAbstract);
687 //      if (isLocalDeclaration()) {
688 //              // we ignore the local variable declarations
689 //              return;
690 //      }
691 //      MethodDeclaration md = (MethodDeclaration) astStack[astPtr];
692 //      requestor.exitMethod(endStatementPosition, md.declarationSourceEnd);
693 //}
694 ///**
695 // *
696 // * INTERNAL USE-ONLY
697 // */
698 //protected void consumeMethodHeader() {
699 //      // MethodHeader ::= MethodHeaderName MethodHeaderParameters MethodHeaderExtendedDims ThrowsClauseopt
700 //      super.consumeMethodHeader();
701 //      if (isLocalDeclaration()) {
702 //              // we ignore the local variable declarations
703 //              intArrayPtr--;
704 //              return;
705 //      }
706 //      MethodDeclaration md = (MethodDeclaration) astStack[astPtr];
707 //
708 //      TypeReference returnType = md.returnType;
709 //      char[] returnTypeName = returnTypeName(returnType);
710 //      Argument[] arguments = md.arguments;
711 //      char[][] argumentTypes = null;
712 //      char[][] argumentNames = null;
713 //      int[] argumentTypeStarts = null;
714 //      int[] argumentTypeEnds = null;
715 //      int[] argumentNameStarts = null;
716 //      int[] argumentNameEnds = null;
717 //      if (arguments != null) {
718 //              int argumentLength = arguments.length;
719 //              argumentTypes = new char[argumentLength][];
720 //              argumentNames = new char[argumentLength][];
721 //              argumentNameStarts = new int[argumentLength];
722 //              argumentNameEnds = new int[argumentLength];
723 //              argumentTypeStarts = new int[argumentLength];
724 //              argumentTypeEnds = new int[argumentLength];
725 //              for (int i = 0; i < argumentLength; i++) {
726 //                      Argument argument = arguments[i];
727 //                      TypeReference argumentType = argument.type;
728 //                      argumentTypes[i] = returnTypeName(argumentType);
729 //                      argumentNames[i] = argument.name;
730 //                      argumentNameStarts[i] = argument.sourceStart;
731 //                      argumentNameEnds[i] = argument.sourceEnd;
732 //                      argumentTypeStarts[i] = argumentType.sourceStart;
733 //                      argumentTypeEnds[i] = argumentType.sourceEnd;
734 //              }
735 //      }
736 //      TypeReference[] thrownExceptions = md.thrownExceptions;
737 //      char[][] exceptionTypes = null;
738 //      int[] exceptionTypeStarts = null;
739 //      int[] exceptionTypeEnds = null;
740 //      if (thrownExceptions != null) {
741 //              int thrownExceptionLength = thrownExceptions.length;
742 //              exceptionTypeStarts = new int[thrownExceptionLength];
743 //              exceptionTypeEnds = new int[thrownExceptionLength];
744 //              exceptionTypes = new char[thrownExceptionLength][];
745 //              for (int i = 0; i < thrownExceptionLength; i++) {
746 //                      TypeReference exception = thrownExceptions[i];
747 //                      exceptionTypes[i] = CharOperation.concatWith(exception.getTypeName(), '.');
748 //                      exceptionTypeStarts[i] = exception.sourceStart;
749 //                      exceptionTypeEnds[i] = exception.sourceEnd;
750 //              }
751 //      }
752 //      requestor
753 //              .enterMethod(
754 //                      md.declarationSourceStart, 
755 //                      intArrayStack[intArrayPtr--], 
756 //                      md.modifiers, 
757 //                      md.modifiersSourceStart, 
758 //                      returnTypeName, 
759 //                      returnType.sourceStart, 
760 //                      returnType.sourceEnd, 
761 //                      typeDims, 
762 //                      md.selector, 
763 //                      md.sourceStart, 
764 //                      (int) (selectorSourcePositions & 0xFFFFFFFFL), 
765 //                      argumentTypes, 
766 //                      argumentTypeStarts, 
767 //                      argumentTypeEnds, 
768 //                      argumentNames, 
769 //                      argumentNameStarts, 
770 //                      argumentNameEnds, 
771 //                      rParenPos, 
772 //                      extendsDim, 
773 //                      extendsDim == 0 ? -1 : endPosition, 
774 //                      exceptionTypes, 
775 //                      exceptionTypeStarts, 
776 //                      exceptionTypeEnds, 
777 //                      scanner.currentPosition - 1); 
778 //}
779 //protected void consumeMethodHeaderExtendedDims() {
780 //      // MethodHeaderExtendedDims ::= Dimsopt
781 //      // now we update the returnType of the method
782 //      MethodDeclaration md = (MethodDeclaration) astStack[astPtr];
783 //      int extendedDims = intStack[intPtr--];
784 //      extendsDim = extendedDims;
785 //      if (extendedDims != 0) {
786 //              TypeReference returnType = md.returnType;
787 //              md.sourceEnd = endPosition;
788 //              int dims = returnType.dimensions() + extendedDims;
789 //              int baseType;
790 //              if ((baseType = identifierLengthStack[identifierLengthPtr + 1]) < 0) {
791 //                      //it was a baseType
792 //                      int sourceStart = returnType.sourceStart;
793 //                      int sourceEnd = returnType.sourceEnd;
794 //                      returnType = TypeReference.baseTypeReference(-baseType, dims);
795 //                      returnType.sourceStart = sourceStart;
796 //                      returnType.sourceEnd = sourceEnd;
797 //                      md.returnType = returnType;
798 //              } else {
799 //                      md.returnType = this.copyDims(md.returnType, dims);
800 //              }
801 //              if (currentToken == TokenNameLBRACE) {
802 //                      md.bodyStart = endPosition + 1;
803 //              }
804 //      }
805 //}
806 //protected void consumeMethodHeaderName() {
807 //      // MethodHeaderName ::= Modifiersopt Type 'Identifier' '('
808 //      MethodDeclaration md = new MethodDeclaration(this.compilationUnit.compilationResult);
809 //
810 //      //name
811 //      md.selector = identifierStack[identifierPtr];
812 //      selectorSourcePositions = identifierPositionStack[identifierPtr--];
813 //      identifierLengthPtr--;
814 //      //type
815 //      md.returnType = getTypeReference(typeDims = intStack[intPtr--]);
816 //      //modifiers
817 //      md.declarationSourceStart = intStack[intPtr--];
818 //      md.modifiersSourceStart = intStack[intPtr--];
819 //      md.modifiers = intStack[intPtr--];
820 //
821 //      //highlight starts at selector start
822 //      md.sourceStart = (int) (selectorSourcePositions >>> 32);
823 //      pushOnAstStack(md);
824 //      md.bodyStart = scanner.currentPosition-1;
825 //}
826 //protected void consumeModifiers() {
827 //      checkAnnotation(); // might update modifiers with AccDeprecated
828 //      pushOnIntStack(modifiers); // modifiers
829 //      pushOnIntStack(modifiersSourceStart);
830 //      pushOnIntStack(
831 //              declarationSourceStart >= 0 ? declarationSourceStart : modifiersSourceStart); 
832 //      resetModifiers();
833 //}
834 /**
835  *
836  * INTERNAL USE-ONLY
837  */
838 //protected void consumePackageDeclarationName() {
839 //      /* persisting javadoc positions */
840 //      pushOnIntArrayStack(this.getJavaDocPositions());
841 //
842 //      super.consumePackageDeclarationName();
843 //      ImportReference importReference = compilationUnit.currentPackage;
844 //
845 //      requestor.acceptPackage(
846 //              importReference.declarationSourceStart, 
847 //              importReference.declarationSourceEnd, 
848 //              intArrayStack[intArrayPtr--], 
849 //              CharOperation.concatWith(importReference.getImportName(), '.'),
850 //              importReference.sourceStart);
851 //}
852 //protected void consumePushModifiers() {
853 //      checkAnnotation(); // might update modifiers with AccDeprecated
854 //      pushOnIntStack(modifiers); // modifiers
855 //      if (modifiersSourceStart < 0) {
856 //              pushOnIntStack(-1);
857 //              pushOnIntStack(
858 //                      declarationSourceStart >= 0 ? declarationSourceStart : scanner.startPosition); 
859 //      } else {
860 //              pushOnIntStack(modifiersSourceStart);
861 //              pushOnIntStack(
862 //                      declarationSourceStart >= 0 ? declarationSourceStart : modifiersSourceStart); 
863 //      }
864 //      resetModifiers();
865 //}
866 ///**
867 // *
868 // * INTERNAL USE-ONLY
869 // */
870 //protected void consumeSingleTypeImportDeclarationName() {
871 //      // SingleTypeImportDeclarationName ::= 'import' Name
872 //
873 //      /* persisting javadoc positions */
874 //      pushOnIntArrayStack(this.getJavaDocPositions());
875 //
876 //      super.consumeSingleTypeImportDeclarationName();
877 //      ImportReference importReference = (ImportReference) astStack[astPtr];
878 //      requestor.acceptImport(
879 //              importReference.declarationSourceStart, 
880 //              importReference.declarationSourceEnd,
881 //              intArrayStack[intArrayPtr--],
882 //              CharOperation.concatWith(importReference.getImportName(), '.'),
883 //              importReference.sourceStart,
884 //              false);
885 //}
886 ///**
887 // *
888 // * INTERNAL USE-ONLY
889 // */
890 //protected void consumeStaticInitializer() {
891 //      // StaticInitializer ::=  StaticOnly Block
892 //      //push an Initializer
893 //      //optimize the push/pop
894 //      super.consumeStaticInitializer();
895 //      Initializer initializer = (Initializer) astStack[astPtr];
896 //      requestor.acceptInitializer(
897 //              initializer.declarationSourceStart,
898 //              initializer.declarationSourceEnd,
899 //              intArrayStack[intArrayPtr--],
900 //              AccStatic, 
901 //              intStack[intPtr--], 
902 //              initializer.block.sourceStart,
903 //              initializer.declarationSourceEnd);
904 //}
905 //protected void consumeStaticOnly() {
906 //      // StaticOnly ::= 'static'
907 //      checkAnnotation(); // might update declaration source start
908 //      pushOnIntStack(modifiersSourceStart);
909 //      pushOnIntStack(
910 //              declarationSourceStart >= 0 ? declarationSourceStart : modifiersSourceStart); 
911 //      jumpOverMethodBody();
912 //      nestedMethod[nestedType]++;
913 //      resetModifiers();
914 //}
915 ///**
916 // *
917 // * INTERNAL USE-ONLY
918 // */
919 //protected void consumeTypeImportOnDemandDeclarationName() {
920 //      // TypeImportOnDemandDeclarationName ::= 'import' Name '.' '*'
921 //
922 //      /* persisting javadoc positions */
923 //      pushOnIntArrayStack(this.getJavaDocPositions());
924 //
925 //      super.consumeTypeImportOnDemandDeclarationName();
926 //      ImportReference importReference = (ImportReference) astStack[astPtr];
927 //      requestor.acceptImport(
928 //              importReference.declarationSourceStart, 
929 //              importReference.declarationSourceEnd,
930 //              intArrayStack[intArrayPtr--],
931 //              CharOperation.concatWith(importReference.getImportName(), '.'), 
932 //              importReference.sourceStart,
933 //              true);
934 //}
935 public CompilationUnitDeclaration endParse(int act) {
936         if (scanner.recordLineSeparator) {
937                 requestor.acceptLineSeparatorPositions(scanner.getLineEnds());
938         }
939         return super.endParse(act);
940 }
941 /*
942  * Flush annotations defined prior to a given positions.
943  *
944  * Note: annotations are stacked in syntactical order
945  *
946  * Either answer given <position>, or the end position of a comment line 
947  * immediately following the <position> (same line)
948  *
949  * e.g.
950  * void foo(){
951  * } // end of method foo
952  */
953  
954 //public int flushAnnotationsDefinedPriorTo(int position) {
955 //
956 //      return lastFieldEndPosition = super.flushAnnotationsDefinedPriorTo(position);
957 //}
958 //protected TypeReference getTypeReference(int dim) { /* build a Reference on a variable that may be qualified or not
959 //This variable is a type reference and dim will be its dimensions*/
960 //
961 //      int length;
962 //      TypeReference ref;
963 //      if ((length = identifierLengthStack[identifierLengthPtr--]) == 1) {
964 //              // single variable reference
965 //              if (dim == 0) {
966 //                      ref = 
967 //                              new SingleTypeReference(
968 //                                      identifierStack[identifierPtr], 
969 //                                      identifierPositionStack[identifierPtr--]); 
970 //              } else {
971 //                      ref = 
972 //                              new ArrayTypeReference(
973 //                                      identifierStack[identifierPtr], 
974 //                                      dim, 
975 //                                      identifierPositionStack[identifierPtr--]); 
976 //                      ref.sourceEnd = endPosition;
977 //              }
978 //      } else {
979 //              if (length < 0) { //flag for precompiled type reference on base types
980 //                      ref = TypeReference.baseTypeReference(-length, dim);
981 //                      ref.sourceStart = intStack[intPtr--];
982 //                      if (dim == 0) {
983 //                              ref.sourceEnd = intStack[intPtr--];
984 //                      } else {
985 //                              intPtr--;
986 //                              ref.sourceEnd = endPosition;
987 //                      }
988 //              } else { //Qualified variable reference
989 //                      char[][] tokens = new char[length][];
990 //                      identifierPtr -= length;
991 //                      long[] positions = new long[length];
992 //                      System.arraycopy(identifierStack, identifierPtr + 1, tokens, 0, length);
993 //                      System.arraycopy(
994 //                              identifierPositionStack, 
995 //                              identifierPtr + 1, 
996 //                              positions, 
997 //                              0, 
998 //                              length); 
999 //                      if (dim == 0) {
1000 //                              ref = new QualifiedTypeReference(tokens, positions);
1001 //                      } else {
1002 //                              ref = new ArrayQualifiedTypeReference(tokens, dim, positions);
1003 //                              ref.sourceEnd = endPosition;
1004 //                      }
1005 //              }
1006 //      };
1007 //      return ref;
1008 //}
1009 public void initialize() {
1010         //positionning the parser for a new compilation unit
1011         //avoiding stack reallocation and all that....
1012         super.initialize();
1013         intArrayPtr = -1;
1014 }
1015 /**
1016  *
1017  * INTERNAL USE-ONLY
1018  */
1019 //private boolean isLocalDeclaration() {
1020 //      int nestedDepth = nestedType;
1021 //      while (nestedDepth >= 0) {
1022 //              if (nestedMethod[nestedDepth] != 0) {
1023 //                      return true;
1024 //              }
1025 //              nestedDepth--;
1026 //      }
1027 //      return false;
1028 //}
1029 /*
1030  * Investigate one entire unit.
1031  */
1032 public void parseCompilationUnit(ICompilationUnit unit) {
1033         char[] regionSource = unit.getContents();
1034         try {
1035                 initialize();
1036                 goForCompilationUnit();
1037                 referenceContext =
1038                         compilationUnit = 
1039                                 compilationUnit = 
1040                                         new CompilationUnitDeclaration(
1041                                                 problemReporter(), 
1042                                                 new CompilationResult(unit, 0, 0, 10), //this.options.maxProblemsPerUnit), 
1043                                                 regionSource.length); 
1044                 scanner.resetTo(0, regionSource.length);
1045                 scanner.setSource(regionSource);
1046                 parse();
1047         } catch (CoreException e) {
1048                 e.printStackTrace();
1049         } catch (AbortCompilation ex) {
1050         }
1051 }
1052 /*
1053  * Investigate one constructor declaration.
1054  */
1055 //public void parseConstructor(char[] regionSource) {
1056 //      try {
1057 //              initialize();
1058 //              goForClassBodyDeclarations();
1059 //              referenceContext = 
1060 //                      compilationUnit = 
1061 //                              compilationUnit = 
1062 //                                      new CompilationUnitDeclaration(
1063 //                                              problemReporter(), 
1064 //                                              new CompilationResult(regionSource, 0, 0, 10), //this.options.maxProblemsPerUnit), 
1065 //                                              regionSource.length); 
1066 //              scanner.resetTo(0, regionSource.length);
1067 //              scanner.setSource(regionSource);
1068 //              parse();
1069 //      } catch (AbortCompilation ex) {
1070 //      }
1071 //}
1072 /*
1073  * Investigate one field declaration statement (might have multiple declarations in it).
1074  */
1075 //public void parseField(char[] regionSource) {
1076 //      try {
1077 //              initialize();
1078 //              goForFieldDeclaration();
1079 //              referenceContext = 
1080 //                      compilationUnit = 
1081 //                              compilationUnit = 
1082 //                                      new CompilationUnitDeclaration(
1083 //                                              problemReporter(), 
1084 //                                              new CompilationResult(regionSource, 0, 0, this.options.maxProblemsPerUnit), 
1085 //                                              regionSource.length); 
1086 //              scanner.resetTo(0, regionSource.length);
1087 //              scanner.setSource(regionSource);
1088 //              parse();
1089 //      } catch (AbortCompilation ex) {
1090 //      }
1091 //
1092 //}
1093 ///*
1094 // * Investigate one import statement declaration.
1095 // */
1096 //public void parseImport(char[] regionSource) {
1097 //      try {
1098 //              initialize();
1099 //              goForImportDeclaration();
1100 //              referenceContext = 
1101 //                      compilationUnit = 
1102 //                              compilationUnit = 
1103 //                                      new CompilationUnitDeclaration(
1104 //                                              problemReporter(), 
1105 //                                              new CompilationResult(regionSource, 0, 0, this.options.maxProblemsPerUnit), 
1106 //                                              regionSource.length); 
1107 //              scanner.resetTo(0, regionSource.length);
1108 //              scanner.setSource(regionSource);
1109 //              parse();
1110 //      } catch (AbortCompilation ex) {
1111 //      }
1112 //
1113 //}
1114 ///*
1115 // * Investigate one initializer declaration.
1116 // * regionSource need to content exactly an initializer declaration.
1117 // * e.g: static { i = 4; }
1118 // * { name = "test"; }
1119 // */
1120 //public void parseInitializer(char[] regionSource) {
1121 //      try {
1122 //              initialize();
1123 //              goForInitializer();
1124 //              referenceContext = 
1125 //                      compilationUnit = 
1126 //                              compilationUnit = 
1127 //                                      new CompilationUnitDeclaration(
1128 //                                              problemReporter(), 
1129 //                                              new CompilationResult(regionSource, 0, 0, this.options.maxProblemsPerUnit), 
1130 //                                              regionSource.length); 
1131 //              scanner.resetTo(0, regionSource.length);
1132 //              scanner.setSource(regionSource);
1133 //              parse();
1134 //      } catch (AbortCompilation ex) {
1135 //      }
1136 //
1137 //}
1138 ///*
1139 // * Investigate one method declaration.
1140 // */
1141 //public void parseMethod(char[] regionSource) {
1142 //      try {
1143 //              initialize();
1144 //              goForGenericMethodDeclaration();
1145 //              referenceContext = 
1146 //                      compilationUnit = 
1147 //                              compilationUnit = 
1148 //                                      new CompilationUnitDeclaration(
1149 //                                              problemReporter(), 
1150 //                                              new CompilationResult(regionSource, 0, 0, this.options.maxProblemsPerUnit), 
1151 //                                              regionSource.length); 
1152 //              scanner.resetTo(0, regionSource.length);
1153 //              scanner.setSource(regionSource);
1154 //              parse();
1155 //      } catch (AbortCompilation ex) {
1156 //      }
1157 //
1158 //}
1159 ///*
1160 // * Investigate one package statement declaration.
1161 // */
1162 //public void parsePackage(char[] regionSource) {
1163 //      try {
1164 //              initialize();
1165 //              goForPackageDeclaration();
1166 //              referenceContext = 
1167 //                      compilationUnit = 
1168 //                              compilationUnit = 
1169 //                                      new CompilationUnitDeclaration(
1170 //                                              problemReporter(), 
1171 //                                              new CompilationResult(regionSource, 0, 0, this.options.maxProblemsPerUnit), 
1172 //                                              regionSource.length); 
1173 //              scanner.resetTo(0, regionSource.length);
1174 //              scanner.setSource(regionSource);
1175 //              parse();
1176 //      } catch (AbortCompilation ex) {
1177 //      }
1178 //
1179 //}
1180 ///*
1181 // * Investigate one type declaration, its fields, methods and member types.
1182 // */
1183 //public void parseType(char[] regionSource) {
1184 //      try {
1185 //              initialize();
1186 //              goForTypeDeclaration();
1187 //              referenceContext = 
1188 //                      compilationUnit = 
1189 //                              compilationUnit = 
1190 //                                      new CompilationUnitDeclaration(
1191 //                                              problemReporter(), 
1192 //                                              new CompilationResult(regionSource, 0, 0, this.options.maxProblemsPerUnit), 
1193 //                                              regionSource.length); 
1194 //              scanner.resetTo(0, regionSource.length);
1195 //              scanner.setSource(regionSource);
1196 //              parse();
1197 //      } catch (AbortCompilation ex) {
1198 //      }
1199 //
1200 //}
1201 /**
1202  * Returns this parser's problem reporter initialized with its reference context.
1203  * Also it is assumed that a problem is going to be reported, so initializes
1204  * the compilation result's line positions.
1205  */
1206 public ProblemReporter problemReporter() {
1207         problemReporter.referenceContext = referenceContext;
1208         return problemReporter;
1209 }
1210 protected void pushOnIntArrayStack(int[] positions) {
1211
1212         try {
1213                 intArrayStack[++intArrayPtr] = positions;
1214         } catch (IndexOutOfBoundsException e) {
1215                 //intPtr is correct 
1216                 int oldStackLength = intArrayStack.length;
1217                 int oldStack[][] = intArrayStack;
1218                 intArrayStack = new int[oldStackLength + StackIncrement][];
1219                 System.arraycopy(oldStack, 0, intArrayStack, 0, oldStackLength);
1220                 intArrayStack[intArrayPtr] = positions;
1221         }
1222 }
1223 //protected void resetModifiers() {
1224 //      super.resetModifiers();
1225 //      declarationSourceStart = -1;
1226 //}
1227 /*
1228  * Syntax error was detected. Will attempt to perform some recovery action in order
1229  * to resume to the regular parse loop.
1230  */
1231 protected boolean resumeOnSyntaxError() {
1232         return false;
1233 }
1234 /*
1235  * Answer a char array representation of the type name formatted like:
1236  * - type name + dimensions
1237  * Example:
1238  * "A[][]".toCharArray()
1239  * "java.lang.String".toCharArray()
1240  */
1241 //private char[] returnTypeName(TypeReference type) {
1242 //      int dimension = type.dimensions();
1243 //      if (dimension != 0) {
1244 //              char[] dimensionsArray = new char[dimension * 2];
1245 //              for (int i = 0; i < dimension; i++) {
1246 //                      dimensionsArray[i*2] = '[';
1247 //                      dimensionsArray[(i*2) + 1] = ']';
1248 //              }
1249 //              return CharOperation.concat(
1250 //                      CharOperation.concatWith(type.getTypeName(), '.'), 
1251 //                      dimensionsArray); 
1252 //      }
1253 //      return CharOperation.concatWith(type.getTypeName(), '.');
1254 //}
1255 //public String toString() {
1256 //      StringBuffer buffer = new StringBuffer();
1257 //      buffer.append("intArrayPtr = " + intArrayPtr + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
1258 //      buffer.append(super.toString());
1259 //      return buffer.toString();
1260 //}
1261 ///**
1262 // * INTERNAL USE ONLY
1263 // */
1264 //protected TypeReference typeReference(
1265 //      int dim,
1266 //      int localIdentifierPtr, 
1267 //      int localIdentifierLengthPtr) {
1268 //      /* build a Reference on a variable that may be qualified or not
1269 //       * This variable is a type reference and dim will be its dimensions.
1270 //       * We don't have any side effect on the stacks' pointers.
1271 //       */
1272 //
1273 //      int length;
1274 //      TypeReference ref;
1275 //      if ((length = identifierLengthStack[localIdentifierLengthPtr]) == 1) {
1276 //              // single variable reference
1277 //              if (dim == 0) {
1278 //                      ref = 
1279 //                              new SingleTypeReference(
1280 //                                      identifierStack[localIdentifierPtr], 
1281 //                                      identifierPositionStack[localIdentifierPtr--]); 
1282 //              } else {
1283 //                      ref = 
1284 //                              new ArrayTypeReference(
1285 //                                      identifierStack[localIdentifierPtr], 
1286 //                                      dim, 
1287 //                                      identifierPositionStack[localIdentifierPtr--]); 
1288 //                      ref.sourceEnd = endPosition;                            
1289 //              }
1290 //      } else {
1291 //              if (length < 0) { //flag for precompiled type reference on base types
1292 //                      ref = TypeReference.baseTypeReference(-length, dim);
1293 //                      ref.sourceStart = intStack[localIntPtr--];
1294 //                      if (dim == 0) {
1295 //                              ref.sourceEnd = intStack[localIntPtr--];
1296 //                      } else {
1297 //                              localIntPtr--;
1298 //                              ref.sourceEnd = endPosition;
1299 //                      }
1300 //              } else { //Qualified variable reference
1301 //                      char[][] tokens = new char[length][];
1302 //                      localIdentifierPtr -= length;
1303 //                      long[] positions = new long[length];
1304 //                      System.arraycopy(identifierStack, localIdentifierPtr + 1, tokens, 0, length);
1305 //                      System.arraycopy(
1306 //                              identifierPositionStack, 
1307 //                              localIdentifierPtr + 1, 
1308 //                              positions, 
1309 //                              0, 
1310 //                              length); 
1311 //                      if (dim == 0)
1312 //                              ref = new QualifiedTypeReference(tokens, positions);
1313 //                      else
1314 //                              ref = new ArrayQualifiedTypeReference(tokens, dim, positions);
1315 //              }
1316 //      };
1317 //      return ref;
1318 //}
1319 }