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