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