EclipseJDT Source Viewer

Home|eclipse_jdt/src/org/eclipse/jdt/core/dom/ASTConverter.java
1/*******************************************************************************
2 * Copyright (c) 2000, 2022 IBM Corporation and others.
3 *
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
8 *
9 * SPDX-License-Identifier: EPL-2.0
10 *
11 * Contributors:
12 *     IBM Corporation - initial API and implementation
13 *     Stephan Herrmann - Contribution for
14 *                                bug 393719 - [compiler] inconsistent warnings on iteration variables
15 *******************************************************************************/
16
17package org.eclipse.jdt.core.dom;
18
19import java.util.ArrayList;
20import java.util.Comparator;
21import java.util.HashSet;
22import java.util.Iterator;
23import java.util.List;
24import java.util.Map;
25import java.util.Set;
26import java.util.TreeSet;
27
28import org.eclipse.core.runtime.IProgressMonitor;
29import org.eclipse.core.runtime.OperationCanceledException;
30import org.eclipse.jdt.core.JavaCore;
31import org.eclipse.jdt.core.compiler.CategorizedProblem;
32import org.eclipse.jdt.core.compiler.CharOperation;
33import org.eclipse.jdt.core.compiler.IProblem;
34import org.eclipse.jdt.core.compiler.InvalidInputException;
35import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
36import org.eclipse.jdt.core.dom.ModuleModifier.ModuleModifierKeyword;
37import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
38import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
39import org.eclipse.jdt.internal.compiler.ast.Argument;
40import org.eclipse.jdt.internal.compiler.ast.CompactConstructorDeclaration;
41import org.eclipse.jdt.internal.compiler.ast.FieldReference;
42import org.eclipse.jdt.internal.compiler.ast.ForeachStatement;
43import org.eclipse.jdt.internal.compiler.ast.IntersectionCastTypeReference;
44import org.eclipse.jdt.internal.compiler.ast.JavadocArgumentExpression;
45import org.eclipse.jdt.internal.compiler.ast.JavadocFieldReference;
46import org.eclipse.jdt.internal.compiler.ast.JavadocMessageSend;
47import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
48import org.eclipse.jdt.internal.compiler.ast.MessageSend;
49import org.eclipse.jdt.internal.compiler.ast.ModuleReference;
50import org.eclipse.jdt.internal.compiler.ast.NameReference;
51import org.eclipse.jdt.internal.compiler.ast.OperatorIds;
52import org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference;
53import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference;
54import org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression;
55import org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference;
56import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
57import org.eclipse.jdt.internal.compiler.ast.Receiver;
58import org.eclipse.jdt.internal.compiler.ast.RecordComponent;
59import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
60import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
61import org.eclipse.jdt.internal.compiler.ast.StringLiteralConcatenation;
62import org.eclipse.jdt.internal.compiler.ast.SuperReference;
63import org.eclipse.jdt.internal.compiler.ast.TypeReference;
64import org.eclipse.jdt.internal.compiler.ast.UnionTypeReference;
65import org.eclipse.jdt.internal.compiler.ast.Wildcard;
66import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
67import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
68import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
69import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
70import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
71import org.eclipse.jdt.internal.compiler.parser.RecoveryScanner;
72import org.eclipse.jdt.internal.compiler.parser.Scanner;
73import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
74import org.eclipse.jdt.internal.core.dom.SourceRangeVerifier;
75import org.eclipse.jdt.internal.core.dom.util.DOMASTUtil;
76import org.eclipse.jdt.internal.core.util.Util;
77
78/**
79 * Internal class for converting internal compiler ASTs into public ASTs.
80 */
81@SuppressWarnings({ "rawtypes""unchecked" })
82class ASTConverter {
83
84    protected AST ast;
85    private ASTNode referenceContext;
86    protected Comment[] commentsTable;
87    char[] compilationUnitSource;
88    int compilationUnitSourceLength;
89    protected DocCommentParser docParser;
90    // comments
91    protected boolean insideComments;
92    protected IProgressMonitor monitor;
93    protected Set pendingNameScopeResolution;
94    protected Set pendingThisExpressionScopeResolution;
95    protected boolean resolveBindings;
96    Scanner scanner;
97    private DefaultCommentMapper commentMapper;
98
99    public ASTConverter(Map<StringStringoptionsboolean resolveBindingsIProgressMonitor monitor) {
100        this.resolveBindings = resolveBindings;
101        this.referenceContext = null;
102        String sourceModeSetting = options.get(JavaCore.COMPILER_SOURCE);
103        long sourceLevel = CompilerOptions.versionToJdkLevel(sourceModeSetting);
104        if (sourceLevel == 0) {
105            // unknown sourceModeSetting
106            sourceLevel = ClassFileConstants.JDK1_3;
107        }
108        this.scanner = new Scanner(
109            true /*comment*/,
110            false /*whitespace*/,
111            false /*nls*/,
112            sourceLevel /*sourceLevel*/,
113            null /*taskTags*/,
114            null/*taskPriorities*/,
115            true/*taskCaseSensitive*/,
116            JavaCore.ENABLED.equals(options.get(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES)));
117        this.monitor = monitor;
118        this.insideComments = JavaCore.ENABLED.equals(options.get(JavaCore.COMPILER_DOC_COMMENT_SUPPORT));
119    }
120
121    protected void adjustSourcePositionsForParent(org.eclipse.jdt.internal.compiler.ast.Expression expression) {
122        int start = expression.sourceStart;
123        int end = expression.sourceEnd;
124        int leftParentCount = 1;
125        int rightParentCount = 0;
126        this.scanner.resetTo(startend);
127        try {
128            int token = this.scanner.getNextToken();
129            expression.sourceStart = this.scanner.currentPosition;
130            boolean stop = false;
131            while (!stop && ((token  = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF)) {
132                switch(token) {
133                    case TerminalTokens.TokenNameLPAREN:
134                        leftParentCount++;
135                        break;
136                    case TerminalTokens.TokenNameRPAREN:
137                        rightParentCount++;
138                        if (rightParentCount == leftParentCount) {
139                            // we found the matching parenthesis
140                            stop = true;
141                        }
142                }
143            }
144            expression.sourceEnd = this.scanner.startPosition - 1;
145        } catch(InvalidInputException e) {
146            // ignore
147        }
148    }
149
150    protected void buildBodyDeclarations(
151            org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration,
152            AbstractTypeDeclaration typeDecl,
153            boolean isInterface) {
154        // add body declaration in the lexical order
155        org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] members = typeDeclaration.memberTypes;
156        org.eclipse.jdt.internal.compiler.ast.FieldDeclaration[] fields = typeDeclaration.fields;
157        org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration[] methods = typeDeclaration.methods;
158
159        int fieldsLength = fields == null0 : fields.length;
160        int methodsLength = methods == null0 : methods.length;
161        int membersLength = members == null ? 0 : members.length;
162        int fieldsIndex = 0;
163        int methodsIndex = 0;
164        int membersIndex = 0;
165
166        while ((fieldsIndex < fieldsLength)
167            || (membersIndex < membersLength)
168            || (methodsIndex < methodsLength)) {
169            org.eclipse.jdt.internal.compiler.ast.FieldDeclaration nextFieldDeclaration = null;
170            org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration nextMethodDeclaration = null;
171            org.eclipse.jdt.internal.compiler.ast.TypeDeclaration nextMemberDeclaration = null;
172
173            int position = Integer.MAX_VALUE;
174            int nextDeclarationType = -1;
175            if (fieldsIndex < fieldsLength) {
176                nextFieldDeclaration = fields[fieldsIndex];
177                if (nextFieldDeclaration.declarationSourceStart < position) {
178                    position = nextFieldDeclaration.declarationSourceStart;
179                    nextDeclarationType = 0// FIELD
180                }
181            }
182            if (methodsIndex < methodsLength) {
183                nextMethodDeclaration = methods[methodsIndex];
184                if (nextMethodDeclaration.declarationSourceStart < position) {
185                    position = nextMethodDeclaration.declarationSourceStart;
186                    nextDeclarationType = 1// METHOD
187                }
188            }
189            if (membersIndex < membersLength) {
190                nextMemberDeclaration = members[membersIndex];
191                if (nextMemberDeclaration.declarationSourceStart < position) {
192                    position = nextMemberDeclaration.declarationSourceStart;
193                    nextDeclarationType = 2// MEMBER
194                }
195            }
196            switch (nextDeclarationType) {
197                case 0 :
198                    if (nextFieldDeclaration.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) {
199                        typeDecl.bodyDeclarations().add(convert(nextFieldDeclaration));
200                    } else {
201                        checkAndAddMultipleFieldDeclaration(fieldsfieldsIndextypeDecl.bodyDeclarations());
202                    }
203                    fieldsIndex++;
204                    break;
205                case 1 :
206                    methodsIndex++;
207                    if (!nextMethodDeclaration.isDefaultConstructor() && !nextMethodDeclaration.isClinit()) {
208                        typeDecl.bodyDeclarations().add(convert(isInterfacenextMethodDeclaration));
209                    }
210                    break;
211                case 2 :
212                    membersIndex++;
213                    ASTNode node = convert(nextMemberDeclaration);
214                    if (node == null) {
215                        typeDecl.setFlags(typeDecl.getFlags() | ASTNode.MALFORMED);
216                    } else {
217                        typeDecl.bodyDeclarations().add(node);
218                    }
219            }
220        }
221        // Convert javadoc
222        convert(typeDeclaration.javadoctypeDecl);
223    }
224
225    protected void buildBodyDeclarations(
226            org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration,
227            RecordDeclaration recordDeclaration,
228            boolean isInterface) {
229        // add body declaration in the lexical order
230        org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] members = typeDeclaration.memberTypes;
231        org.eclipse.jdt.internal.compiler.ast.FieldDeclaration[] fields = typeDeclaration.fields;
232        org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration[] methods = typeDeclaration.methods;
233
234        int fieldsLength = fields == null0 : fields.length;
235        int methodsLength = methods == null0 : methods.length;
236        int membersLength = members == null ? 0 : members.length;
237        int fieldsIndex = 0;
238        int methodsIndex = 0;
239        int membersIndex = 0;
240
241        while ((fieldsIndex < fieldsLength)
242            || (membersIndex < membersLength)
243            || (methodsIndex < methodsLength)) {
244            org.eclipse.jdt.internal.compiler.ast.FieldDeclaration nextFieldDeclaration = null;
245            org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration nextMethodDeclaration = null;
246            org.eclipse.jdt.internal.compiler.ast.TypeDeclaration nextMemberDeclaration = null;
247
248            int position = Integer.MAX_VALUE;
249            int nextDeclarationType = -1;
250            if (fieldsIndex < fieldsLength) {
251                nextFieldDeclaration = fields[fieldsIndex];
252                if (!nextFieldDeclaration.isARecordComponent) {
253                    if (nextFieldDeclaration.declarationSourceStart < position) {
254                            position = nextFieldDeclaration.declarationSourceStart;
255                            nextDeclarationType = 0// FIELD
256                    }
257                } else {
258                    fieldsIndex++;
259                }
260
261            }
262            if (methodsIndex < methodsLength) {
263                nextMethodDeclaration = methods[methodsIndex];
264                if ((nextMethodDeclaration.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.IsImplicit) == 0) {
265                    if (nextMethodDeclaration.declarationSourceStart < position) {
266                        position = nextMethodDeclaration.declarationSourceStart;
267                        nextDeclarationType = 1// METHOD
268                    }
269
270              } else {
271                  methodsIndex++;
272              }
273
274            }
275            if (membersIndex < membersLength) {
276                nextMemberDeclaration = members[membersIndex];
277                if (nextMemberDeclaration.declarationSourceStart < position) {
278                    position = nextMemberDeclaration.declarationSourceStart;
279                    nextDeclarationType = 2// MEMBER
280                }
281            }
282            switch (nextDeclarationType) {
283                case 0 :
284                    checkAndAddMultipleFieldDeclaration(fieldsfieldsIndexrecordDeclaration.bodyDeclarations());
285                    fieldsIndex++;
286                    break;
287                case 1 :
288                    methodsIndex++;
289                    if (!nextMethodDeclaration.isDefaultConstructor() && !nextMethodDeclaration.isClinit()) {
290                        recordDeclaration.bodyDeclarations().add(convert(isInterfacenextMethodDeclaration));
291                    }
292                    break;
293                case 2 :
294                    membersIndex++;
295                    ASTNode node = convert(nextMemberDeclaration);
296                    if (node == null) {
297                        recordDeclaration.setFlags(recordDeclaration.getFlags() | ASTNode.MALFORMED);
298                    } else {
299                        recordDeclaration.bodyDeclarations().add(node);
300                    }
301            }
302        }
303        // Convert javadoc
304        convert(typeDeclaration.javadocrecordDeclaration);
305    }
306
307    protected void buildBodyDeclarations(org.eclipse.jdt.internal.compiler.ast.TypeDeclaration enumDeclaration2EnumDeclaration enumDeclaration) {
308        // add body declaration in the lexical order
309        org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] members = enumDeclaration2.memberTypes;
310        org.eclipse.jdt.internal.compiler.ast.FieldDeclaration[] fields = enumDeclaration2.fields;
311        org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration[] methods = enumDeclaration2.methods;
312
313        int fieldsLength = fields == null0 : fields.length;
314        int methodsLength = methods == null0 : methods.length;
315        int membersLength = members == null ? 0 : members.length;
316        int fieldsIndex = 0;
317        int methodsIndex = 0;
318        int membersIndex = 0;
319
320        while ((fieldsIndex < fieldsLength)
321            || (membersIndex < membersLength)
322            || (methodsIndex < methodsLength)) {
323            org.eclipse.jdt.internal.compiler.ast.FieldDeclaration nextFieldDeclaration = null;
324            org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration nextMethodDeclaration = null;
325            org.eclipse.jdt.internal.compiler.ast.TypeDeclaration nextMemberDeclaration = null;
326
327            int position = Integer.MAX_VALUE;
328            int nextDeclarationType = -1;
329            if (fieldsIndex < fieldsLength) {
330                nextFieldDeclaration = fields[fieldsIndex];
331                if (nextFieldDeclaration.declarationSourceStart < position) {
332                    position = nextFieldDeclaration.declarationSourceStart;
333                    nextDeclarationType = 0// FIELD
334                }
335            }
336            if (methodsIndex < methodsLength) {
337                nextMethodDeclaration = methods[methodsIndex];
338                if (nextMethodDeclaration.declarationSourceStart < position) {
339                    position = nextMethodDeclaration.declarationSourceStart;
340                    nextDeclarationType = 1// METHOD
341                }
342            }
343            if (membersIndex < membersLength) {
344                nextMemberDeclaration = members[membersIndex];
345                if (nextMemberDeclaration.declarationSourceStart < position) {
346                    position = nextMemberDeclaration.declarationSourceStart;
347                    nextDeclarationType = 2// MEMBER
348                }
349            }
350            switch (nextDeclarationType) {
351                case 0 :
352                    if (nextFieldDeclaration.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) {
353                        enumDeclaration.enumConstants().add(convert(nextFieldDeclaration));
354                    } else {
355                        checkAndAddMultipleFieldDeclaration(fieldsfieldsIndexenumDeclaration.bodyDeclarations());
356                    }
357                    fieldsIndex++;
358                    break;
359                case 1 :
360                    methodsIndex++;
361                    if (!nextMethodDeclaration.isDefaultConstructor() && !nextMethodDeclaration.isClinit()) {
362                        enumDeclaration.bodyDeclarations().add(convert(falsenextMethodDeclaration));
363                    }
364                    break;
365                case 2 :
366                    membersIndex++;
367                    enumDeclaration.bodyDeclarations().add(convert(nextMemberDeclaration));
368                    break;
369            }
370        }
371        convert(enumDeclaration2.javadocenumDeclaration);
372    }
373
374    protected void buildBodyDeclarations(org.eclipse.jdt.internal.compiler.ast.TypeDeclaration expressionAnonymousClassDeclaration anonymousClassDeclaration) {
375        // add body declaration in the lexical order
376        org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] members = expression.memberTypes;
377        org.eclipse.jdt.internal.compiler.ast.FieldDeclaration[] fields = expression.fields;
378        org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration[] methods = expression.methods;
379
380        int fieldsLength = fields == null0 : fields.length;
381        int methodsLength = methods == null0 : methods.length;
382        int membersLength = members == null ? 0 : members.length;
383        int fieldsIndex = 0;
384        int methodsIndex = 0;
385        int membersIndex = 0;
386
387        while ((fieldsIndex < fieldsLength)
388            || (membersIndex < membersLength)
389            || (methodsIndex < methodsLength)) {
390            org.eclipse.jdt.internal.compiler.ast.FieldDeclaration nextFieldDeclaration = null;
391            org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration nextMethodDeclaration = null;
392            org.eclipse.jdt.internal.compiler.ast.TypeDeclaration nextMemberDeclaration = null;
393
394            int position = Integer.MAX_VALUE;
395            int nextDeclarationType = -1;
396            if (fieldsIndex < fieldsLength) {
397                nextFieldDeclaration = fields[fieldsIndex];
398                if (nextFieldDeclaration.declarationSourceStart < position) {
399                    position = nextFieldDeclaration.declarationSourceStart;
400                    nextDeclarationType = 0// FIELD
401                }
402            }
403            if (methodsIndex < methodsLength) {
404                nextMethodDeclaration = methods[methodsIndex];
405                if (nextMethodDeclaration.declarationSourceStart < position) {
406                    position = nextMethodDeclaration.declarationSourceStart;
407                    nextDeclarationType = 1// METHOD
408                }
409            }
410            if (membersIndex < membersLength) {
411                nextMemberDeclaration = members[membersIndex];
412                if (nextMemberDeclaration.declarationSourceStart < position) {
413                    position = nextMemberDeclaration.declarationSourceStart;
414                    nextDeclarationType = 2// MEMBER
415                }
416            }
417            switch (nextDeclarationType) {
418                case 0 :
419                    if (nextFieldDeclaration.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) {
420                        anonymousClassDeclaration.bodyDeclarations().add(convert(nextFieldDeclaration));
421                    } else {
422                        checkAndAddMultipleFieldDeclaration(fieldsfieldsIndexanonymousClassDeclaration.bodyDeclarations());
423                    }
424                    fieldsIndex++;
425                    break;
426                case 1 :
427                    methodsIndex++;
428                    if (!nextMethodDeclaration.isDefaultConstructor() && !nextMethodDeclaration.isClinit()) {
429                        anonymousClassDeclaration.bodyDeclarations().add(convert(falsenextMethodDeclaration));
430                    }
431                    break;
432                case 2 :
433                    membersIndex++;
434                    ASTNode node = convert(nextMemberDeclaration);
435                    if (node == null) {
436                        anonymousClassDeclaration.setFlags(anonymousClassDeclaration.getFlags() | ASTNode.MALFORMED);
437                    } else {
438                        anonymousClassDeclaration.bodyDeclarations().add(node);
439                    }
440            }
441        }
442    }
443
444    private void checkAndSetMalformed(ASTNode spannedNodeASTNode spanningNode) {
445        if ((spannedNode.getFlags() & ASTNode.MALFORMED) != 0) {
446            spanningNode.setFlags(spanningNode.getFlags() | ASTNode.MALFORMED);
447        }
448    }
449    /**
450     * Internal access method to SwitchCase#setExpression() for avoiding deprecated warnings
451     * @param switchCase
452     * @param exp
453     * @deprecated
454     */
455    private static void internalSetExpression(SwitchCase switchCaseExpression exp) {
456        switchCase.setExpression(exp);
457    }
458    /**
459     * Internal access method to SingleVariableDeclaration#setExtraDimensions() for avoiding deprecated warnings
460     *
461     * @param node
462     * @param dimensions
463     * @deprecated
464     */
465    private static void internalSetExtraDimensions(SingleVariableDeclaration nodeint dimensions) {
466        node.setExtraDimensions(dimensions);
467    }
468    /**
469     * Internal access method to VariableDeclarationFragment#setExtraDimensions() for avoiding deprecated warnings
470     *
471     * @param node
472     * @param dimensions
473     * @deprecated
474     */
475    private static void internalSetExtraDimensions(VariableDeclarationFragment nodeint dimensions) {
476        node.setExtraDimensions(dimensions);
477    }
478    /**
479     * Internal access method to MethodDeclaration#setExtraDimension() for avoiding deprecated warnings
480     *
481     * @param node
482     * @param dimensions
483     * @deprecated
484     */
485    private static void internalSetExtraDimensions(MethodDeclaration nodeint dimensions) {
486        node.setExtraDimensions(dimensions);
487    }
488    /**
489     * Internal access method to MethodDeclaration#thrownExceptions() for avoiding deprecated warnings
490     *
491     * @param node
492     * @deprecated
493     */
494    private static List internalThownExceptions(MethodDeclaration node) {
495        return node.thrownExceptions();
496    }
497
498    /**
499     * @param compilationUnit
500     * @param comments
501     */
502    void buildCommentsTable(CompilationUnit compilationUnitint[][] comments) {
503        // Build comment table
504        this.commentsTable = new Comment[comments.length];
505        int nbr = 0;
506        for (int i = 0i < comments.lengthi++) {
507            Comment comment = createComment(comments[i]);
508            if (comment != null) {
509                comment.setAlternateRoot(compilationUnit);
510                this.commentsTable[nbr++] = comment;
511            }
512        }
513        // Resize table if  necessary
514        if (nbr<comments.length) {
515            Comment[] newCommentsTable = new Comment[nbr];
516            System.arraycopy(this.commentsTable0newCommentsTable0nbr);
517            this.commentsTable = newCommentsTable;
518        }
519        compilationUnit.setCommentTable(this.commentsTable);
520    }
521
522    protected void checkAndAddMultipleFieldDeclaration(org.eclipse.jdt.internal.compiler.ast.FieldDeclaration[] fieldsint indexList bodyDeclarations) {
523        if (fields[index] instanceof org.eclipse.jdt.internal.compiler.ast.Initializer) {
524            org.eclipse.jdt.internal.compiler.ast.Initializer oldInitializer = (org.eclipse.jdt.internal.compiler.ast.Initializerfields[index];
525            Initializer initializer = new Initializer(this.ast);
526            initializer.setBody(convert(oldInitializer.block));
527            setModifiers(initializeroldInitializer);
528            initializer.setSourceRange(oldInitializer.declarationSourceStartoldInitializer.sourceEnd - oldInitializer.declarationSourceStart + 1);
529            // The javadoc comment is now got from list store in compilation unit declaration
530            convert(oldInitializer.javadocinitializer);
531            bodyDeclarations.add(initializer);
532            return;
533        }
534        if (index > 0 && fields[index - 1].declarationSourceStart == fields[index].declarationSourceStart) {
535            // we have a multiple field declaration
536            // We retrieve the existing fieldDeclaration to add the new VariableDeclarationFragment
537            FieldDeclaration fieldDeclaration = (FieldDeclarationbodyDeclarations.get(bodyDeclarations.size() - 1);
538            fieldDeclaration.fragments().add(convertToVariableDeclarationFragment(fields[index]));
539        } else {
540            // we can create a new FieldDeclaration
541            bodyDeclarations.add(convertToFieldDeclaration(fields[index]));
542        }
543    }
544
545    protected void checkAndAddMultipleLocalDeclaration(org.eclipse.jdt.internal.compiler.ast.Statement[] stmtsint indexList blockStatements) {
546        if (index > 0
547                && stmts[index - 1] instanceof org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) {
548            org.eclipse.jdt.internal.compiler.ast.LocalDeclaration local1 = (org.eclipse.jdt.internal.compiler.ast.LocalDeclarationstmts[index - 1];
549            org.eclipse.jdt.internal.compiler.ast.LocalDeclaration local2 = (org.eclipse.jdt.internal.compiler.ast.LocalDeclarationstmts[index];
550            if (local1.declarationSourceStart == local2.declarationSourceStart) {
551                // we have a multiple local declarations
552                // We retrieve the existing VariableDeclarationStatement to add the new VariableDeclarationFragment
553                VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatementblockStatements.get(blockStatements.size() - 1);
554                variableDeclarationStatement.fragments().add(convertToVariableDeclarationFragment((org.eclipse.jdt.internal.compiler.ast.LocalDeclaration)stmts[index]));
555            } else {
556                // we can create a new FieldDeclaration
557                blockStatements.add(convertToVariableDeclarationStatement((org.eclipse.jdt.internal.compiler.ast.LocalDeclaration)stmts[index]));
558            }
559        } else {
560            // we can create a new FieldDeclaration
561            blockStatements.add(convertToVariableDeclarationStatement((org.eclipse.jdt.internal.compiler.ast.LocalDeclaration)stmts[index]));
562        }
563    }
564
565    protected void checkCanceled() {
566        if (this.monitor != null && this.monitor.isCanceled())
567            throw new OperationCanceledException();
568    }
569
570    private int checkLength(int startint end) {
571        int len = end - start + 1;
572        return len > 0 ? len : 0;
573    }
574    protected void completeRecord(ArrayType arrayTypeorg.eclipse.jdt.internal.compiler.ast.ASTNode astNode) {
575        ArrayType array = arrayType;
576        this.recordNodes(arrayTypeastNode);
577        if (this.ast.apiLevel() >= AST.JLS8_INTERNAL) {
578            this.recordNodes(arrayType.getElementType(), astNode);
579            return;
580        }
581        int dimensions = array.getDimensions();
582        for (int i = 0i < dimensionsi++) {
583            Type componentType = componentType(array);
584            this.recordNodes(componentTypeastNode);
585            if (componentType.isArrayType()) {
586                array = (ArrayTypecomponentType;
587            }
588        }
589    }
590
591    /**
592     * @deprecated
593     */
594    private Type componentType(ArrayType array) {
595        return array.getComponentType();
596    }
597
598    public ASTNode convert(boolean isInterfaceorg.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration methodDeclaration) {
599        checkCanceled();
600        if (methodDeclaration instanceof org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration) {
601            return convert((org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclarationmethodDeclaration);
602        }
603        MethodDeclaration methodDecl = new MethodDeclaration(this.ast);
604        ASTNode oldReferenceContext = this.referenceContext;
605        this.referenceContext = methodDecl;
606        setModifiers(methodDeclmethodDeclaration);
607        boolean isConstructor = methodDeclaration.isConstructor();
608        methodDecl.setConstructor(isConstructor);
609        final SimpleName methodName = new SimpleName(this.ast);
610        methodName.internalSetIdentifier(new String(methodDeclaration.selector));
611        int start = methodDeclaration.sourceStart;
612        int end;
613        if (DOMASTUtil.isRecordDeclarationSupported(this.ast) && methodDeclaration instanceof CompactConstructorDeclaration) {
614            methodDecl.setCompactConstructor(true);
615            end = start + methodDeclaration.selector.length -1;
616        }else {
617             end = retrieveIdentifierEndPosition(startmethodDeclaration.sourceEnd);
618            if (end < start)
619                end = start + methodDeclaration.selector.length;// naive recovery with method name
620        }
621        methodName.setSourceRange(startend - start + 1);
622        methodDecl.setName(methodName);
623        org.eclipse.jdt.internal.compiler.ast.TypeReference[] thrownExceptions = methodDeclaration.thrownExceptions;
624        int methodHeaderEnd = methodDeclaration.sourceEnd;
625        int thrownExceptionsLength = thrownExceptions == null ? 0 : thrownExceptions.length;
626        if (thrownExceptionsLength > 0) {
627            if (this.ast.apiLevel() < AST.JLS8_INTERNAL) {
628                Name thrownException;
629                int i = 0;
630                do {
631                    TypeReference typeRef = thrownExceptions[i++];
632                    thrownException = convert(typeRef);
633                    if (typeRef.annotations != null && typeRef.annotations.length > 0) {
634                        thrownException.setFlags(thrownException.getFlags() | ASTNode.MALFORMED);
635                    }
636                    internalThownExceptions(methodDecl).add(thrownException);
637                } while (i < thrownExceptionsLength);
638                methodHeaderEnd = thrownException.getStartPosition() + thrownException.getLength();
639            } else {
640                Type thrownExceptionType;
641                int i = 0;
642                do {
643                    thrownExceptionType = convertType(thrownExceptions[i++]);
644                    methodDecl.thrownExceptionTypes().add(thrownExceptionType);
645                } while (i < thrownExceptionsLength);
646                methodHeaderEnd = thrownExceptionType.getStartPosition() + thrownExceptionType.getLength();
647            }
648        }
649
650        if (methodDeclaration.receiver != null) {
651            if(this.ast.apiLevel >= AST.JLS8_INTERNAL) {
652                convertAndSetReceiver(methodDeclarationmethodDecl);
653            } else {
654                methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED);
655            }
656        }
657        org.eclipse.jdt.internal.compiler.ast.Argument[] parameters = methodDeclaration.arguments;
658        int parametersLength = parameters == null ? 0 : parameters.length;
659        if (parametersLength > 0) {
660            if (!(DOMASTUtil.isRecordDeclarationSupported(this.ast) && methodDecl.isCompactConstructor())) {
661                SingleVariableDeclaration parameter;
662                int i = 0;
663                do {
664                    parameter = convert(parameters[i++]);
665                    methodDecl.parameters().add(parameter);
666                } while (i < parametersLength);
667                if (thrownExceptionsLength == 0) {
668                    methodHeaderEnd = parameter.getStartPosition() + parameter.getLength();
669                }
670            }
671        }
672        org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall explicitConstructorCall = null;
673        if (isConstructor) {
674            if (isInterface) {
675                // interface cannot have a constructor
676                methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED);
677            }
678            org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration constructorDeclaration = (org.eclipse.jdt.internal.compiler.ast.ConstructorDeclarationmethodDeclaration;
679            explicitConstructorCall = constructorDeclaration.constructorCall;
680            switch(this.ast.apiLevel) {
681                case AST.JLS2_INTERNAL :
682                    // set the return type to VOID
683                    PrimitiveType returnType = new PrimitiveType(this.ast);
684                    returnType.setPrimitiveTypeCode(PrimitiveType.VOID);
685                    returnType.setSourceRange(methodDeclaration.sourceStart0);
686                    methodDecl.internalSetReturnType(returnType);
687                    break;
688                default :
689                    methodDecl.setReturnType2(null);
690            }
691        } else if (methodDeclaration instanceof org.eclipse.jdt.internal.compiler.ast.MethodDeclaration) {
692            org.eclipse.jdt.internal.compiler.ast.MethodDeclaration method = (org.eclipse.jdt.internal.compiler.ast.MethodDeclarationmethodDeclaration;
693            org.eclipse.jdt.internal.compiler.ast.TypeReference typeReference = method.returnType;
694            if (typeReference != null) {
695                Type returnType = convertType(typeReference);
696                // get the positions of the right parenthesis
697                int rightParenthesisPosition = retrieveEndOfRightParenthesisPosition(endmethod.bodyEnd);
698                int extraDimensions = typeReference.extraDimensions();
699                if (this.ast.apiLevel >= AST.JLS8_INTERNAL) {
700                    setExtraAnnotatedDimensions(rightParenthesisPositionmethod.bodyEndtypeReference,
701                                                methodDecl.extraDimensions(), extraDimensions);
702                } else {
703                    internalSetExtraDimensions(methodDeclextraDimensions);
704                }
705                setTypeForMethodDeclaration(methodDeclreturnTypeextraDimensions);
706            } else {
707                // no return type for a method that is not a constructor
708                methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED);
709                switch(this.ast.apiLevel) {
710                    case AST.JLS2_INTERNAL :
711                        break;
712                    default :
713                        methodDecl.setReturnType2(null);
714                }
715            }
716        }
717        int declarationSourceStart = methodDeclaration.declarationSourceStart;
718        int bodyEnd = methodDeclaration.bodyEnd;
719        methodDecl.setSourceRange(declarationSourceStartcheckLength(declarationSourceStartbodyEnd));
720        int declarationSourceEnd = methodDeclaration.declarationSourceEnd;
721        int rightBraceOrSemiColonPositionStart = bodyEnd == declarationSourceEnd ? bodyEnd : bodyEnd + 1;
722        int closingPosition = retrieveRightBraceOrSemiColonPosition(rightBraceOrSemiColonPositionStartdeclarationSourceEnd);
723        if (closingPosition != -1) {
724            int startPosition = methodDecl.getStartPosition();
725            methodDecl.setSourceRange(startPositionclosingPosition - startPosition + 1);
726
727            org.eclipse.jdt.internal.compiler.ast.Statement[] statements = methodDeclaration.statements;
728
729            start = retrieveStartBlockPosition(methodHeaderEndmethodDeclaration.bodyStart);
730            if (start == -1start = methodDeclaration.bodyStart// use recovery position for body start
731            end = retrieveRightBrace(methodDeclaration.bodyEnd + 1declarationSourceEnd);
732            Block block = null;
733            if (start != -1 && end != -1) {
734                /*
735                 * start or end can be equal to -1 if we have an interface's method.
736                 */
737                block = new Block(this.ast);
738                block.setSourceRange(startclosingPosition - start + 1);
739                methodDecl.setBody(block);
740            }
741            if (block != null && (statements != null || explicitConstructorCall != null)) {
742                if (explicitConstructorCall != null && explicitConstructorCall.accessMode != org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall.ImplicitSuper) {
743                    block.statements().add(convert(explicitConstructorCall));
744                }
745                int statementsLength = statements == null ? 0 : statements.length;
746                for (int i = 0i < statementsLengthi++) {
747                    org.eclipse.jdt.internal.compiler.ast.Statement astStatement = statements[i];
748                    if (astStatement instanceof org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) {
749                        checkAndAddMultipleLocalDeclaration(statementsiblock.statements());
750                    } else if ((astStatement.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.IsImplicit) == 0 ){ // Don't convert Implicit statements
751                        final Statement statement = convert(astStatement);
752                        if (statement != null) {
753                            block.statements().add(statement);
754                        }
755                    }
756                }
757            }
758            if (block != null) {
759                if ((methodDeclaration.modifiers & (ClassFileConstants.AccAbstract | ClassFileConstants.AccNative)) != 0
760                        || (isInterface && (this.ast.apiLevel < AST.JLS8_INTERNAL ||
761                            (methodDeclaration.modifiers & (ClassFileConstants.AccStatic | ExtraCompilerModifiers.AccDefaultMethod |
762                                    (this.ast.apiLevel > AST.JLS8_INTERNAL ? ClassFileConstants.AccPrivate : 0))) == 0))) {
763                    methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED);
764                }
765            }
766        } else {
767            // syntax error in this method declaration
768            methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED);
769            if (!methodDeclaration.isNative() && !methodDeclaration.isAbstract()) {
770                start = retrieveStartBlockPosition(methodHeaderEndbodyEnd);
771                if (start == -1start = methodDeclaration.bodyStart// use recovery position for body start
772                end = methodDeclaration.bodyEnd;
773                // try to get the best end position
774                CategorizedProblem[] problems = methodDeclaration.compilationResult().problems;
775                if (problems != null) {
776                    for (int i = 0max = methodDeclaration.compilationResult().problemCounti < maxi++) {
777                        CategorizedProblem currentProblem = problems[i];
778                        if (currentProblem.getSourceStart() == start && currentProblem.getID() == IProblem.ParsingErrorInsertToComplete) {
779                            end = currentProblem.getSourceEnd();
780                            break;
781                        }
782                    }
783                }
784                int startPosition = methodDecl.getStartPosition();
785                methodDecl.setSourceRange(startPositioncheckLength(startPositionend));
786                if (start != -1 && end != -1) {
787                    /*
788                     * start or end can be equal to -1 if we have an interface's method.
789                     */
790                    Block block = new Block(this.ast);
791                    block.setSourceRange(startcheckLength(startend));
792                    methodDecl.setBody(block);
793                }
794            }
795        }
796
797        org.eclipse.jdt.internal.compiler.ast.TypeParameter[] typeParameters = methodDeclaration.typeParameters();
798        if (typeParameters != null) {
799            switch(this.ast.apiLevel) {
800                case AST.JLS2_INTERNAL :
801                    methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED);
802                    break;
803                default :
804                    for (int i = 0max = typeParameters.lengthi < maxi++) {
805                        methodDecl.typeParameters().add(convert(typeParameters[i]));
806                    }
807            }
808        }
809
810        // The javadoc comment is now got from list store in compilation unit declaration
811        convert(methodDeclaration.javadocmethodDecl);
812        if (this.resolveBindings) {
813            recordNodes(methodDeclmethodDeclaration);
814            recordNodes(methodNamemethodDeclaration);
815            methodDecl.resolveBinding();
816        }
817        this.referenceContext = oldReferenceContext;
818        return methodDecl;
819    }
820
821    public ClassInstanceCreation convert(org.eclipse.jdt.internal.compiler.ast.AllocationExpression expression) {
822        ClassInstanceCreation classInstanceCreation = new ClassInstanceCreation(this.ast);
823        if (this.resolveBindings) {
824            recordNodes(classInstanceCreationexpression);
825        }
826        if (expression.typeArguments != null) {
827            switch(this.ast.apiLevel) {
828                case AST.JLS2_INTERNAL :
829                    classInstanceCreation.setFlags(classInstanceCreation.getFlags() | ASTNode.MALFORMED);
830                    break;
831                default :
832                    for (int i = 0max = expression.typeArguments.lengthi < maxi++) {
833                        classInstanceCreation.typeArguments().add(convertType(expression.typeArguments[i]));
834                    }
835            }
836        }
837        switch(this.ast.apiLevel) {
838            case AST.JLS2_INTERNAL :
839                classInstanceCreation.internalSetName(convert(expression.type));
840                break;
841            default :
842                classInstanceCreation.setType(convertType(expression.type));
843        }
844        classInstanceCreation.setSourceRange(expression.sourceStartexpression.sourceEnd - expression.sourceStart + 1);
845        org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = expression.arguments;
846        if (arguments != null) {
847            int length = arguments.length;
848            for (int i = 0i < lengthi++) {
849                classInstanceCreation.arguments().add(convert(arguments[i]));
850            }
851        }
852        return classInstanceCreation;
853    }
854
855    public Expression convert(org.eclipse.jdt.internal.compiler.ast.AND_AND_Expression expression) {
856        InfixExpression infixExpression = new InfixExpression(this.ast);
857        infixExpression.setOperator(InfixExpression.Operator.CONDITIONAL_AND);
858        if (this.resolveBindings) {
859            this.recordNodes(infixExpressionexpression);
860        }
861        final int expressionOperatorID = (expression.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT;
862        if (expression.left instanceof org.eclipse.jdt.internal.compiler.ast.BinaryExpression
863                && ((expression.left.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0)) {
864            // create an extended string literal equivalent => use the extended operands list
865            infixExpression.extendedOperands().add(convert(expression.right));
866            org.eclipse.jdt.internal.compiler.ast.Expression leftOperand = expression.left;
867            org.eclipse.jdt.internal.compiler.ast.Expression rightOperand = null;
868            do {
869                rightOperand = ((org.eclipse.jdt.internal.compiler.ast.BinaryExpressionleftOperand).right;
870                if ((((leftOperand.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT) != expressionOperatorID
871                            && ((leftOperand.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0))
872                     || ((rightOperand instanceof org.eclipse.jdt.internal.compiler.ast.BinaryExpression
873                             && ((rightOperand.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT) != expressionOperatorID)
874                            && ((rightOperand.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0))) {
875                     List extendedOperands = infixExpression.extendedOperands();
876                     InfixExpression temp = new InfixExpression(this.ast);
877                    if (this.resolveBindings) {
878                        this.recordNodes(tempexpression);
879                    }
880                     temp.setOperator(getOperatorFor(expressionOperatorID));
881                     Expression leftSide = convert(leftOperand);
882                    temp.setLeftOperand(leftSide);
883                    temp.setSourceRange(leftSide.getStartPosition(), leftSide.getLength());
884                    int size = extendedOperands.size();
885                     for (int i = 0i < size - 1i++) {
886                         Expression expr = temp;
887                         temp = new InfixExpression(this.ast);
888
889                        if (this.resolveBindings) {
890                            this.recordNodes(tempexpression);
891                        }
892                         temp.setLeftOperand(expr);
893                         temp.setOperator(getOperatorFor(expressionOperatorID));
894                        temp.setSourceRange(expr.getStartPosition(), expr.getLength());
895                     }
896                     infixExpression = temp;
897                     for (int i = 0i < sizei++) {
898                         Expression extendedOperand = (ExpressionextendedOperands.remove(size - 1 - i);
899                         temp.setRightOperand(extendedOperand);
900                         int startPosition = temp.getLeftOperand().getStartPosition();
901                         temp.setSourceRange(startPositionextendedOperand.getStartPosition() + extendedOperand.getLength() - startPosition);
902                         if (temp.getLeftOperand().getNodeType() == ASTNode.INFIX_EXPRESSION) {
903                             temp = (InfixExpressiontemp.getLeftOperand();
904                         }
905                     }
906                     setInfixSourcePositions(infixExpressionexpression.sourceStart);
907                    if (this.resolveBindings) {
908                        this.recordNodes(infixExpressionexpression);
909                    }
910                    return infixExpression;
911                }
912                infixExpression.extendedOperands().add(0convert(rightOperand));
913                leftOperand = ((org.eclipse.jdt.internal.compiler.ast.BinaryExpressionleftOperand).left;
914            } while (leftOperand instanceof org.eclipse.jdt.internal.compiler.ast.BinaryExpression && ((leftOperand.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0));
915            Expression leftExpression = convert(leftOperand);
916            infixExpression.setLeftOperand(leftExpression);
917            infixExpression.setRightOperand((Expression)infixExpression.extendedOperands().remove(0));
918             setInfixSourcePositions(infixExpressionexpression.sourceStart);
919            return infixExpression;
920        }
921        Expression leftExpression = convert(expression.left);
922        infixExpression.setLeftOperand(leftExpression);
923        infixExpression.setRightOperand(convert(expression.right));
924        infixExpression.setOperator(InfixExpression.Operator.CONDITIONAL_AND);
925         setInfixSourcePositions(infixExpressionexpression.sourceStart);
926        return infixExpression;
927    }
928
929    private AnnotationTypeDeclaration convertToAnnotationDeclaration(org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) {
930        checkCanceled();
931        if (this.scanner.sourceLevel < ClassFileConstants.JDK1_5) return null;
932        AnnotationTypeDeclaration typeDecl = this.ast.newAnnotationTypeDeclaration();
933        setModifiers(typeDecltypeDeclaration);
934        final SimpleName typeName = new SimpleName(this.ast);
935        typeName.internalSetIdentifier(new String(typeDeclaration.name));
936        typeName.setSourceRange(typeDeclaration.sourceStarttypeDeclaration.sourceEnd - typeDeclaration.sourceStart + 1);
937        typeDecl.setName(typeName);
938        typeDecl.setSourceRange(typeDeclaration.declarationSourceStarttypeDeclaration.bodyEnd - typeDeclaration.declarationSourceStart + 1);
939
940        buildBodyDeclarations(typeDeclarationtypeDeclfalse);
941        // The javadoc comment is now got from list store in compilation unit declaration
942        if (this.resolveBindings) {
943            recordNodes(typeDecltypeDeclaration);
944            recordNodes(typeNametypeDeclaration);
945            typeDecl.resolveBinding();
946        }
947        return typeDecl;
948    }
949
950    public ASTNode convert(org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration annotationTypeMemberDeclaration) {
951        checkCanceled();
952        if (this.ast.apiLevel == AST.JLS2_INTERNAL) {
953            return null;
954        }
955        AnnotationTypeMemberDeclaration annotationTypeMemberDeclaration2 = new AnnotationTypeMemberDeclaration(this.ast);
956        setModifiers(annotationTypeMemberDeclaration2annotationTypeMemberDeclaration);
957        final SimpleName methodName = new SimpleName(this.ast);
958        methodName.internalSetIdentifier(new String(annotationTypeMemberDeclaration.selector));
959        int start = annotationTypeMemberDeclaration.sourceStart;
960        int end = retrieveIdentifierEndPosition(startannotationTypeMemberDeclaration.sourceEnd);
961        methodName.setSourceRange(startend - start + 1);
962        annotationTypeMemberDeclaration2.setName(methodName);
963        org.eclipse.jdt.internal.compiler.ast.TypeReference typeReference = annotationTypeMemberDeclaration.returnType;
964        if (typeReference != null) {
965            Type returnType = convertType(typeReference);
966            setTypeForMethodDeclaration(annotationTypeMemberDeclaration2returnType0);
967        }
968        int declarationSourceStart = annotationTypeMemberDeclaration.declarationSourceStart;
969        int declarationSourceEnd = annotationTypeMemberDeclaration.bodyEnd;
970        annotationTypeMemberDeclaration2.setSourceRange(declarationSourceStartdeclarationSourceEnd - declarationSourceStart + 1);
971        // The javadoc comment is now got from list store in compilation unit declaration
972        convert(annotationTypeMemberDeclaration.javadocannotationTypeMemberDeclaration2);
973        org.eclipse.jdt.internal.compiler.ast.Expression memberValue = annotationTypeMemberDeclaration.defaultValue;
974        if (memberValue != null) {
975            annotationTypeMemberDeclaration2.setDefault(convert(memberValue));
976        }
977        if (this.resolveBindings) {
978            recordNodes(annotationTypeMemberDeclaration2annotationTypeMemberDeclaration);
979            recordNodes(methodNameannotationTypeMemberDeclaration);
980            annotationTypeMemberDeclaration2.resolveBinding();
981        }
982        return annotationTypeMemberDeclaration2;
983    }
984
985    private void convertAndSetReceiver(AbstractMethodDeclaration methodMethodDeclaration methodDecl) {
986        Receiver receiver = method.receiver;
987        if (receiver.qualifyingName != null) {
988            final SimpleName name = new SimpleName(this.ast);
989            name.internalSetIdentifier(new String(receiver.qualifyingName.getName()[0]));
990            int start = receiver.qualifyingName.sourceStart;
991            int nameEnd = receiver.qualifyingName.sourceEnd;
992            name.setSourceRange(startnameEnd - start + 1);
993            methodDecl.setReceiverQualifier(name);
994            if (this.resolveBindings) {
995                recordNodes(namereceiver);
996            }
997        }
998        Type type = convertType(receiver.type);
999        methodDecl.setReceiverType(type);
1000        if (receiver.modifiers != 0) {
1001            methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED);
1002        }
1003        if (this.resolveBindings) {
1004            recordNodes(typereceiver);
1005            type.resolveBinding();
1006        }
1007    }
1008
1009    public SingleVariableDeclaration convert(org.eclipse.jdt.internal.compiler.ast.Argument argument) {
1010        SingleVariableDeclaration variableDecl = new SingleVariableDeclaration(this.ast);
1011        setModifiers(variableDeclargument);
1012        final SimpleName name = new SimpleName(this.ast);
1013        name.internalSetIdentifier(new String(argument.name));
1014        if (argument instanceof Receiver) {
1015            name.setFlags(name.getFlags() | ASTNode.MALFORMED);
1016        }
1017        int start = argument.sourceStart;
1018        int nameEnd = argument.sourceEnd;
1019        name.setSourceRange(startnameEnd - start + 1);
1020        variableDecl.setName(name);
1021        final int typeSourceEnd = argument.type.sourceEnd;
1022        TypeReference typeReference = argument.type;
1023        final int extraDimensions = typeReference.extraDimensions();
1024        if (this.ast.apiLevel >= AST.JLS8_INTERNAL) {
1025            setExtraAnnotatedDimensions(nameEnd + 1typeSourceEndtypeReference,
1026                                        variableDecl.extraDimensions(), extraDimensions);
1027        } else {
1028            internalSetExtraDimensions(variableDeclextraDimensions);
1029        }
1030        final boolean isVarArgs = argument.isVarArgs();
1031        if (isVarArgs && extraDimensions == 0) {
1032            // remove the ellipsis from the type source end
1033            argument.type.sourceEnd = retrieveEllipsisStartPosition(argument.type.sourceStarttypeSourceEnd);
1034        }
1035        Type type = convertType(argument.type);
1036        int typeEnd = type.getStartPosition() + type.getLength() - 1;
1037        int rightEnd = Math.max(typeEndargument.declarationSourceEnd);
1038        /*
1039         * There is extra work to do to set the proper type positions
1040         * See PR http://bugs.eclipse.org/bugs/show_bug.cgi?id=23284
1041         */
1042        if (isVarArgs) {
1043            Dimension lastDimension = null;
1044            if (this.ast.apiLevel() >= AST.JLS8_INTERNAL) {
1045                if (type.isArrayType()) { // should always be true
1046                    List dimensions = ((ArrayTypetype).dimensions();
1047                    if (!dimensions.isEmpty()) {
1048                        lastDimension = (Dimensiondimensions.get(dimensions.size() - 1);
1049                    }
1050                }
1051            }
1052            setTypeForSingleVariableDeclaration(variableDecltypeextraDimensions + 1);
1053            // https://bugs.eclipse.org/bugs/show_bug.cgi?id=391898
1054            if (this.ast.apiLevel() >= AST.JLS8_INTERNAL) {
1055                if (lastDimension != null) { // should always be true
1056                    List annotations = lastDimension.annotations();
1057                    Iterator iter = annotations.iterator();
1058                    while (iter.hasNext()) {
1059                        Annotation annotation = (Annotationiter.next();
1060                        annotation.setParent(nullnull);
1061                        variableDecl.varargsAnnotations().add(annotation);
1062                    }
1063                }
1064            }
1065            if (extraDimensions != 0) {
1066                variableDecl.setFlags(variableDecl.getFlags() | ASTNode.MALFORMED);
1067            }
1068        } else {
1069            setTypeForSingleVariableDeclaration(variableDecltypeextraDimensions);
1070        }
1071        variableDecl.setSourceRange(argument.declarationSourceStartrightEnd - argument.declarationSourceStart + 1);
1072
1073        if (isVarArgs) {
1074            switch(this.ast.apiLevel) {
1075                case AST.JLS2_INTERNAL :
1076                    variableDecl.setFlags(variableDecl.getFlags() | ASTNode.MALFORMED);
1077                    break;
1078                default :
1079                    variableDecl.setVarargs(true);
1080            }
1081        }
1082        if (this.resolveBindings) {
1083            recordNodes(nameargument);
1084            recordNodes(variableDeclargument);
1085            variableDecl.resolveBinding();
1086        }
1087        return variableDecl;
1088    }
1089
1090
1091    public Annotation convert(org.eclipse.jdt.internal.compiler.ast.Annotation annotation) {
1092        if (annotation instanceof org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation) {
1093            return convert((org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotationannotation);
1094        } else if (annotation instanceof org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation) {
1095            return convert((org.eclipse.jdt.internal.compiler.ast.MarkerAnnotationannotation);
1096        } else {
1097            return convert((org.eclipse.jdt.internal.compiler.ast.NormalAnnotationannotation);
1098        }
1099    }
1100
1101    public ArrayCreation convert(org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression expression) {
1102        ArrayCreation arrayCreation = new ArrayCreation(this.ast);
1103        if (this.resolveBindings) {
1104            recordNodes(arrayCreationexpression);
1105        }
1106        arrayCreation.setSourceRange(expression.sourceStartexpression.sourceEnd - expression.sourceStart + 1);
1107        org.eclipse.jdt.internal.compiler.ast.Expression[] dimensions = expression.dimensions;
1108
1109        int dimensionsLength = dimensions.length;
1110        for (int i = 0i < dimensionsLengthi++) {
1111            if (dimensions[i] != null) {
1112                Expression dimension = convert(dimensions[i]);
1113                if (this.resolveBindings) {
1114                    recordNodes(dimensiondimensions[i]);
1115                }
1116                arrayCreation.dimensions().add(dimension);
1117            }
1118        }
1119        Type type = convertType(expression.type);
1120        if (this.resolveBindings) {
1121            recordNodes(typeexpression.type);
1122        }
1123        ArrayType arrayType = null;
1124        if (type.isArrayType()) {
1125            arrayType = (ArrayTypetype;
1126            if (expression.annotationsOnDimensions != null) {
1127                if (this.ast.apiLevel() < AST.JLS8_INTERNAL) {
1128                    arrayType.setFlags(arrayType.getFlags() | ASTNode.MALFORMED);
1129                } else {
1130                    setTypeAnnotationsAndSourceRangeOnArray(arrayTypeexpression.annotationsOnDimensions);
1131                }
1132            }
1133        } else {
1134            arrayType = convertToArray(typetype.getStartPosition(), -1dimensionsLengthexpression.annotationsOnDimensions);
1135        }
1136        arrayCreation.setType(arrayType);
1137        if (this.resolveBindings) {
1138            completeRecord(arrayTypeexpression);
1139        }
1140        if (expression.initializer != null) {
1141            arrayCreation.setInitializer(convert(expression.initializer));
1142        }
1143        return arrayCreation;
1144    }
1145
1146    public ArrayInitializer convert(org.eclipse.jdt.internal.compiler.ast.ArrayInitializer expression) {
1147        ArrayInitializer arrayInitializer = new ArrayInitializer(this.ast);
1148        if (this.resolveBindings) {
1149            recordNodes(arrayInitializerexpression);
1150        }
1151        arrayInitializer.setSourceRange(expression.sourceStartexpression.sourceEnd - expression.sourceStart + 1);
1152        org.eclipse.jdt.internal.compiler.ast.Expression[] expressions = expression.expressions;
1153        if (expressions != null) {
1154            int length = expressions.length;
1155            for (int i = 0i < lengthi++) {
1156                Expression expr = convert(expressions[i]);
1157                if (this.resolveBindings) {
1158                    recordNodes(exprexpressions[i]);
1159                }
1160                arrayInitializer.expressions().add(expr);
1161            }
1162        }
1163        return arrayInitializer;
1164    }
1165
1166    public ArrayAccess convert(org.eclipse.jdt.internal.compiler.ast.ArrayReference reference) {
1167        ArrayAccess arrayAccess = new ArrayAccess(this.ast);
1168        if (this.resolveBindings) {
1169            recordNodes(arrayAccessreference);
1170        }
1171        arrayAccess.setSourceRange(reference.sourceStartreference.sourceEnd - reference.sourceStart + 1);
1172        arrayAccess.setArray(convert(reference.receiver));
1173        arrayAccess.setIndex(convert(reference.position));
1174        return arrayAccess;
1175    }
1176
1177    public AssertStatement convert(org.eclipse.jdt.internal.compiler.ast.AssertStatement statement) {
1178        AssertStatement assertStatement = new AssertStatement(this.ast);
1179        final Expression assertExpression = convert(statement.assertExpression);
1180        Expression searchingNode = assertExpression;
1181        assertStatement.setExpression(assertExpression);
1182        org.eclipse.jdt.internal.compiler.ast.Expression exceptionArgument = statement.exceptionArgument;
1183        if (exceptionArgument != null) {
1184            final Expression exceptionMessage = convert(exceptionArgument);
1185            assertStatement.setMessage(exceptionMessage);
1186            searchingNode = exceptionMessage;
1187        }
1188        int start = statement.sourceStart;
1189        int sourceEnd = retrieveSemiColonPosition(searchingNode);
1190        if (sourceEnd == -1) {
1191            sourceEnd = searchingNode.getStartPosition() + searchingNode.getLength() - 1;
1192            assertStatement.setSourceRange(startsourceEnd - start + 1);
1193        } else {
1194            assertStatement.setSourceRange(startsourceEnd - start + 1);
1195        }
1196        return assertStatement;
1197    }
1198
1199    public Assignment convert(org.eclipse.jdt.internal.compiler.ast.Assignment expression) {
1200        Assignment assignment = new Assignment(this.ast);
1201        if (this.resolveBindings) {
1202            recordNodes(assignmentexpression);
1203        }
1204        Expression lhs = convert(expression.lhs);
1205        assignment.setLeftHandSide(lhs);
1206        assignment.setOperator(Assignment.Operator.ASSIGN);
1207        Expression rightHandSide = convert(expression.expression);
1208        assignment.setRightHandSide(rightHandSide);
1209        int start = lhs.getStartPosition();
1210        int end = rightHandSide.getStartPosition() + rightHandSide.getLength() - 1;
1211        assignment.setSourceRange(startend - start + 1);
1212        return assignment;
1213    }
1214
1215    public RecordDeclaration convertToRecord(org.eclipse.jdt.internal.compiler.ast.ASTNode[] nodes) {
1216        final RecordDeclaration typeDecl = new RecordDeclaration(this.ast);
1217        ASTNode oldReferenceContext = this.referenceContext;
1218        this.referenceContext = typeDecl;
1219        getAbstractTypeDeclarationDetails(nodestypeDecl);
1220        this.referenceContext = oldReferenceContext;
1221        return typeDecl;
1222    }
1223
1224    private void getAbstractTypeDeclarationDetails(org.eclipse.jdt.internal.compiler.ast.ASTNode[] nodes,
1225            final AbstractTypeDeclaration typeDecl) {
1226        int nodesLength = nodes.length;
1227        for (int i = 0i < nodesLengthi++) {
1228            org.eclipse.jdt.internal.compiler.ast.ASTNode node = nodes[i];
1229            if (node instanceof org.eclipse.jdt.internal.compiler.ast.Initializer) {
1230                org.eclipse.jdt.internal.compiler.ast.Initializer oldInitializer = (org.eclipse.jdt.internal.compiler.ast.Initializernode;
1231                Initializer initializer = new Initializer(this.ast);
1232                initializer.setBody(convert(oldInitializer.block));
1233                setModifiers(initializeroldInitializer);
1234                initializer.setSourceRange(oldInitializer.declarationSourceStartoldInitializer.sourceEnd - oldInitializer.declarationSourceStart + 1);
1235                convert(oldInitializer.javadocinitializer);
1236                typeDecl.bodyDeclarations().add(initializer);
1237            } else if (node instanceof org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) {
1238                org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration = (org.eclipse.jdt.internal.compiler.ast.FieldDeclarationnode;
1239                if (i > 0
1240                    && (nodes[i - 1] instanceof org.eclipse.jdt.internal.compiler.ast.FieldDeclaration)
1241                    && ((org.eclipse.jdt.internal.compiler.ast.FieldDeclaration)nodes[i - 1]).declarationSourceStart == fieldDeclaration.declarationSourceStart) {
1242                    // we have a multiple field declaration
1243                    // We retrieve the existing fieldDeclaration to add the new VariableDeclarationFragment
1244                    FieldDeclaration currentFieldDeclaration = (FieldDeclarationtypeDecl.bodyDeclarations().get(typeDecl.bodyDeclarations().size() - 1);
1245                    currentFieldDeclaration.fragments().add(convertToVariableDeclarationFragment(fieldDeclaration));
1246                } else {
1247                    // we can create a new FieldDeclaration
1248                    typeDecl.bodyDeclarations().add(convertToFieldDeclaration(fieldDeclaration));
1249                }
1250            } else if(node instanceof org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration) {
1251                AbstractMethodDeclaration nextMethodDeclaration = (AbstractMethodDeclarationnode;
1252                if (!nextMethodDeclaration.isDefaultConstructor() && !nextMethodDeclaration.isClinit()) {
1253                    typeDecl.bodyDeclarations().add(convert(falsenextMethodDeclaration));
1254                }
1255            } else if(node instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) {
1256                org.eclipse.jdt.internal.compiler.ast.TypeDeclaration nextMemberDeclaration = (org.eclipse.jdt.internal.compiler.ast.TypeDeclarationnode;
1257                ASTNode nextMemberDeclarationNode = convert(nextMemberDeclaration);
1258                if (nextMemberDeclarationNode == null) {
1259                    typeDecl.setFlags(typeDecl.getFlags() | ASTNode.MALFORMED);
1260                } else {
1261                    typeDecl.bodyDeclarations().add(nextMemberDeclarationNode);
1262                }
1263            }
1264        }
1265    }
1266    /*
1267     * Internal use only
1268     * Used to convert class body declarations
1269     */
1270    public TypeDeclaration convert(org.eclipse.jdt.internal.compiler.ast.ASTNode[] nodes) {
1271        final TypeDeclaration typeDecl = new TypeDeclaration(this.ast);
1272        ASTNode oldReferenceContext = this.referenceContext;
1273        this.referenceContext = typeDecl;
1274        typeDecl.setInterface(false);
1275        getAbstractTypeDeclarationDetails(nodestypeDecl);
1276        this.referenceContext = oldReferenceContext;
1277        return typeDecl;
1278    }
1279
1280    public Expression convert(org.eclipse.jdt.internal.compiler.ast.BinaryExpression expression) {
1281        InfixExpression infixExpression = new InfixExpression(this.ast);
1282        if (this.resolveBindings) {
1283            this.recordNodes(infixExpressionexpression);
1284        }
1285
1286        int expressionOperatorID = (expression.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT;
1287        infixExpression.setOperator(getOperatorFor(expressionOperatorID));
1288
1289        if (expression.left instanceof org.eclipse.jdt.internal.compiler.ast.BinaryExpression
1290                && ((expression.left.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0)) {
1291            // create an extended string literal equivalent => use the extended operands list
1292            infixExpression.extendedOperands().add(convert(expression.right));
1293            org.eclipse.jdt.internal.compiler.ast.Expression leftOperand = expression.left;
1294            org.eclipse.jdt.internal.compiler.ast.Expression rightOperand = null;
1295            do {
1296                rightOperand = ((org.eclipse.jdt.internal.compiler.ast.BinaryExpressionleftOperand).right;
1297                if ((((leftOperand.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT) != expressionOperatorID
1298                            && ((leftOperand.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0))
1299                     || ((rightOperand instanceof org.eclipse.jdt.internal.compiler.ast.BinaryExpression
1300                             && ((rightOperand.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT) != expressionOperatorID)
1301                            && ((rightOperand.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0))) {
1302                     List extendedOperands = infixExpression.extendedOperands();
1303                     InfixExpression temp = new InfixExpression(this.ast);
1304                    if (this.resolveBindings) {
1305                        this.recordNodes(tempexpression);
1306                    }
1307                     temp.setOperator(getOperatorFor(expressionOperatorID));
1308                     Expression leftSide = convert(leftOperand);
1309                    temp.setLeftOperand(leftSide);
1310                    temp.setSourceRange(leftSide.getStartPosition(), leftSide.getLength());
1311                    int size = extendedOperands.size();
1312                     for (int i = 0i < size - 1i++) {
1313                         Expression expr = temp;
1314                         temp = new InfixExpression(this.ast);
1315
1316                        if (this.resolveBindings) {
1317                            this.recordNodes(tempexpression);
1318                        }
1319                         temp.setLeftOperand(expr);
1320                         temp.setOperator(getOperatorFor(expressionOperatorID));
1321                        temp.setSourceRange(expr.getStartPosition(), expr.getLength());
1322                     }
1323                     infixExpression = temp;
1324                     for (int i = 0i < sizei++) {
1325                         Expression extendedOperand = (ExpressionextendedOperands.remove(size - 1 - i);
1326                         temp.setRightOperand(extendedOperand);
1327                         int startPosition = temp.getLeftOperand().getStartPosition();
1328                         temp.setSourceRange(startPositionextendedOperand.getStartPosition() + extendedOperand.getLength() - startPosition);
1329                         if (temp.getLeftOperand().getNodeType() == ASTNode.INFIX_EXPRESSION) {
1330                             temp = (InfixExpressiontemp.getLeftOperand();
1331                         }
1332                     }
1333                    setInfixSourcePositions(infixExpressioninfixExpression.getLeftOperand().getStartPosition());
1334                    if (this.resolveBindings) {
1335                        this.recordNodes(infixExpressionexpression);
1336                    }
1337                    return infixExpression;
1338                }
1339                infixExpression.extendedOperands().add(0convert(rightOperand));
1340                leftOperand = ((org.eclipse.jdt.internal.compiler.ast.BinaryExpressionleftOperand).left;
1341            } while (leftOperand instanceof org.eclipse.jdt.internal.compiler.ast.BinaryExpression && ((leftOperand.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0));
1342            Expression leftExpression = convert(leftOperand);
1343            infixExpression.setLeftOperand(leftExpression);
1344            infixExpression.setRightOperand((Expression)infixExpression.extendedOperands().remove(0));
1345            int startPosition = leftExpression.getStartPosition();
1346            setInfixSourcePositions(infixExpressionstartPosition);
1347            return infixExpression;
1348        } else if (expression.left instanceof StringLiteralConcatenation
1349                && ((expression.left.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0)
1350                && (OperatorIds.PLUS == expressionOperatorID)) {
1351            StringLiteralConcatenation literal = (StringLiteralConcatenationexpression.left;
1352            final org.eclipse.jdt.internal.compiler.ast.Expression[] stringLiterals = literal.literals;
1353            infixExpression.setLeftOperand(convert(stringLiterals[0]));
1354            infixExpression.setRightOperand(convert(stringLiterals[1]));
1355            for (int i = 2i < literal.counteri++) {
1356                infixExpression.extendedOperands().add(convert(stringLiterals[i]));
1357            }
1358            infixExpression.extendedOperands().add(convert(expression.right));
1359            int startPosition = literal.sourceStart;
1360            setInfixSourcePositions(infixExpressionstartPosition);
1361            return infixExpression;
1362        }
1363        Expression leftExpression = convert(expression.left);
1364        infixExpression.setLeftOperand(leftExpression);
1365        infixExpression.setRightOperand(convert(expression.right));
1366        int startPosition = leftExpression.getStartPosition();
1367        setInfixSourcePositions(infixExpressionstartPosition);
1368        return infixExpression;
1369    }
1370
1371    public Block convert(org.eclipse.jdt.internal.compiler.ast.Block statement) {
1372        Block block = new Block(this.ast);
1373        if (statement.sourceEnd > 0) {
1374            block.setSourceRange(statement.sourceStartstatement.sourceEnd - statement.sourceStart + 1);
1375        }
1376        org.eclipse.jdt.internal.compiler.ast.Statement[] statements = statement.statements;
1377        if (statements != null) {
1378            int statementsLength = statements.length;
1379            for (int i = 0i < statementsLengthi++) {
1380                if (statements[i] instanceof org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) {
1381                    checkAndAddMultipleLocalDeclaration(statementsiblock.statements());
1382                } else {
1383                    Statement statement2 = convert(statements[i]);
1384                    if (statement2 != null) {
1385                        block.statements().add(statement2);
1386                    }
1387                }
1388            }
1389        }
1390        return block;
1391    }
1392
1393    public BreakStatement convert(org.eclipse.jdt.internal.compiler.ast.BreakStatement statement)  {
1394        BreakStatement breakStatement = new BreakStatement(this.ast);
1395        breakStatement.setSourceRange(statement.sourceStartstatement.sourceEnd - statement.sourceStart + 1);
1396        if (statement.label != null) {
1397            final SimpleName name = new SimpleName(this.ast);
1398            name.internalSetIdentifier(new String(statement.label));
1399            retrieveIdentifierAndSetPositions(statement.sourceStartstatement.sourceEndname);
1400            breakStatement.setLabel(name);
1401        }
1402        return breakStatement;
1403    }
1404
1405    public SwitchCase convert(org.eclipse.jdt.internal.compiler.ast.CaseStatement statement) {
1406        SwitchCase switchCase = new SwitchCase(this.ast);
1407        if (this.ast.apiLevel >= AST.JLS14_INTERNAL) {
1408            org.eclipse.jdt.internal.compiler.ast.Expression[] expressions = statement.constantExpressions;
1409            if (expressions == null || expressions.length == 0) {
1410                switchCase.expressions().clear();
1411            } else if (expressions.length == 1 && expressions[0] instanceof org.eclipse.jdt.internal.compiler.ast.FakeDefaultLiteral) {
1412                switchCase.expressions().add(convert((org.eclipse.jdt.internal.compiler.ast.FakeDefaultLiteral)expressions[0]));
1413            } else {
1414                for (org.eclipse.jdt.internal.compiler.ast.Expression expression : expressions) {
1415                    switchCase.expressions().add(convert(expression));
1416                }
1417            }
1418        } else {
1419            org.eclipse.jdt.internal.compiler.ast.Expression[] constantExpressions = statement.constantExpressions;
1420            org.eclipse.jdt.internal.compiler.ast.Expression constantExpression =
1421                    constantExpressions != null && constantExpressions.length > 0 ? constantExpressions[0] : null;
1422            if (constantExpression == null) {
1423                internalSetExpression(switchCasenull);
1424            } else {
1425                internalSetExpression(switchCaseconvert(constantExpression));
1426            }
1427        }
1428        if (this.ast.apiLevel >= AST.JLS14_INTERNAL) {
1429            switchCase.setSwitchLabeledRule(statement.isExpr);
1430        }
1431        switchCase.setSourceRange(statement.sourceStartstatement.sourceEnd - statement.sourceStart + 1);
1432        if (statement.isExpr) {
1433            retrieveArrowPosition(switchCase);
1434        } else {
1435            retrieveColonPosition(switchCase);
1436        }
1437        return switchCase;
1438    }
1439
1440    public Expression convert(org.eclipse.jdt.internal.compiler.ast.FakeDefaultLiteral fakeDefaultLiteral) {
1441        CaseDefaultExpression caseDefaultExpression = new CaseDefaultExpression(this.ast);
1442        caseDefaultExpression.setSourceRange(fakeDefaultLiteral.sourceStartfakeDefaultLiteral.sourceEnd - fakeDefaultLiteral.sourceStart + 1);
1443        return caseDefaultExpression;
1444    }
1445
1446    public CastExpression convert(org.eclipse.jdt.internal.compiler.ast.CastExpression expression) {
1447        CastExpression castExpression = new CastExpression(this.ast);
1448        castExpression.setSourceRange(expression.sourceStartexpression.sourceEnd - expression.sourceStart + 1);
1449        TypeReference type = expression.type;
1450        trimWhiteSpacesAndComments(type);
1451        castExpression.setType(convertType(type));
1452        castExpression.setExpression(convert(expression.expression));
1453        if (this.resolveBindings) {
1454            recordNodes(castExpressionexpression);
1455        }
1456        return castExpression;
1457    }
1458
1459    public CharacterLiteral convert(org.eclipse.jdt.internal.compiler.ast.CharLiteral expression) {
1460        int length = expression.sourceEnd - expression.sourceStart + 1;
1461        int sourceStart = expression.sourceStart;
1462        CharacterLiteral literal = new CharacterLiteral(this.ast);
1463        if (this.resolveBindings) {
1464            this.recordNodes(literalexpression);
1465        }
1466        literal.internalSetEscapedValue(new String(this.compilationUnitSourcesourceStartlength));
1467        literal.setSourceRange(sourceStartlength);
1468        removeLeadingAndTrailingCommentsFromLiteral(literal);
1469        return literal;
1470    }
1471    public Expression convert(org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess expression) {
1472        TypeLiteral typeLiteral = new TypeLiteral(this.ast);
1473        if (this.resolveBindings) {
1474            this.recordNodes(typeLiteralexpression);
1475        }
1476        typeLiteral.setSourceRange(expression.sourceStartexpression.sourceEnd - expression.sourceStart + 1);
1477        typeLiteral.setType(convertType(expression.type));
1478        return typeLiteral;
1479    }
1480
1481    public CompilationUnit convert(org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration unitchar[] source) {
1482        try {
1483            if(unit.compilationResult.recoveryScannerData != null) {
1484                RecoveryScanner recoveryScanner = new RecoveryScanner(this.scannerunit.compilationResult.recoveryScannerData.removeUnused());
1485                this.scanner = recoveryScanner;
1486                this.docParser.scanner = this.scanner;
1487            }
1488            this.compilationUnitSource = source;
1489            this.compilationUnitSourceLength = source.length;
1490            this.scanner.setSource(sourceunit.compilationResult);
1491            CompilationUnit compilationUnit = new CompilationUnit(this.ast);
1492            compilationUnit.setStatementsRecoveryData(unit.compilationResult.recoveryScannerData);
1493
1494            // Parse comments
1495            int[][] comments = unit.comments;
1496            if (comments != null) {
1497                buildCommentsTable(compilationUnitcomments);
1498            }
1499
1500            // handle the package declaration immediately
1501            // There is no node corresponding to the package declaration
1502            if (this.resolveBindings) {
1503                recordNodes(compilationUnitunit);
1504            }
1505            if (unit.currentPackage != null) {
1506                PackageDeclaration packageDeclaration = convertPackage(unit);
1507                compilationUnit.setPackage(packageDeclaration);
1508            }
1509            org.eclipse.jdt.internal.compiler.ast.ImportReference[] imports = unit.imports;
1510            if (imports != null) {
1511                int importLength = imports.length;
1512                for (int i = 0i < importLengthi++) {
1513                    compilationUnit.imports().add(convertImport(imports[i]));
1514                }
1515            }
1516
1517            org.eclipse.jdt.internal.compiler.ast.ModuleDeclaration mod = unit.moduleDeclaration;
1518            if (mod != null) {
1519                ASTNode declaration = convertToModuleDeclaration(mod);
1520                if (declaration == null) {
1521                    compilationUnit.setFlags(compilationUnit.getFlags() | ASTNode.MALFORMED);
1522                } else {
1523                    compilationUnit.setModule((ModuleDeclarationdeclaration);
1524                }
1525            } else {
1526                org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = unit.types;
1527                if (types != null) {
1528                    int typesLength = types.length;
1529                    for (int i = 0i < typesLengthi++) {
1530                        org.eclipse.jdt.internal.compiler.ast.TypeDeclaration declaration = types[i];
1531                        if (CharOperation.equals(declaration.nameTypeConstants.PACKAGE_INFO_NAME)) {
1532                            continue;
1533                        }
1534                        ASTNode type = convert(declaration);
1535                        if (type == null) {
1536                            compilationUnit.setFlags(compilationUnit.getFlags() | ASTNode.MALFORMED);
1537                        } else {
1538                            if (type instanceof ModuleDeclaration)
1539                                compilationUnit.setModule((ModuleDeclarationtype);
1540                            else
1541                                compilationUnit.types().add(type);
1542                        }
1543                    }
1544                }
1545            }
1546            compilationUnit.setSourceRange(unit.sourceStartunit.sourceEnd - unit.sourceStart  + 1);
1547
1548            int problemLength = unit.compilationResult.problemCount;
1549            if (problemLength != 0) {
1550                CategorizedProblem[] resizedProblems = null;
1551                final CategorizedProblem[] problems = unit.compilationResult.getProblems();
1552                final int realProblemLength=problems.length;
1553                if (realProblemLength == problemLength) {
1554                    resizedProblems = problems;
1555                } else {
1556                    System.arraycopy(problems0, (resizedProblems = new CategorizedProblem[realProblemLength]), 0realProblemLength);
1557                }
1558                ASTSyntaxErrorPropagator syntaxErrorPropagator = new ASTSyntaxErrorPropagator(resizedProblems);
1559                compilationUnit.accept(syntaxErrorPropagator);
1560                ASTRecoveryPropagator recoveryPropagator =
1561                    new ASTRecoveryPropagator(resizedProblemsunit.compilationResult.recoveryScannerData);
1562                compilationUnit.accept(recoveryPropagator);
1563                compilationUnit.setProblems(resizedProblems);
1564            }
1565            if (this.resolveBindings) {
1566                lookupForScopes();
1567            }
1568            compilationUnit.initCommentMapper(this.scanner);
1569            if (SourceRangeVerifier.DEBUG) {
1570                String bugs = new SourceRangeVerifier().process(compilationUnit);
1571                if (bugs != null) {
1572                    StringBuilder message = new StringBuilder("Bad AST node structure:");  //$NON-NLS-1$
1573                    String lineDelimiter = Util.findLineSeparator(source);
1574                    if (lineDelimiter == nulllineDelimiter = System.getProperty("line.separator");//$NON-NLS-1$
1575                    message.append(lineDelimiter);
1576                    message.append(bugs.replace("\n"lineDelimiter)); //$NON-NLS-1$
1577                    message.append(lineDelimiter);
1578                    message.append("----------------------------------- SOURCE BEGIN -------------------------------------"); //$NON-NLS-1$
1579                    message.append(lineDelimiter);
1580                    message.append(source);
1581                    message.append(lineDelimiter);
1582                    message.append("----------------------------------- SOURCE END -------------------------------------"); //$NON-NLS-1$
1583                    Util.log(new IllegalStateException("Bad AST node structure"), message.toString()); //$NON-NLS-1$
1584                    if (SourceRangeVerifier.DEBUG_THROW) {
1585                        throw new IllegalStateException(message.toString());
1586                    }
1587                }
1588            }
1589            return compilationUnit;
1590        } catch(IllegalArgumentException e) {
1591            StringBuilder message = new StringBuilder("Exception occurred during compilation unit conversion:");  //$NON-NLS-1$
1592            String lineDelimiter = Util.findLineSeparator(source);
1593            if (lineDelimiter == nulllineDelimiter = System.getProperty("line.separator");//$NON-NLS-1$
1594            message.append(lineDelimiter);
1595            message.append("----------------------------------- SOURCE BEGIN -------------------------------------"); //$NON-NLS-1$
1596            message.append(lineDelimiter);
1597            message.append(source);
1598            message.append(lineDelimiter);
1599            message.append("----------------------------------- SOURCE END -------------------------------------"); //$NON-NLS-1$
1600            Util.log(emessage.toString());
1601            throw e;
1602        }
1603    }
1604
1605    public SingleVariableDeclaration convert(org.eclipse.jdt.internal.compiler.ast.RecordComponent component) {
1606        SingleVariableDeclaration variableDecl = new SingleVariableDeclaration(this.ast);
1607        setModifiers(variableDeclcomponent);
1608        final SimpleName name = new SimpleName(this.ast);
1609        name.internalSetIdentifier(new String(component.name));
1610        int start = component.sourceStart;
1611        int nameEnd = component.sourceEnd;
1612        name.setSourceRange(startnameEnd - start + 1);
1613        variableDecl.setName(name);
1614        final int typeSourceEnd = component.type.sourceEnd;
1615        TypeReference typeReference = component.type;
1616        final int extraDimensions = typeReference.extraDimensions();
1617        if (this.ast.apiLevel >= AST.JLS8_INTERNAL) {
1618            setExtraAnnotatedDimensions(nameEnd + 1typeSourceEndtypeReference,
1619                                        variableDecl.extraDimensions(), extraDimensions);
1620        } else {
1621            internalSetExtraDimensions(variableDeclextraDimensions);
1622        }
1623        final boolean isVarArgs = component.isVarArgs();
1624        if (isVarArgs && extraDimensions == 0) {
1625            // remove the ellipsis from the type source end
1626            component.type.sourceEnd = retrieveEllipsisStartPosition(component.type.sourceStarttypeSourceEnd);
1627        }
1628        Type type = convertType(component.type);
1629        int typeEnd = type.getStartPosition() + type.getLength() - 1;
1630        int rightEnd = Math.max(typeEndcomponent.declarationSourceEnd);
1631        /*
1632         * There is extra work to do to set the proper type positions
1633         * See PR http://bugs.eclipse.org/bugs/show_bug.cgi?id=23284
1634         */
1635        if (isVarArgs) {
1636            Dimension lastDimension = null;
1637            if (this.ast.apiLevel() >= AST.JLS8_INTERNAL) {
1638                if (type.isArrayType()) { // should always be true
1639                    List dimensions = ((ArrayTypetype).dimensions();
1640                    if (!dimensions.isEmpty()) {
1641                        lastDimension = (Dimensiondimensions.get(dimensions.size() - 1);
1642                    }
1643                }
1644            }
1645            setTypeForSingleVariableDeclaration(variableDecltypeextraDimensions + 1);
1646            // https://bugs.eclipse.org/bugs/show_bug.cgi?id=391898
1647            if (this.ast.apiLevel() >= AST.JLS8_INTERNAL) {
1648                if (lastDimension != null) { // should always be true
1649                    List annotations = lastDimension.annotations();
1650                    Iterator iter = annotations.iterator();
1651                    while (iter.hasNext()) {
1652                        Annotation annotation = (Annotationiter.next();
1653                        annotation.setParent(nullnull);
1654                        variableDecl.varargsAnnotations().add(annotation);
1655                    }
1656                }
1657            }
1658            if (extraDimensions != 0) {
1659                variableDecl.setFlags(variableDecl.getFlags() | ASTNode.MALFORMED);
1660            }
1661        } else {
1662            setTypeForSingleVariableDeclaration(variableDecltypeextraDimensions);
1663        }
1664        variableDecl.setSourceRange(component.declarationSourceStartrightEnd - component.declarationSourceStart + 1);
1665
1666        if (isVarArgs) {
1667            switch(this.ast.apiLevel) {
1668                case AST.JLS2_INTERNAL :
1669                    variableDecl.setFlags(variableDecl.getFlags() | ASTNode.MALFORMED);
1670                    break;
1671                default :
1672                    variableDecl.setVarargs(true);
1673            }
1674        }
1675        if (this.resolveBindings) {
1676            recordNodes(namecomponent);
1677            recordNodes(variableDeclcomponent);
1678            variableDecl.resolveBinding();
1679        }
1680        return variableDecl;
1681    }
1682
1683    public Assignment convert(org.eclipse.jdt.internal.compiler.ast.CompoundAssignment expression) {
1684        Assignment assignment = new Assignment(this.ast);
1685        Expression lhs = convert(expression.lhs);
1686        assignment.setLeftHandSide(lhs);
1687        int start = lhs.getStartPosition();
1688        assignment.setSourceRange(startexpression.sourceEnd - start + 1);
1689        switch (expression.operator) {
1690            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS :
1691                assignment.setOperator(Assignment.Operator.PLUS_ASSIGN);
1692                break;
1693            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS :
1694                assignment.setOperator(Assignment.Operator.MINUS_ASSIGN);
1695                break;
1696            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.MULTIPLY :
1697                assignment.setOperator(Assignment.Operator.TIMES_ASSIGN);
1698                break;
1699            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.DIVIDE :
1700                assignment.setOperator(Assignment.Operator.DIVIDE_ASSIGN);
1701                break;
1702            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.AND :
1703                assignment.setOperator(Assignment.Operator.BIT_AND_ASSIGN);
1704                break;
1705            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.OR :
1706                assignment.setOperator(Assignment.Operator.BIT_OR_ASSIGN);
1707                break;
1708            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.XOR :
1709                assignment.setOperator(Assignment.Operator.BIT_XOR_ASSIGN);
1710                break;
1711            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.REMAINDER :
1712                assignment.setOperator(Assignment.Operator.REMAINDER_ASSIGN);
1713                break;
1714            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.LEFT_SHIFT :
1715                assignment.setOperator(Assignment.Operator.LEFT_SHIFT_ASSIGN);
1716                break;
1717            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.RIGHT_SHIFT :
1718                assignment.setOperator(Assignment.Operator.RIGHT_SHIFT_SIGNED_ASSIGN);
1719                break;
1720            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.UNSIGNED_RIGHT_SHIFT :
1721                assignment.setOperator(Assignment.Operator.RIGHT_SHIFT_UNSIGNED_ASSIGN);
1722                break;
1723        }
1724        assignment.setRightHandSide(convert(expression.expression));
1725        if (this.resolveBindings) {
1726            recordNodes(assignmentexpression);
1727        }
1728        return assignment;
1729    }
1730
1731    public ConditionalExpression convert(org.eclipse.jdt.internal.compiler.ast.ConditionalExpression expression) {
1732        ConditionalExpression conditionalExpression = new ConditionalExpression(this.ast);
1733        if (this.resolveBindings) {
1734            recordNodes(conditionalExpressionexpression);
1735        }
1736        conditionalExpression.setExpression(convert(expression.condition));
1737        conditionalExpression.setThenExpression(convert(expression.valueIfTrue));
1738        Expression elseExpression = convert(expression.valueIfFalse);
1739        conditionalExpression.setElseExpression(elseExpression);
1740        conditionalExpression.setSourceRange(expression.sourceStartelseExpression.getStartPosition() + elseExpression.getLength() - expression.sourceStart);
1741        return conditionalExpression;
1742    }
1743
1744    public ContinueStatement convert(org.eclipse.jdt.internal.compiler.ast.ContinueStatement statement)  {
1745        ContinueStatement continueStatement = new ContinueStatement(this.ast);
1746        continueStatement.setSourceRange(statement.sourceStartstatement.sourceEnd - statement.sourceStart + 1);
1747        if (statement.label != null) {
1748            final SimpleName name = new SimpleName(this.ast);
1749            name.internalSetIdentifier(new String(statement.label));
1750            retrieveIdentifierAndSetPositions(statement.sourceStartstatement.sourceEndname);
1751            continueStatement.setLabel(name);
1752        }
1753        return continueStatement;
1754    }
1755
1756    public DoStatement convert(org.eclipse.jdt.internal.compiler.ast.DoStatement statement) {
1757        DoStatement doStatement = new DoStatement(this.ast);
1758        doStatement.setSourceRange(statement.sourceStartstatement.sourceEnd - statement.sourceStart + 1);
1759        doStatement.setExpression(convert(statement.condition));
1760        final Statement action = convert(statement.action);
1761        if (action == null) return null;
1762        doStatement.setBody(action);
1763        return doStatement;
1764    }
1765
1766    public NumberLiteral convert(org.eclipse.jdt.internal.compiler.ast.DoubleLiteral expression) {
1767        int length = expression.sourceEnd - expression.sourceStart + 1;
1768        int sourceStart = expression.sourceStart;
1769        NumberLiteral literal = new NumberLiteral(this.ast);
1770        literal.internalSetToken(new String(this.compilationUnitSourcesourceStartlength));
1771        if (this.resolveBindings) {
1772            this.recordNodes(literalexpression);
1773        }
1774        literal.setSourceRange(sourceStartlength);
1775        removeLeadingAndTrailingCommentsFromLiteral(literal);
1776        return literal;
1777    }
1778
1779    public EmptyStatement convert(org.eclipse.jdt.internal.compiler.ast.EmptyStatement statement) {
1780        EmptyStatement emptyStatement = new EmptyStatement(this.ast);
1781        emptyStatement.setSourceRange(statement.sourceStartstatement.sourceEnd - statement.sourceStart + 1);
1782        return emptyStatement;
1783    }
1784
1785    // field is an enum constant
1786    public EnumConstantDeclaration convert(org.eclipse.jdt.internal.compiler.ast.FieldDeclaration enumConstant) {
1787        checkCanceled();
1788        EnumConstantDeclaration enumConstantDeclaration = new EnumConstantDeclaration(this.ast);
1789        final SimpleName typeName = new SimpleName(this.ast);
1790        typeName.internalSetIdentifier(new String(enumConstant.name));
1791        typeName.setSourceRange(enumConstant.sourceStartenumConstant.sourceEnd - enumConstant.sourceStart + 1);
1792        enumConstantDeclaration.setName(typeName);
1793        int declarationSourceStart = enumConstant.declarationSourceStart;
1794        int declarationSourceEnd = enumConstant.declarationSourceEnd;
1795        final org.eclipse.jdt.internal.compiler.ast.Expression initialization = enumConstant.initialization;
1796        if (initialization != null) {
1797            if (initialization instanceof QualifiedAllocationExpression) {
1798                org.eclipse.jdt.internal.compiler.ast.TypeDeclaration anonymousType = ((QualifiedAllocationExpressioninitialization).anonymousType;
1799                if (anonymousType != null) {
1800                    AnonymousClassDeclaration anonymousClassDeclaration = new AnonymousClassDeclaration(this.ast);
1801                    int start = retrieveStartBlockPosition(anonymousType.sourceEndanonymousType.bodyEnd);
1802                    int end = retrieveRightBrace(anonymousType.bodyEnd +1declarationSourceEnd);
1803                    if (end == -1end = anonymousType.bodyEnd;
1804                    anonymousClassDeclaration.setSourceRange(startend - start + 1);
1805                    enumConstantDeclaration.setAnonymousClassDeclaration(anonymousClassDeclaration);
1806                    buildBodyDeclarations(anonymousTypeanonymousClassDeclaration);
1807                    if (this.resolveBindings) {
1808                        recordNodes(anonymousClassDeclarationanonymousType);
1809                        anonymousClassDeclaration.resolveBinding();
1810                    }
1811                    enumConstantDeclaration.setSourceRange(declarationSourceStartend - declarationSourceStart + 1);
1812                }
1813            } else {
1814                enumConstantDeclaration.setSourceRange(declarationSourceStartdeclarationSourceEnd - declarationSourceStart + 1);
1815            }
1816            final org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = ((org.eclipse.jdt.internal.compiler.ast.AllocationExpressioninitialization).arguments;
1817            if (arguments != null) {
1818                for (int i = 0max = arguments.lengthi < maxi++) {
1819                    enumConstantDeclaration.arguments().add(convert(arguments[i]));
1820                }
1821            }
1822        } else {
1823            enumConstantDeclaration.setSourceRange(declarationSourceStartdeclarationSourceEnd - declarationSourceStart + 1);
1824        }
1825        setModifiers(enumConstantDeclarationenumConstant);
1826        if (this.resolveBindings) {
1827            recordNodes(enumConstantDeclarationenumConstant);
1828            recordNodes(typeNameenumConstant);
1829            enumConstantDeclaration.resolveVariable();
1830        }
1831        convert(enumConstant.javadocenumConstantDeclaration);
1832        return enumConstantDeclaration;
1833    }
1834
1835    public Expression convert(org.eclipse.jdt.internal.compiler.ast.EqualExpression expression) {
1836        InfixExpression infixExpression = new InfixExpression(this.ast);
1837        if (this.resolveBindings) {
1838            recordNodes(infixExpressionexpression);
1839        }
1840        Expression leftExpression = convert(expression.left);
1841        infixExpression.setLeftOperand(leftExpression);
1842        infixExpression.setRightOperand(convert(expression.right));
1843        int startPosition = leftExpression.getStartPosition();
1844        setInfixSourcePositions(infixExpressionstartPosition);
1845        switch ((expression.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT) {
1846            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.EQUAL_EQUAL :
1847                infixExpression.setOperator(InfixExpression.Operator.EQUALS);
1848                break;
1849            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.NOT_EQUAL :
1850                infixExpression.setOperator(InfixExpression.Operator.NOT_EQUALS);
1851        }
1852        return infixExpression;
1853
1854    }
1855
1856    public Statement convert(org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall statement) {
1857        Statement newStatement;
1858        int sourceStart = statement.sourceStart;
1859        if (statement.isSuperAccess() || statement.isSuper()) {
1860            SuperConstructorInvocation superConstructorInvocation = new SuperConstructorInvocation(this.ast);
1861            if (statement.qualification != null) {
1862                superConstructorInvocation.setExpression(convert(statement.qualification));
1863            }
1864            org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = statement.arguments;
1865            if (arguments != null) {
1866                int length = arguments.length;
1867                for (int i = 0i < lengthi++) {
1868                    superConstructorInvocation.arguments().add(convert(arguments[i]));
1869                }
1870            }
1871            if (statement.typeArguments != null) {
1872                if (sourceStart > statement.typeArgumentsSourceStart) {
1873                    sourceStart = statement.typeArgumentsSourceStart;
1874                }
1875                switch(this.ast.apiLevel) {
1876                    case AST.JLS2_INTERNAL :
1877                        superConstructorInvocation.setFlags(superConstructorInvocation.getFlags() | ASTNode.MALFORMED);
1878                        break;
1879                    default :
1880                        for (int i = 0max = statement.typeArguments.lengthi < maxi++) {
1881                            superConstructorInvocation.typeArguments().add(convertType(statement.typeArguments[i]));
1882                        }
1883                        break;
1884                }
1885            }
1886            newStatement = superConstructorInvocation;
1887        } else {
1888            ConstructorInvocation constructorInvocation = new ConstructorInvocation(this.ast);
1889            org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = statement.arguments;
1890            if (arguments != null) {
1891                int length = arguments.length;
1892                for (int i = 0i < lengthi++) {
1893                    constructorInvocation.arguments().add(convert(arguments[i]));
1894                }
1895            }
1896            if (statement.typeArguments != null) {
1897                if (sourceStart > statement.typeArgumentsSourceStart) {
1898                    sourceStart = statement.typeArgumentsSourceStart;
1899                }
1900                switch(this.ast.apiLevel) {
1901                    case AST.JLS2_INTERNAL :
1902                        constructorInvocation.setFlags(constructorInvocation.getFlags() | ASTNode.MALFORMED);
1903                        break;
1904                    default :
1905                        for (int i = 0max = statement.typeArguments.lengthi < maxi++) {
1906                            constructorInvocation.typeArguments().add(convertType(statement.typeArguments[i]));
1907                        }
1908                    break;
1909                }
1910            }
1911            if (statement.qualification != null) {
1912                // this is an error
1913                constructorInvocation.setFlags(constructorInvocation.getFlags() | ASTNode.MALFORMED);
1914            }
1915            newStatement = constructorInvocation;
1916        }
1917        newStatement.setSourceRange(sourceStartstatement.sourceEnd - sourceStart + 1);
1918        if (this.resolveBindings) {
1919            recordNodes(newStatementstatement);
1920        }
1921        return newStatement;
1922    }
1923
1924    private ModulePackageAccess getPackageVisibilityStatement(
1925            org.eclipse.jdt.internal.compiler.ast.PackageVisibilityStatement pvsStmtModulePackageAccess stmt) {
1926        int sourceEnd = pvsStmt.declarationSourceEnd;
1927        if (pvsStmt.declarationEnd > sourceEndsourceEnd = pvsStmt.declarationEnd// TODO: working around a compiler issue
1928        Name name = getImportName(pvsStmt.pkgRef);
1929        stmt.setName(name);
1930        if (this.resolveBindings) {
1931            recordNodes(namepvsStmt.pkgRef);
1932        }
1933        int tmp = sourceEnd;
1934        if (pvsStmt.targets != null && pvsStmt.targets.length > 0) {
1935            List<Namemodules = stmt.modules();
1936            for (ModuleReference moduleRef : pvsStmt.getTargetedModules()) {
1937                Name target = getName(moduleRefCharOperation.splitOn('.'moduleRef.moduleName), moduleRef.sourcePositions);
1938                modules.add(target);
1939                if (tmp < moduleRef.sourceEndtmp = moduleRef.sourceEnd;
1940                if (this.resolveBindings) {
1941                    this.recordNodes(targetmoduleRef);
1942                }
1943
1944            }
1945        }
1946        if (tmp > sourceEndsourceEnd = tmp;
1947        stmt.setSourceRange(pvsStmt.declarationSourceStartsourceEnd - pvsStmt.declarationSourceStart + 1);
1948        return stmt;
1949    }
1950
1951    public Expression convert(org.eclipse.jdt.internal.compiler.ast.Expression expression) {
1952        if ((expression.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) != 0) {
1953            return convertToParenthesizedExpression(expression);
1954        }
1955        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.Annotation) {
1956            return convert((org.eclipse.jdt.internal.compiler.ast.Annotationexpression);
1957        }
1958        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.CastExpression) {
1959            return convert((org.eclipse.jdt.internal.compiler.ast.CastExpressionexpression);
1960        }
1961        // switch between all types of expression
1962        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression) {
1963            return convert((org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpressionexpression);
1964        }
1965        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression) {
1966            return convert((org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpressionexpression);
1967        }
1968        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.AllocationExpression) {
1969            return convert((org.eclipse.jdt.internal.compiler.ast.AllocationExpressionexpression);
1970        }
1971        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.ArrayInitializer) {
1972            return convert((org.eclipse.jdt.internal.compiler.ast.ArrayInitializerexpression);
1973        }
1974        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.FakeDefaultLiteral) {
1975            return convert((org.eclipse.jdt.internal.compiler.ast.FakeDefaultLiteralexpression);
1976        }
1977        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.Pattern) {
1978            return convert((org.eclipse.jdt.internal.compiler.ast.Patternexpression);
1979        }
1980        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.PrefixExpression) {
1981            return convert((org.eclipse.jdt.internal.compiler.ast.PrefixExpressionexpression);
1982        }
1983        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.PostfixExpression) {
1984            return convert((org.eclipse.jdt.internal.compiler.ast.PostfixExpressionexpression);
1985        }
1986        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.CompoundAssignment) {
1987            return convert((org.eclipse.jdt.internal.compiler.ast.CompoundAssignmentexpression);
1988        }
1989        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.Assignment) {
1990            return convert((org.eclipse.jdt.internal.compiler.ast.Assignmentexpression);
1991        }
1992        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess) {
1993            return convert((org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccessexpression);
1994        }
1995        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.FalseLiteral) {
1996            return convert((org.eclipse.jdt.internal.compiler.ast.FalseLiteralexpression);
1997        }
1998        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.TrueLiteral) {
1999            return convert((org.eclipse.jdt.internal.compiler.ast.TrueLiteralexpression);
2000        }
2001        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.NullLiteral) {
2002            return convert((org.eclipse.jdt.internal.compiler.ast.NullLiteralexpression);
2003        }
2004        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.CharLiteral) {
2005            return convert((org.eclipse.jdt.internal.compiler.ast.CharLiteralexpression);
2006        }
2007        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.DoubleLiteral) {
2008            return convert((org.eclipse.jdt.internal.compiler.ast.DoubleLiteralexpression);
2009        }
2010        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.FloatLiteral) {
2011            return convert((org.eclipse.jdt.internal.compiler.ast.FloatLiteralexpression);
2012        }
2013        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue) {
2014            return convert((org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValueexpression);
2015        }
2016        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.IntLiteral) {
2017            return convert((org.eclipse.jdt.internal.compiler.ast.IntLiteralexpression);
2018        }
2019        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValue) {
2020            return convert((org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValueexpression);
2021        }
2022        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.LongLiteral) {
2023            return convert((org.eclipse.jdt.internal.compiler.ast.LongLiteralexpression);
2024        }
2025        if (expression instanceof StringLiteralConcatenation) {
2026            return convert((StringLiteralConcatenationexpression);
2027        }
2028        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral) {
2029            return convert((org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteralexpression);
2030        }
2031        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.TextBlock) {
2032            return convert((org.eclipse.jdt.internal.compiler.ast.TextBlockexpression);
2033        }
2034        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.StringLiteral) {
2035            return convert((org.eclipse.jdt.internal.compiler.ast.StringLiteralexpression);
2036        }
2037        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.AND_AND_Expression) {
2038            return convert((org.eclipse.jdt.internal.compiler.ast.AND_AND_Expressionexpression);
2039        }
2040        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.OR_OR_Expression) {
2041            return convert((org.eclipse.jdt.internal.compiler.ast.OR_OR_Expressionexpression);
2042        }
2043        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.EqualExpression) {
2044            return convert((org.eclipse.jdt.internal.compiler.ast.EqualExpressionexpression);
2045        }
2046        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.BinaryExpression) {
2047            return convert((org.eclipse.jdt.internal.compiler.ast.BinaryExpressionexpression);
2048        }
2049        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression) {
2050            return convert((org.eclipse.jdt.internal.compiler.ast.InstanceOfExpressionexpression);
2051        }
2052        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.UnaryExpression) {
2053            return convert((org.eclipse.jdt.internal.compiler.ast.UnaryExpressionexpression);
2054        }
2055        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.ConditionalExpression) {
2056            return convert((org.eclipse.jdt.internal.compiler.ast.ConditionalExpressionexpression);
2057        }
2058        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.MessageSend) {
2059            return convert((org.eclipse.jdt.internal.compiler.ast.MessageSendexpression);
2060        }
2061        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.Reference) {
2062            return convert((org.eclipse.jdt.internal.compiler.ast.Referenceexpression);
2063        }
2064        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.TypeReference) {
2065            return convert((org.eclipse.jdt.internal.compiler.ast.TypeReferenceexpression);
2066        }
2067        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.LambdaExpression) {
2068            return convert((org.eclipse.jdt.internal.compiler.ast.LambdaExpressionexpression);
2069        }
2070        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.ReferenceExpression) {
2071            return convert((org.eclipse.jdt.internal.compiler.ast.ReferenceExpressionexpression);
2072        }
2073        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.SwitchExpression) {
2074            return convert((org.eclipse.jdt.internal.compiler.ast.SwitchExpressionexpression);
2075        }
2076        return null;
2077    }
2078
2079    public StringLiteral convert(org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral expression) {
2080        expression.computeConstant();
2081        StringLiteral literal = new StringLiteral(this.ast);
2082        if (this.resolveBindings) {
2083            this.recordNodes(literalexpression);
2084        }
2085        literal.setLiteralValue(expression.constant.stringValue());
2086        literal.setSourceRange(expression.sourceStartexpression.sourceEnd - expression.sourceStart + 1);
2087        return literal;
2088    }
2089
2090    public BooleanLiteral convert(org.eclipse.jdt.internal.compiler.ast.FalseLiteral expression) {
2091        final BooleanLiteral literal =  new BooleanLiteral(this.ast);
2092        literal.setBooleanValue(false);
2093        if (this.resolveBindings) {
2094            this.recordNodes(literalexpression);
2095        }
2096        literal.setSourceRange(expression.sourceStartexpression.sourceEnd - expression.sourceStart + 1);
2097        return literal;
2098    }
2099
2100    public Expression convert(org.eclipse.jdt.internal.compiler.ast.FieldReference reference) {
2101        if (reference.receiver.isSuper()) {
2102            final SuperFieldAccess superFieldAccess = new SuperFieldAccess(this.ast);
2103            if (this.resolveBindings) {
2104                recordNodes(superFieldAccessreference);
2105            }
2106            if (reference.receiver instanceof org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference) {
2107                Name qualifier = convert((org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReferencereference.receiver);
2108                superFieldAccess.setQualifier(qualifier);
2109                if (this.resolveBindings) {
2110                    recordNodes(qualifierreference.receiver);
2111                }
2112            }
2113            final SimpleName simpleName = new SimpleName(this.ast);
2114            simpleName.internalSetIdentifier(new String(reference.token));
2115            int sourceStart = (int)(reference.nameSourcePosition>>>32);
2116            int length = (int)(reference.nameSourcePosition & 0xFFFFFFFF) - sourceStart + 1;
2117            simpleName.setSourceRange(sourceStartlength);
2118            superFieldAccess.setName(simpleName);
2119            if (this.resolveBindings) {
2120                recordNodes(simpleNamereference);
2121            }
2122            superFieldAccess.setSourceRange(reference.receiver.sourceStartreference.sourceEnd - reference.receiver.sourceStart + 1);
2123            return superFieldAccess;
2124        } else {
2125            final FieldAccess fieldAccess = new FieldAccess(this.ast);
2126            if (this.resolveBindings) {
2127                recordNodes(fieldAccessreference);
2128            }
2129            Expression receiver = convert(reference.receiver);
2130            fieldAccess.setExpression(receiver);
2131            final SimpleName simpleName = new SimpleName(this.ast);
2132            simpleName.internalSetIdentifier(new String(reference.token));
2133            int sourceStart = (int)(reference.nameSourcePosition>>>32);
2134            int length = (int)(reference.nameSourcePosition & 0xFFFFFFFF) - sourceStart + 1;
2135            simpleName.setSourceRange(sourceStartlength);
2136            fieldAccess.setName(simpleName);
2137            if (this.resolveBindings) {
2138                recordNodes(simpleNamereference);
2139            }
2140            fieldAccess.setSourceRange(receiver.getStartPosition(), reference.sourceEnd - receiver.getStartPosition() + 1);
2141            return fieldAccess;
2142        }
2143    }
2144
2145    public NumberLiteral convert(org.eclipse.jdt.internal.compiler.ast.FloatLiteral expression) {
2146        int length = expression.sourceEnd - expression.sourceStart + 1;
2147        int sourceStart = expression.sourceStart;
2148        NumberLiteral literal = new NumberLiteral(this.ast);
2149        literal.internalSetToken(new String(this.compilationUnitSourcesourceStartlength));
2150        if (this.resolveBindings) {
2151            this.recordNodes(literalexpression);
2152        }
2153        literal.setSourceRange(sourceStartlength);
2154        removeLeadingAndTrailingCommentsFromLiteral(literal);
2155        return literal;
2156    }
2157
2158    public Statement convert(ForeachStatement statement) {
2159        switch(this.ast.apiLevel) {
2160            case AST.JLS2_INTERNAL :
2161                return createFakeEmptyStatement(statement);
2162            default :
2163                EnhancedForStatement enhancedForStatement = new EnhancedForStatement(this.ast);
2164                enhancedForStatement.setParameter(convertToSingleVariableDeclaration(statement.elementVariable));
2165                org.eclipse.jdt.internal.compiler.ast.Expression collection = statement.collection;
2166                if (collection == null) return null;
2167                enhancedForStatement.setExpression(convert(collection));
2168                final Statement action = convert(statement.action);
2169                if (action == null) return null;
2170                enhancedForStatement.setBody(action);
2171                int start = statement.sourceStart;
2172                int end = statement.sourceEnd;
2173                enhancedForStatement.setSourceRange(startend - start + 1);
2174                return enhancedForStatement;
2175        }
2176    }
2177
2178    public ForStatement convert(org.eclipse.jdt.internal.compiler.ast.ForStatement statement) {
2179        ForStatement forStatement = new ForStatement(this.ast);
2180        forStatement.setSourceRange(statement.sourceStartstatement.sourceEnd - statement.sourceStart + 1);
2181        org.eclipse.jdt.internal.compiler.ast.Statement[] initializations = statement.initializations;
2182        if (initializations != null) {
2183            // we know that we have at least one initialization
2184            if (initializations[0] instanceof org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) {
2185                org.eclipse.jdt.internal.compiler.ast.LocalDeclaration initialization = (org.eclipse.jdt.internal.compiler.ast.LocalDeclarationinitializations[0];
2186                VariableDeclarationExpression variableDeclarationExpression = convertToVariableDeclarationExpression(initialization);
2187                int initializationsLength = initializations.length;
2188                for (int i = 1i < initializationsLengthi++) {
2189                    initialization = (org.eclipse.jdt.internal.compiler.ast.LocalDeclaration)initializations[i];
2190                    variableDeclarationExpression.fragments().add(convertToVariableDeclarationFragment(initialization));
2191                }
2192                if (initializationsLength != 1) {
2193                    int start = variableDeclarationExpression.getStartPosition();
2194                    int end = ((org.eclipse.jdt.internal.compiler.ast.LocalDeclarationinitializations[initializationsLength - 1]).declarationSourceEnd;
2195                    variableDeclarationExpression.setSourceRange(startend - start + 1);
2196                }
2197                forStatement.initializers().add(variableDeclarationExpression);
2198            } else {
2199                int initializationsLength = initializations.length;
2200                for (int i = 0i < initializationsLengthi++) {
2201                    Expression initializer = convertToExpression(initializations[i]);
2202                    if (initializer != null) {
2203                        forStatement.initializers().add(initializer);
2204                    } else {
2205                        forStatement.setFlags(forStatement.getFlags() | ASTNode.MALFORMED);
2206                    }
2207                }
2208            }
2209        }
2210        if (statement.condition != null) {
2211            forStatement.setExpression(convert(statement.condition));
2212        }
2213        org.eclipse.jdt.internal.compiler.ast.Statement[] increments = statement.increments;
2214        if (increments != null) {
2215            int incrementsLength = increments.length;
2216            for (int i = 0i < incrementsLengthi++) {
2217                forStatement.updaters().add(convertToExpression(increments[i]));
2218            }
2219        }
2220        final Statement action = convert(statement.action);
2221        if (action == null) return null;
2222        forStatement.setBody(action);
2223        return forStatement;
2224    }
2225
2226    public Pattern convert(org.eclipse.jdt.internal.compiler.ast.GuardedPattern pattern) {
2227        final GuardedPattern guardedPattern = new GuardedPattern(this.ast);
2228        if (this.resolveBindings) {
2229            recordNodes(guardedPatternpattern);
2230        }
2231        guardedPattern.setPattern(convert(pattern.primaryPattern));
2232        guardedPattern.setExpression(convert(pattern.condition));
2233        int startPosition = pattern.sourceStart;
2234        int sourceEnd = pattern.sourceEnd;
2235        guardedPattern.setSourceRange(startPositionsourceEnd - startPosition + 1);
2236        return guardedPattern;
2237    }
2238
2239    public IfStatement convert(org.eclipse.jdt.internal.compiler.ast.IfStatement statement) {
2240        IfStatement ifStatement = new IfStatement(this.ast);
2241        ifStatement.setSourceRange(statement.sourceStartstatement.sourceEnd - statement.sourceStart + 1);
2242        ifStatement.setExpression(convert(statement.condition));
2243        final Statement thenStatement = convert(statement.thenStatement);
2244        if (thenStatement == null) return null;
2245        ifStatement.setThenStatement(thenStatement);
2246        org.eclipse.jdt.internal.compiler.ast.Statement statement2 = statement.elseStatement;
2247        if (statement2 != null) {
2248            final Statement elseStatement = convert(statement2);
2249            if (elseStatement != null) {
2250                ifStatement.setElseStatement(elseStatement);
2251            }
2252        }
2253        return ifStatement;
2254    }
2255
2256    public Expression convert(org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression expression) {
2257        if (DOMASTUtil.isPatternInstanceofExpressionSupported(this.ast) && expression.elementVariable != null) {
2258            return convertToPatternInstanceOfExpression(expression);
2259        }
2260        InstanceofExpression instanceOfExpression = new InstanceofExpression(this.ast);
2261        if (this.resolveBindings) {
2262            recordNodes(instanceOfExpressionexpression);
2263        }
2264        Expression leftExpression = convert(expression.expression);
2265        instanceOfExpression.setLeftOperand(leftExpression);
2266        final Type convertType = convertType(expression.type);
2267        instanceOfExpression.setRightOperand(convertType);
2268        int startPosition = leftExpression.getStartPosition();
2269        int sourceEnd = convertType.getStartPosition() + convertType.getLength() - 1;
2270
2271        instanceOfExpression.setSourceRange(startPositionsourceEnd - startPosition + 1);
2272        return instanceOfExpression;
2273    }
2274
2275    public PatternInstanceofExpression convertToPatternInstanceOfExpression(org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression expression) {
2276        PatternInstanceofExpression patternInstanceOfExpression = new PatternInstanceofExpression(this.ast);
2277        if (this.resolveBindings) {
2278            recordNodes(patternInstanceOfExpressionexpression);
2279        }
2280        Expression leftExpression = convert(expression.expression);
2281        patternInstanceOfExpression.setLeftOperand(leftExpression);
2282        patternInstanceOfExpression.setRightOperand(convertToSingleVariableDeclaration(expression.elementVariable));
2283        int startPosition = leftExpression.getStartPosition();
2284        int sourceEndexpression.elementVariable.sourceEnd;
2285
2286        patternInstanceOfExpression.setSourceRange(startPositionsourceEnd - startPosition + 1);
2287        return patternInstanceOfExpression;
2288    }
2289
2290    public NumberLiteral convert(org.eclipse.jdt.internal.compiler.ast.IntLiteral expression) {
2291        int length = expression.sourceEnd - expression.sourceStart + 1;
2292        int sourceStart = expression.sourceStart;
2293        final NumberLiteral literal = new NumberLiteral(this.ast);
2294        literal.internalSetToken(new String(this.compilationUnitSourcesourceStartlength));
2295        if (this.resolveBindings) {
2296            this.recordNodes(literalexpression);
2297        }
2298        literal.setSourceRange(sourceStartlength);
2299        removeLeadingAndTrailingCommentsFromLiteral(literal);
2300        return literal;
2301    }
2302
2303    public NumberLiteral convert(org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue expression) {
2304        int length = expression.sourceEnd - expression.sourceStart + 1;
2305        int sourceStart = expression.sourceStart;
2306        NumberLiteral literal = new NumberLiteral(this.ast);
2307        literal.internalSetToken(new String(this.compilationUnitSourcesourceStartlength));
2308        if (this.resolveBindings) {
2309            this.recordNodes(literalexpression);
2310        }
2311        literal.setSourceRange(sourceStartlength);
2312        removeLeadingAndTrailingCommentsFromLiteral(literal);
2313        return literal;
2314    }
2315
2316    interface IGetJavaDoc {
2317        Javadoc getJavaDoc();
2318    }
2319    interface ISetJavaDoc {
2320        void setJavadoc(Javadoc javadoc);
2321    }
2322    public void convert(org.eclipse.jdt.internal.compiler.ast.Javadoc javadocIGetJavaDoc getJISetJavaDoc setJ) {
2323        if (getJ.getJavaDoc() == null) {
2324            Javadoc docComment = convert(javadoc);
2325            if (docComment != null)
2326                setJ.setJavadoc(docComment);
2327        }
2328    }
2329    private Javadoc convert(org.eclipse.jdt.internal.compiler.ast.Javadoc javadoc) {
2330        Javadoc docComment = null;
2331        if (javadoc != null) {
2332            if (this.commentMapper == null || !this.commentMapper.hasSameTable(this.commentsTable)) {
2333                this.commentMapper = new DefaultCommentMapper(this.commentsTable);
2334            }
2335            Comment comment = this.commentMapper.getComment(javadoc.sourceStart);
2336            if (comment != null && comment.isDocComment() && comment.getParent() == null) {
2337                docComment = (Javadoccomment;
2338                if (this.resolveBindings) {
2339                    recordNodes(docCommentjavadoc);
2340                    // resolve member and method references binding
2341                    Iterator tags = docComment.tags().listIterator();
2342                    while (tags.hasNext()) {
2343                        recordNodes(javadoc, (TagElementtags.next());
2344                    }
2345                }
2346            }
2347        }
2348        return docComment;
2349    }
2350    public void convert(org.eclipse.jdt.internal.compiler.ast.Javadoc javadocBodyDeclaration bodyDeclaration) {
2351        convert(javadocbodyDeclaration::getJavadocbodyDeclaration::setJavadoc);
2352    }
2353    public void convert(org.eclipse.jdt.internal.compiler.ast.Javadoc javadocModuleDeclaration moduleDeclaration) {
2354        convert(javadocmoduleDeclaration::getJavadocmoduleDeclaration::setJavadoc);
2355    }
2356
2357    public void convert(org.eclipse.jdt.internal.compiler.ast.Javadoc javadocPackageDeclaration packageDeclaration) {
2358        if (this.ast.apiLevel == AST.JLS2_INTERNAL) return;
2359        convert(javadocpackageDeclaration::getJavadocpackageDeclaration::setJavadoc);
2360    }
2361
2362    public LabeledStatement convert(org.eclipse.jdt.internal.compiler.ast.LabeledStatement statement) {
2363        LabeledStatement labeledStatement = new LabeledStatement(this.ast);
2364        final int sourceStart = statement.sourceStart;
2365        labeledStatement.setSourceRange(sourceStartstatement.sourceEnd - sourceStart + 1);
2366        Statement body = convert(statement.statement);
2367        if (body == null) return null;
2368        labeledStatement.setBody(body);
2369        final SimpleName name = new SimpleName(this.ast);
2370        name.internalSetIdentifier(new String(statement.label));
2371        name.setSourceRange(sourceStartstatement.labelEnd - sourceStart + 1);
2372        labeledStatement.setLabel(name);
2373        return labeledStatement;
2374    }
2375
2376    public NumberLiteral convert(org.eclipse.jdt.internal.compiler.ast.LongLiteral expression) {
2377        int length = expression.sourceEnd - expression.sourceStart + 1;
2378        int sourceStart = expression.sourceStart;
2379        final NumberLiteral literal = new NumberLiteral(this.ast);
2380        literal.internalSetToken(new String(this.compilationUnitSourcesourceStartlength));
2381        if (this.resolveBindings) {
2382            this.recordNodes(literalexpression);
2383        }
2384        literal.setSourceRange(sourceStartlength);
2385        removeLeadingAndTrailingCommentsFromLiteral(literal);
2386        return literal;
2387    }
2388
2389    public NumberLiteral convert(org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValue expression) {
2390        int length = expression.sourceEnd - expression.sourceStart + 1;
2391        int sourceStart = expression.sourceStart;
2392        final NumberLiteral literal = new NumberLiteral(this.ast);
2393        literal.internalSetToken(new String(this.compilationUnitSourcesourceStartlength));
2394        if (this.resolveBindings) {
2395            this.recordNodes(literalexpression);
2396        }
2397        literal.setSourceRange(sourceStartlength);
2398        removeLeadingAndTrailingCommentsFromLiteral(literal);
2399        return literal;
2400    }
2401
2402    public Expression convert(MessageSend expression) {
2403        // will return a MethodInvocation or a SuperMethodInvocation or
2404        Expression expr;
2405        int sourceStart = expression.sourceStart;
2406        if (expression.isSuperAccess()) {
2407            // returns a SuperMethodInvocation
2408            final SuperMethodInvocation superMethodInvocation = new SuperMethodInvocation(this.ast);
2409            if (this.resolveBindings) {
2410                recordNodes(superMethodInvocationexpression);
2411            }
2412            final SimpleName name = new SimpleName(this.ast);
2413            name.internalSetIdentifier(new String(expression.selector));
2414            int nameSourceStart =  (int) (expression.nameSourcePosition >>> 32);
2415            int nameSourceLength = ((intexpression.nameSourcePosition) - nameSourceStart + 1;
2416            name.setSourceRange(nameSourceStartnameSourceLength);
2417            if (this.resolveBindings) {
2418                recordNodes(nameexpression);
2419            }
2420            superMethodInvocation.setName(name);
2421            // expression.receiver is either a QualifiedSuperReference or a SuperReference
2422            // so the casting cannot fail
2423            if (expression.receiver instanceof org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference) {
2424                Name qualifier = convert((org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReferenceexpression.receiver);
2425                superMethodInvocation.setQualifier(qualifier);
2426                if (this.resolveBindings) {
2427                    recordNodes(qualifierexpression.receiver);
2428                }
2429                if (qualifier != null) {
2430                    sourceStart = qualifier.getStartPosition();
2431                }
2432            }
2433            org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = expression.arguments;
2434            if (arguments != null) {
2435                int argumentsLength = arguments.length;
2436                for (int i = 0i < argumentsLengthi++) {
2437                    Expression expri = convert(arguments[i]);
2438                    if (this.resolveBindings) {
2439                        recordNodes(expriarguments[i]);
2440                    }
2441                    superMethodInvocation.arguments().add(expri);
2442                }
2443            }
2444            final TypeReference[] typeArguments = expression.typeArguments;
2445            if (typeArguments != null) {
2446                switch(this.ast.apiLevel) {
2447                    case AST.JLS2_INTERNAL :
2448                        superMethodInvocation.setFlags(superMethodInvocation.getFlags() | ASTNode.MALFORMED);
2449                        break;
2450                    default :
2451                        for (int i = 0max = typeArguments.lengthi < maxi++) {
2452                            superMethodInvocation.typeArguments().add(convertType(typeArguments[i]));
2453                        }
2454                        break;
2455                }
2456            }
2457            expr = superMethodInvocation;
2458        } else {
2459            // returns a MethodInvocation
2460            final MethodInvocation methodInvocation = new MethodInvocation(this.ast);
2461            if (this.resolveBindings) {
2462                recordNodes(methodInvocationexpression);
2463            }
2464            final SimpleName name = new SimpleName(this.ast);
2465            name.internalSetIdentifier(new String(expression.selector));
2466            int nameSourceStart =  (int) (expression.nameSourcePosition >>> 32);
2467            int nameSourceLength = ((intexpression.nameSourcePosition) - nameSourceStart + 1;
2468            name.setSourceRange(nameSourceStartnameSourceLength);
2469            methodInvocation.setName(name);
2470            if (this.resolveBindings) {
2471                recordNodes(nameexpression);
2472            }
2473            org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = expression.arguments;
2474            if (arguments != null) {
2475                int argumentsLength = arguments.length;
2476                for (int i = 0i < argumentsLengthi++) {
2477                    Expression expri = convert(arguments[i]);
2478                    if (this.resolveBindings) {
2479                        recordNodes(expriarguments[i]);
2480                    }
2481                    methodInvocation.arguments().add(expri);
2482                }
2483            }
2484            Expression qualifier = null;
2485            org.eclipse.jdt.internal.compiler.ast.Expression receiver = expression.receiver;
2486            if (receiver instanceof MessageSend) {
2487                if ((receiver.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) != 0) {
2488                    qualifier = convertToParenthesizedExpression(receiver);
2489                } else {
2490                    qualifier = convert((MessageSendreceiver);
2491                }
2492            } else {
2493                qualifier = convert(receiver);
2494            }
2495            if (qualifier instanceof Name && this.resolveBindings) {
2496                recordNodes(qualifierreceiver);
2497            }
2498            methodInvocation.setExpression(qualifier);
2499            if (qualifier != null) {
2500                sourceStart = qualifier.getStartPosition();
2501            }
2502            final TypeReference[] typeArguments = expression.typeArguments;
2503            if (typeArguments != null) {
2504                switch(this.ast.apiLevel) {
2505                    case AST.JLS2_INTERNAL :
2506                        methodInvocation.setFlags(methodInvocation.getFlags() | ASTNode.MALFORMED);
2507                        break;
2508                    default :
2509                        for (int i = 0max = typeArguments.lengthi < maxi++) {
2510                            methodInvocation.typeArguments().add(convertType(typeArguments[i]));
2511                        }
2512                        break;
2513                }
2514            }
2515            expr = methodInvocation;
2516        }
2517        expr.setSourceRange(sourceStartexpression.sourceEnd - sourceStart + 1);
2518        return expr;
2519    }
2520
2521    public Expression convert(org.eclipse.jdt.internal.compiler.ast.LambdaExpression lambda) {
2522        if (this.ast.apiLevel < AST.JLS8_INTERNAL) {
2523            return createFakeNullLiteral(lambda);
2524        }
2525        final LambdaExpression    lambdaExpression = new LambdaExpression(this.ast);
2526        if (this.resolveBindings) {
2527            recordNodes(lambdaExpressionlambda);
2528        }
2529        org.eclipse.jdt.internal.compiler.ast.Argument[] arguments = lambda.arguments();
2530        if (arguments != null) {
2531            int argumentsLength = arguments.length;
2532            for (int i = 0i < argumentsLengthi++) {
2533                org.eclipse.jdt.internal.compiler.ast.Argument argument = arguments[i];
2534                if (argument.type == null) {
2535                    VariableDeclarationFragment variableDeclarationFragment = new VariableDeclarationFragment(this.ast);
2536                    SimpleName simpleName = new SimpleName(this.ast);
2537                    simpleName.internalSetIdentifier(new String(argument.name));
2538                    int start = argument.sourceStart;
2539                    int end = argument.sourceEnd;
2540                    simpleName.setSourceRange(startend - start + 1);
2541                    if (this.resolveBindings) {
2542                        recordNodes(simpleNameargument);
2543                        recordNodes(variableDeclarationFragmentargument);
2544                        variableDeclarationFragment.resolveBinding();
2545                    }
2546                    variableDeclarationFragment.setName(simpleName);
2547                    variableDeclarationFragment.setSourceRange(startend - start + 1);
2548                    lambdaExpression.parameters().add(variableDeclarationFragment);
2549                } else {
2550                    SingleVariableDeclaration singleVariableDeclaration = convert(argument);
2551                    lambdaExpression.parameters().add(singleVariableDeclaration);
2552                }
2553            }
2554        }
2555        final org.eclipse.jdt.internal.compiler.ast.Statement body = lambda.body();
2556        if (body instanceof org.eclipse.jdt.internal.compiler.ast.Expression &&
2557                ((org.eclipse.jdt.internal.compiler.ast.Expressionbody).isTrulyExpression()) {
2558            lambdaExpression.setBody(convert((org.eclipse.jdt.internal.compiler.ast.Expressionbody));
2559        } else {
2560            lambdaExpression.setBody(convert((org.eclipse.jdt.internal.compiler.ast.Blockbody));
2561        }
2562        int sourceStart = lambda.sourceStart;
2563        lambdaExpression.setSourceRange(sourceStartlambda.sourceEnd - sourceStart + 1);
2564        lambdaExpression.setParentheses(lambda.hasParentheses);
2565        return lambdaExpression;
2566    }
2567
2568    public MarkerAnnotation convert(org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation annotation) {
2569        final MarkerAnnotation markerAnnotation = new MarkerAnnotation(this.ast);
2570        setTypeNameForAnnotation(annotationmarkerAnnotation);
2571        int start = annotation.sourceStart;
2572        int end = annotation.declarationSourceEnd;
2573        markerAnnotation.setSourceRange(startend - start + 1);
2574        if (this.resolveBindings) {
2575            recordNodes(markerAnnotationannotation);
2576            markerAnnotation.resolveAnnotationBinding();
2577        }
2578        return markerAnnotation;
2579    }
2580
2581    public MemberValuePair convert(org.eclipse.jdt.internal.compiler.ast.MemberValuePair memberValuePair) {
2582        final MemberValuePair pair = new MemberValuePair(this.ast);
2583        final SimpleName simpleName = new SimpleName(this.ast);
2584        simpleName.internalSetIdentifier(new String(memberValuePair.name));
2585        int start = memberValuePair.sourceStart;
2586        int end = memberValuePair.sourceEnd;
2587        simpleName.setSourceRange(startend - start + 1);
2588        pair.setName(simpleName);
2589        final Expression value = convert(memberValuePair.value);
2590        pair.setValue(value);
2591        start = memberValuePair.sourceStart;
2592        end = value.getStartPosition() + value.getLength() - 1;
2593        pair.setSourceRange(startend - start + 1);
2594
2595        if (memberValuePair.value instanceof SingleNameReference &&
2596                ((SingleNameReference)memberValuePair.value).token == RecoveryScanner.FAKE_IDENTIFIER) {
2597            pair.setFlags(pair.getFlags() | ASTNode.RECOVERED);
2598        }
2599
2600        if (this.resolveBindings) {
2601            recordNodes(simpleNamememberValuePair);
2602            recordNodes(pairmemberValuePair);
2603        }
2604        return pair;
2605    }
2606
2607    public Name convert(org.eclipse.jdt.internal.compiler.ast.NameReference reference) {
2608        if (reference instanceof org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference) {
2609            return convert((org.eclipse.jdt.internal.compiler.ast.QualifiedNameReferencereference);
2610        } else {
2611            return convert((org.eclipse.jdt.internal.compiler.ast.SingleNameReferencereference);
2612        }
2613    }
2614
2615    public InfixExpression convert(StringLiteralConcatenation expression) {
2616        expression.computeConstant();
2617        final InfixExpression infixExpression = new InfixExpression(this.ast);
2618        infixExpression.setOperator(InfixExpression.Operator.PLUS);
2619        org.eclipse.jdt.internal.compiler.ast.Expression[] stringLiterals = expression.literals;
2620        infixExpression.setLeftOperand(convert(stringLiterals[0]));
2621        infixExpression.setRightOperand(convert(stringLiterals[1]));
2622        for (int i = 2i < expression.counteri++) {
2623            infixExpression.extendedOperands().add(convert(stringLiterals[i]));
2624        }
2625        if (this.resolveBindings) {
2626            this.recordNodes(infixExpressionexpression);
2627        }
2628        infixExpression.setSourceRange(expression.sourceStartexpression.sourceEnd - expression.sourceStart + 1);
2629        return infixExpression;
2630    }
2631
2632    public NormalAnnotation convert(org.eclipse.jdt.internal.compiler.ast.NormalAnnotation annotation) {
2633        final NormalAnnotation normalAnnotation = new NormalAnnotation(this.ast);
2634        setTypeNameForAnnotation(annotationnormalAnnotation);
2635
2636        int start = annotation.sourceStart;
2637        int end = annotation.declarationSourceEnd;
2638
2639        org.eclipse.jdt.internal.compiler.ast.MemberValuePair[] memberValuePairs = annotation.memberValuePairs;
2640        if (memberValuePairs != null) {
2641            for (int i = 0max = memberValuePairs.lengthi < maxi++) {
2642                MemberValuePair memberValuePair = convert(memberValuePairs[i]);
2643                int memberValuePairEnd = memberValuePair.getStartPosition() + memberValuePair.getLength() - 1;
2644                if (end == memberValuePairEnd) {
2645                    normalAnnotation.setFlags(normalAnnotation.getFlags() | ASTNode.RECOVERED);
2646                }
2647                normalAnnotation.values().add(memberValuePair);
2648            }
2649        }
2650
2651        normalAnnotation.setSourceRange(startend - start + 1);
2652        if (this.resolveBindings) {
2653            recordNodes(normalAnnotationannotation);
2654            normalAnnotation.resolveAnnotationBinding();
2655        }
2656        return normalAnnotation;
2657    }
2658
2659    public NullLiteral convert(org.eclipse.jdt.internal.compiler.ast.NullLiteral expression) {
2660        final NullLiteral literal = new NullLiteral(this.ast);
2661        if (this.resolveBindings) {
2662            this.recordNodes(literalexpression);
2663        }
2664        literal.setSourceRange(expression.sourceStartexpression.sourceEnd - expression.sourceStart + 1);
2665        return literal;
2666    }
2667
2668    public Expression convert(org.eclipse.jdt.internal.compiler.ast.OR_OR_Expression expression) {
2669        InfixExpression infixExpression = new InfixExpression(this.ast);
2670        infixExpression.setOperator(InfixExpression.Operator.CONDITIONAL_OR);
2671        if (this.resolveBindings) {
2672            this.recordNodes(infixExpressionexpression);
2673        }
2674        final int expressionOperatorID = (expression.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT;
2675        if (expression.left instanceof org.eclipse.jdt.internal.compiler.ast.BinaryExpression
2676                && ((expression.left.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0)) {
2677            // create an extended string literal equivalent => use the extended operands list
2678            infixExpression.extendedOperands().add(convert(expression.right));
2679            org.eclipse.jdt.internal.compiler.ast.Expression leftOperand = expression.left;
2680            org.eclipse.jdt.internal.compiler.ast.Expression rightOperand = null;
2681            do {
2682                rightOperand = ((org.eclipse.jdt.internal.compiler.ast.BinaryExpressionleftOperand).right;
2683                if ((((leftOperand.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT) != expressionOperatorID
2684                            && ((leftOperand.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0))
2685                     || ((rightOperand instanceof org.eclipse.jdt.internal.compiler.ast.BinaryExpression
2686                             && ((rightOperand.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT) != expressionOperatorID)
2687                            && ((rightOperand.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0))) {
2688                     List extendedOperands = infixExpression.extendedOperands();
2689                     InfixExpression temp = new InfixExpression(this.ast);
2690                    if (this.resolveBindings) {
2691                        this.recordNodes(tempexpression);
2692                    }
2693                     temp.setOperator(getOperatorFor(expressionOperatorID));
2694                     Expression leftSide = convert(leftOperand);
2695                    temp.setLeftOperand(leftSide);
2696                    temp.setSourceRange(leftSide.getStartPosition(), leftSide.getLength());
2697                    int size = extendedOperands.size();
2698                     for (int i = 0i < size - 1i++) {
2699                         Expression expr = temp;
2700                         temp = new InfixExpression(this.ast);
2701
2702                        if (this.resolveBindings) {
2703                            this.recordNodes(tempexpression);
2704                        }
2705                         temp.setLeftOperand(expr);
2706                         temp.setOperator(getOperatorFor(expressionOperatorID));
2707                        temp.setSourceRange(expr.getStartPosition(), expr.getLength());
2708                     }
2709                     infixExpression = temp;
2710                     for (int i = 0i < sizei++) {
2711                         Expression extendedOperand = (ExpressionextendedOperands.remove(size - 1 - i);
2712                         temp.setRightOperand(extendedOperand);
2713                         int startPosition = temp.getLeftOperand().getStartPosition();
2714                         temp.setSourceRange(startPositionextendedOperand.getStartPosition() + extendedOperand.getLength() - startPosition);
2715                         if (temp.getLeftOperand().getNodeType() == ASTNode.INFIX_EXPRESSION) {
2716                             temp = (InfixExpressiontemp.getLeftOperand();
2717                         }
2718                     }
2719                     setInfixSourcePositions(infixExpressionexpression.sourceStart);
2720                    if (this.resolveBindings) {
2721                        this.recordNodes(infixExpressionexpression);
2722                    }
2723                    return infixExpression;
2724                }
2725                infixExpression.extendedOperands().add(0convert(rightOperand));
2726                leftOperand = ((org.eclipse.jdt.internal.compiler.ast.BinaryExpressionleftOperand).left;
2727            } while (leftOperand instanceof org.eclipse.jdt.internal.compiler.ast.BinaryExpression && ((leftOperand.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0));
2728            Expression leftExpression = convert(leftOperand);
2729            infixExpression.setLeftOperand(leftExpression);
2730            infixExpression.setRightOperand((Expression)infixExpression.extendedOperands().remove(0));
2731             setInfixSourcePositions(infixExpressionexpression.sourceStart);
2732            return infixExpression;
2733        }
2734        Expression leftExpression = convert(expression.left);
2735        infixExpression.setLeftOperand(leftExpression);
2736        infixExpression.setRightOperand(convert(expression.right));
2737        infixExpression.setOperator(InfixExpression.Operator.CONDITIONAL_OR);
2738         setInfixSourcePositions(infixExpressionexpression.sourceStart);
2739        return infixExpression;
2740    }
2741
2742    private void setInfixSourcePositions(InfixExpression infixExpressionint sourceStart) {
2743        int n = infixExpression.extendedOperands().size();
2744        Expression rightMostExp = n <= 0 ? infixExpression.getRightOperand() : (ExpressioninfixExpression.extendedOperands().get(n - 1);
2745        int rightSourceEnd = rightMostExp.getStartPosition() + rightMostExp.getLength() - 1;
2746        int infixSourceEnd = infixExpression.getStartPosition() + infixExpression.getLength() - 1;
2747        infixSourceEnd = rightSourceEnd > infixSourceEnd ? rightSourceEnd : infixSourceEnd;
2748        infixExpression.setSourceRange(sourceStartinfixSourceEnd - sourceStart + 1);
2749    }
2750
2751    public PostfixExpression convert(org.eclipse.jdt.internal.compiler.ast.PostfixExpression expression) {
2752        final PostfixExpression postfixExpression = new PostfixExpression(this.ast);
2753        if (this.resolveBindings) {
2754            recordNodes(postfixExpressionexpression);
2755        }
2756        postfixExpression.setSourceRange(expression.sourceStartexpression.sourceEnd - expression.sourceStart + 1);
2757        postfixExpression.setOperand(convert(expression.lhs));
2758        switch (expression.operator) {
2759            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS :
2760                postfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
2761                break;
2762            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS :
2763                postfixExpression.setOperator(PostfixExpression.Operator.DECREMENT);
2764                break;
2765        }
2766        return postfixExpression;
2767    }
2768
2769    public Pattern convert(org.eclipse.jdt.internal.compiler.ast.Pattern pattern) {
2770            if (!DOMASTUtil.isPatternSupported(this.ast)) {
2771                return createFakeNullPattern(pattern);
2772            }
2773            if (pattern instanceof org.eclipse.jdt.internal.compiler.ast.GuardedPattern) {
2774                return convert((org.eclipse.jdt.internal.compiler.ast.GuardedPatternpattern);
2775            }
2776            if (pattern instanceof org.eclipse.jdt.internal.compiler.ast.TypePattern) {
2777                return convert((org.eclipse.jdt.internal.compiler.ast.TypePatternpattern);
2778            }
2779
2780            return null;
2781    }
2782
2783    public PrefixExpression convert(org.eclipse.jdt.internal.compiler.ast.PrefixExpression expression) {
2784        final PrefixExpression prefixExpression = new PrefixExpression(this.ast);
2785        if (this.resolveBindings) {
2786            recordNodes(prefixExpressionexpression);
2787        }
2788        prefixExpression.setSourceRange(expression.sourceStartexpression.sourceEnd - expression.sourceStart + 1);
2789        prefixExpression.setOperand(convert(expression.lhs));
2790        switch (expression.operator) {
2791            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS :
2792                prefixExpression.setOperator(PrefixExpression.Operator.INCREMENT);
2793                break;
2794            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS :
2795                prefixExpression.setOperator(PrefixExpression.Operator.DECREMENT);
2796                break;
2797        }
2798        return prefixExpression;
2799    }
2800
2801    public Expression convert(org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression allocation) {
2802        final ClassInstanceCreation classInstanceCreation = new ClassInstanceCreation(this.ast);
2803        if (allocation.enclosingInstance != null) {
2804            classInstanceCreation.setExpression(convert(allocation.enclosingInstance));
2805        }
2806        switch(this.ast.apiLevel) {
2807            case AST.JLS2_INTERNAL :
2808                classInstanceCreation.internalSetName(convert(allocation.type));
2809                break;
2810            default :
2811                classInstanceCreation.setType(convertType(allocation.type));
2812        }
2813        org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = allocation.arguments;
2814        if (arguments != null) {
2815            int length = arguments.length;
2816            for (int i = 0i < lengthi++) {
2817                Expression argument = convert(arguments[i]);
2818                if (this.resolveBindings) {
2819                    recordNodes(argumentarguments[i]);
2820                }
2821                classInstanceCreation.arguments().add(argument);
2822            }
2823        }
2824        if (allocation.typeArguments != null) {
2825            switch(this.ast.apiLevel) {
2826                case AST.JLS2_INTERNAL :
2827                    classInstanceCreation.setFlags(classInstanceCreation.getFlags() | ASTNode.MALFORMED);
2828                    break;
2829                default :
2830                    for (int i = 0max = allocation.typeArguments.lengthi < maxi++) {
2831                        classInstanceCreation.typeArguments().add(convertType(allocation.typeArguments[i]));
2832                    }
2833            }
2834        }
2835        if (allocation.anonymousType != null) {
2836            int declarationSourceStart = allocation.sourceStart;
2837            classInstanceCreation.setSourceRange(declarationSourceStartallocation.anonymousType.bodyEnd - declarationSourceStart + 1);
2838            final AnonymousClassDeclaration anonymousClassDeclaration = new AnonymousClassDeclaration(this.ast);
2839            int start = retrieveStartBlockPosition(allocation.anonymousType.sourceEndallocation.anonymousType.bodyEnd);
2840            anonymousClassDeclaration.setSourceRange(startallocation.anonymousType.bodyEnd - start + 1);
2841            classInstanceCreation.setAnonymousClassDeclaration(anonymousClassDeclaration);
2842            buildBodyDeclarations(allocation.anonymousTypeanonymousClassDeclaration);
2843            if (this.resolveBindings) {
2844                recordNodes(classInstanceCreationallocation.anonymousType);
2845                recordNodes(anonymousClassDeclarationallocation.anonymousType);
2846                anonymousClassDeclaration.resolveBinding();
2847            }
2848            return classInstanceCreation;
2849        } else {
2850            final int start = allocation.sourceStart;
2851            classInstanceCreation.setSourceRange(startallocation.sourceEnd - start + 1);
2852            if (this.resolveBindings) {
2853                recordNodes(classInstanceCreationallocation);
2854            }
2855            return classInstanceCreation;
2856        }
2857    }
2858
2859    public Name convert(org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference nameReference) {
2860        return setQualifiedNameNameAndSourceRanges(nameReference.tokensnameReference.sourcePositionsnameReference);
2861    }
2862
2863    public Name convert(org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference reference) {
2864        return convert(reference.qualification);
2865    }
2866
2867    public ThisExpression convert(org.eclipse.jdt.internal.compiler.ast.QualifiedThisReference reference) {
2868        final ThisExpression thisExpression = new ThisExpression(this.ast);
2869        thisExpression.setSourceRange(reference.sourceStartreference.sourceEnd - reference.sourceStart + 1);
2870        thisExpression.setQualifier(convert(reference.qualification));
2871        if (this.resolveBindings) {
2872            recordNodes(thisExpressionreference);
2873            recordPendingThisExpressionScopeResolution(thisExpression);
2874        }
2875        return thisExpression;
2876    }
2877
2878    public Expression convert(org.eclipse.jdt.internal.compiler.ast.Reference reference) {
2879        if (reference instanceof org.eclipse.jdt.internal.compiler.ast.NameReference) {
2880            return convert((org.eclipse.jdt.internal.compiler.ast.NameReferencereference);
2881        }
2882        if (reference instanceof org.eclipse.jdt.internal.compiler.ast.ThisReference) {
2883            return convert((org.eclipse.jdt.internal.compiler.ast.ThisReferencereference);
2884        }
2885        if (reference instanceof org.eclipse.jdt.internal.compiler.ast.ArrayReference) {
2886            return convert((org.eclipse.jdt.internal.compiler.ast.ArrayReferencereference);
2887        }
2888        if (reference instanceof org.eclipse.jdt.internal.compiler.ast.FieldReference) {
2889            return convert((org.eclipse.jdt.internal.compiler.ast.FieldReferencereference);
2890        }
2891        return null// cannot be reached
2892    }
2893
2894    public Expression convert(org.eclipse.jdt.internal.compiler.ast.ReferenceExpression reference) {
2895        if (this.ast.apiLevel < AST.JLS8_INTERNAL) {
2896            return createFakeNullLiteral(reference);
2897        }
2898        Expression result = null;
2899        org.eclipse.jdt.internal.compiler.ast.Expression lhs = reference.lhs;
2900        org.eclipse.jdt.internal.compiler.ast.TypeReference[] arguments = reference.typeArguments;
2901        int start = arguments != null && arguments.length > 0 ? arguments[arguments.length - 1].sourceEnd + 1 : reference.lhs.sourceEnd + 1;
2902        final SimpleName name = new SimpleName(this.ast);
2903        retrieveIdentifierAndSetPositions(startreference.sourceEndname);
2904        name.internalSetIdentifier(new String(reference.selector));
2905        if (this.resolveBindings) {
2906            recordNodes(namereference);
2907        }
2908        List typeArguments = null;
2909        if (name.getStartPosition() == -1 && name.getIdentifier().equals("<init>")) { // check for "new"  //$NON-NLS-1$
2910            retrieveInitAndSetPositions(startreference.sourceEndname);
2911            Type type = null;
2912            if (lhs instanceof TypeReference) {
2913                type = convertType((TypeReferencelhs);
2914            } else if (lhs instanceof NameReference) {
2915                Name typeName = convert((NameReferencelhs);
2916                SimpleType simpleType = new SimpleType(this.ast);
2917                simpleType.setName(typeName);
2918                if (this.resolveBindings) {
2919                    recordNodes(simpleTypelhs);
2920                }
2921                simpleType.setSourceRange(lhs.sourceStartlhs.sourceEnd - lhs.sourceStart + 1);
2922                type = simpleType;
2923            }
2924            CreationReference creationReference = new CreationReference(this.ast);
2925            creationReference.setType(type);
2926            typeArguments = creationReference.typeArguments();
2927            result = creationReference;
2928        } else if (lhs instanceof TypeReference) {
2929            TypeMethodReference typeMethodReference = new TypeMethodReference(this.ast);
2930            typeMethodReference.setType(convertType((TypeReferencelhs));
2931            typeMethodReference.setName(name);
2932            typeArguments = typeMethodReference.typeArguments();
2933            result = typeMethodReference;
2934        } else if (lhs instanceof SuperReference) {
2935            SuperMethodReference superMethodReference = new SuperMethodReference(this.ast);
2936            superMethodReference.setName(name);
2937            typeArguments = superMethodReference.typeArguments();
2938            result = superMethodReference;
2939        } else if (lhs instanceof QualifiedSuperReference) {
2940            SuperMethodReference superMethodReference = new SuperMethodReference(this.ast);
2941            superMethodReference.setQualifier(convert((QualifiedSuperReference)lhs));
2942            superMethodReference.setName(name);
2943            typeArguments = superMethodReference.typeArguments();
2944            result = superMethodReference;
2945        } else {
2946            ExpressionMethodReference expressionMethodReference = new ExpressionMethodReference(this.ast);
2947            expressionMethodReference.setExpression(convert(lhs));
2948            typeArguments = expressionMethodReference.typeArguments();
2949            expressionMethodReference.setName(name);
2950            result = expressionMethodReference;
2951        }
2952        if (typeArguments != null && arguments != null) {
2953            int argumentsLength = arguments.length;
2954            for (int i = 0i < argumentsLengthi++) {
2955                org.eclipse.jdt.internal.compiler.ast.TypeReference argument = arguments[i];
2956                typeArguments.add(convertType(argument));
2957            }
2958        }
2959        if (this.resolveBindings) {
2960            recordNodes(resultreference);
2961        }
2962        int sourceStart = reference.sourceStart;
2963        result.setSourceRange(sourceStartreference.sourceEnd - sourceStart + 1);
2964        return result;
2965    }
2966
2967
2968    public ReturnStatement convert(org.eclipse.jdt.internal.compiler.ast.ReturnStatement statement) {
2969        final ReturnStatement returnStatement = new ReturnStatement(this.ast);
2970        returnStatement.setSourceRange(statement.sourceStartstatement.sourceEnd - statement.sourceStart + 1);
2971        if (statement.expression != null) {
2972            returnStatement.setExpression(convert(statement.expression));
2973        }
2974        return returnStatement;
2975    }
2976
2977    public SingleMemberAnnotation convert(org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation annotation) {
2978        final SingleMemberAnnotation singleMemberAnnotation = new SingleMemberAnnotation(this.ast);
2979        setTypeNameForAnnotation(annotationsingleMemberAnnotation);
2980        singleMemberAnnotation.setValue(convert(annotation.memberValue));
2981        int start = annotation.sourceStart;
2982        int end = annotation.declarationSourceEnd;
2983        singleMemberAnnotation.setSourceRange(startend - start + 1);
2984        if (this.resolveBindings) {
2985            recordNodes(singleMemberAnnotationannotation);
2986            singleMemberAnnotation.resolveAnnotationBinding();
2987        }
2988        return singleMemberAnnotation;
2989    }
2990
2991    public SimpleName convert(org.eclipse.jdt.internal.compiler.ast.SingleNameReference nameReference) {
2992        final SimpleName name = new SimpleName(this.ast);
2993        name.internalSetIdentifier(new String(nameReference.token));
2994        if (this.resolveBindings) {
2995            recordNodes(namenameReference);
2996        }
2997        name.setSourceRange(nameReference.sourceStartnameReference.sourceEnd - nameReference.sourceStart + 1);
2998        return name;
2999    }
3000
3001    public Statement convert(org.eclipse.jdt.internal.compiler.ast.Statement statement) {
3002        if (statement instanceof ForeachStatement) {
3003            return convert((ForeachStatementstatement);
3004        }
3005        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) {
3006            org.eclipse.jdt.internal.compiler.ast.LocalDeclaration localDeclaration = (org.eclipse.jdt.internal.compiler.ast.LocalDeclaration)statement;
3007            return convertToVariableDeclarationStatement(localDeclaration);
3008        }
3009        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.AssertStatement) {
3010            return convert((org.eclipse.jdt.internal.compiler.ast.AssertStatementstatement);
3011        }
3012        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.Block) {
3013            return convert((org.eclipse.jdt.internal.compiler.ast.Blockstatement);
3014        }
3015        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.BreakStatement) {
3016            return convert((org.eclipse.jdt.internal.compiler.ast.BreakStatementstatement);
3017        }
3018        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.ContinueStatement) {
3019            return convert((org.eclipse.jdt.internal.compiler.ast.ContinueStatementstatement);
3020        }
3021        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.CaseStatement) {
3022            return convert((org.eclipse.jdt.internal.compiler.ast.CaseStatementstatement);
3023        }
3024        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.DoStatement) {
3025            return convert((org.eclipse.jdt.internal.compiler.ast.DoStatementstatement);
3026        }
3027        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.EmptyStatement) {
3028            return convert((org.eclipse.jdt.internal.compiler.ast.EmptyStatementstatement);
3029        }
3030        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall) {
3031            return convert((org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCallstatement);
3032        }
3033        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.ForStatement) {
3034            return convert((org.eclipse.jdt.internal.compiler.ast.ForStatementstatement);
3035        }
3036        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.IfStatement) {
3037            return convert((org.eclipse.jdt.internal.compiler.ast.IfStatementstatement);
3038        }
3039        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.LabeledStatement) {
3040            return convert((org.eclipse.jdt.internal.compiler.ast.LabeledStatementstatement);
3041        }
3042        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.ReturnStatement) {
3043            return convert((org.eclipse.jdt.internal.compiler.ast.ReturnStatementstatement);
3044        }
3045        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.SwitchStatement) {
3046            return convert((org.eclipse.jdt.internal.compiler.ast.SwitchStatementstatement);
3047        }
3048        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.SynchronizedStatement) {
3049            return convert((org.eclipse.jdt.internal.compiler.ast.SynchronizedStatementstatement);
3050        }
3051        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.ThrowStatement) {
3052            return convert((org.eclipse.jdt.internal.compiler.ast.ThrowStatementstatement);
3053        }
3054        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.TryStatement) {
3055            return convert((org.eclipse.jdt.internal.compiler.ast.TryStatementstatement);
3056        }
3057        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) {
3058            ASTNode result = convert((org.eclipse.jdt.internal.compiler.ast.TypeDeclarationstatement);
3059            if (result == null || !(result instanceof TypeDeclaration || result instanceof RecordDeclaration || result instanceof EnumDeclaration)) {
3060                return createFakeEmptyStatement(statement);
3061            }
3062            TypeDeclarationStatement typeDeclarationStatement = new TypeDeclarationStatement(this.ast);
3063            if (result instanceof TypeDeclaration) {
3064                // annotation and enum type declarations are not returned by the parser inside method bodies
3065                TypeDeclaration typeDeclaration = (TypeDeclarationresult;
3066                typeDeclarationStatement.setDeclaration(typeDeclaration);
3067            } else if (result instanceof RecordDeclaration) {
3068                RecordDeclaration recordDeclaration = (RecordDeclarationresult;
3069                typeDeclarationStatement.setDeclaration(recordDeclaration);
3070            } else {
3071                EnumDeclaration enumDeclaration = (EnumDeclarationresult;
3072                typeDeclarationStatement.setDeclaration(enumDeclaration);
3073            }
3074            switch(this.ast.apiLevel) {
3075                case AST.JLS2_INTERNAL :
3076                    TypeDeclaration typeDecl = typeDeclarationStatement.internalGetTypeDeclaration();
3077                    typeDeclarationStatement.setSourceRange(typeDecl.getStartPosition(), typeDecl.getLength());
3078                    break;
3079                default :
3080                    AbstractTypeDeclaration typeDeclAST3 = typeDeclarationStatement.getDeclaration();
3081                    typeDeclarationStatement.setSourceRange(typeDeclAST3.getStartPosition(), typeDeclAST3.getLength());
3082                    break;
3083            }
3084            return typeDeclarationStatement;
3085        }
3086        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.WhileStatement) {
3087            return convert((org.eclipse.jdt.internal.compiler.ast.WhileStatementstatement);
3088        }
3089        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.YieldStatement) {
3090            return convert((org.eclipse.jdt.internal.compiler.ast.YieldStatementstatement);
3091        }
3092        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.Expression &&
3093                ((org.eclipse.jdt.internal.compiler.ast.Expressionstatement).isTrulyExpression()) {
3094            org.eclipse.jdt.internal.compiler.ast.Expression statement2 = (org.eclipse.jdt.internal.compiler.ast.Expressionstatement;
3095            final Expression expr = convert(statement2);
3096            final ExpressionStatement stmt = new ExpressionStatement(this.ast);
3097            stmt.setExpression(expr);
3098            int sourceStart = expr.getStartPosition();
3099            int sourceEnd = statement2.statementEnd;
3100            stmt.setSourceRange(sourceStartsourceEnd - sourceStart + 1);
3101            return stmt;
3102        }
3103        return createFakeEmptyStatement(statement);
3104    }
3105
3106    public Expression convert(org.eclipse.jdt.internal.compiler.ast.StringLiteral expression) {
3107        if (expression instanceof StringLiteralConcatenation) {
3108            return convert((StringLiteralConcatenationexpression);
3109        }
3110        int length = expression.sourceEnd - expression.sourceStart + 1;
3111        int sourceStart = expression.sourceStart;
3112        StringLiteral literal = new StringLiteral(this.ast);
3113        if (this.resolveBindings) {
3114            this.recordNodes(literalexpression);
3115        }
3116        literal.internalSetEscapedValue(new String(this.compilationUnitSourcesourceStartlength));
3117        literal.setSourceRange(expression.sourceStartexpression.sourceEnd - expression.sourceStart + 1);
3118        return literal;
3119    }
3120
3121    public Expression convert(org.eclipse.jdt.internal.compiler.ast.SwitchExpression expression) {
3122        if (this.ast.apiLevel < AST.JLS14_INTERNAL) {
3123            return createFakeNullLiteral(expression);
3124        }
3125        SwitchExpression switchExpression = new SwitchExpression(this.ast);
3126        if (this.resolveBindings) {
3127            recordNodes(switchExpressionexpression);
3128        }
3129        switchExpression.setSourceRange(expression.sourceStartexpression.sourceEnd - expression.sourceStart + 1);
3130        switchExpression.setExpression(convert(expression.expression));
3131        org.eclipse.jdt.internal.compiler.ast.Statement[] statements = expression.statements;
3132        if (statements != null) {
3133            int statementsLength = statements.length;
3134            for (int i = 0i < statementsLengthi++) {
3135                if (statements[i] instanceof org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) {
3136                    checkAndAddMultipleLocalDeclaration(statementsiswitchExpression.statements());
3137                } else {
3138                    final Statement currentStatement = convert(statements[i]);
3139                    if (currentStatement != null) {
3140                        switchExpression.statements().add(currentStatement);
3141                    }
3142                }
3143            }
3144        }
3145        return switchExpression;
3146    }
3147
3148    public SwitchStatement convert(org.eclipse.jdt.internal.compiler.ast.SwitchStatement statement) {
3149        SwitchStatement switchStatement = new SwitchStatement(this.ast);
3150        switchStatement.setSourceRange(statement.sourceStartstatement.sourceEnd - statement.sourceStart + 1);
3151        switchStatement.setExpression(convert(statement.expression));
3152        org.eclipse.jdt.internal.compiler.ast.Statement[] statements = statement.statements;
3153        if (statements != null) {
3154            int statementsLength = statements.length;
3155            for (int i = 0i < statementsLengthi++) {
3156                if (statements[i] instanceof org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) {
3157                    checkAndAddMultipleLocalDeclaration(statementsiswitchStatement.statements());
3158                } else {
3159                    final Statement currentStatement = convert(statements[i]);
3160                    if (currentStatement != null) {
3161                        switchStatement.statements().add(currentStatement);
3162                    }
3163                }
3164            }
3165        }
3166        return switchStatement;
3167    }
3168
3169    public SynchronizedStatement convert(org.eclipse.jdt.internal.compiler.ast.SynchronizedStatement statement) {
3170        SynchronizedStatement synchronizedStatement = new SynchronizedStatement(this.ast);
3171        synchronizedStatement.setSourceRange(statement.sourceStartstatement.sourceEnd - statement.sourceStart + 1);
3172        synchronizedStatement.setBody(convert(statement.block));
3173        synchronizedStatement.setExpression(convert(statement.expression));
3174        return synchronizedStatement;
3175    }
3176
3177    public Expression convert(org.eclipse.jdt.internal.compiler.ast.TextBlock expression) {
3178        if (this.ast.apiLevel < AST.JLS15_INTERNAL) {
3179            return createFakeNullLiteral(expression);
3180        }
3181        int length = expression.sourceEnd - expression.sourceStart + 1;
3182        int sourceStart = expression.sourceStart;
3183        TextBlock literal = new TextBlock(this.ast);
3184        if (this.resolveBindings) {
3185            this.recordNodes(literalexpression);
3186        }
3187        literal.internalSetEscapedValue(
3188                new String(this.compilationUnitSourcesourceStartlength),
3189                new String(expression.source()));
3190        literal.setSourceRange(expression.sourceStartexpression.sourceEnd - expression.sourceStart + 1);
3191        return literal;
3192    }
3193
3194    public Expression convert(org.eclipse.jdt.internal.compiler.ast.ThisReference reference) {
3195        if (reference.isImplicitThis()) {
3196            // There is no source associated with an implicit this
3197            return null;
3198        } else if (reference instanceof org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference) {
3199            return convert((org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReferencereference);
3200        } else if (reference instanceof org.eclipse.jdt.internal.compiler.ast.QualifiedThisReference) {
3201            return convert((org.eclipse.jdt.internal.compiler.ast.QualifiedThisReferencereference);
3202        }  else {
3203            ThisExpression thisExpression = new ThisExpression(this.ast);
3204            thisExpression.setSourceRange(reference.sourceStartreference.sourceEnd - reference.sourceStart + 1);
3205            if (this.resolveBindings) {
3206                recordNodes(thisExpressionreference);
3207                recordPendingThisExpressionScopeResolution(thisExpression);
3208            }
3209            return thisExpression;
3210        }
3211    }
3212
3213    public ThrowStatement convert(org.eclipse.jdt.internal.compiler.ast.ThrowStatement statement) {
3214        final ThrowStatement throwStatement = new ThrowStatement(this.ast);
3215        throwStatement.setSourceRange(statement.sourceStartstatement.sourceEnd - statement.sourceStart + 1);
3216        throwStatement.setExpression(convert(statement.exception));
3217        return throwStatement;
3218    }
3219
3220    public BooleanLiteral convert(org.eclipse.jdt.internal.compiler.ast.TrueLiteral expression) {
3221        final BooleanLiteral literal = new BooleanLiteral(this.ast);
3222        literal.setBooleanValue(true);
3223        if (this.resolveBindings) {
3224            this.recordNodes(literalexpression);
3225        }
3226        literal.setSourceRange(expression.sourceStartexpression.sourceEnd - expression.sourceStart + 1);
3227        return literal;
3228    }
3229
3230    public TryStatement convert(org.eclipse.jdt.internal.compiler.ast.TryStatement statement) {
3231        final TryStatement tryStatement = new TryStatement(this.ast);
3232        tryStatement.setSourceRange(statement.sourceStartstatement.sourceEnd - statement.sourceStart + 1);
3233        int resourcesLength = statement.resources.length;
3234        if (resourcesLength > 0) {
3235            switch(this.ast.apiLevel) {
3236                case AST.JLS2_INTERNAL :
3237                case AST.JLS3_INTERNAL :
3238                    // convert it to a simple try statement tagged as MALFORMED
3239                    tryStatement.setFlags(tryStatement.getFlags() | ASTNode.MALFORMED);
3240                    break;
3241                case AST.JLS4_INTERNAL:
3242                case AST.JLS8_INTERNAL:
3243                    for (int i = 0i < resourcesLengthi++) {
3244                        if (!(statement.resources[i] instanceof LocalDeclaration)) {
3245                            tryStatement.setFlags(tryStatement.getFlags() | ASTNode.MALFORMED);
3246                            break;
3247                        }
3248                        LocalDeclaration localDeclaration = (LocalDeclaration)statement.resources[i];
3249                        VariableDeclarationExpression variableDeclarationExpression = convertToVariableDeclarationExpression(localDeclaration);
3250                        int start = variableDeclarationExpression.getStartPosition();
3251                        int end = localDeclaration.declarationEnd;
3252                        variableDeclarationExpression.setSourceRange(startend - start + 1);
3253                        tryStatement.resources().add(variableDeclarationExpression);
3254                    }
3255                    break;
3256                default:
3257                    for (int i = 0i < resourcesLengthi++) {
3258                        org.eclipse.jdt.internal.compiler.ast.Statement resource = statement.resources[i];
3259                        if (resource instanceof LocalDeclaration) {
3260                            LocalDeclaration localDeclaration = (LocalDeclaration)resource;
3261                            VariableDeclarationExpression variableDeclarationExpression = convertToVariableDeclarationExpression(localDeclaration);
3262                            int start = variableDeclarationExpression.getStartPosition();
3263                            int end = localDeclaration.declarationEnd;
3264                            variableDeclarationExpression.setSourceRange(startend - start + 1);
3265                            tryStatement.resources().add(variableDeclarationExpression);
3266                        } else if (resource instanceof NameReference) {
3267                            tryStatement.resources().add(convert((NameReferenceresource));
3268                        } else if (resource instanceof FieldReference) {
3269                            tryStatement.resources().add(convert((FieldReferenceresource));
3270                        } else {
3271                            tryStatement.setFlags(tryStatement.getFlags() | ASTNode.MALFORMED);
3272                            break;
3273                        }
3274                    }
3275                    break;
3276            }
3277        }
3278        tryStatement.setBody(convert(statement.tryBlock));
3279        org.eclipse.jdt.internal.compiler.ast.Argument[] catchArguments = statement.catchArguments;
3280        if (catchArguments != null) {
3281            int catchArgumentsLength = catchArguments.length;
3282            org.eclipse.jdt.internal.compiler.ast.Block[] catchBlocks = statement.catchBlocks;
3283            int start = statement.tryBlock.sourceEnd;
3284            for (int i = 0i < catchArgumentsLengthi++) {
3285                CatchClause catchClause = new CatchClause(this.ast);
3286                int catchClauseSourceStart = retrieveStartingCatchPosition(startcatchArguments[i].sourceStart);
3287                catchClause.setSourceRange(catchClauseSourceStartcatchBlocks[i].sourceEnd - catchClauseSourceStart + 1);
3288                catchClause.setBody(convert(catchBlocks[i]));
3289                catchClause.setException(convert(catchArguments[i]));
3290                tryStatement.catchClauses().add(catchClause);
3291                start = catchBlocks[i].sourceEnd;
3292            }
3293        }
3294        if (statement.finallyBlock != null) {
3295            tryStatement.setFinally(convert(statement.finallyBlock));
3296        }
3297        return tryStatement;
3298    }
3299
3300    public ASTNode convert(org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) {
3301        int kind = org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.kind(typeDeclaration.modifiers);
3302        switch (kind) {
3303            case org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.ENUM_DECL :
3304                if (this.ast.apiLevel == AST.JLS2_INTERNAL) {
3305                    return null;
3306                } else {
3307                    return convertToEnumDeclaration(typeDeclaration);
3308                }
3309            case org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.ANNOTATION_TYPE_DECL :
3310                if (this.ast.apiLevel == AST.JLS2_INTERNAL) {
3311                    return null;
3312                } else {
3313                    return convertToAnnotationDeclaration(typeDeclaration);
3314                }
3315        }
3316        if (typeDeclaration.isRecord()) {
3317            if (!DOMASTUtil.isRecordDeclarationSupported(this.ast)) {
3318                return null;
3319            }
3320            return convertToRecordDeclaration(typeDeclaration);
3321        }
3322        checkCanceled();
3323        TypeDeclaration typeDecl = new TypeDeclaration(this.ast);
3324        ASTNode oldReferenceContext = this.referenceContext;
3325        this.referenceContext = typeDecl;
3326        if (typeDeclaration.modifiersSourceStart != -1) {
3327            setModifiers(typeDecltypeDeclaration);
3328        }
3329        boolean isInterface = kind == org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.INTERFACE_DECL;
3330        typeDecl.setInterface(isInterface);
3331        final SimpleName typeName = new SimpleName(this.ast);
3332        typeName.internalSetIdentifier(new String(typeDeclaration.name));
3333        typeName.setSourceRange(typeDeclaration.sourceStarttypeDeclaration.sourceEnd - typeDeclaration.sourceStart + 1);
3334        typeDecl.setName(typeName);
3335        typeDecl.setSourceRange(typeDeclaration.declarationSourceStarttypeDeclaration.bodyEnd - typeDeclaration.declarationSourceStart + 1);
3336
3337        // need to set the superclass and super interfaces here since we cannot distinguish them at
3338        // the type references level.
3339        if (typeDeclaration.superclass != null) {
3340            switch(this.ast.apiLevel) {
3341                case AST.JLS2_INTERNAL :
3342                    typeDecl.internalSetSuperclass(convert(typeDeclaration.superclass));
3343                    break;
3344                default :
3345                    typeDecl.setSuperclassType(convertType(typeDeclaration.superclass));
3346                    break;
3347            }
3348        }
3349
3350        org.eclipse.jdt.internal.compiler.ast.TypeReference[] superInterfaces = typeDeclaration.superInterfaces;
3351        if (superInterfaces != null) {
3352            switch(this.ast.apiLevel) {
3353                case AST.JLS2_INTERNAL :
3354                    for (int index = 0length = superInterfaces.lengthindex < lengthindex++) {
3355                        typeDecl.internalSuperInterfaces().add(convert(superInterfaces[index]));
3356                    }
3357                    break;
3358                default :
3359                    for (int index = 0length = superInterfaces.lengthindex < lengthindex++) {
3360                        typeDecl.superInterfaceTypes().add(convertType(superInterfaces[index]));
3361                    }
3362            }
3363        }
3364        org.eclipse.jdt.internal.compiler.ast.TypeParameter[] typeParameters = typeDeclaration.typeParameters;
3365        if (typeParameters != null) {
3366            switch(this.ast.apiLevel) {
3367                case AST.JLS2_INTERNAL :
3368                    typeDecl.setFlags(typeDecl.getFlags() | ASTNode.MALFORMED);
3369                    break;
3370                default :
3371                    for (int index = 0length = typeParameters.lengthindex < lengthindex++) {
3372                        typeDecl.typeParameters().add(convert(typeParameters[index]));
3373                    }
3374            }
3375        }
3376        org.eclipse.jdt.internal.compiler.ast.TypeReference[] permittedTypes = typeDeclaration.permittedTypes;
3377        if (permittedTypes != null) {
3378            if (DOMASTUtil.isFeatureSupportedinAST(this.astModifier.SEALED)) {
3379                for (int index = 0length = permittedTypes.lengthindex < lengthindex++) {
3380                    Type convertType = convertType(permittedTypes[index]);
3381                    if (convertType != null) {
3382                        typeDecl.permittedTypes().add(convertType);
3383                    }
3384                }
3385                if (permittedTypes.length > 0 && typeDeclaration.restrictedIdentifierStart >= 0) {
3386                    typeDecl.setRestrictedIdentifierStartPosition(typeDeclaration.restrictedIdentifierStart);
3387                }
3388            }
3389        }
3390        buildBodyDeclarations(typeDeclarationtypeDeclisInterface);
3391        if (this.resolveBindings) {
3392            recordNodes(typeDecltypeDeclaration);
3393            recordNodes(typeNametypeDeclaration);
3394            typeDecl.resolveBinding();
3395        }
3396        this.referenceContext = oldReferenceContext;
3397        return typeDecl;
3398    }
3399
3400    public TypeParameter convert(org.eclipse.jdt.internal.compiler.ast.TypeParameter typeParameter) {
3401        final TypeParameter typeParameter2 = new TypeParameter(this.ast);
3402        final SimpleName simpleName = new SimpleName(this.ast);
3403        simpleName.internalSetIdentifier(new String(typeParameter.name));
3404        int start = typeParameter.sourceStart;
3405        int end = typeParameter.sourceEnd;
3406        simpleName.setSourceRange(startend - start + 1);
3407        typeParameter2.setName(simpleName);
3408        int annotationsStart = start;
3409        org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = typeParameter.annotations;
3410        if (annotations != null) {
3411            if (annotations[0] != null)
3412                annotationsStart = annotations[0].sourceStart;
3413            annotateTypeParameter(typeParameter2typeParameter.annotations);
3414        }
3415        final TypeReference superType = typeParameter.type;
3416        end = typeParameter.declarationSourceEnd;
3417        if (superType != null) {
3418            Type type = convertType(superType);
3419            typeParameter2.typeBounds().add(type);
3420            end = type.getStartPosition() + type.getLength() - 1;
3421        }
3422        TypeReference[] bounds = typeParameter.bounds;
3423        if (bounds != null) {
3424            Type type = null;
3425            for (int index = 0length = bounds.lengthindex < lengthindex++) {
3426                type = convertType(bounds[index]);
3427                typeParameter2.typeBounds().add(type);
3428                end = type.getStartPosition() + type.getLength() - 1;
3429            }
3430        }
3431        start = annotationsStart < typeParameter.declarationSourceStart ? annotationsStart : typeParameter.declarationSourceStart;
3432        end = retrieveClosingAngleBracketPosition(end);
3433        typeParameter2.setSourceRange(startend - start + 1);
3434        if (this.resolveBindings) {
3435            recordName(simpleNametypeParameter);
3436            recordNodes(typeParameter2typeParameter);
3437            typeParameter2.resolveBinding();
3438        }
3439        return typeParameter2;
3440    }
3441
3442    public Pattern convert(org.eclipse.jdt.internal.compiler.ast.TypePattern pattern) {
3443        TypePattern typePattern = new TypePattern(this.ast);
3444        if (this.resolveBindings) {
3445            recordNodes(typePatternpattern);
3446        }
3447        if (pattern.local == null) {
3448            return createFakeNullPattern(pattern);
3449        }
3450        typePattern.setPatternVariable(convertToSingleVariableDeclaration(pattern.local));
3451        int startPosition = pattern.local.declarationSourceStart;
3452        int sourceEndpattern.sourceEnd;
3453        typePattern.setSourceRange(startPositionsourceEnd - startPosition + 1);
3454        return typePattern;
3455    }
3456
3457    public Name convert(org.eclipse.jdt.internal.compiler.ast.TypeReference typeReference) {
3458        char[][] typeName = typeReference.getTypeName();
3459        int length = typeName.length;
3460        if (length > 1) {
3461            // QualifiedName
3462            org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference qualifiedTypeReference = (org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReferencetypeReference;
3463            final long[] positions = qualifiedTypeReference.sourcePositions;
3464            return setQualifiedNameNameAndSourceRanges(typeNamepositionstypeReference);
3465        } else {
3466            final SimpleName name = new SimpleName(this.ast);
3467            name.internalSetIdentifier(new String(typeName[0]));
3468            name.setSourceRange(typeReference.sourceStarttypeReference.sourceEnd - typeReference.sourceStart + 1);
3469            name.index = 1;
3470            if (this.resolveBindings) {
3471                recordNodes(nametypeReference);
3472            }
3473            return name;
3474        }
3475    }
3476
3477    public PrefixExpression convert(org.eclipse.jdt.internal.compiler.ast.UnaryExpression expression) {
3478        final PrefixExpression prefixExpression = new PrefixExpression(this.ast);
3479        if (this.resolveBindings) {
3480            this.recordNodes(prefixExpressionexpression);
3481        }
3482        prefixExpression.setSourceRange(expression.sourceStartexpression.sourceEnd - expression.sourceStart + 1);
3483        prefixExpression.setOperand(convert(expression.expression));
3484        switch ((expression.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT) {
3485            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS :
3486                prefixExpression.setOperator(PrefixExpression.Operator.PLUS);
3487                break;
3488            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS :
3489                prefixExpression.setOperator(PrefixExpression.Operator.MINUS);
3490                break;
3491            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.NOT :
3492                prefixExpression.setOperator(PrefixExpression.Operator.NOT);
3493                break;
3494            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.TWIDDLE :
3495                prefixExpression.setOperator(PrefixExpression.Operator.COMPLEMENT);
3496        }
3497        return prefixExpression;
3498    }
3499
3500    public WhileStatement convert(org.eclipse.jdt.internal.compiler.ast.WhileStatement statement) {
3501        final WhileStatement whileStatement = new WhileStatement(this.ast);
3502        whileStatement.setSourceRange(statement.sourceStartstatement.sourceEnd - statement.sourceStart + 1);
3503        whileStatement.setExpression(convert(statement.condition));
3504        final Statement action = convert(statement.action);
3505        if (action == null) return null;
3506        whileStatement.setBody(action);
3507        return whileStatement;
3508    }
3509
3510    public Statement convert(org.eclipse.jdt.internal.compiler.ast.YieldStatement statement) {
3511        if (this.ast.apiLevel < AST.JLS14_INTERNAL) {
3512            return createFakeEmptyStatement(statement);
3513        }
3514        YieldStatement yieldStatement = new YieldStatement(this.ast);
3515        // We don't need to record Nodes
3516        yieldStatement.setExpression(convert(statement.expression));
3517        yieldStatement.setImplicit(statement.isImplicit);
3518        yieldStatement.setSourceRange(statement.sourceStartstatement.sourceEnd - statement.sourceStart + 1);
3519        return yieldStatement;
3520    }
3521
3522    public ImportDeclaration convertImport(org.eclipse.jdt.internal.compiler.ast.ImportReference importReference) {
3523        final ImportDeclaration importDeclaration = new ImportDeclaration(this.ast);
3524        Name name = getImportName(importReference);
3525        importDeclaration.setName(name);
3526        final boolean onDemand = (importReference.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.OnDemand) != 0;
3527        importDeclaration.setSourceRange(importReference.declarationSourceStartimportReference.declarationEnd - importReference.declarationSourceStart + 1);
3528        importDeclaration.setOnDemand(onDemand);
3529        int modifiers = importReference.modifiers;
3530        if (modifiers != ClassFileConstants.AccDefault) {
3531            switch(this.ast.apiLevel) {
3532                case AST.JLS2_INTERNAL :
3533                    importDeclaration.setFlags(importDeclaration.getFlags() | ASTNode.MALFORMED);
3534                    break;
3535                default :
3536                    if (modifiers == ClassFileConstants.AccStatic) {
3537                        importDeclaration.setStatic(true);
3538                    } else {
3539                        importDeclaration.setFlags(importDeclaration.getFlags() | ASTNode.MALFORMED);
3540                    }
3541            }
3542        }
3543        if (this.resolveBindings) {
3544            recordNodes(importDeclarationimportReference);
3545        }
3546        return importDeclaration;
3547    }
3548
3549    public Name getImportName(org.eclipse.jdt.internal.compiler.ast.ImportReference importReference) {
3550        return getName(importReferenceimportReference.tokensimportReference.sourcePositions);
3551    }
3552
3553    private Name getName(org.eclipse.jdt.internal.compiler.ast.ASTNode nodefinal char[][] tokens,
3554            final long[] positions) {
3555        Name name;
3556        int length = tokens != null ? tokens.length : 0;
3557        if (length > 1) {
3558            name = setQualifiedNameNameAndSourceRanges(tokenspositionsnode);
3559        } else {
3560            name = new SimpleName(this.ast);
3561            ((SimpleName)name).internalSetIdentifier(new String(tokens[0]));
3562            final int start = (int)(positions[0]>>>32);
3563            final int end = (int)(positions[0] & 0xFFFFFFFF);
3564            name.setSourceRange(startend - start + 1);
3565            name.index = 1;
3566            if (this.resolveBindings) {
3567                recordNodes(namenode);
3568            }
3569        }
3570        return name;
3571    }
3572
3573    public PackageDeclaration convertPackage(org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration compilationUnitDeclaration) {
3574        org.eclipse.jdt.internal.compiler.ast.ImportReference importReference = compilationUnitDeclaration.currentPackage;
3575        final PackageDeclaration packageDeclaration = new PackageDeclaration(this.ast);
3576        final char[][] tokens = importReference.tokens;
3577        final int length = importReference.tokens.length;
3578        long[] positions = importReference.sourcePositions;
3579        if (length > 1) {
3580            packageDeclaration.setName(setQualifiedNameNameAndSourceRanges(tokenspositionsimportReference));
3581        } else {
3582            final SimpleName name = new SimpleName(this.ast);
3583            name.internalSetIdentifier(new String(tokens[0]));
3584            int start = (int)(positions[0]>>>32);
3585            int end = (int)(positions[length - 1] & 0xFFFFFFFF);
3586            name.setSourceRange(startend - start + 1);
3587            name.index = 1;
3588            packageDeclaration.setName(name);
3589            if (this.resolveBindings) {
3590                recordNodes(namecompilationUnitDeclaration);
3591            }
3592        }
3593        packageDeclaration.setSourceRange(importReference.declarationSourceStartimportReference.declarationEnd - importReference.declarationSourceStart + 1);
3594        org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = importReference.annotations;
3595        if (annotations != null) {
3596            switch(this.ast.apiLevel) {
3597                case AST.JLS2_INTERNAL :
3598                    packageDeclaration.setFlags(packageDeclaration.getFlags() & ASTNode.MALFORMED);
3599                    break;
3600                default :
3601                    for (int i = 0max = annotations.lengthi < maxi++) {
3602                        packageDeclaration.annotations().add(convert(annotations[i]));
3603                    }
3604            }
3605        }
3606        if (this.resolveBindings) {
3607            recordNodes(packageDeclarationimportReference);
3608        }
3609        // Set javadoc
3610        convert(compilationUnitDeclaration.javadocpackageDeclaration);
3611        return packageDeclaration;
3612    }
3613
3614    private ArrayType convertToArray(Type elementTypeint sourceStartint lengthint dimensionsorg.eclipse.jdt.internal.compiler.ast.Annotation[][] annotationsOnDimensions) {
3615        ArrayType arrayType = this.ast.newArrayType(elementTypedimensions);
3616        if (length > 0arrayType.setSourceRange(sourceStartlength);
3617        if (this.ast.apiLevel() < AST.JLS8_INTERNAL) {
3618            if (annotationsOnDimensions != null) {
3619                arrayType.setFlags(arrayType.getFlags() | ASTNode.MALFORMED);
3620            }
3621            ArrayType subarrayType = arrayType;
3622            int index = dimensions - 1;
3623            int arrayEnd = retrieveProperRightBracketPosition(dimensionssourceStart);
3624            while (index > 0) {
3625                subarrayType = (ArrayTypecomponentType(subarrayType);
3626                int end = retrieveProperRightBracketPosition(indexsourceStart);
3627                subarrayType.setSourceRange(sourceStartend - sourceStart + 1);
3628                index--;
3629            }
3630            if (length < arrayEnd - sourceStartarrayType.setSourceRange(sourceStartarrayEnd - sourceStart + 1);
3631            return arrayType;
3632        }
3633
3634        setTypeAnnotationsAndSourceRangeOnArray(arrayTypeannotationsOnDimensions);
3635        return arrayType;
3636    }
3637
3638    private EnumDeclaration convertToEnumDeclaration(org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) {
3639        checkCanceled();
3640        // enum declaration cannot be built if the source is not >= 1.5, since enum is then seen as an identifier
3641        final EnumDeclaration enumDeclaration2 = new EnumDeclaration(this.ast);
3642        setModifiers(enumDeclaration2typeDeclaration);
3643        final SimpleName typeName = new SimpleName(this.ast);
3644        typeName.internalSetIdentifier(new String(typeDeclaration.name));
3645        typeName.setSourceRange(typeDeclaration.sourceStarttypeDeclaration.sourceEnd - typeDeclaration.sourceStart + 1);
3646        enumDeclaration2.setName(typeName);
3647        enumDeclaration2.setSourceRange(typeDeclaration.declarationSourceStarttypeDeclaration.bodyEnd - typeDeclaration.declarationSourceStart + 1);
3648
3649        org.eclipse.jdt.internal.compiler.ast.TypeReference[] superInterfaces = typeDeclaration.superInterfaces;
3650        if (superInterfaces != null) {
3651            for (int index = 0length = superInterfaces.lengthindex < lengthindex++) {
3652                enumDeclaration2.superInterfaceTypes().add(convertType(superInterfaces[index]));
3653            }
3654        }
3655        buildBodyDeclarations(typeDeclarationenumDeclaration2);
3656        if (this.resolveBindings) {
3657            recordNodes(enumDeclaration2typeDeclaration);
3658            recordNodes(typeNametypeDeclaration);
3659            enumDeclaration2.resolveBinding();
3660        }
3661        return enumDeclaration2;
3662    }
3663
3664    private RecordDeclaration convertToRecordDeclaration(org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) {
3665        checkCanceled();
3666        // record declaration cannot be built if the source is not >= 14, since record is then seen as an identifier
3667        final RecordDeclaration recordDeclaration = new RecordDeclaration(this.ast);
3668        setModifiers(recordDeclarationtypeDeclaration);
3669        final SimpleName typeName = new SimpleName(this.ast);
3670        typeName.internalSetIdentifier(new String(typeDeclaration.name));
3671        typeName.setSourceRange(typeDeclaration.sourceStarttypeDeclaration.name.length);
3672        recordDeclaration.setName(typeName);
3673        recordDeclaration.setSourceRange(typeDeclaration.declarationSourceStarttypeDeclaration.bodyEnd - typeDeclaration.declarationSourceStart + 1);
3674        recordDeclaration.setRestrictedIdentifierStartPosition(typeDeclaration.restrictedIdentifierStart);
3675
3676        org.eclipse.jdt.internal.compiler.ast.TypeReference[] superInterfaces = typeDeclaration.superInterfaces;
3677        if (superInterfaces != null) {
3678            for (TypeReference superInterface : superInterfaces) {
3679                recordDeclaration.superInterfaceTypes().add(convertType(superInterface));
3680            }
3681        }
3682        org.eclipse.jdt.internal.compiler.ast.TypeParameter[] typeParameters = typeDeclaration.typeParameters;
3683        if (typeParameters != null) {
3684            for (org.eclipse.jdt.internal.compiler.ast.TypeParameter typeParameter : typeParameters) {
3685                recordDeclaration.typeParameters().add(convert(typeParameter));
3686            }
3687        }
3688        RecordComponent[] recComps = typeDeclaration.recordComponents;
3689        if (recComps != null) {
3690            for (RecordComponent recComp : recComps) {
3691                recordDeclaration.recordComponents().add(convert(recComp));
3692            }
3693        }
3694        buildBodyDeclarations(typeDeclarationrecordDeclarationfalse);
3695        if (this.resolveBindings) {
3696            recordNodes(recordDeclarationtypeDeclaration);
3697            recordNodes(typeNametypeDeclaration);
3698            recordDeclaration.resolveBinding();
3699        }
3700        return recordDeclaration;
3701    }
3702    public Expression convertToExpression(org.eclipse.jdt.internal.compiler.ast.Statement statement) {
3703        if (statement instanceof org.eclipse.jdt.internal.compiler.ast.Expression &&
3704                ((org.eclipse.jdt.internal.compiler.ast.Expressionstatement).isTrulyExpression()) {
3705            return convert((org.eclipse.jdt.internal.compiler.ast.Expressionstatement);
3706        } else {
3707            return null;
3708        }
3709    }
3710
3711    protected FieldDeclaration convertToFieldDeclaration(org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDecl) {
3712        VariableDeclarationFragment variableDeclarationFragment = convertToVariableDeclarationFragment(fieldDecl);
3713        final FieldDeclaration fieldDeclaration = new FieldDeclaration(this.ast);
3714        fieldDeclaration.fragments().add(variableDeclarationFragment);
3715        if (this.resolveBindings) {
3716            recordNodes(variableDeclarationFragmentfieldDecl);
3717            variableDeclarationFragment.resolveBinding();
3718        }
3719        fieldDeclaration.setSourceRange(fieldDecl.declarationSourceStartfieldDecl.declarationEnd - fieldDecl.declarationSourceStart + 1);
3720        Type type = convertType(fieldDecl.type);
3721        setTypeForField(fieldDeclarationtypevariableDeclarationFragment.getExtraDimensions());
3722        setModifiers(fieldDeclarationfieldDecl);
3723        convert(fieldDecl.javadocfieldDeclaration);
3724        return fieldDeclaration;
3725    }
3726
3727    /**
3728     * If there is a parsing error causing a recovered module the source positions may be updated only partially.
3729     * See bug 518843 for a case where this issue occurred. This method provide a safety net with
3730     * source positions updated even in case of a recovery - if there is no recovery, the source positions will
3731     * be retained in-tact identical to the compile time ast module node.
3732     */
3733    private int getKnownEnd(ModuleDeclaration mdint sourceEndint declSourceEnd) {
3734        int end =  retrieveRightBrace(md.getStartPosition() + 1, this.compilationUnitSourceLength);
3735        end = end > sourceEnd ? end : sourceEnd;
3736        end = end > declSourceEnd ? end : declSourceEnd;
3737        return end;
3738    }
3739    public ModuleDeclaration convertToModuleDeclaration(org.eclipse.jdt.internal.compiler.ast.ModuleDeclaration moduleDeclaration) {
3740        checkCanceled();
3741        if (this.scanner.sourceLevel < ClassFileConstants.JDK9
3742                || this.ast.apiLevel < AST.JLS9_INTERNAL) return null;
3743        ModuleDeclaration moduleDecl = this.ast.newModuleDeclaration();
3744        // TODO
3745        //convert(moduleDeclaration.javadoc, moduleDecl);
3746        setAnnotations(moduleDeclmoduleDeclaration); // only annotations
3747        moduleDecl.setOpen(moduleDeclaration.isOpen());
3748        Name moduleName = getName(moduleDeclarationCharOperation.splitOn('.'moduleDeclaration.moduleName), moduleDeclaration.sourcePositions);
3749        moduleDecl.setName(moduleName);
3750
3751        List<ModuleDirectivestmts = moduleDecl.moduleStatements();
3752        TreeSet<ModuleDirectivetSet = new TreeSet<> (new Comparator() {
3753            @Override
3754            public int compare(Object o1Object o2) {
3755                int p1 = ((ModuleDirectiveo1).getStartPosition();
3756                int p2 = ((ModuleDirectiveo2).getStartPosition();
3757                return p1 < p2 ? -1 : p1 == p2 ? 0 : 1;
3758            }
3759        });
3760        for (int i = 0i < moduleDeclaration.exportsCount; ++i) {
3761            tSet.add(getPackageVisibilityStatement(moduleDeclaration.exports[i], new ExportsDirective(this.ast)));
3762        }
3763        for (int i = 0i < moduleDeclaration.opensCount; ++i) {
3764            tSet.add(getPackageVisibilityStatement(moduleDeclaration.opens[i], new OpensDirective(this.ast)));
3765        }
3766        for (int i = 0i < moduleDeclaration.requiresCount; ++i) {
3767            org.eclipse.jdt.internal.compiler.ast.RequiresStatement req = moduleDeclaration.requires[i];
3768            ModuleReference moduleRef = req.module;
3769            RequiresDirective stmt = new RequiresDirective(this.ast);
3770            Name name = getName(moduleRefCharOperation.splitOn('.'moduleRef.moduleName), moduleRef.sourcePositions);
3771            stmt.setName(name);
3772            if (this.resolveBindings) {
3773                recordNodes(namemoduleRef);
3774            }
3775
3776            setModuleModifiers(reqstmt);
3777            stmt.setSourceRange(req.declarationSourceStartreq.declarationEnd - req.declarationSourceStart + 1);
3778            tSet.add(stmt);
3779        }
3780        for (int i = 0i < moduleDeclaration.usesCount; ++i) {
3781            org.eclipse.jdt.internal.compiler.ast.UsesStatement usesStatement = moduleDeclaration.uses[i];
3782            UsesDirective stmt = new UsesDirective(this.ast);
3783            TypeReference usesRef = usesStatement.serviceInterface;
3784            Name name = convert(usesRef);
3785            stmt.setName(name);
3786            stmt.setSourceRange(usesStatement.declarationSourceStartusesStatement.declarationSourceEnd - usesStatement.declarationSourceStart + 1);
3787            tSet.add(stmt);
3788        }
3789        for (int i = 0i < moduleDeclaration.servicesCount; ++i) {
3790            org.eclipse.jdt.internal.compiler.ast.ProvidesStatement pStmt = moduleDeclaration.services[i];
3791            ProvidesDirective stmt = new ProvidesDirective(this.ast);
3792            stmt.setName(convert(pStmt.serviceInterface));
3793            TypeReference[] impls = pStmt.implementations;
3794            for (TypeReference impl : impls) {
3795                stmt.implementations().add(convert(impl));
3796            }
3797            stmt.setSourceRange(pStmt.declarationSourceStartpStmt.declarationSourceEnd - pStmt.declarationSourceStart + 1);
3798            tSet.add(stmt);
3799        }
3800        // The javadoc comment is now got from     list store in compilation unit declaration
3801        if (this.resolveBindings) {
3802            recordNodes(moduleDeclmoduleDeclaration);
3803            recordNodes(moduleNamemoduleDeclaration);
3804            moduleDecl.resolveBinding();
3805        }
3806        stmts.addAll(tSet);
3807        int end = getKnownEnd(moduleDeclmoduleDeclaration.sourceEndmoduleDeclaration.declarationSourceEnd);
3808        moduleDecl.setSourceRange(moduleDeclaration.declarationSourceStartend  - moduleDeclaration.declarationSourceStart + 1);
3809        return moduleDecl;
3810    }
3811
3812    private void setModuleModifiers(org.eclipse.jdt.internal.compiler.ast.RequiresStatement req,    RequiresDirective stmt) {
3813        boolean fakeInModule = this.scanner.fakeInModule;
3814        this.scanner.fakeInModule = true;
3815        this.scanner.resetTo(req.declarationSourceStartreq.sourceEnd);
3816        try {
3817            int token;
3818            ModuleModifier modifier;
3819            while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
3820                switch(token) {
3821                    case TerminalTokens.TokenNamestatic:
3822                        modifier = createModuleModifier(ModuleModifier.ModuleModifierKeyword.STATIC_KEYWORD);
3823                        break;
3824                    case TerminalTokens.TokenNametransitive:
3825                        modifier = createModuleModifier(ModuleModifier.ModuleModifierKeyword.TRANSITIVE_KEYWORD);
3826                        break;
3827                    default :
3828                        continue;
3829                }
3830                if (modifier != null) {
3831                    stmt.modifiers().add(modifier);
3832                }
3833            }
3834        } catch(InvalidInputException e) {
3835            // ignore
3836        } finally {
3837            this.scanner.fakeInModule = fakeInModule;
3838        }
3839    }
3840
3841    public ParenthesizedExpression convertToParenthesizedExpression(org.eclipse.jdt.internal.compiler.ast.Expression expression) {
3842        final ParenthesizedExpression parenthesizedExpression = new ParenthesizedExpression(this.ast);
3843        if (this.resolveBindings) {
3844            recordNodes(parenthesizedExpressionexpression);
3845        }
3846        parenthesizedExpression.setSourceRange(expression.sourceStartexpression.sourceEnd - expression.sourceStart + 1);
3847        adjustSourcePositionsForParent(expression);
3848        trimWhiteSpacesAndComments(expression);
3849        // decrement the number of parenthesis
3850        int numberOfParenthesis = (expression.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) >> org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedSHIFT;
3851        expression.bits &= ~org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK;
3852        expression.bits |= (numberOfParenthesis - 1) << org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedSHIFT;
3853        parenthesizedExpression.setExpression(convert(expression));
3854        return parenthesizedExpression;
3855    }
3856
3857    protected VariableDeclarationExpression convertToVariableDeclarationExpression(org.eclipse.jdt.internal.compiler.ast.LocalDeclaration localDeclaration) {
3858        final VariableDeclarationFragment variableDeclarationFragment = convertToVariableDeclarationFragment(localDeclaration);
3859        final VariableDeclarationExpression variableDeclarationExpression = new VariableDeclarationExpression(this.ast);
3860        variableDeclarationExpression.fragments().add(variableDeclarationFragment);
3861        if (this.resolveBindings) {
3862            recordNodes(variableDeclarationFragmentlocalDeclaration);
3863        }
3864        variableDeclarationExpression.setSourceRange(localDeclaration.declarationSourceStartlocalDeclaration.declarationSourceEnd - localDeclaration.declarationSourceStart + 1);
3865        Type type = convertType(localDeclaration.type);
3866        setTypeForVariableDeclarationExpression(variableDeclarationExpressiontypevariableDeclarationFragment.getExtraDimensions());
3867        if (localDeclaration.modifiersSourceStart != -1) {
3868            setModifiers(variableDeclarationExpressionlocalDeclaration);
3869        }
3870        return variableDeclarationExpression;
3871    }
3872
3873    protected SingleVariableDeclaration convertToSingleVariableDeclaration(LocalDeclaration localDeclaration) {
3874        final SingleVariableDeclaration variableDecl = new SingleVariableDeclaration(this.ast);
3875        setModifiers(variableDecllocalDeclaration);
3876        final SimpleName name = new SimpleName(this.ast);
3877        name.internalSetIdentifier(new String(localDeclaration.name));
3878        int start = localDeclaration.sourceStart;
3879        int nameEnd = localDeclaration.sourceEnd;
3880        name.setSourceRange(startnameEnd - start + 1);
3881        variableDecl.setName(name);
3882        TypeReference typeReference = localDeclaration.type;
3883        final int extraDimensions = typeReference.extraDimensions();
3884        if (this.ast.apiLevel >= AST.JLS8_INTERNAL) {
3885            setExtraAnnotatedDimensions(nameEnd + 1localDeclaration.declarationSourceEndtypeReference,
3886                    variableDecl.extraDimensions(), extraDimensions);
3887        } else {
3888            internalSetExtraDimensions(variableDeclextraDimensions);
3889        }
3890        Type type = convertType(localDeclaration.type);
3891        int typeEnd = type.getStartPosition() + type.getLength() - 1;
3892        // https://bugs.eclipse.org/393719 - [compiler] inconsistent warnings on iteration variables
3893        // compiler considers collectionExpression as within the declarationSourceEnd, DOM AST must use the shorter range to avoid overlap
3894        int sourceEnd = ((localDeclaration.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.IsForeachElementVariable) != 0)
3895                ? localDeclaration.sourceEnd : localDeclaration.declarationSourceEnd;
3896        int rightEnd = Math.max(typeEndsourceEnd);
3897        /*
3898         * There is extra work to do to set the proper type positions
3899         * See PR http://bugs.eclipse.org/bugs/show_bug.cgi?id=23284
3900         */
3901        setTypeForSingleVariableDeclaration(variableDecltypeextraDimensions);
3902        variableDecl.setSourceRange(localDeclaration.declarationSourceStartrightEnd - localDeclaration.declarationSourceStart + 1);
3903        if (this.resolveBindings) {
3904            recordNodes(namelocalDeclaration);
3905            recordNodes(variableDecllocalDeclaration);
3906            variableDecl.resolveBinding();
3907        }
3908        return variableDecl;
3909    }
3910
3911    private Dimension convertToDimensions(int startint endorg.eclipse.jdt.internal.compiler.ast.Annotation[] annotation) {
3912        int length = annotation == null ? 0 : annotation.length;
3913        Dimension dimension = this.ast.newDimension();
3914        for (int i = 0i < lengthi++) {
3915            Annotation annot = convert(annotation[i]);
3916            dimension.annotations().add(annot);
3917        }
3918        retrieveDimensionAndSetPositions(startenddimension);
3919        return dimension;
3920    }
3921
3922    protected VariableDeclarationFragment convertToVariableDeclarationFragment(org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration) {
3923        final VariableDeclarationFragment variableDeclarationFragment = new VariableDeclarationFragment(this.ast);
3924        final SimpleName name = new SimpleName(this.ast);
3925        name.internalSetIdentifier(new String(fieldDeclaration.name));
3926        name.setSourceRange(fieldDeclaration.sourceStartfieldDeclaration.sourceEnd - fieldDeclaration.sourceStart + 1);
3927        variableDeclarationFragment.setName(name);
3928        int start = fieldDeclaration.sourceEnd;
3929        int end = start;
3930        TypeReference typeReference = fieldDeclaration.type;
3931        int extraDimensions = typeReference.extraDimensions();
3932        if (this.ast.apiLevel >= AST.JLS8_INTERNAL) {
3933            setExtraAnnotatedDimensions(fieldDeclaration.sourceEnd + 1fieldDeclaration.declarationSourceEnd,
3934                    typeReferencevariableDeclarationFragment.extraDimensions(), extraDimensions);
3935        } else {
3936            internalSetExtraDimensions(variableDeclarationFragmentextraDimensions);
3937        }
3938        if (fieldDeclaration.initialization != null) {
3939            final Expression expression = convert(fieldDeclaration.initialization);
3940            variableDeclarationFragment.setInitializer(expression);
3941            start = expression.getStartPosition() + expression.getLength();
3942            end = start - 1;
3943        } else {
3944            // we need to do it even if extendedDimension is null in case of syntax error in an array initializer
3945            // need the exclusive range for retrieveEndOfPotentialExtendedDimensions
3946            int possibleEnd = retrieveEndOfPotentialExtendedDimensions(start + 1fieldDeclaration.sourceEndfieldDeclaration.declarationSourceEnd);
3947            if (possibleEnd == Integer.MIN_VALUE) {
3948                end = fieldDeclaration.declarationSourceEnd;
3949                variableDeclarationFragment.setFlags(variableDeclarationFragment.getFlags() | ASTNode.MALFORMED);
3950            } if (possibleEnd < 0) {
3951                end = -possibleEnd;
3952                variableDeclarationFragment.setFlags(variableDeclarationFragment.getFlags() | ASTNode.MALFORMED);
3953            } else {
3954                end = possibleEnd;
3955            }
3956        }
3957        variableDeclarationFragment.setSourceRange(fieldDeclaration.sourceStartend - fieldDeclaration.sourceStart + 1);
3958        if (this.resolveBindings) {
3959            recordNodes(namefieldDeclaration);
3960            recordNodes(variableDeclarationFragmentfieldDeclaration);
3961            variableDeclarationFragment.resolveBinding();
3962        }
3963        return variableDeclarationFragment;
3964    }
3965
3966    protected VariableDeclarationFragment convertToVariableDeclarationFragment(org.eclipse.jdt.internal.compiler.ast.LocalDeclaration localDeclaration) {
3967        final VariableDeclarationFragment variableDeclarationFragment = new VariableDeclarationFragment(this.ast);
3968        final SimpleName name = new SimpleName(this.ast);
3969        name.internalSetIdentifier(new String(localDeclaration.name));
3970        name.setSourceRange(localDeclaration.sourceStartlocalDeclaration.sourceEnd - localDeclaration.sourceStart + 1);
3971        variableDeclarationFragment.setName(name);
3972        int start = localDeclaration.sourceEnd;
3973        org.eclipse.jdt.internal.compiler.ast.Expression initialization = localDeclaration.initialization;
3974        TypeReference typeReference = localDeclaration.type;
3975        int extraDimension = typeReference.extraDimensions();
3976        if (this.ast.apiLevel >= AST.JLS8_INTERNAL) {
3977            setExtraAnnotatedDimensions(localDeclaration.sourceEnd + 1, this.compilationUnitSourceLength,
3978                    typeReferencevariableDeclarationFragment.extraDimensions(), extraDimension);
3979        } else {
3980            internalSetExtraDimensions(variableDeclarationFragmentextraDimension);
3981        }
3982
3983        boolean hasInitialization = initialization != null;
3984        int end;
3985        if (hasInitialization) {
3986            final Expression expression = convert(initialization);
3987            variableDeclarationFragment.setInitializer(expression);
3988            start = expression.getStartPosition() + expression.getLength();
3989            end = start - 1;
3990        } else {
3991            // we need to do it even if extendedDimension is null in case of syntax error in an array initializer
3992            // start + 1 because we need the exclusive range for retrieveEndOfPotentialExtendedDimensions
3993            int possibleEnd = retrieveEndOfPotentialExtendedDimensions(start + 1localDeclaration.sourceEndlocalDeclaration.declarationSourceEnd);
3994            if (possibleEnd == Integer.MIN_VALUE) {
3995                end = start;
3996                variableDeclarationFragment.setFlags(variableDeclarationFragment.getFlags() | ASTNode.MALFORMED);
3997            } else if (possibleEnd < 0) {
3998                end = -possibleEnd;
3999                variableDeclarationFragment.setFlags(variableDeclarationFragment.getFlags() | ASTNode.MALFORMED);
4000            } else {
4001                end = possibleEnd;
4002            }
4003        }
4004        variableDeclarationFragment.setSourceRange(localDeclaration.sourceStartend - localDeclaration.sourceStart + 1);
4005        if (this.resolveBindings) {
4006            recordNodes(variableDeclarationFragmentlocalDeclaration);
4007            recordNodes(namelocalDeclaration);
4008            variableDeclarationFragment.resolveBinding();
4009        }
4010        return variableDeclarationFragment;
4011    }
4012
4013    protected void setExtraAnnotatedDimensions(int startint endTypeReference typefinal List extraAnnotatedDimensionsint extraDimension) {
4014        if (extraDimension > 0) {
4015            org.eclipse.jdt.internal.compiler.ast.Annotation[][] annotationsOnDims = type.getAnnotationsOnDimensions(true);
4016            int length = (annotationsOnDims == null) ? 0 : annotationsOnDims.length;
4017            for (int i = (length - extraDimension); i < lengthi++) {
4018                Dimension dim = convertToDimensions(startend, (annotationsOnDims == null) ? null : annotationsOnDims[i]);
4019                extraAnnotatedDimensions.add(dim);
4020                start = dim.getStartPosition() + dim.getLength();
4021            }
4022        }
4023    }
4024
4025    private void setTypeAnnotationsOnDimension(Dimension currentDimensionorg.eclipse.jdt.internal.compiler.ast.Annotation[][] annotationsOnDimensionsint dimension) {
4026        if (annotationsOnDimensions == null) return;
4027        org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = annotationsOnDimensions[dimension];
4028        if (annotations != null) {
4029            for (int j = 0length = annotations.lengthj < lengthj++) {
4030                Annotation annotation = convert(annotations[j]);
4031                currentDimension.annotations().add(annotation);
4032            }
4033        }
4034    }
4035
4036    private void setTypeAnnotationsAndSourceRangeOnArray(ArrayType arrayTypeorg.eclipse.jdt.internal.compiler.ast.Annotation[][] annotationsOnDimensions) {
4037        List dimensions = arrayType.dimensions();
4038        Type elementType = arrayType.getElementType();
4039
4040        // Object[] a
4041        // ^
4042        int start = elementType.getStartPosition();
4043
4044        // Object[] a
4045        //       ^
4046        int startArray = start + elementType.getLength();
4047
4048        // Object[] a
4049        //        ^
4050        int end = retrieveProperRightBracketPosition(dimensions.size(), startArray);
4051        if (end == -1) {
4052            end = startArray - 1;
4053        }
4054        arrayType.setSourceRange(startend - start + 1);
4055
4056        start = startArray;
4057        for (int i = 0i < dimensions.size(); i++) {
4058            Dimension currentDimension = (Dimensiondimensions.get(i);
4059            setTypeAnnotationsOnDimension(currentDimensionannotationsOnDimensionsi);
4060            retrieveDimensionAndSetPositions(startendcurrentDimension);
4061            start = currentDimension.getStartPosition() + currentDimension.getLength();
4062        }
4063    }
4064
4065    protected VariableDeclarationStatement convertToVariableDeclarationStatement(org.eclipse.jdt.internal.compiler.ast.LocalDeclaration localDeclaration) {
4066        final VariableDeclarationFragment variableDeclarationFragment = convertToVariableDeclarationFragment(localDeclaration);
4067        final VariableDeclarationStatement variableDeclarationStatement = new VariableDeclarationStatement(this.ast);
4068        variableDeclarationStatement.fragments().add(variableDeclarationFragment);
4069        variableDeclarationStatement.setSourceRange(localDeclaration.declarationSourceStartlocalDeclaration.declarationSourceEnd - localDeclaration.declarationSourceStart + 1);
4070        Type type = convertType(localDeclaration.type);
4071        setTypeForVariableDeclarationStatement(variableDeclarationStatementtypevariableDeclarationFragment.getExtraDimensions());
4072        if (this.resolveBindings) {
4073            recordNodes(variableDeclarationFragmentlocalDeclaration);
4074            if (this.ast.apiLevel() >= AST.JLS10_INTERNAL && type.isVar()) {
4075                SimpleName varName = (SimpleName) ((SimpleTypetype).getName();
4076                varName.setVar(true);
4077                recordNodes(varNamelocalDeclaration);
4078            }
4079        }
4080        if (localDeclaration.modifiersSourceStart != -1) {
4081            setModifiers(variableDeclarationStatementlocalDeclaration);
4082        }
4083        return variableDeclarationStatement;
4084    }
4085
4086    private int annotateType(AnnotatableType typeorg.eclipse.jdt.internal.compiler.ast.Annotation[] annotations) {
4087        int annotationsEnd = 0;
4088        switch(this.ast.apiLevel) {
4089            case AST.JLS2_INTERNAL :
4090            case AST.JLS3_INTERNAL :
4091            case AST.JLS4_INTERNAL:
4092                type.setFlags(type.getFlags() | ASTNode.MALFORMED);
4093                break;
4094            default:
4095                if (annotations == null) break;
4096                int start = type.getStartPosition();
4097                int length = type.getLength();
4098                int annotationsLength = annotations.length;
4099                for (int i = 0i < annotationsLengthi++) {
4100                    org.eclipse.jdt.internal.compiler.ast.Annotation typeAnnotation = annotations[i];
4101                    if (typeAnnotation != null) {
4102                        Annotation annotation = convert(typeAnnotation);
4103                        type.annotations().add(annotation);
4104                        annotationsEnd = annotation.getStartPosition() + annotation.getLength();
4105                    }
4106                }
4107                int annotationsStart;
4108                if (annotations[0] != null && (annotationsStart = annotations[0].sourceStart) < start && annotationsStart > 0) {
4109                    length +=  start - annotationsStart;
4110                    start = annotationsStart;
4111                }
4112                type.setSourceRange(startlength);
4113        }
4114        return annotationsEnd;
4115    }
4116    private void annotateTypeParameter(TypeParameter typeParameterorg.eclipse.jdt.internal.compiler.ast.Annotation[] annotations) {
4117        switch(this.ast.apiLevel) {
4118            case AST.JLS2_INTERNAL :
4119            case AST.JLS3_INTERNAL :
4120            case AST.JLS4_INTERNAL:
4121                typeParameter.setFlags(typeParameter.getFlags() | ASTNode.MALFORMED);
4122                break;
4123            default:
4124                int annotationsLength = annotations.length;
4125                for (int i = 0i < annotationsLengthi++) {
4126                    org.eclipse.jdt.internal.compiler.ast.Annotation typeAnnotation = annotations[i];
4127                    if (typeAnnotation != null) {
4128                        Annotation annotation = convert(typeAnnotation);
4129                        typeParameter.modifiers().add(annotation);
4130                    }
4131                }
4132        }
4133    }
4134
4135    public Type convertType(TypeReference typeReference) {
4136        org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations;
4137        if (typeReference instanceof Wildcard) {
4138            final Wildcard wildcard = (WildcardtypeReference;
4139            final WildcardType wildcardType = new WildcardType(this.ast);
4140            if (wildcard.bound != null) {
4141                final Type bound = convertType(wildcard.bound);
4142                wildcardType.setBound(boundwildcard.kind == Wildcard.EXTENDS);
4143                int start = wildcard.sourceStart;
4144                wildcardType.setSourceRange(startbound.getStartPosition() + bound.getLength() - start);
4145            } else {
4146                final int start = wildcard.sourceStart;
4147                final int end = wildcard.sourceEnd;
4148                wildcardType.setSourceRange(startend - start + 1);
4149            }
4150            if (this.resolveBindings) {
4151                recordNodes(wildcardTypetypeReference);
4152            }
4153            if (typeReference.annotations != null && (annotations = typeReference.annotations[0]) != null) {
4154                annotateType(wildcardTypeannotations);
4155            }
4156            return wildcardType;
4157        }
4158        Type type = null;
4159        int sourceStart = typeReference.sourceStart;
4160        int length = 0;
4161        int dimensions = typeReference.dimensions();
4162        if (typeReference instanceof org.eclipse.jdt.internal.compiler.ast.SingleTypeReference) {
4163            annotations = typeReference.annotations != null ? typeReference.annotations[0] : null;
4164            int annotationsEnd = annotations != null ? annotations[annotations.length - 1].declarationSourceEnd + 1 : -1;
4165            // this is either an ArrayTypeReference or a SingleTypeReference
4166            char[] name = ((org.eclipse.jdt.internal.compiler.ast.SingleTypeReferencetypeReference).getTypeName()[0];
4167            length = typeReference.sourceEnd - typeReference.sourceStart + 1;
4168            // need to find out if this is an array type of primitive types or not
4169            if (isPrimitiveType(name)) {
4170                int[] positions = retrieveEndOfElementTypeNamePosition(sourceStart < annotationsEnd ? annotationsEnd : sourceStartsourceStart + length);
4171                int end = positions[1];
4172                if (end == -1) {
4173                    end = sourceStart + length - 1;
4174                }
4175                final PrimitiveType primitiveType = new PrimitiveType(this.ast);
4176                primitiveType.setPrimitiveTypeCode(getPrimitiveTypeCode(name));
4177                primitiveType.setSourceRange(sourceStartend - sourceStart + 1);
4178                type = primitiveType;
4179                if (typeReference.annotations != null && (annotations = typeReference.annotations[0]) != null) {
4180                    annotateType(primitiveTypeannotations);
4181                }
4182            } else if (typeReference instanceof ParameterizedSingleTypeReference) {
4183                ParameterizedSingleTypeReference parameterizedSingleTypeReference = (ParameterizedSingleTypeReferencetypeReference;
4184                final SimpleName simpleName = new SimpleName(this.ast);
4185                simpleName.internalSetIdentifier(new String(name));
4186                int[] positions = retrieveEndOfElementTypeNamePosition(sourceStart < annotationsEnd ? annotationsEnd : sourceStartsourceStart + length);
4187                int end = positions[1];
4188                if (end == -1) {
4189                    end = sourceStart + length - 1;
4190                }
4191                if (positions[0] != -1) {
4192                    simpleName.setSourceRange(positions[0], end - positions[0] + 1);
4193                } else {
4194                    simpleName.setSourceRange(sourceStartend - sourceStart + 1);
4195                }
4196
4197                switch(this.ast.apiLevel) {
4198                    case AST.JLS2_INTERNAL :
4199                        SimpleType simpleType = new SimpleType(this.ast);
4200                        simpleType.setName(simpleName);
4201                        simpleType.setFlags(simpleType.getFlags() | ASTNode.MALFORMED);
4202                        simpleType.setSourceRange(sourceStartend - sourceStart + 1);
4203                        type = simpleType;
4204                        if (this.resolveBindings) {
4205                            this.recordNodes(simpleNametypeReference);
4206                        }
4207                        break;
4208                    default :
4209                        simpleType = new SimpleType(this.ast);
4210                        simpleType.setName(simpleName);
4211                        simpleType.setSourceRange(simpleName.getStartPosition(), simpleName.getLength());
4212                        if (typeReference.annotations != null && (annotations = typeReference.annotations[0]) != null) {
4213                            annotateType(simpleTypeannotations);
4214                        }
4215                        int newSourceStart = simpleType.getStartPosition();
4216                        if (newSourceStart > 0 && newSourceStart < sourceStart)
4217                            sourceStart = newSourceStart;
4218                        final ParameterizedType parameterizedType = new ParameterizedType(this.ast);
4219                        parameterizedType.setType(simpleType);
4220                        type = parameterizedType;
4221                        TypeReference[] typeArguments = parameterizedSingleTypeReference.typeArguments;
4222                        if (typeArguments != null) {
4223                            Type type2 = null;
4224                            for (int i = 0max = typeArguments.lengthi < maxi++) {
4225                                type2 = convertType(typeArguments[i]);
4226                                ((ParameterizedTypetype).typeArguments().add(type2);
4227                                end = type2.getStartPosition() + type2.getLength() - 1;
4228                            }
4229                            end = retrieveClosingAngleBracketPosition(end + 1);
4230                            type.setSourceRange(sourceStartend - sourceStart + 1);
4231                        } else {
4232                            type.setSourceRange(sourceStartend - sourceStart + 1);
4233                        }
4234                        if (this.resolveBindings) {
4235                            this.recordNodes(simpleNametypeReference);
4236                            this.recordNodes(simpleTypetypeReference);
4237                        }
4238                }
4239            } else {
4240                final SimpleName simpleName = new SimpleName(this.ast);
4241                simpleName.internalSetIdentifier(new String(name));
4242                // we need to search for the starting position of the first brace in order to set the proper length
4243                // PR http://dev.eclipse.org/bugs/show_bug.cgi?id=10759
4244                int[] positions = retrieveEndOfElementTypeNamePosition(sourceStart < annotationsEnd ? annotationsEnd : sourceStartsourceStart + length);
4245                int end = positions[1];
4246                if (end == -1) {
4247                    end = sourceStart + length - 1;
4248                }
4249                if (positions[0] != -1) {
4250                    simpleName.setSourceRange(positions[0], end - positions[0] + 1);
4251                } else {
4252                    simpleName.setSourceRange(sourceStartend - sourceStart + 1);
4253                }
4254                final SimpleType simpleType = new SimpleType(this.ast);
4255                simpleType.setName(simpleName);
4256                type = simpleType;
4257                type.setSourceRange(sourceStartend - sourceStart + 1);
4258                type = simpleType;
4259                if (this.ast.apiLevel() >= AST.JLS10_INTERNAL && type.isVar()) {
4260                    simpleName.setVar(true);
4261                }
4262                if (this.resolveBindings) {
4263                    this.recordNodes(simpleNametypeReference);
4264                }
4265                if (typeReference.annotations != null && (annotations = typeReference.annotations[0]) != null) {
4266                    annotateType(simpleTypeannotations);
4267                }
4268            }
4269            if (dimensions != 0) {
4270                type = convertToArray(typesourceStartlengthdimensionstypeReference.getAnnotationsOnDimensions(true));
4271                if (this.resolveBindings) {
4272                    // store keys for inner types
4273                    completeRecord((ArrayTypetypetypeReference);
4274                }
4275            }
4276        } else {
4277            if (typeReference instanceof ParameterizedQualifiedTypeReference) {
4278                ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference = (ParameterizedQualifiedTypeReferencetypeReference;
4279                char[][] tokens = parameterizedQualifiedTypeReference.tokens;
4280                TypeReference[][] typeArguments = parameterizedQualifiedTypeReference.typeArguments;
4281                org.eclipse.jdt.internal.compiler.ast.Annotation[][] typeAnnotations = parameterizedQualifiedTypeReference.annotations;
4282                TypeReference[] arguments = null;
4283                int lenth = tokens.length;
4284                int firstTypeIndex = lenth - 1;
4285                long[] positions = parameterizedQualifiedTypeReference.sourcePositions;
4286                switch(this.ast.apiLevel) {
4287                    case AST.JLS2_INTERNAL : {
4288                        char[][] name = ((org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReferencetypeReference).getTypeName();
4289                        int nameLength = name.length;
4290                        sourceStart = (int)(positions[0]>>>32);
4291                        length = (int)(positions[nameLength - 1] & 0xFFFFFFFF) - sourceStart + 1;
4292                        Name qualifiedName = this.setQualifiedNameNameAndSourceRanges(namepositionstypeReference);
4293                        final SimpleType simpleType = new SimpleType(this.ast);
4294                        simpleType.setName(qualifiedName);
4295                        simpleType.setSourceRange(sourceStartlength);
4296                        simpleType.setFlags(simpleType.getFlags() | ASTNode.MALFORMED);
4297                        type = simpleType;
4298                    }
4299                    break;
4300                    default :
4301                        boolean isTypeArgumentBased = false;
4302                        for (int i = 0i < lenth; ++i) {
4303                            if (typeArguments != null && typeArguments[i] != null) {
4304                                firstTypeIndex = i;
4305                                isTypeArgumentBased = true;
4306                                break;
4307                            }
4308                            if (typeAnnotations != null && typeAnnotations[i] != null) {
4309                                firstTypeIndex = i;
4310                                isTypeArgumentBased = false;
4311                                break;
4312                            }
4313                        }
4314                        int start = (int) (positions[0] >>> 32);
4315                        int end = (intpositions[firstTypeIndex];
4316
4317                        Type currentType = createBaseType(typeReferencepositionstypeAnnotationstokenslenthfirstTypeIndexisTypeArgumentBased);
4318                        int indexOfEnclosingType = 1;
4319                        if (typeArguments != null && (arguments = typeArguments[firstTypeIndex]) != null) {
4320                            int arglen = arguments.length;
4321                            ParameterizedType parameterizedType = new ParameterizedType(this.ast);
4322                            parameterizedType.index = indexOfEnclosingType;
4323                            parameterizedType.setType(currentType);
4324                            if (this.resolveBindings) {
4325                                recordNodes(parameterizedTypetypeReference);
4326                            }
4327                            Type type2 = null;
4328                            for (int i = 0i < arglen; ++i ) {
4329                                type2 = convertType(arguments[i]);
4330                                parameterizedType.typeArguments().add(type2);
4331                            }
4332                            end = type2 != null ? type2.getStartPosition() + type2.getLength() - 1 : end;
4333                            end = retrieveClosingAngleBracketPosition(end + 1);
4334                            int baseStart = currentType.getStartPosition();
4335                            start = start <= baseStart ? start : baseStart;
4336                            parameterizedType.setSourceRange(startend - start + 1);
4337                            currentType = parameterizedType;
4338                        }
4339
4340                        for (int i = firstTypeIndex + 1i < lenth; ++i) {
4341                            SimpleName simpleName = new SimpleName(this.ast);
4342                            simpleName.setIdentifier(new String(tokens[i]));
4343                            simpleName.index = i + 1;
4344                            start = (int) (positions[i] >>> 32);
4345                            end = (intpositions[i];
4346                            simpleName.setSourceRange(startend - start + 1);
4347                            recordPendingNameScopeResolution(simpleName);
4348                            QualifiedType qualifiedType = new QualifiedType(this.ast);
4349                            qualifiedType.setQualifier(currentType);
4350                            qualifiedType.setName(simpleName);
4351                            start = currentType.getStartPosition();
4352                            end = simpleName.getStartPosition() + simpleName.getLength() - 1;
4353                            qualifiedType.setSourceRange(startend - start + 1);
4354                            if (typeAnnotations != null &&  (annotations = typeAnnotations[i]) != null) {
4355                                int nextPosition = annotateType(qualifiedTypeannotations);
4356                                if (simpleName.getStartPosition() < nextPosition && nextPosition <= end) {
4357                                    simpleName.setSourceRange(nextPositionend - nextPosition + 1);
4358                                    trimWhiteSpacesAndComments(simpleName);
4359                                }
4360                            }
4361                            if (this.resolveBindings) {
4362                                recordNodes(simpleNametypeReference);
4363                                recordNodes(qualifiedTypetypeReference);
4364                            }
4365                            currentType = qualifiedType;
4366                            indexOfEnclosingType++;
4367
4368                            if (typeArguments != null && (arguments = typeArguments[i]) != null) {
4369                                int arglen = arguments.length;
4370                                qualifiedType.index = indexOfEnclosingType;
4371                                ParameterizedType parameterizedType = new ParameterizedType(this.ast);
4372                                parameterizedType.index = indexOfEnclosingType;
4373                                parameterizedType.setType(currentType);
4374                                if (this.resolveBindings) {
4375                                    recordNodes(parameterizedTypetypeReference);
4376                                }
4377                                Type type2 = null;
4378                                for (int j = 0j < arglen; ++j ) {
4379                                    type2 = convertType(arguments[j]);
4380                                    parameterizedType.typeArguments().add(type2);
4381                                }
4382                                end = type2 != null ? type2.getStartPosition() + type2.getLength() - 1 : end;
4383                                end = retrieveClosingAngleBracketPosition(end + 1);
4384                                parameterizedType.setSourceRange(startend - start + 1);
4385                                currentType = parameterizedType;
4386                            } else {
4387                                qualifiedType.index = indexOfEnclosingType;
4388                            }
4389                        }
4390                        type = currentType;
4391                }
4392            } else if (typeReference instanceof org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference) {
4393                QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReferencetypeReference;
4394                long[] positions = ((org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReferencetypeReference).sourcePositions;
4395                org.eclipse.jdt.internal.compiler.ast.Annotation [][] typeAnnotations = typeReference.annotations;
4396                char [][] tokens = qualifiedTypeReference.tokens;
4397                int lenth = tokens.length;
4398                int firstTypeIndex = lenth;
4399
4400                if (typeAnnotations != null) {
4401                    for (int i = 0i < lenth; ++i) {
4402                        if (typeAnnotations[i] != null) {
4403                            firstTypeIndex = i;
4404                            break;
4405                        }
4406                    }
4407                }
4408                Type currentType = createBaseType(typeReferencepositionstypeAnnotationstokenslenthfirstTypeIndexfalse);
4409                for (int i = firstTypeIndex + 1i < lenth; ++i) {
4410                    currentType = createQualifiedType(typeReferencepositions,  typeAnnotationstokensicurrentType);
4411                }
4412                type = currentType;
4413            } else if (typeReference instanceof UnionTypeReference){
4414                TypeReference[] typeReferences = ((org.eclipse.jdt.internal.compiler.ast.UnionTypeReferencetypeReference).typeReferences;
4415                switch(this.ast.apiLevel) {
4416                    case AST.JLS2_INTERNAL :
4417                    case AST.JLS3_INTERNAL :
4418                        // recovery
4419                        type = this.convertType(typeReferences[0]);
4420                        int start = typeReference.sourceStart;
4421                        int endPosition = typeReference.sourceEnd;
4422                        length = endPosition - start + 1;
4423                        type.setSourceRange(startlength);
4424                        type.setFlags(type.getFlags() | ASTNode.MALFORMED);
4425                        break;
4426                    default:
4427                        // union type reference
4428                        final UnionType unionType = new UnionType(this.ast);
4429                        for (int i = 0max = typeReferences.lengthi < maxi++) {
4430                            unionType.types().add(this.convertType(typeReferences[i]));
4431                        }
4432                        type = unionType;
4433                        List types = unionType.types();
4434                        int size = types.size();
4435                        start = ((Typetypes.get(0)).getStartPosition();
4436                        Type lastType = (Typetypes.get(size - 1);
4437                        endPosition = lastType.getStartPosition() + lastType.getLength();
4438                        length = endPosition - start/* + 1 - 1 == 0 */
4439                        type.setSourceRange(startlength);
4440                }
4441            } else if (typeReference instanceof IntersectionCastTypeReference) {
4442                TypeReference[] typeReferences = ((IntersectionCastTypeReferencetypeReference).typeReferences;
4443                switch(this.ast.apiLevel) {
4444                    case AST.JLS2_INTERNAL :
4445                    case AST.JLS3_INTERNAL :
4446                    case AST.JLS4_INTERNAL :
4447                        type = this.convertType(typeReferences[0]);
4448                        int start = typeReference.sourceStart;
4449                        int endPosition = typeReference.sourceEnd;
4450                        length = endPosition - start + 1;
4451                        type.setSourceRange(startlength);
4452                        type.setFlags(type.getFlags() | ASTNode.MALFORMED);
4453                        break;
4454                    default:
4455                        // intersection type reference
4456                        final IntersectionType castType = new IntersectionType(this.ast);
4457                        for (int i = 0max = typeReferences.lengthi < maxi++) {
4458                            castType.types().add(this.convertType(typeReferences[i]));
4459                        }
4460                        type = castType;
4461                        List types = castType.types();
4462                        int size = types.size();
4463                        start = ((Typetypes.get(0)).getStartPosition();
4464                        Type lastType = (Typetypes.get(size - 1);
4465                        endPosition = lastType.getStartPosition() + lastType.getLength();
4466                        length = endPosition - start;
4467                        type.setSourceRange(startlength);
4468                }
4469            }
4470
4471            length = typeReference.sourceEnd - sourceStart + 1;
4472            if (dimensions != 0) {
4473                type = convertToArray(typesourceStartlengthdimensionstypeReference.getAnnotationsOnDimensions(true));
4474                if (this.resolveBindings) {
4475                    completeRecord((ArrayTypetypetypeReference);
4476                }
4477            }
4478        }
4479        if (this.resolveBindings) {
4480            this.recordNodes(typetypeReference);
4481        }
4482        boolean sawDiamond = false;
4483        if (typeReference instanceof ParameterizedSingleTypeReference) {
4484            ParameterizedSingleTypeReference pstr = (ParameterizedSingleTypeReferencetypeReference;
4485            if (pstr.typeArguments == TypeReference.NO_TYPE_ARGUMENTS) {
4486                sawDiamond = true;
4487            }
4488        } else if (typeReference instanceof ParameterizedQualifiedTypeReference) {
4489            ParameterizedQualifiedTypeReference pqtr = (ParameterizedQualifiedTypeReferencetypeReference;
4490            for (int i = 0len = pqtr.typeArguments.lengthi < leni++) {
4491                if (pqtr.typeArguments[i] == TypeReference.NO_TYPE_ARGUMENTS) {
4492                    sawDiamond = true;
4493                    break;
4494                }
4495            }
4496        }
4497        if (sawDiamond) {
4498            switch(this.ast.apiLevel) {
4499                case AST.JLS2_INTERNAL :
4500                case AST.JLS3_INTERNAL :
4501                    type.setFlags(type.getFlags() | ASTNode.MALFORMED);
4502            }
4503        }
4504        return type;
4505    }
4506
4507    private Type createBaseType(TypeReference typeReferencelong[] positions,
4508            org.eclipse.jdt.internal.compiler.ast.Annotation[][] typeAnnotationschar[][] tokensint lenth,
4509            int firstTypeIndexboolean isTypeArgumentBased) {
4510        Type currentType;
4511        Name name = null;
4512        if (firstTypeIndex == 0) {
4513            name = createSimpleName(typeReferencepositionstokens0 );
4514            currentType = createSimpleType(nametypeReferencepositions00);
4515            setSourceRangeAnnotationsAndRecordNodes(typeReference, (SimpleTypecurrentTypepositionstypeAnnotations00name.index > 0 ? name.index - 1 : 0);
4516        } else if (firstTypeIndex == lenth) {//Just a QualifiedName
4517            name = setQualifiedNameNameAndSourceRanges(tokenspositionsfirstTypeIndex - 1typeReference);
4518            currentType = createSimpleType(nametypeReferencepositions0firstTypeIndex - 1);
4519        } else if (isTypeArgumentBased && (typeAnnotations == null || typeAnnotations[firstTypeIndex] == null)) {
4520            name = setQualifiedNameNameAndSourceRanges(tokenspositionsfirstTypeIndextypeReference);
4521            currentType = createSimpleType(nametypeReferencepositions0firstTypeIndex);
4522        } else {
4523            if (firstTypeIndex == 1) {
4524                name = createSimpleName(typeReferencepositionstokens0 );
4525            } else {
4526                name = setQualifiedNameNameAndSourceRanges(tokenspositionsfirstTypeIndex - 1typeReference);
4527            }
4528
4529            boolean createNameQualifiedType = typeAnnotations != null && typeAnnotations[firstTypeIndex] != null;
4530            if (createNameQualifiedType && this.ast.apiLevel >= AST.JLS8_INTERNAL) {
4531                NameQualifiedType nameQualifiedType = new NameQualifiedType(this.ast);
4532                nameQualifiedType.setQualifier(name);
4533                nameQualifiedType.setName(createSimpleName(typeReferencepositionstokensfirstTypeIndex));
4534                setSourceRangeAnnotationsAndRecordNodes(typeReferencenameQualifiedTypepositionstypeAnnotationsfirstTypeIndex0firstTypeIndex);
4535                currentType = nameQualifiedType;
4536            } else {
4537                SimpleType simpleType = this.ast.newSimpleType(name);
4538                setSourceRangeAnnotationsAndRecordNodes(typeReferencesimpleTypepositionstypeAnnotations00name.index > 0 ? name.index - 1 : 0);
4539                currentType = createQualifiedType(typeReferencepositions,  typeAnnotationstokensfirstTypeIndexsimpleType);
4540                if (createNameQualifiedType)
4541                    currentType.setFlags(currentType.getFlags() | ASTNode.MALFORMED);
4542            }
4543        }
4544        return currentType;
4545    }
4546
4547    private QualifiedType createQualifiedType(TypeReference typeReferencelong[] positions,
4548            org.eclipse.jdt.internal.compiler.ast.Annotation[][] typeAnnotationschar[][] tokensint index,
4549            Type qualifier) {
4550        SimpleName simpleName = createSimpleName(typeReferencepositionstokensindex);
4551        QualifiedType qualifiedType = new QualifiedType(this.ast);
4552        qualifiedType.setQualifier(qualifier);
4553        qualifiedType.setName(simpleName);
4554        int start = qualifier.getStartPosition();
4555        int end = simpleName.getStartPosition() + simpleName.getLength() - 1;
4556        setSourceRangeAnnotationsAndRecordNodes(typeReferencequalifiedTypetypeAnnotationsindexstartend);
4557        return qualifiedType;
4558    }
4559
4560    private SimpleType createSimpleType(Name nameTypeReference typeReferencelong[] positions,
4561            int startIndexint endIndex) {
4562        SimpleType simpleType = new SimpleType(this.ast);
4563        simpleType.setName(name);
4564        int start = (int)(positions[startIndex] >>> 32);
4565        int end = (int)positions[endIndex];
4566        simpleType.setSourceRange(startend - start + 1);
4567        if (this.resolveBindings) {
4568            recordNodes(simpleTypetypeReference);
4569        }
4570        return simpleType;
4571    }
4572
4573    private void setSourceRangeAnnotationsAndRecordNodes(TypeReference typeReferenceAnnotatableType annotatableType,
4574            org.eclipse.jdt.internal.compiler.ast.Annotation[][] typeAnnotationsint indexint startint end) {
4575        org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations;
4576        int length = end - start + 1;
4577        annotatableType.setSourceRange(startlength);
4578        if (typeAnnotations != null && (annotations = typeAnnotations[index]) != null) {
4579            annotateType(annotatableTypeannotations);
4580        }
4581        if (this.resolveBindings) {
4582            recordNodes(annotatableTypetypeReference);
4583        }
4584    }
4585
4586    private void setSourceRangeAnnotationsAndRecordNodes(TypeReference typeReferenceAnnotatableType annotatableType,
4587            long[] positionsorg.eclipse.jdt.internal.compiler.ast.Annotation[][] typeAnnotationsint indexint startIndexint endIndex) {
4588        int start = (int) (positions[startIndex] >>> 32);
4589        int end = (intpositions[endIndex];
4590        setSourceRangeAnnotationsAndRecordNodes(typeReferenceannotatableTypetypeAnnotationsindexstartend);
4591    }
4592
4593    private SimpleName createSimpleName(TypeReference typeReferencelong[] positionschar[][] tokensint index) {
4594        final SimpleName simpleName = new SimpleName(this.ast);
4595        simpleName.internalSetIdentifier(new String(tokens[index]));
4596        recordPendingNameScopeResolution(simpleName);
4597        int start = (int) (positions[index] >>> 32);
4598        int end = (intpositions[index];
4599        simpleName.setSourceRange(startend - start + 1);
4600        simpleName.index = index + 1;
4601        if (this.resolveBindings) {
4602            recordNodes(simpleNametypeReference);
4603        }
4604        return simpleName;
4605    }
4606
4607    protected Comment createComment(int[] positions) {
4608        // Create comment node
4609        Comment comment = null;
4610        int start = positions[0];
4611        int end = positions[1];
4612        if (positions[1]>0) { // Javadoc comments have positive end position
4613            Javadoc docComment = this.docParser.parse(positions);
4614            if (docComment == null) return null;
4615            comment = docComment;
4616        } else {
4617            end = -end;
4618            if (positions[0] == 0) { // we cannot know without testing chars again
4619                if (this.docParser.scanner.source[1] == '/') {
4620                    comment = new LineComment(this.ast);
4621                } else {
4622                    comment = new BlockComment(this.ast);
4623                }
4624            }
4625            else if (positions[0]>0) { // Block comment have positive start position
4626                comment = new BlockComment(this.ast);
4627            } else { // Line comment have negative start and end position
4628                start = -start;
4629                comment = new LineComment(this.ast);
4630            }
4631            comment.setSourceRange(startend - start);
4632        }
4633        return comment;
4634    }
4635
4636    protected Statement createFakeEmptyStatement(org.eclipse.jdt.internal.compiler.ast.Statement statement) {
4637        if (statement == null) return null;
4638        EmptyStatement emptyStatement = new EmptyStatement(this.ast);
4639        emptyStatement.setFlags(emptyStatement.getFlags() | ASTNode.MALFORMED);
4640        int start = statement.sourceStart;
4641        int end = statement.sourceEnd;
4642        emptyStatement.setSourceRange(startend - start + 1);
4643        return emptyStatement;
4644    }
4645
4646    /**
4647     * Warning: Callers of this method must ensure that the fake literal node is not recorded in
4648     * {@link #recordNodes(ASTNode, org.eclipse.jdt.internal.compiler.ast.ASTNode)}, see bug 403444!
4649     */
4650    protected Expression createFakeNullLiteral(org.eclipse.jdt.internal.compiler.ast.Expression expression) {
4651        if (this.referenceContext != null) {
4652            this.referenceContext.setFlags(this.referenceContext.getFlags() | ASTNode.MALFORMED);
4653        }
4654        NullLiteral nullLiteral = new NullLiteral(this.ast);
4655        nullLiteral.setFlags(nullLiteral.getFlags() | ASTNode.MALFORMED);
4656        nullLiteral.setSourceRange(expression.sourceStartexpression.sourceEnd - expression.sourceStart + 1);
4657        return nullLiteral;
4658    }
4659
4660    /**
4661     * Warning: Callers of this method must ensure that the fake pattern node is not recorded in
4662     * {@link #recordNodes(ASTNode, org.eclipse.jdt.internal.compiler.ast.ASTNode)},similar to fake NullLiteral
4663     */
4664    protected Pattern createFakeNullPattern(org.eclipse.jdt.internal.compiler.ast.Pattern pattern) {
4665        if (this.referenceContext != null) {
4666            this.referenceContext.setFlags(this.referenceContext.getFlags() | ASTNode.MALFORMED);
4667        }
4668        NullPattern nullPattern= new NullPattern(this.ast);
4669        nullPattern.setFlags(nullPattern.getFlags() | ASTNode.MALFORMED);
4670        nullPattern.setSourceRange(pattern.sourceStartpattern.sourceEnd - pattern.sourceStart + 1);
4671        return nullPattern;
4672    }
4673
4674    /**
4675     * @return a new modifier
4676     */
4677    private Modifier createModifier(ModifierKeyword keyword) {
4678        final Modifier modifier = new Modifier(this.ast);
4679        modifier.setKeyword(keyword);
4680        int start = this.scanner.getCurrentTokenStartPosition();
4681        int end = this.scanner.getCurrentTokenEndPosition();
4682        modifier.setSourceRange(startend - start + 1);
4683        return modifier;
4684    }
4685
4686    /**
4687     * @return a new module modifier
4688     */
4689    private ModuleModifier createModuleModifier(ModuleModifierKeyword keyword) {
4690        final ModuleModifier modifier = new ModuleModifier(this.ast);
4691        modifier.setKeyword(keyword);
4692        int start = this.scanner.getCurrentTokenStartPosition();
4693        int end = this.scanner.getCurrentTokenEndPosition();
4694        modifier.setSourceRange(startend - start + 1);
4695        return modifier;
4696    }
4697
4698    protected InfixExpression.Operator getOperatorFor(int operatorID) {
4699        switch (operatorID) {
4700            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.EQUAL_EQUAL :
4701                return InfixExpression.Operator.EQUALS;
4702            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.LESS_EQUAL :
4703                return InfixExpression.Operator.LESS_EQUALS;
4704            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.GREATER_EQUAL :
4705                return InfixExpression.Operator.GREATER_EQUALS;
4706            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.NOT_EQUAL :
4707                return InfixExpression.Operator.NOT_EQUALS;
4708            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.LEFT_SHIFT :
4709                return InfixExpression.Operator.LEFT_SHIFT;
4710            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.RIGHT_SHIFT :
4711                return InfixExpression.Operator.RIGHT_SHIFT_SIGNED;
4712            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.UNSIGNED_RIGHT_SHIFT :
4713                return InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED;
4714            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.OR_OR :
4715                return InfixExpression.Operator.CONDITIONAL_OR;
4716            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.AND_AND :
4717                return InfixExpression.Operator.CONDITIONAL_AND;
4718            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS :
4719                return InfixExpression.Operator.PLUS;
4720            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS :
4721                return InfixExpression.Operator.MINUS;
4722            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.REMAINDER :
4723                return InfixExpression.Operator.REMAINDER;
4724            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.XOR :
4725                return InfixExpression.Operator.XOR;
4726            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.AND :
4727                return InfixExpression.Operator.AND;
4728            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.MULTIPLY :
4729                return InfixExpression.Operator.TIMES;
4730            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.OR :
4731                return InfixExpression.Operator.OR;
4732            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.DIVIDE :
4733                return InfixExpression.Operator.DIVIDE;
4734            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.GREATER :
4735                return InfixExpression.Operator.GREATER;
4736            case org.eclipse.jdt.internal.compiler.ast.OperatorIds.LESS :
4737                return InfixExpression.Operator.LESS;
4738        }
4739        return null;
4740    }
4741
4742    protected PrimitiveType.Code getPrimitiveTypeCode(char[] name) {
4743        switch(name[0]) {
4744            case 'i' :
4745                if (name.length == 3 && name[1] == 'n' && name[2] == 't') {
4746                    return PrimitiveType.INT;
4747                }
4748                break;
4749            case 'l' :
4750                if (name.length == 4 && name[1] == 'o' && name[2] == 'n' && name[3] == 'g') {
4751                    return PrimitiveType.LONG;
4752                }
4753                break;
4754            case 'd' :
4755                if (name.length == 6
4756                     && name[1] == 'o'
4757                     && name[2] == 'u'
4758                     && name[3] == 'b'
4759                     && name[4] == 'l'
4760                     && name[5] == 'e') {
4761                    return PrimitiveType.DOUBLE;
4762                }
4763                break;
4764            case 'f' :
4765                if (name.length == 5
4766                     && name[1] == 'l'
4767                     && name[2] == 'o'
4768                     && name[3] == 'a'
4769                     && name[4] == 't') {
4770                    return PrimitiveType.FLOAT;
4771                }
4772                break;
4773            case 'b' :
4774                if (name.length == 4
4775                     && name[1] == 'y'
4776                     && name[2] == 't'
4777                     && name[3] == 'e') {
4778                    return PrimitiveType.BYTE;
4779                } else
4780                    if (name.length == 7
4781                         && name[1] == 'o'
4782                         && name[2] == 'o'
4783                         && name[3] == 'l'
4784                         && name[4] == 'e'
4785                         && name[5] == 'a'
4786                         && name[6] == 'n') {
4787                    return PrimitiveType.BOOLEAN;
4788                }
4789                break;
4790            case 'c' :
4791                if (name.length == 4
4792                     && name[1] == 'h'
4793                     && name[2] == 'a'
4794                     && name[3] == 'r') {
4795                    return PrimitiveType.CHAR;
4796                }
4797                break;
4798            case 's' :
4799                if (name.length == 5
4800                     && name[1] == 'h'
4801                     && name[2] == 'o'
4802                     && name[3] == 'r'
4803                     && name[4] == 't') {
4804                    return PrimitiveType.SHORT;
4805                }
4806                break;
4807            case 'v' :
4808                if (name.length == 4
4809                     && name[1] == 'o'
4810                     && name[2] == 'i'
4811                     && name[3] == 'd') {
4812                    return PrimitiveType.VOID;
4813                }
4814        }
4815        return null// cannot be reached
4816    }
4817
4818    protected boolean isPrimitiveType(char[] name) {
4819        switch(name[0]) {
4820            case 'i' :
4821                if (name.length == 3 && name[1] == 'n' && name[2] == 't') {
4822                    return true;
4823                }
4824                return false;
4825            case 'l' :
4826                if (name.length == 4 && name[1] == 'o' && name[2] == 'n' && name[3] == 'g') {
4827                    return true;
4828                }
4829                return false;
4830            case 'd' :
4831                if (name.length == 6
4832                     && name[1] == 'o'
4833                     && name[2] == 'u'
4834                     && name[3] == 'b'
4835                     && name[4] == 'l'
4836                     && name[5] == 'e') {
4837                    return true;
4838                }
4839                return false;
4840            case 'f' :
4841                if (name.length == 5
4842                     && name[1] == 'l'
4843                     && name[2] == 'o'
4844                     && name[3] == 'a'
4845                     && name[4] == 't') {
4846                    return true;
4847                }
4848                return false;
4849            case 'b' :
4850                if (name.length == 4
4851                     && name[1] == 'y'
4852                     && name[2] == 't'
4853                     && name[3] == 'e') {
4854                    return true;
4855                } else
4856                    if (name.length == 7
4857                         && name[1] == 'o'
4858                         && name[2] == 'o'
4859                         && name[3] == 'l'
4860                         && name[4] == 'e'
4861                         && name[5] == 'a'
4862                         && name[6] == 'n') {
4863                    return true;
4864                }
4865                return false;
4866            case 'c' :
4867                if (name.length == 4
4868                     && name[1] == 'h'
4869                     && name[2] == 'a'
4870                     && name[3] == 'r') {
4871                    return true;
4872                }
4873                return false;
4874            case 's' :
4875                if (name.length == 5
4876                     && name[1] == 'h'
4877                     && name[2] == 'o'
4878                     && name[3] == 'r'
4879                     && name[4] == 't') {
4880                    return true;
4881                }
4882                return false;
4883            case 'v' :
4884                if (name.length == 4
4885                     && name[1] == 'o'
4886                     && name[2] == 'i'
4887                     && name[3] == 'd') {
4888                    return true;
4889                }
4890                return false;
4891        }
4892        return false;
4893    }
4894    private void lookupForScopes() {
4895        if (this.pendingNameScopeResolution != null) {
4896            for (Iterator iterator = this.pendingNameScopeResolution.iterator(); iterator.hasNext(); ) {
4897                Name name = (Nameiterator.next();
4898                this.ast.getBindingResolver().recordScope(namelookupScope(name));
4899            }
4900        }
4901        if (this.pendingThisExpressionScopeResolution != null) {
4902            for (Iterator iterator = this.pendingThisExpressionScopeResolution.iterator(); iterator.hasNext(); ) {
4903                ThisExpression thisExpression = (ThisExpressioniterator.next();
4904                this.ast.getBindingResolver().recordScope(thisExpressionlookupScope(thisExpression));
4905            }
4906        }
4907
4908    }
4909
4910    private BlockScope lookupScope(ASTNode node) {
4911        ASTNode currentNode = node;
4912        while(currentNode != null
4913            &&!(currentNode instanceof MethodDeclaration)
4914            && !(currentNode instanceof Initializer)
4915            && !(currentNode instanceof FieldDeclaration)
4916            && !(currentNode instanceof AbstractTypeDeclaration)) {
4917            currentNode = currentNode.getParent();
4918        }
4919        if (currentNode == null) {
4920            return null;
4921        }
4922        if (currentNode instanceof Initializer) {
4923            Initializer initializer = (InitializercurrentNode;
4924            while(!(currentNode instanceof AbstractTypeDeclaration)) {
4925                currentNode = currentNode.getParent();
4926            }
4927            if (currentNode instanceof TypeDeclaration
4928                || currentNode instanceof EnumDeclaration
4929                || currentNode instanceof AnnotationTypeDeclaration
4930                || currentNode instanceof RecordDeclaration) {
4931                org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDecl =
4932                        (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration)
4933                        this.ast.getBindingResolver().getCorrespondingNode(currentNode);
4934                if ((initializer.getModifiers() & Modifier.STATIC) != 0) {
4935                    return typeDecl.staticInitializerScope;
4936                } else {
4937                    return typeDecl.initializerScope;
4938                }
4939            }
4940        } else if (currentNode instanceof FieldDeclaration) {
4941            FieldDeclaration fieldDeclaration = (FieldDeclarationcurrentNode;
4942            while(!(currentNode instanceof AbstractTypeDeclaration)) {
4943                currentNode = currentNode.getParent();
4944            }
4945            org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDecl = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) this.ast.getBindingResolver().getCorrespondingNode(currentNode);
4946            if ((fieldDeclaration.getModifiers() & Modifier.STATIC) != 0) {
4947                return typeDecl.staticInitializerScope;
4948            } else {
4949                return typeDecl.initializerScope;
4950            }
4951        } else if (currentNode instanceof AbstractTypeDeclaration) {
4952            org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDecl = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) this.ast.getBindingResolver().getCorrespondingNode(currentNode);
4953            return typeDecl.initializerScope;
4954        }
4955        AbstractMethodDeclaration abstractMethodDeclaration = (AbstractMethodDeclaration) this.ast.getBindingResolver().getCorrespondingNode(currentNode);
4956        return abstractMethodDeclaration.scope;
4957    }
4958
4959    protected void recordName(Name nameorg.eclipse.jdt.internal.compiler.ast.ASTNode compilerNode) {
4960        if (compilerNode != null) {
4961            if (name instanceof ModuleQualifiedName &&
4962                    compilerNode instanceof org.eclipse.jdt.internal.compiler.ast.TypeReference) {
4963                Name tName = ((ModuleQualifiedName)name).getName();
4964                if (tName != null) {
4965                    recordName(tNamecompilerNode);
4966                    return;
4967                }
4968            }
4969            recordNodes(namecompilerNode);
4970            if (compilerNode instanceof org.eclipse.jdt.internal.compiler.ast.TypeReference) {
4971                org.eclipse.jdt.internal.compiler.ast.TypeReference typeRef = (org.eclipse.jdt.internal.compiler.ast.TypeReferencecompilerNode;
4972                if (name.isQualifiedName()) {
4973                    SimpleName simpleName = null;
4974                    while (name.isQualifiedName()) {
4975                        simpleName = ((QualifiedNamename).getName();
4976                        recordNodes(simpleNametypeRef);
4977                        name = ((QualifiedNamename).getQualifier();
4978                        recordNodes(nametypeRef);
4979                    }
4980                }
4981            }
4982        }
4983    }
4984
4985    protected void recordNodes(ASTNode nodeorg.eclipse.jdt.internal.compiler.ast.ASTNode oldASTNode) {
4986        // Do not record the fake literal node created in lieu of functional expressions at JLS levels < 8, as it would lead to CCE down the road.
4987        if (oldASTNode instanceof org.eclipse.jdt.internal.compiler.ast.FunctionalExpression && node instanceof NullLiteral) {
4988            return;
4989        }
4990        if (oldASTNode instanceof org.eclipse.jdt.internal.compiler.ast.Pattern && node instanceof NullPattern) {
4991            return;
4992        }
4993        this.ast.getBindingResolver().store(nodeoldASTNode);
4994    }
4995
4996    protected void recordNodes(org.eclipse.jdt.internal.compiler.ast.Javadoc javadocTagElement tagElement) {
4997        // To do: for Tag property
4998        Iterator fragments = tagElement.fragments().listIterator();
4999        while (fragments.hasNext()) {
5000            ASTNode node = (ASTNodefragments.next();
5001            if (node.getNodeType() == ASTNode.MEMBER_REF) {
5002                MemberRef memberRef = (MemberRefnode;
5003                Name name = memberRef.getName();
5004                // get compiler node and record nodes
5005                int start = name.getStartPosition();
5006                org.eclipse.jdt.internal.compiler.ast.ASTNode compilerNode = javadoc.getNodeStartingAt(start);
5007                if (compilerNode!= null) {
5008                    recordNodes(namecompilerNode);
5009                    recordNodes(nodecompilerNode);
5010                }
5011                // Replace qualifier to have all nodes recorded
5012                if (memberRef.getQualifier() != null) {
5013                    org.eclipse.jdt.internal.compiler.ast.TypeReference typeRef = null;
5014                    org.eclipse.jdt.internal.compiler.ast.JavadocModuleReference modRef = null;
5015                    if (compilerNode instanceof JavadocFieldReference) {
5016                        org.eclipse.jdt.internal.compiler.ast.Expression expression = ((JavadocFieldReference)compilerNode).receiver;
5017                        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.TypeReference) {
5018                            typeRef = (org.eclipse.jdt.internal.compiler.ast.TypeReferenceexpression;
5019                        } else if (expression instanceof org.eclipse.jdt.internal.compiler.ast.JavadocModuleReference) {
5020                            modRef = (org.eclipse.jdt.internal.compiler.ast.JavadocModuleReferenceexpression;
5021                            if (modRef.typeReference != null) {
5022                                typeRef = modRef.typeReference;
5023                            }
5024                        }
5025                    }
5026                    else if (compilerNode instanceof JavadocMessageSend) {
5027                        org.eclipse.jdt.internal.compiler.ast.Expression expression = ((JavadocMessageSend)compilerNode).receiver;
5028                        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.TypeReference) {
5029                            typeRef = (org.eclipse.jdt.internal.compiler.ast.TypeReferenceexpression;
5030                        }
5031                    }
5032                    Name mQual = memberRef.getQualifier();
5033                    if (typeRef != null) {
5034                        if (mQual instanceof ModuleQualifiedName
5035                                && modRef != null) {
5036                            ModuleQualifiedName moduleQualifiedName = (ModuleQualifiedName)mQual;
5037                            recordName(moduleQualifiedNamemodRef);
5038                            recordName(moduleQualifiedName.getModuleQualifier(), modRef.moduleReference);
5039                            recordName(moduleQualifiedName.getName(), typeRef);
5040                        } else {
5041                            recordName(memberRef.getQualifier(), typeRef);
5042                        }
5043                    }
5044                }
5045            } else if (node.getNodeType() == ASTNode.METHOD_REF) {
5046                MethodRef methodRef = (MethodRefnode;
5047                Name name = methodRef.getName();
5048                // get method name start position
5049                int start = methodRef.getStartPosition();
5050                this.scanner.resetTo(startstart + name.getStartPosition()+name.getLength());
5051                int token;
5052                try {
5053                    nextToken: while((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF && token != TerminalTokens.TokenNameLPAREN)  {
5054                        if (token == TerminalTokens.TokenNameERROR && this.scanner.currentCharacter == '#') {
5055                            start = this.scanner.getCurrentTokenEndPosition()+1;
5056                            break nextToken;
5057                        }
5058                    }
5059                }
5060                catch(InvalidInputException e) {
5061                    // ignore
5062                }
5063                // get compiler node and record nodes
5064                org.eclipse.jdt.internal.compiler.ast.ASTNode compilerNode = javadoc.getNodeStartingAt(start);
5065                // record nodes
5066                if (compilerNode != null) {
5067                    recordNodes(methodRefcompilerNode);
5068                    // get type ref
5069                    org.eclipse.jdt.internal.compiler.ast.TypeReference typeRef = null;
5070                    if (compilerNode instanceof org.eclipse.jdt.internal.compiler.ast.JavadocAllocationExpression) {
5071                        typeRef = ((org.eclipse.jdt.internal.compiler.ast.JavadocAllocationExpression)compilerNode).type;
5072                        if (typeRef != nullrecordNodes(namecompilerNode);
5073                    }
5074                    else if (compilerNode instanceof org.eclipse.jdt.internal.compiler.ast.JavadocMessageSend) {
5075                        org.eclipse.jdt.internal.compiler.ast.Expression expression = ((org.eclipse.jdt.internal.compiler.ast.JavadocMessageSend)compilerNode).receiver;
5076                        if (expression instanceof org.eclipse.jdt.internal.compiler.ast.TypeReference) {
5077                            typeRef = (org.eclipse.jdt.internal.compiler.ast.TypeReferenceexpression;
5078                        }
5079                        recordNodes(namecompilerNode);
5080                    }
5081                    Name mQualmethodRef.getQualifier();
5082                    // record name and qualifier
5083                    if (typeRef != null && mQual != null) {
5084                        if (mQual instanceof ModuleQualifiedName) {
5085                            recordName(mQualjavadoc.getNodeStartingAt(mQual.getStartPosition()));
5086                        }
5087                        recordName(methodRef.getQualifier(), typeRef);
5088                    }
5089                }
5090                // Resolve parameters
5091                Iterator parameters = methodRef.parameters().listIterator();
5092                while (parameters.hasNext()) {
5093                    MethodRefParameter param = (MethodRefParameterparameters.next();
5094                    org.eclipse.jdt.internal.compiler.ast.Expression expression = (org.eclipse.jdt.internal.compiler.ast.Expressionjavadoc.getNodeStartingAt(param.getStartPosition());
5095                    if (expression != null) {
5096                        recordNodes(paramexpression);
5097                        if (expression instanceof JavadocArgumentExpression) {
5098                            JavadocArgumentExpression argExpr = (JavadocArgumentExpressionexpression;
5099                            org.eclipse.jdt.internal.compiler.ast.TypeReference typeRef = argExpr.argument.type;
5100                            if (this.ast.apiLevel >= AST.JLS3_INTERNAL) {
5101                                param.setVarargs(argExpr.argument.isVarArgs());
5102                            }
5103                            recordNodes(param.getType(), typeRef);
5104                            if (param.getType().isSimpleType()) {
5105                                recordName(((SimpleType)param.getType()).getName(), typeRef);
5106                            } else if (param.getType().isArrayType()) {
5107                                Type type = ((ArrayTypeparam.getType()).getElementType();
5108                                recordNodes(typetypeRef);
5109                                if (type.isSimpleType()) {
5110                                    recordName(((SimpleType)type).getName(), typeRef);
5111                                }
5112                            }
5113                        }
5114                    }
5115                }
5116            } else if (node.getNodeType() == ASTNode.SIMPLE_NAME ||
5117                    node.getNodeType() == ASTNode.QUALIFIED_NAME) {
5118                org.eclipse.jdt.internal.compiler.ast.ASTNode compilerNode = javadoc.getNodeStartingAt(node.getStartPosition());
5119                recordName((NamenodecompilerNode);
5120            } else if (node.getNodeType() == ASTNode.MODULE_QUALIFIED_NAME) {
5121                ModuleQualifiedName mqName = (ModuleQualifiedNamenode;
5122                org.eclipse.jdt.internal.compiler.ast.ASTNode compilerNode = javadoc.getNodeStartingAt(mqName.getStartPosition());
5123                recordName(mqNamecompilerNode);
5124                Name name = mqName.getName();
5125                if (name != null) {
5126                    org.eclipse.jdt.internal.compiler.ast.ASTNode internalNode = javadoc.getNodeStartingAt(name.getStartPosition());
5127                    recordName(nameinternalNode);
5128                }
5129                if (compilerNode instanceof org.eclipse.jdt.internal.compiler.ast.JavadocModuleReference) {
5130                    org.eclipse.jdt.internal.compiler.ast.ASTNode internalNode = ((org.eclipse.jdt.internal.compiler.ast.JavadocModuleReference)compilerNode).moduleReference;
5131                    recordNodes(mqName.getModuleQualifier(), internalNode);
5132                }
5133            } else if (node.getNodeType() == ASTNode.TAG_ELEMENT) {
5134                // resolve member and method references binding
5135                recordNodes(javadoc, (TagElementnode);
5136            }
5137        }
5138    }
5139
5140    protected void recordPendingNameScopeResolution(Name name) {
5141        if (this.pendingNameScopeResolution == null) {
5142            this.pendingNameScopeResolution = new HashSet();
5143        }
5144        this.pendingNameScopeResolution.add(name);
5145    }
5146
5147    protected void recordPendingThisExpressionScopeResolution(ThisExpression thisExpression) {
5148        if (this.pendingThisExpressionScopeResolution == null) {
5149            this.pendingThisExpressionScopeResolution = new HashSet();
5150        }
5151        this.pendingThisExpressionScopeResolution.add(thisExpression);
5152    }
5153
5154    /**
5155     * Remove whitespaces and comments before and after the expression.
5156     */
5157    private void trimWhiteSpacesAndComments(org.eclipse.jdt.internal.compiler.ast.Expression expression) {
5158        int[] positions = trimWhiteSpacesAndComments(expression.sourceStartexpression.sourceEnd);
5159        expression.sourceStart = positions[0];
5160        expression.sourceEnd = positions[1];
5161    }
5162    private void trimWhiteSpacesAndComments(ASTNode node) {
5163        int start = node.getStartPosition();
5164        int end = start + node.getLength() - 1;
5165        int[] positions = trimWhiteSpacesAndComments(startend);
5166        start = positions[0];
5167        end = positions[1];
5168        node.setSourceRange(startend - start + 1);
5169    }
5170    private int [] trimWhiteSpacesAndComments(int startint end) {
5171        int [] positions = new int[]{startend};
5172        int token;
5173        int trimLeftPosition = start;
5174        int trimRightPosition = end;
5175        boolean first = true;
5176        Scanner removeBlankScanner = this.ast.scanner;
5177        try {
5178            removeBlankScanner.setSource(this.compilationUnitSource);
5179            removeBlankScanner.resetTo(startend);
5180            while (true) {
5181                token = removeBlankScanner.getNextToken();
5182                switch (token) {
5183                    case TerminalTokens.TokenNameCOMMENT_JAVADOC :
5184                    case TerminalTokens.TokenNameCOMMENT_LINE :
5185                    case TerminalTokens.TokenNameCOMMENT_BLOCK :
5186                        if (first) {
5187                            trimLeftPosition = removeBlankScanner.currentPosition;
5188                        }
5189                        break;
5190                    case TerminalTokens.TokenNameWHITESPACE :
5191                        if (first) {
5192                            trimLeftPosition = removeBlankScanner.currentPosition;
5193                        }
5194                        break;
5195                    case TerminalTokens.TokenNameEOF :
5196                        positions[0] = trimLeftPosition;
5197                        positions[1] = trimRightPosition;
5198                        return positions;
5199                    default :
5200                        /*
5201                         * if we find something else than a whitespace or a comment,
5202                         * then we reset the trimRigthPosition to the expression
5203                         * source end.
5204                         */
5205                        trimRightPosition = removeBlankScanner.currentPosition - 1;
5206                        first = false;
5207                }
5208            }
5209        } catch (InvalidInputException e){
5210            // ignore
5211        }
5212        return positions;
5213    }
5214
5215    /**
5216     * Remove potential trailing comment by settings the source end on the closing parenthesis
5217     */
5218    protected void removeLeadingAndTrailingCommentsFromLiteral(ASTNode node) {
5219        int start = node.getStartPosition();
5220        this.scanner.resetTo(startstart + node.getLength());
5221        int token;
5222        int startPosition = -1;
5223        try {
5224            while((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF)  {
5225                switch(token) {
5226                    case TerminalTokens.TokenNameIntegerLiteral :
5227                    case TerminalTokens.TokenNameFloatingPointLiteral :
5228                    case TerminalTokens.TokenNameLongLiteral :
5229                    case TerminalTokens.TokenNameDoubleLiteral :
5230                    case TerminalTokens.TokenNameCharacterLiteral :
5231                        if (startPosition == -1) {
5232                            startPosition = this.scanner.startPosition;
5233                        }
5234                        int end = this.scanner.currentPosition;
5235                        node.setSourceRange(startPositionend - startPosition);
5236                        return;
5237                    case TerminalTokens.TokenNameMINUS :
5238                        startPosition = this.scanner.startPosition;
5239                        break;
5240                }
5241            }
5242        } catch(InvalidInputException e) {
5243            // ignore
5244        }
5245    }
5246
5247    /**
5248     * This method is used to retrieve the end position of the block.
5249     * @return the dimension found, -1 if none
5250     */
5251    protected int retrieveClosingAngleBracketPosition(int start) {
5252        this.scanner.resetTo(start, this.compilationUnitSourceLength);
5253        this.scanner.returnOnlyGreater = true;
5254        try {
5255            int token;
5256            while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
5257                switch(token) {
5258                    case TerminalTokens.TokenNameGREATER:
5259                        return this.scanner.currentPosition - 1;
5260                    case TerminalTokens.TokenNameLESS:
5261                        // TokenNameLESS can only be found if the current type has a diamond, start is located before the '<'
5262                        continue;
5263                    default:
5264                        return start;
5265                }
5266            }
5267        } catch(InvalidInputException e) {
5268            // ignore
5269        }
5270        this.scanner.returnOnlyGreater = false;
5271        return start;
5272    }
5273
5274    /**
5275     * This method is used to set the right end position for expression
5276     * statement. The actual AST nodes don't include the trailing semicolon.
5277     * This method fixes the length of the corresponding node.
5278     */
5279    protected void retrieveColonPosition(ASTNode node) {
5280        setNodeSourceEndPosition(nodeTerminalTokens.TokenNameCOLON);
5281    }
5282    /**
5283     * This method is used to set the right end position for switch labeled rules ie with '->'
5284     * The actual AST nodes don't include the trailing semicolon.
5285     * This method fixes the length of the corresponding node.
5286     */
5287    private void retrieveArrowPosition(ASTNode node) {
5288        setNodeSourceEndPosition(nodeTerminalTokens.TokenNameARROW);
5289    }
5290    private void setNodeSourceEndPosition(ASTNode nodeint expectedToken) {
5291        int start = node.getStartPosition();
5292        int length = node.getLength();
5293        int end = start + length;
5294        this.scanner.resetTo(end, this.compilationUnitSourceLength);
5295        try {
5296            int token;
5297            while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
5298                if (token == expectedToken) {
5299                        node.setSourceRange(start, this.scanner.currentPosition - start);
5300                        return;
5301                }
5302            }
5303        } catch(InvalidInputException e) {
5304            // ignore
5305        }
5306    }
5307    /**
5308     * This method is used to retrieve the start position of the Ellipsis
5309     */
5310    protected int retrieveEllipsisStartPosition(int startint end) {
5311        this.scanner.resetTo(startend);
5312        try {
5313            int token;
5314            while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
5315                switch(token) {
5316                    case TerminalTokens.TokenNameELLIPSIS:
5317                        return this.scanner.startPosition - 1;
5318                }
5319            }
5320        } catch(InvalidInputException e) {
5321            // ignore
5322        }
5323        return -1;
5324
5325    }
5326
5327    protected int retrieveSemiColonPosition(Expression node) {
5328        int start = node.getStartPosition();
5329        int length = node.getLength();
5330        int end = start + length;
5331        this.scanner.resetTo(end, this.compilationUnitSourceLength);
5332        try {
5333            int token;
5334            while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
5335                switch(token) {
5336                    case TerminalTokens.TokenNameSEMICOLON:
5337                        return this.scanner.currentPosition - 1;
5338                }
5339            }
5340        } catch(InvalidInputException e) {
5341            // ignore
5342        }
5343        return -1;
5344    }
5345
5346    /**
5347     * This method is used to retrieve the start and end position of a name or primitive type token.
5348     *
5349     * @return int[] a single dimensional array, with two elements, for the start and end positions of the name respectively
5350     */
5351    protected int[] retrieveEndOfElementTypeNamePosition(int startint end) {
5352        this.scanner.resetTo(startend);
5353        try {
5354            int token;
5355            int count = 0;
5356            while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
5357                switch(token) {
5358                    case TerminalTokens.TokenNameLPAREN:
5359                        ++count;
5360                        break;
5361                    case TerminalTokens.TokenNameRPAREN:
5362                        --count;
5363                        break;
5364                    case TerminalTokens.TokenNameIdentifier:
5365                    case TerminalTokens.TokenNamebyte:
5366                    case TerminalTokens.TokenNamechar:
5367                    case TerminalTokens.TokenNamedouble:
5368                    case TerminalTokens.TokenNamefloat:
5369                    case TerminalTokens.TokenNameint:
5370                    case TerminalTokens.TokenNamelong:
5371                    case TerminalTokens.TokenNameshort:
5372                    case TerminalTokens.TokenNameboolean:
5373                        if (count > 0) break;
5374                        return new int[]{this.scanner.startPosition, this.scanner.currentPosition - 1};
5375                }
5376            }
5377        } catch(InvalidInputException e) {
5378            // ignore
5379        }
5380        return new int[]{-1, -1};
5381    }
5382
5383    /**
5384     * This method is used to retrieve the position after the right parenthesis.
5385     * @return int the position found
5386     */
5387    protected int retrieveEndOfRightParenthesisPosition(int startint end) {
5388        this.scanner.resetTo(startend);
5389        try {
5390            int token;
5391            int count = 0;
5392            while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
5393                switch(token) {
5394                    case TerminalTokens.TokenNameRPAREN:
5395                        count--;
5396                        if (count <= 0) return this.scanner.currentPosition;
5397                         break;
5398                    case TerminalTokens.TokenNameLPAREN:
5399                        count++;
5400                        //$FALL-THROUGH$
5401                    default:
5402                        break;
5403                }
5404            }
5405        } catch(InvalidInputException e) {
5406            // ignore
5407        }
5408        return -1;
5409    }
5410
5411    protected void retrieveDimensionAndSetPositions(int startint endDimension dim) {
5412        this.scanner.resetTo(startend);
5413        int token;
5414        int count = 0lParenCount = 0;
5415        boolean startSet = false;
5416        try {
5417            while((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF)  {
5418                if (token != TerminalTokens.TokenNameWHITESPACE) {
5419                    if (!startSet) {
5420                        start = this.scanner.startPosition;
5421                        startSet = true;
5422                    }
5423                    switch(token) {
5424                        case TerminalTokens.TokenNameRBRACKET:
5425                            if (lParenCount > 0) break;
5426                            --count;
5427                            if (count > 0) break;
5428                            int endDim = this.scanner.currentPosition - 1;
5429                            dim.setSourceRange(startendDim - start + 1);
5430                            return;
5431                        case TerminalTokens.TokenNameLBRACKET:
5432                            if (lParenCount > 0) break;
5433                            count++;
5434                            break;
5435                        case TerminalTokens.TokenNameLPAREN:
5436                            lParenCount++;
5437                            break;
5438                        case TerminalTokens.TokenNameRPAREN:
5439                            --lParenCount;
5440                            break;
5441                        default:
5442                            break;
5443                    }
5444                }
5445            }
5446        } catch(InvalidInputException e) {
5447            // ignore
5448        }
5449    }
5450    protected void retrieveIdentifierAndSetPositions(int startint endName name) {
5451        this.scanner.resetTo(startend);
5452        int token;
5453        try {
5454            while((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF)  {
5455                if (token == TerminalTokens.TokenNameIdentifier) {
5456                    int startName = this.scanner.startPosition;
5457                    int endName = this.scanner.currentPosition - 1;
5458                    name.setSourceRange(startNameendName - startName + 1);
5459                    return;
5460                }
5461            }
5462        } catch(InvalidInputException e) {
5463            // ignore
5464        }
5465    }
5466
5467    /**
5468     * This method is used to retrieve the start position of the block.
5469     * @return int the dimension found, -1 if none
5470     */
5471    protected int retrieveIdentifierEndPosition(int startint end) {
5472        this.scanner.resetTo(startend);
5473        try {
5474            int token;
5475            while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
5476                switch(token) {
5477                    case TerminalTokens.TokenNameIdentifier://110
5478                        return this.scanner.getCurrentTokenEndPosition();
5479                }
5480            }
5481        } catch(InvalidInputException e) {
5482            // ignore
5483        }
5484        return -1;
5485    }
5486
5487    /**
5488     * retrieves the start and and of new and set the positions of the name
5489     * @param start position to start search
5490     * @param end position to end search
5491     * @param name object where these positions will be updated.
5492     */
5493    protected void retrieveInitAndSetPositions(int startint endName name) {
5494        this.scanner.resetTo(startend);
5495        int token;
5496        try {
5497            while((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF)  {
5498                if (token == TerminalTokens.TokenNamenew) {
5499                    int startName = this.scanner.startPosition;
5500                    int endName = this.scanner.currentPosition;
5501                    name.setSourceRange(startNameendName - startName);
5502                    return;
5503                }
5504            }
5505        } catch(InvalidInputException e) {
5506            // ignore
5507        }
5508    }
5509
5510    /**
5511     * This method is used to retrieve position before the next comma or semi-colon.
5512     * @param initializerEnd the given initializer end exclusive
5513     * @return int the position found.
5514     */
5515    protected int retrieveEndOfPotentialExtendedDimensions(int initializerEndint nameEndint end) {
5516        this.scanner.resetTo(initializerEndend);
5517        boolean hasTokens = false;
5518        int balance = 0;
5519        int pos = initializerEnd > nameEnd ? initializerEnd - 1 : nameEnd;
5520        try {
5521            int tokenlParenCount = 0;
5522            boolean hasAnnotations = false;
5523            while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
5524                hasTokens = true;
5525                if (hasAnnotations) {
5526                    if (token == TerminalTokens.TokenNameLPAREN) ++lParenCount;
5527                    else if (token == TerminalTokens.TokenNameRPAREN) {
5528                        --lParenCount;
5529                        continue;
5530                    }
5531                    if (lParenCount > 0) continue;
5532                }
5533                switch(token) {
5534                    case TerminalTokens.TokenNameAT:
5535                        hasAnnotations = true;
5536                        break;
5537                    case TerminalTokens.TokenNameLBRACE :
5538                    case TerminalTokens.TokenNameLBRACKET :
5539                        balance++;
5540                        break;
5541                    case TerminalTokens.TokenNameRBRACKET :
5542                    case TerminalTokens.TokenNameRBRACE :
5543                        balance --;
5544                        pos = this.scanner.currentPosition - 1;
5545                        break;
5546                    case TerminalTokens.TokenNameCOMMA :
5547                        if (balance == 0) return pos;
5548                        // case where a missing closing brace doesn't close an array initializer
5549                        pos = this.scanner.currentPosition - 1;
5550                        break;
5551                    case TerminalTokens.TokenNameSEMICOLON :
5552                        if (balance == 0) return pos;
5553                        return -pos;
5554                }
5555            }
5556        } catch(InvalidInputException e) {
5557            // ignore
5558        }
5559        // no token, we simply return pos as the right position
5560        return hasTokens ? Integer.MIN_VALUE : pos;
5561    }
5562
5563    protected int retrieveProperRightBracketPosition(int bracketNumberint startint end) {
5564        this.scanner.resetTo(start, this.compilationUnitSourceLength);
5565        try {
5566            int tokencount = 0lParentCount = 0balance = 0;
5567            while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
5568                switch(token) {
5569                    case TerminalTokens.TokenNameLPAREN:
5570                        ++lParentCount;
5571                        break;
5572                    case TerminalTokens.TokenNameRPAREN:
5573                        --lParentCount;
5574                        break;
5575                    case TerminalTokens.TokenNameLBRACKET:
5576                        ++balance;
5577                        break;
5578                    case TerminalTokens.TokenNameELLIPSIS:
5579                        ++balance// special case for varargs - simulate lbracket found
5580                        //$FALL-THROUGH$
5581                    case TerminalTokens.TokenNameRBRACKET:
5582                        --balance;
5583                        if (lParentCount > 0) break;
5584                        if (balance > 0) break;
5585                        count++;
5586                        if (count == bracketNumber) {
5587                            return this.scanner.currentPosition - 1;
5588                        }
5589                }
5590            }
5591        } catch(InvalidInputException e) {
5592            // ignore
5593        }
5594        return -1;
5595    }
5596
5597    protected int retrieveProperRightBracketPosition(int bracketNumberint start) {
5598        return retrieveProperRightBracketPosition(bracketNumberstart, this.compilationUnitSourceLength);
5599    }
5600
5601    /**
5602     * This method is used to retrieve position before the next right brace or semi-colon.
5603     * @return int the position found.
5604     */
5605    protected int retrieveRightBraceOrSemiColonPosition(int startint end) {
5606        this.scanner.resetTo(startend);
5607        try {
5608            int token;
5609            while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
5610                switch(token) {
5611                    case TerminalTokens.TokenNameRBRACE :
5612                        return this.scanner.currentPosition - 1;
5613                    case TerminalTokens.TokenNameSEMICOLON :
5614                        return this.scanner.currentPosition - 1;
5615                }
5616            }
5617        } catch(InvalidInputException e) {
5618            // ignore
5619        }
5620        return -1;
5621    }
5622
5623    /**
5624     * This method is used to retrieve position before the next right brace or semi-colon.
5625     * @return int the position found.
5626     */
5627    protected int retrieveRightBrace(int startint end) {
5628        this.scanner.resetTo(startend);
5629        try {
5630            int token;
5631            while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
5632                switch(token) {
5633                    case TerminalTokens.TokenNameRBRACE :
5634                        return this.scanner.currentPosition - 1;
5635                }
5636            }
5637        } catch(InvalidInputException e) {
5638            // ignore
5639        }
5640        return -1;
5641    }
5642
5643    /**
5644     * This method is used to retrieve the start position of the block.
5645     * @return int the dimension found, -1 if none
5646     */
5647    protected int retrieveStartBlockPosition(int startint end) {
5648        this.scanner.resetTo(startend);
5649        try {
5650            int token;
5651            while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
5652                switch(token) {
5653                    case TerminalTokens.TokenNameLBRACE://110
5654                        return this.scanner.startPosition;
5655                }
5656            }
5657        } catch(InvalidInputException e) {
5658            // ignore
5659        }
5660        return -1;
5661    }
5662
5663    /**
5664     * This method is used to retrieve the starting position of the catch keyword.
5665     * @return int the dimension found, -1 if none
5666     */
5667    protected int retrieveStartingCatchPosition(int startint end) {
5668        this.scanner.resetTo(startend);
5669        try {
5670            int token;
5671            while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
5672                switch(token) {
5673                    case TerminalTokens.TokenNamecatch://225
5674                        return this.scanner.startPosition;
5675                }
5676            }
5677        } catch(InvalidInputException e) {
5678            // ignore
5679        }
5680        return -1;
5681    }
5682
5683    public void setAST(AST ast) {
5684        this.ast = ast;
5685        this.docParser = new DocCommentParser(this.ast, this.scanner, this.insideComments);
5686    }
5687
5688    protected void setModifiers(AnnotationTypeDeclaration typeDeclorg.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) {
5689        this.scanner.resetTo(typeDeclaration.declarationSourceStarttypeDeclaration.sourceStart);
5690        this.setModifiers(typeDecltypeDeclaration.annotationstypeDeclaration.sourceStart);
5691    }
5692
5693    protected void setModifiers(AnnotationTypeMemberDeclaration annotationTypeMemberDeclorg.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration annotationTypeMemberDeclaration) {
5694        this.scanner.resetTo(annotationTypeMemberDeclaration.declarationSourceStartannotationTypeMemberDeclaration.sourceStart);
5695        this.setModifiers(annotationTypeMemberDeclannotationTypeMemberDeclaration.annotationsannotationTypeMemberDeclaration.sourceStart);
5696    }
5697
5698    /**
5699     * @param bodyDeclaration
5700     */
5701    protected void setModifiers(BodyDeclaration bodyDeclarationorg.eclipse.jdt.internal.compiler.ast.Annotation[] annotationsint modifiersEnd) {
5702        setModifiers(bodyDeclaration.modifiers(), annotationsmodifiersEnd);
5703    }
5704    protected void setModifiers(List modifiersorg.eclipse.jdt.internal.compiler.ast.Annotation[] annotationsint modifiersEnd) {
5705        this.scanner.tokenizeWhiteSpace = false;
5706        try {
5707            int token;
5708            int indexInAnnotations = 0;
5709            while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
5710                IExtendedModifier modifier = null;
5711                switch(token) {
5712                    case TerminalTokens.TokenNameabstract:
5713                        modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD);
5714                        break;
5715                    case TerminalTokens.TokenNamepublic:
5716                        modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
5717                        break;
5718                    case TerminalTokens.TokenNamestatic:
5719                        modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD);
5720                        break;
5721                    case TerminalTokens.TokenNameprotected:
5722                        modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD);
5723                        break;
5724                    case TerminalTokens.TokenNameprivate:
5725                        modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD);
5726                        break;
5727                    case TerminalTokens.TokenNamefinal:
5728                        modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD);
5729                        break;
5730                    case TerminalTokens.TokenNamenative:
5731                        modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD);
5732                        break;
5733                    case TerminalTokens.TokenNamesynchronized:
5734                        modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD);
5735                        break;
5736                    case TerminalTokens.TokenNametransient:
5737                        modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD);
5738                        break;
5739                    case TerminalTokens.TokenNamevolatile:
5740                        modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD);
5741                        break;
5742                    case TerminalTokens.TokenNamestrictfp:
5743                        modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD);
5744                        break;
5745                    case TerminalTokens.TokenNamedefault:
5746                        modifier = createModifier(Modifier.ModifierKeyword.DEFAULT_KEYWORD);
5747                        break;
5748                    case TerminalTokens.TokenNameRestrictedIdentifiersealed:
5749                        modifier = createModifier(Modifier.ModifierKeyword.SEALED_KEYWORD);
5750                        break;
5751                    case TerminalTokens.TokenNamenon_sealed:
5752                        modifier = createModifier(Modifier.ModifierKeyword.NON_SEALED_KEYWORD);
5753                        break;
5754                    case TerminalTokens.TokenNameAT :
5755                        // we have an annotation
5756                        if (annotations != null && indexInAnnotations < annotations.length) {
5757                            org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++];
5758                            modifier = convert(annotation);
5759                            this.scanner.resetTo(annotation.declarationSourceEnd + 1modifiersEnd);
5760                        }
5761                        break;
5762                    case TerminalTokens.TokenNameCOMMENT_BLOCK :
5763                    case TerminalTokens.TokenNameCOMMENT_LINE :
5764                    case TerminalTokens.TokenNameCOMMENT_JAVADOC :
5765                        break;
5766                    default :
5767                        // there is some syntax errors in source code
5768                        break;
5769                }
5770                if (modifier != null) {
5771                    modifiers.add(modifier);
5772                }
5773            }
5774        } catch(InvalidInputException e) {
5775            // ignore
5776        }
5777    }
5778
5779    protected void setModifiers(EnumDeclaration enumDeclarationorg.eclipse.jdt.internal.compiler.ast.TypeDeclaration enumDeclaration2) {
5780        this.scanner.resetTo(enumDeclaration2.declarationSourceStartenumDeclaration2.sourceStart);
5781        this.setModifiers(enumDeclarationenumDeclaration2.annotationsenumDeclaration2.sourceStart);
5782    }
5783
5784    protected void setModifiers(RecordDeclaration recordDeclarationorg.eclipse.jdt.internal.compiler.ast.TypeDeclaration recordDeclaration2) {
5785        this.scanner.resetTo(recordDeclaration2.declarationSourceStartrecordDeclaration2.sourceStart);
5786        this.setModifiers(recordDeclarationrecordDeclaration2.annotationsrecordDeclaration2.sourceStart);
5787    }
5788
5789    protected void setModifiers(EnumConstantDeclaration enumConstantDeclarationorg.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration) {
5790        switch(this.ast.apiLevel) {
5791            case AST.JLS2_INTERNAL :
5792                enumConstantDeclaration.internalSetModifiers(fieldDeclaration.modifiers & ExtraCompilerModifiers.AccJustFlag);
5793                if (fieldDeclaration.annotations != null) {
5794                    enumConstantDeclaration.setFlags(enumConstantDeclaration.getFlags() | ASTNode.MALFORMED);
5795                }
5796                break;
5797            default :
5798                this.scanner.resetTo(fieldDeclaration.declarationSourceStartfieldDeclaration.sourceStart);
5799                this.setModifiers(enumConstantDeclarationfieldDeclaration.annotationsfieldDeclaration.sourceStart);
5800        }
5801    }
5802
5803    /**
5804     * @param fieldDeclaration
5805     * @param fieldDecl
5806     */
5807    protected void setModifiers(FieldDeclaration fieldDeclarationorg.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDecl) {
5808        switch(this.ast.apiLevel) {
5809            case AST.JLS2_INTERNAL :
5810                fieldDeclaration.internalSetModifiers(fieldDecl.modifiers & ExtraCompilerModifiers.AccJustFlag);
5811                if (fieldDecl.annotations != null) {
5812                    fieldDeclaration.setFlags(fieldDeclaration.getFlags() | ASTNode.MALFORMED);
5813                }
5814                break;
5815            default :
5816                this.scanner.resetTo(fieldDecl.declarationSourceStartfieldDecl.sourceStart);
5817                this.setModifiers(fieldDeclarationfieldDecl.annotationsfieldDecl.sourceStart);
5818        }
5819    }
5820
5821    /**
5822     * @param initializer
5823     * @param oldInitializer
5824     */
5825    protected void setModifiers(Initializer initializerorg.eclipse.jdt.internal.compiler.ast.Initializer oldInitializer) {
5826        switch(this.ast.apiLevel) {
5827            case AST.JLS2_INTERNAL:
5828                initializer.internalSetModifiers(oldInitializer.modifiers & ExtraCompilerModifiers.AccJustFlag);
5829                if (oldInitializer.annotations != null) {
5830                    initializer.setFlags(initializer.getFlags() | ASTNode.MALFORMED);
5831                }
5832                break;
5833            default :
5834                this.scanner.resetTo(oldInitializer.declarationSourceStartoldInitializer.bodyStart);
5835                this.setModifiers(initializeroldInitializer.annotationsoldInitializer.bodyStart);
5836        }
5837    }
5838    /**
5839     * @param methodDecl
5840     * @param methodDeclaration
5841     */
5842    protected void setModifiers(MethodDeclaration methodDeclAbstractMethodDeclaration methodDeclaration) {
5843        switch(this.ast.apiLevel) {
5844            case AST.JLS2_INTERNAL :
5845                methodDecl.internalSetModifiers(methodDeclaration.modifiers & ExtraCompilerModifiers.AccJustFlag);
5846                if (methodDeclaration.annotations != null) {
5847                    methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED);
5848                }
5849                break;
5850            default :
5851                this.scanner.resetTo(methodDeclaration.declarationSourceStartmethodDeclaration.sourceStart);
5852                this.setModifiers(methodDeclmethodDeclaration.annotationsmethodDeclaration.sourceStart);
5853        }
5854    }
5855
5856    protected void setAnnotations(ModuleDeclaration moduleDeclorg.eclipse.jdt.internal.compiler.ast.ModuleDeclaration moduleDeclaration) {
5857        this.scanner.resetTo(moduleDeclaration.declarationSourceStartmoduleDeclaration.sourceStart);
5858        List<IExtendedModifiermodifiers = new ArrayList<>();
5859        this.setModifiers(modifiersmoduleDeclaration.annotationsmoduleDeclaration.sourceStart);
5860        for (IExtendedModifier ie : modifiers) {
5861            if (!ie.isAnnotation()) {
5862                continue; // not setting to malformed.
5863            }
5864            moduleDecl.annotations().add(ie);
5865        }
5866    }
5867    /**
5868     * @param variableDecl
5869     * @param argument
5870     */
5871    protected void setModifiers(SingleVariableDeclaration variableDeclArgument argument) {
5872        switch(this.ast.apiLevel) {
5873            case AST.JLS2_INTERNAL :
5874                variableDecl.internalSetModifiers(argument.modifiers & ExtraCompilerModifiers.AccJustFlag);
5875                if (argument.annotations != null) {
5876                    variableDecl.setFlags(variableDecl.getFlags() | ASTNode.MALFORMED);
5877                }
5878                break;
5879            default :
5880                this.scanner.resetTo(argument.declarationSourceStartargument.sourceStart);
5881                org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = argument.annotations;
5882                int indexInAnnotations = 0;
5883                try {
5884                    int token;
5885                    while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
5886                        IExtendedModifier modifier = null;
5887                        switch(token) {
5888                            case TerminalTokens.TokenNameabstract:
5889                                modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD);
5890                                break;
5891                            case TerminalTokens.TokenNamepublic:
5892                                modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
5893                                break;
5894                            case TerminalTokens.TokenNamestatic:
5895                                modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD);
5896                                break;
5897                            case TerminalTokens.TokenNameprotected:
5898                                modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD);
5899                                break;
5900                            case TerminalTokens.TokenNameprivate:
5901                                modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD);
5902                                break;
5903                            case TerminalTokens.TokenNamefinal:
5904                                modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD);
5905                                break;
5906                            case TerminalTokens.TokenNamenative:
5907                                modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD);
5908                                break;
5909                            case TerminalTokens.TokenNamesynchronized:
5910                                modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD);
5911                                break;
5912                            case TerminalTokens.TokenNametransient:
5913                                modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD);
5914                                break;
5915                            case TerminalTokens.TokenNamevolatile:
5916                                modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD);
5917                                break;
5918                            case TerminalTokens.TokenNamestrictfp:
5919                                modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD);
5920                                break;
5921                            case TerminalTokens.TokenNameAT :
5922                                // we have an annotation
5923                                if (annotations != null && indexInAnnotations < annotations.length) {
5924                                    org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++];
5925                                    modifier = convert(annotation);
5926                                    this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength);
5927                                }
5928                                break;
5929                            case TerminalTokens.TokenNameCOMMENT_BLOCK :
5930                            case TerminalTokens.TokenNameCOMMENT_LINE :
5931                            case TerminalTokens.TokenNameCOMMENT_JAVADOC :
5932                                break;
5933                            default :
5934                                return;
5935                        }
5936                        if (modifier != null) {
5937                            variableDecl.modifiers().add(modifier);
5938                        }
5939                    }
5940                } catch(InvalidInputException e) {
5941                    // ignore
5942                }
5943        }
5944    }
5945
5946    protected void setModifiers(SingleVariableDeclaration variableDeclLocalDeclaration localDeclaration) {
5947        switch(this.ast.apiLevel) {
5948        case AST.JLS2_INTERNAL :
5949            variableDecl.internalSetModifiers(localDeclaration.modifiers & ExtraCompilerModifiers.AccJustFlag);
5950            if (localDeclaration.annotations != null) {
5951                variableDecl.setFlags(variableDecl.getFlags() | ASTNode.MALFORMED);
5952            }
5953            break;
5954        default :
5955            this.scanner.resetTo(localDeclaration.declarationSourceStartlocalDeclaration.sourceStart);
5956            org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = localDeclaration.annotations;
5957            int indexInAnnotations = 0;
5958            try {
5959                int token;
5960                while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
5961                    IExtendedModifier modifier = null;
5962                    switch(token) {
5963                        case TerminalTokens.TokenNameabstract:
5964                            modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD);
5965                            break;
5966                        case TerminalTokens.TokenNamepublic:
5967                            modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
5968                            break;
5969                        case TerminalTokens.TokenNamestatic:
5970                            modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD);
5971                            break;
5972                        case TerminalTokens.TokenNameprotected:
5973                            modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD);
5974                            break;
5975                        case TerminalTokens.TokenNameprivate:
5976                            modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD);
5977                            break;
5978                        case TerminalTokens.TokenNamefinal:
5979                            modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD);
5980                            break;
5981                        case TerminalTokens.TokenNamenative:
5982                            modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD);
5983                            break;
5984                        case TerminalTokens.TokenNamesynchronized:
5985                            modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD);
5986                            break;
5987                        case TerminalTokens.TokenNametransient:
5988                            modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD);
5989                            break;
5990                        case TerminalTokens.TokenNamevolatile:
5991                            modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD);
5992                            break;
5993                        case TerminalTokens.TokenNamestrictfp:
5994                            modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD);
5995                            break;
5996                        case TerminalTokens.TokenNameAT :
5997                            // we have an annotation
5998                            if (annotations != null && indexInAnnotations < annotations.length) {
5999                                org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++];
6000                                modifier = convert(annotation);
6001                                this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength);
6002                            }
6003                            break;
6004                        case TerminalTokens.TokenNameCOMMENT_BLOCK :
6005                        case TerminalTokens.TokenNameCOMMENT_LINE :
6006                        case TerminalTokens.TokenNameCOMMENT_JAVADOC :
6007                            break;
6008                        default :
6009                            return;
6010                    }
6011                    if (modifier != null) {
6012                        variableDecl.modifiers().add(modifier);
6013                    }
6014                }
6015            } catch(InvalidInputException e) {
6016                // ignore
6017            }
6018        }
6019    }
6020
6021    /**
6022     * @param variableDecl
6023     * @param component
6024     *
6025     * TODO: just plain copy of sM(SVD, Argument) - need to cut the flab here.
6026     */
6027    protected void setModifiers(SingleVariableDeclaration variableDeclRecordComponent component) {
6028        switch(this.ast.apiLevel) {
6029            case AST.JLS2_INTERNAL :
6030                variableDecl.internalSetModifiers(component.modifiers & ExtraCompilerModifiers.AccJustFlag);
6031                if (component.annotations != null) {
6032                    variableDecl.setFlags(variableDecl.getFlags() | ASTNode.MALFORMED);
6033                }
6034                break;
6035            default :
6036                this.scanner.resetTo(component.declarationSourceStartcomponent.sourceStart);
6037                org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = component.annotations;
6038                int indexInAnnotations = 0;
6039                try {
6040                    int token;
6041                    while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
6042                        IExtendedModifier modifier = null;
6043                        switch(token) {
6044                            case TerminalTokens.TokenNameabstract:
6045                                modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD);
6046                                break;
6047                            case TerminalTokens.TokenNamepublic:
6048                                modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
6049                                break;
6050                            case TerminalTokens.TokenNamestatic:
6051                                modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD);
6052                                break;
6053                            case TerminalTokens.TokenNameprotected:
6054                                modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD);
6055                                break;
6056                            case TerminalTokens.TokenNameprivate:
6057                                modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD);
6058                                break;
6059                            case TerminalTokens.TokenNamefinal:
6060                                modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD);
6061                                break;
6062                            case TerminalTokens.TokenNamenative:
6063                                modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD);
6064                                break;
6065                            case TerminalTokens.TokenNamesynchronized:
6066                                modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD);
6067                                break;
6068                            case TerminalTokens.TokenNametransient:
6069                                modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD);
6070                                break;
6071                            case TerminalTokens.TokenNamevolatile:
6072                                modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD);
6073                                break;
6074                            case TerminalTokens.TokenNamestrictfp:
6075                                modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD);
6076                                break;
6077                            case TerminalTokens.TokenNameAT :
6078                                // we have an annotation
6079                                if (annotations != null && indexInAnnotations < annotations.length) {
6080                                    org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++];
6081                                    modifier = convert(annotation);
6082                                    this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength);
6083                                }
6084                                break;
6085                            case TerminalTokens.TokenNameCOMMENT_BLOCK :
6086                            case TerminalTokens.TokenNameCOMMENT_LINE :
6087                            case TerminalTokens.TokenNameCOMMENT_JAVADOC :
6088                                break;
6089                            default :
6090                                return;
6091                        }
6092                        if (modifier != null) {
6093                            variableDecl.modifiers().add(modifier);
6094                        }
6095                    }
6096                } catch(InvalidInputException e) {
6097                    // ignore
6098                }
6099        }
6100    }
6101    /**
6102     * @param typeDecl
6103     * @param typeDeclaration
6104     */
6105    protected void setModifiers(TypeDeclaration typeDeclorg.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) {
6106        switch(this.ast.apiLevel) {
6107            case AST.JLS2_INTERNAL :
6108                int modifiers = typeDeclaration.modifiers;
6109                modifiers &= ~ClassFileConstants.AccInterface// remove AccInterface flags
6110                modifiers &= ExtraCompilerModifiers.AccJustFlag;
6111                typeDecl.internalSetModifiers(modifiers);
6112                if (typeDeclaration.annotations != null) {
6113                    typeDecl.setFlags(typeDecl.getFlags() | ASTNode.MALFORMED);
6114                }
6115                break;
6116            default :
6117                this.scanner.resetTo(typeDeclaration.declarationSourceStarttypeDeclaration.sourceStart);
6118                this.setModifiers(typeDecltypeDeclaration.annotationstypeDeclaration.sourceStart);
6119        }
6120    }
6121
6122    /**
6123     * @param variableDeclarationExpression
6124     * @param localDeclaration
6125     */
6126    protected void setModifiers(VariableDeclarationExpression variableDeclarationExpressionLocalDeclaration localDeclaration) {
6127        switch(this.ast.apiLevel) {
6128            case AST.JLS2_INTERNAL :
6129                int modifiers = localDeclaration.modifiers & ExtraCompilerModifiers.AccJustFlag;
6130                modifiers &= ~ExtraCompilerModifiers.AccBlankFinal;
6131                variableDeclarationExpression.internalSetModifiers(modifiers);
6132                if (localDeclaration.annotations != null) {
6133                    variableDeclarationExpression.setFlags(variableDeclarationExpression.getFlags() | ASTNode.MALFORMED);
6134                }
6135                break;
6136            default :
6137                this.scanner.resetTo(localDeclaration.declarationSourceStartlocalDeclaration.sourceStart);
6138                org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = localDeclaration.annotations;
6139                int indexInAnnotations = 0;
6140                try {
6141                    int token;
6142                    while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
6143                        IExtendedModifier modifier = null;
6144                        switch(token) {
6145                            case TerminalTokens.TokenNameabstract:
6146                                modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD);
6147                                break;
6148                            case TerminalTokens.TokenNamepublic:
6149                                modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
6150                                break;
6151                            case TerminalTokens.TokenNamestatic:
6152                                modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD);
6153                                break;
6154                            case TerminalTokens.TokenNameprotected:
6155                                modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD);
6156                                break;
6157                            case TerminalTokens.TokenNameprivate:
6158                                modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD);
6159                                break;
6160                            case TerminalTokens.TokenNamefinal:
6161                                modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD);
6162                                break;
6163                            case TerminalTokens.TokenNamenative:
6164                                modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD);
6165                                break;
6166                            case TerminalTokens.TokenNamesynchronized:
6167                                modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD);
6168                                break;
6169                            case TerminalTokens.TokenNametransient:
6170                                modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD);
6171                                break;
6172                            case TerminalTokens.TokenNamevolatile:
6173                                modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD);
6174                                break;
6175                            case TerminalTokens.TokenNamestrictfp:
6176                                modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD);
6177                                break;
6178                            case TerminalTokens.TokenNameAT :
6179                                // we have an annotation
6180                                if (annotations != null && indexInAnnotations < annotations.length) {
6181                                    org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++];
6182                                    modifier = convert(annotation);
6183                                    this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength);
6184                                }
6185                                break;
6186                            case TerminalTokens.TokenNameCOMMENT_BLOCK :
6187                            case TerminalTokens.TokenNameCOMMENT_LINE :
6188                            case TerminalTokens.TokenNameCOMMENT_JAVADOC :
6189                                break;
6190                            default :
6191                                return;
6192                        }
6193                        if (modifier != null) {
6194                            variableDeclarationExpression.modifiers().add(modifier);
6195                        }
6196                    }
6197                } catch(InvalidInputException e) {
6198                    // ignore
6199                }
6200        }
6201    }
6202
6203    /**
6204     * @param variableDeclarationStatement
6205     * @param localDeclaration
6206     */
6207    protected void setModifiers(VariableDeclarationStatement variableDeclarationStatementLocalDeclaration localDeclaration) {
6208        switch(this.ast.apiLevel) {
6209            case AST.JLS2_INTERNAL :
6210                int modifiers = localDeclaration.modifiers & ExtraCompilerModifiers.AccJustFlag;
6211                modifiers &= ~ExtraCompilerModifiers.AccBlankFinal;
6212                variableDeclarationStatement.internalSetModifiers(modifiers);
6213                if (localDeclaration.annotations != null) {
6214                    variableDeclarationStatement.setFlags(variableDeclarationStatement.getFlags() | ASTNode.MALFORMED);
6215                }
6216                break;
6217            default :
6218                this.scanner.resetTo(localDeclaration.declarationSourceStartlocalDeclaration.sourceStart);
6219                org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = localDeclaration.annotations;
6220                int indexInAnnotations = 0;
6221                try {
6222                    int token;
6223                    while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
6224                        IExtendedModifier modifier = null;
6225                        switch(token) {
6226                            case TerminalTokens.TokenNameabstract:
6227                                modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD);
6228                                break;
6229                            case TerminalTokens.TokenNamepublic:
6230                                modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
6231                                break;
6232                            case TerminalTokens.TokenNamestatic:
6233                                modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD);
6234                                break;
6235                            case TerminalTokens.TokenNameprotected:
6236                                modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD);
6237                                break;
6238                            case TerminalTokens.TokenNameprivate:
6239                                modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD);
6240                                break;
6241                            case TerminalTokens.TokenNamefinal:
6242                                modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD);
6243                                break;
6244                            case TerminalTokens.TokenNamenative:
6245                                modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD);
6246                                break;
6247                            case TerminalTokens.TokenNamesynchronized:
6248                                modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD);
6249                                break;
6250                            case TerminalTokens.TokenNametransient:
6251                                modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD);
6252                                break;
6253                            case TerminalTokens.TokenNamevolatile:
6254                                modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD);
6255                                break;
6256                            case TerminalTokens.TokenNamestrictfp:
6257                                modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD);
6258                                break;
6259                            case TerminalTokens.TokenNameAT :
6260                                // we have an annotation
6261                                if (annotations != null && indexInAnnotations < annotations.length) {
6262                                    org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++];
6263                                    modifier = convert(annotation);
6264                                    this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength);
6265                                }
6266                                break;
6267                            case TerminalTokens.TokenNameCOMMENT_BLOCK :
6268                            case TerminalTokens.TokenNameCOMMENT_LINE :
6269                            case TerminalTokens.TokenNameCOMMENT_JAVADOC :
6270                                break;
6271                            default :
6272                                return;
6273                        }
6274                        if (modifier != null) {
6275                            variableDeclarationStatement.modifiers().add(modifier);
6276                        }
6277                    }
6278                } catch(InvalidInputException e) {
6279                    // ignore
6280                }
6281        }
6282    }
6283
6284    protected QualifiedName setQualifiedNameNameAndSourceRanges(char[][] typeNamelong[] positionsorg.eclipse.jdt.internal.compiler.ast.ASTNode node) {
6285        int length = typeName.length;
6286        final SimpleName firstToken = new SimpleName(this.ast);
6287        firstToken.internalSetIdentifier(new String(typeName[0]));
6288        firstToken.index = 1;
6289        int start0 = (int)(positions[0]>>>32);
6290        int start = start0;
6291        int end = (int)(positions[0] & 0xFFFFFFFF);
6292        firstToken.setSourceRange(startend - start + 1);
6293        final SimpleName secondToken = new SimpleName(this.ast);
6294        secondToken.internalSetIdentifier(new String(typeName[1]));
6295        secondToken.index = 2;
6296        start = (int)(positions[1]>>>32);
6297        end = (int)(positions[1] & 0xFFFFFFFF);
6298        secondToken.setSourceRange(startend - start + 1);
6299        QualifiedName qualifiedName = new QualifiedName(this.ast);
6300        qualifiedName.setQualifier(firstToken);
6301        qualifiedName.setName(secondToken);
6302        if (this.resolveBindings) {
6303            recordNodes(qualifiedNamenode);
6304            recordPendingNameScopeResolution(qualifiedName);
6305            recordNodes(firstTokennode);
6306            recordNodes(secondTokennode);
6307            recordPendingNameScopeResolution(firstToken);
6308            recordPendingNameScopeResolution(secondToken);
6309        }
6310        qualifiedName.index = 2;
6311        qualifiedName.setSourceRange(start0end - start0 + 1);
6312        SimpleName newPart = null;
6313        for (int i = 2i < lengthi++) {
6314            newPart = new SimpleName(this.ast);
6315            newPart.internalSetIdentifier(new String(typeName[i]));
6316            newPart.index = i + 1;
6317            start = (int)(positions[i]>>>32);
6318            end = (int)(positions[i] & 0xFFFFFFFF);
6319            newPart.setSourceRange(start,  end - start + 1);
6320            QualifiedName qualifiedName2 = new QualifiedName(this.ast);
6321            qualifiedName2.setQualifier(qualifiedName);
6322            qualifiedName2.setName(newPart);
6323            qualifiedName = qualifiedName2;
6324            qualifiedName.index = newPart.index;
6325            qualifiedName.setSourceRange(start0end - start0 + 1);
6326            if (this.resolveBindings) {
6327                recordNodes(qualifiedNamenode);
6328                recordNodes(newPartnode);
6329                recordPendingNameScopeResolution(qualifiedName);
6330                recordPendingNameScopeResolution(newPart);
6331            }
6332        }
6333        QualifiedName name = qualifiedName;
6334        if (this.resolveBindings) {
6335            recordNodes(namenode);
6336            recordPendingNameScopeResolution(name);
6337        }
6338        return name;
6339    }
6340
6341    protected QualifiedName setQualifiedNameNameAndSourceRanges(char[][] typeNamelong[] positionsint endingIndexorg.eclipse.jdt.internal.compiler.ast.TypeReference node) {
6342         int length = endingIndex + 1;
6343        final SimpleName firstToken = new SimpleName(this.ast);
6344        firstToken.internalSetIdentifier(new String(typeName[0]));
6345        firstToken.index = 1;
6346        int start0 = (int)(positions[0]>>>32);
6347        int start = start0;
6348        int end = (intpositions[0];
6349        firstToken.setSourceRange(startend - start + 1);
6350        final SimpleName secondToken = new SimpleName(this.ast);
6351        secondToken.internalSetIdentifier(new String(typeName[1]));
6352        secondToken.index = 2;
6353        start = (int)(positions[1]>>>32);
6354        end = (intpositions[1];
6355        secondToken.setSourceRange(startend - start + 1);
6356        QualifiedName qualifiedName = new QualifiedName(this.ast);
6357        qualifiedName.setQualifier(firstToken);
6358        qualifiedName.setName(secondToken);
6359        if (this.resolveBindings) {
6360            recordNodes(qualifiedNamenode);
6361            recordPendingNameScopeResolution(qualifiedName);
6362            recordNodes(firstTokennode);
6363            recordNodes(secondTokennode);
6364            recordPendingNameScopeResolution(firstToken);
6365            recordPendingNameScopeResolution(secondToken);
6366        }
6367        qualifiedName.index = 2;
6368        qualifiedName.setSourceRange(start0end - start0 + 1);
6369        SimpleName newPart = null;
6370        for (int i = 2i < lengthi++) {
6371            newPart = new SimpleName(this.ast);
6372            newPart.internalSetIdentifier(new String(typeName[i]));
6373            newPart.index = i + 1;
6374            start = (int)(positions[i]>>>32);
6375            end = (intpositions[i];
6376            newPart.setSourceRange(start,  end - start + 1);
6377            QualifiedName qualifiedName2 = new QualifiedName(this.ast);
6378            qualifiedName2.setQualifier(qualifiedName);
6379            qualifiedName2.setName(newPart);
6380            qualifiedName = qualifiedName2;
6381            qualifiedName.index = newPart.index;
6382            qualifiedName.setSourceRange(start0end - start0 + 1);
6383            if (this.resolveBindings) {
6384                recordNodes(qualifiedNamenode);
6385                recordNodes(newPartnode);
6386                recordPendingNameScopeResolution(qualifiedName);
6387                recordPendingNameScopeResolution(newPart);
6388            }
6389        }
6390        if (newPart == null && this.resolveBindings) {
6391            recordNodes(qualifiedNamenode);
6392            recordPendingNameScopeResolution(qualifiedName);
6393        }
6394        return qualifiedName;
6395    }
6396
6397    protected void setTypeNameForAnnotation(org.eclipse.jdt.internal.compiler.ast.Annotation compilerAnnotationAnnotation annotation) {
6398        TypeReference typeReference = compilerAnnotation.type;
6399        if (typeReference instanceof QualifiedTypeReference) {
6400            QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReferencetypeReference;
6401            char[][] tokens = qualifiedTypeReference.tokens;
6402            long[] positions = qualifiedTypeReference.sourcePositions;
6403            // QualifiedName
6404            annotation.setTypeName(setQualifiedNameNameAndSourceRanges(tokenspositionstypeReference));
6405        } else {
6406            SingleTypeReference singleTypeReference = (SingleTypeReferencetypeReference;
6407            final SimpleName name = new SimpleName(this.ast);
6408            name.internalSetIdentifier(new String(singleTypeReference.token));
6409            int start = singleTypeReference.sourceStart;
6410            int end = singleTypeReference.sourceEnd;
6411            name.setSourceRange(startend - start + 1);
6412            name.index = 1;
6413            annotation.setTypeName(name);
6414            if (this.resolveBindings) {
6415                recordNodes(nametypeReference);
6416            }
6417        }
6418    }
6419
6420    protected void setTypeForField(FieldDeclaration fieldDeclarationType typeint extraDimension) {
6421        if (extraDimension != 0) {
6422            if (type.isArrayType()) {
6423                ArrayType arrayType = (ArrayTypetype;
6424                int remainingDimensions = arrayType.getDimensions() - extraDimension;
6425                if (remainingDimensions == 0)  {
6426                    // the dimensions are after the name so the type of the fieldDeclaration is a simpleType
6427                    Type elementType = arrayType.getElementType();
6428                    // cut the child loose from its parent (without creating garbage)
6429                    elementType.setParent(nullnull);
6430                    this.ast.getBindingResolver().updateKey(typeelementType);
6431                    fieldDeclaration.setType(elementType);
6432                } else {
6433                    ArrayType subarrayType = extractSubArrayType(arrayTyperemainingDimensionsextraDimension);
6434                    fieldDeclaration.setType(subarrayType);
6435                    this.ast.getBindingResolver().updateKey(typesubarrayType);
6436                }
6437                checkAndSetMalformed(typefieldDeclaration);
6438            } else {
6439                fieldDeclaration.setType(type);
6440            }
6441        } else {
6442            if (type.isArrayType() && (this.ast.apiLevel() < AST.JLS8_INTERNAL)) {
6443                // update positions of the component types of the array type
6444                int dimensions = ((ArrayTypetype).getDimensions();
6445                updateInnerPositions(typedimensions);
6446            }
6447            fieldDeclaration.setType(type);
6448        }
6449    }
6450
6451    /** extracts the subArrayType for a given declaration for AST levels less
6452     * @param arrayType parent type
6453     * @param remainingDimensions
6454     * @param dimensionsToRemove
6455     * @return an ArrayType
6456     */
6457    private ArrayType extractSubArrayType(ArrayType arrayTypeint remainingDimensionsint dimensionsToRemove) {
6458        ArrayType subArrayType = arrayType;
6459        int start = subArrayType.getStartPosition();
6460        if (this.ast.apiLevel() < AST.JLS8_INTERNAL) {
6461            while (dimensionsToRemove > 0 ) {
6462                subArrayType = (ArrayTypecomponentType(subArrayType);
6463                dimensionsToRemove--;
6464            }
6465            updateInnerPositions(subArrayTyperemainingDimensions);
6466        } else {
6467            List dimensions = subArrayType.dimensions();
6468            while (dimensionsToRemove > 0 ) {
6469                dimensions.remove(dimensions.size() - 1);
6470                dimensionsToRemove--;
6471            }
6472        }
6473        int end = retrieveProperRightBracketPosition(remainingDimensionsstart);
6474        subArrayType.setSourceRange(startend - start + 1);
6475        // cut the child loose from its parent (without creating garbage)
6476        subArrayType.setParent(nullnull);
6477        return subArrayType;
6478    }
6479
6480    protected void setTypeForMethodDeclaration(MethodDeclaration methodDeclarationType typeint extraDimension) {
6481        if (extraDimension != 0) {
6482            if (type.isArrayType()) {
6483                ArrayType arrayType = (ArrayTypetype;
6484                int remainingDimensions = arrayType.getDimensions() - extraDimension;
6485                if (remainingDimensions == 0)  {
6486                    // the dimensions are after the name so the type of the fieldDeclaration is a simpleType
6487                    Type elementType = arrayType.getElementType();
6488                    // cut the child loose from its parent (without creating garbage)
6489                    elementType.setParent(nullnull);
6490                    this.ast.getBindingResolver().updateKey(typeelementType);
6491                    switch(this.ast.apiLevel) {
6492                        case AST.JLS2_INTERNAL :
6493                            methodDeclaration.internalSetReturnType(elementType);
6494                            break;
6495                        default :
6496                            methodDeclaration.setReturnType2(elementType);
6497                        break;
6498                    }
6499                } else {
6500                    ArrayType subarrayType = extractSubArrayType(arrayTyperemainingDimensionsextraDimension);
6501                    switch(this.ast.apiLevel) {
6502                        case AST.JLS2_INTERNAL :
6503                            methodDeclaration.internalSetReturnType(subarrayType);
6504                            break;
6505                        default :
6506                            methodDeclaration.setReturnType2(subarrayType);
6507                            break;
6508                    }
6509                    this.ast.getBindingResolver().updateKey(typesubarrayType);
6510                }
6511                checkAndSetMalformed(typemethodDeclaration);
6512            } else {
6513                switch(this.ast.apiLevel) {
6514                    case AST.JLS2_INTERNAL :
6515                        methodDeclaration.internalSetReturnType(type);
6516                        break;
6517                    default :
6518                        methodDeclaration.setReturnType2(type);
6519                    break;
6520                }
6521            }
6522        } else {
6523            switch(this.ast.apiLevel) {
6524                case AST.JLS2_INTERNAL :
6525                    methodDeclaration.internalSetReturnType(type);
6526                    break;
6527                default :
6528                    methodDeclaration.setReturnType2(type);
6529                break;
6530            }
6531        }
6532    }
6533
6534    protected void setTypeForMethodDeclaration(AnnotationTypeMemberDeclaration annotationTypeMemberDeclarationType typeint extraDimension) {
6535        annotationTypeMemberDeclaration.setType(type);
6536    }
6537
6538    protected void setTypeForSingleVariableDeclaration(SingleVariableDeclaration singleVariableDeclarationType typeint extraDimension) {
6539        if (extraDimension != 0) {
6540            if (type.isArrayType()) {
6541                ArrayType arrayType = (ArrayTypetype;
6542                int remainingDimensions = arrayType.getDimensions() - extraDimension;
6543                if (remainingDimensions == 0)  {
6544                    // the dimensions are after the name so the type of the fieldDeclaration is a simpleType
6545                    Type elementType = arrayType.getElementType();
6546                    // cut the child loose from its parent (without creating garbage)
6547                    elementType.setParent(nullnull);
6548                    this.ast.getBindingResolver().updateKey(typeelementType);
6549                    singleVariableDeclaration.setType(elementType);
6550                } else {
6551                    ArrayType subarrayType = extractSubArrayType(arrayTyperemainingDimensionsextraDimension);
6552                    this.ast.getBindingResolver().updateKey(typesubarrayType);
6553                    singleVariableDeclaration.setType(subarrayType);
6554                }
6555                checkAndSetMalformed(typesingleVariableDeclaration);
6556
6557            } else {
6558                singleVariableDeclaration.setType(type);
6559            }
6560        } else {
6561            singleVariableDeclaration.setType(type);
6562        }
6563    }
6564
6565    protected void setTypeForVariableDeclarationExpression(VariableDeclarationExpression variableDeclarationExpressionType typeint extraDimension) {
6566        if (extraDimension != 0) {
6567            if (type.isArrayType()) {
6568                ArrayType arrayType = (ArrayTypetype;
6569                int remainingDimensions = arrayType.getDimensions() - extraDimension;
6570                if (remainingDimensions == 0)  {
6571                    // the dimensions are after the name so the type of the fieldDeclaration is a simpleType
6572                    Type elementType = arrayType.getElementType();
6573                    // cut the child loose from its parent (without creating garbage)
6574                    elementType.setParent(nullnull);
6575                    this.ast.getBindingResolver().updateKey(typeelementType);
6576                    variableDeclarationExpression.setType(elementType);
6577                } else {
6578                    ArrayType subarrayType = extractSubArrayType(arrayTyperemainingDimensionsextraDimension);
6579                    variableDeclarationExpression.setType(subarrayType);
6580                    this.ast.getBindingResolver().updateKey(typesubarrayType);
6581                }
6582                checkAndSetMalformed(typevariableDeclarationExpression);
6583            } else {
6584                variableDeclarationExpression.setType(type);
6585            }
6586        } else {
6587            variableDeclarationExpression.setType(type);
6588        }
6589    }
6590
6591    protected void setTypeForVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatementType typeint extraDimension) {
6592        if (extraDimension != 0) {
6593            if (type.isArrayType()) {
6594                ArrayType arrayType = (ArrayTypetype;
6595                int remainingDimensions = arrayType.getDimensions() - extraDimension;
6596                if (remainingDimensions == 0)  {
6597                    // the dimensions are after the name so the type of the fieldDeclaration is a simpleType
6598                    Type elementType = arrayType.getElementType();
6599                    // cut the child loose from its parent (without creating garbage)
6600                    elementType.setParent(nullnull);
6601                    this.ast.getBindingResolver().updateKey(typeelementType);
6602                    variableDeclarationStatement.setType(elementType);
6603                } else {
6604                    ArrayType subarrayType = extractSubArrayType(arrayTyperemainingDimensionsextraDimension);
6605                    variableDeclarationStatement.setType(subarrayType);
6606                    this.ast.getBindingResolver().updateKey(typesubarrayType);
6607                }
6608                checkAndSetMalformed(typevariableDeclarationStatement);
6609            } else {
6610                variableDeclarationStatement.setType(type);
6611            }
6612        } else {
6613            variableDeclarationStatement.setType(type);
6614        }
6615    }
6616
6617    protected void updateInnerPositions(Type typeint dimensions) {
6618        if (dimensions > 1) {
6619            // need to set positions for intermediate array type see 42839
6620            int start = type.getStartPosition();
6621            Type currentComponentType = componentType(((ArrayTypetype));
6622            int searchedDimension = dimensions - 1;
6623            int rightBracketEndPosition = start;
6624            while (currentComponentType.isArrayType()) {
6625                rightBracketEndPosition = retrieveProperRightBracketPosition(searchedDimensionstart);
6626                currentComponentType.setSourceRange(startrightBracketEndPosition - start + 1);
6627                currentComponentType = componentType(((ArrayTypecurrentComponentType));
6628                searchedDimension--;
6629            }
6630        }
6631    }
6632
6633}
6634
MembersX
ASTConverter:setTypeForVariableDeclarationStatement:Block:Block:Block:Block:subarrayType
ASTConverter:setNodeSourceEndPosition:Block:length
ASTConverter:convert:Block:Block:block
ASTConverter:convert:Block:leftExpression
ASTConverter:convert:Block:typePattern
ASTConverter:convert:Block:typeEnd
ASTConverter:retrieveArrowPosition
ASTConverter:trimWhiteSpacesAndComments:Block:removeBlankScanner
ASTConverter:createSimpleName:Block:start
ASTConverter:convert:Block:Block:Block:importLength
ASTConverter:createQualifiedType:Block:simpleName
ASTConverter:recordNodes:Block:Block:Block:memberRef
ASTConverter:createSimpleType:Block:simpleType
ASTConverter:convert:Block:sourceStart
ASTConverter:retrieveEndOfPotentialExtendedDimensions:Block:Block:hasAnnotations
ASTConverter:setTypeAnnotationsAndSourceRangeOnArray:Block:startArray
ASTConverter:convertToParenthesizedExpression:Block:parenthesizedExpression
ASTConverter:adjustSourcePositionsForParent:Block:Block:token
ASTConverter:convert:Block:Block:Block:length
ASTConverter:convert:Block:Block:Block:returnType
ASTConverter:adjustSourcePositionsForParent:Block:Block:stop
ASTConverter:convertToVariableDeclarationExpression
ASTConverter:convertToVariableDeclarationFragment:Block:typeReference
ASTConverter:convert:Block:instanceOfExpression
ASTConverter:convert:Block:Block:Block:enumDeclaration
ASTConverter:convertToRecordDeclaration:Block:superInterfaces
ASTConverter:setQualifiedNameNameAndSourceRanges:Block:Block:qualifiedName2
ASTConverter:convertToExpression
ASTConverter:convertType:Block:Block:Block:unionType
ASTConverter:convert:Block:isInterface
ASTConverter:internalThownExceptions
ASTConverter:getPackageVisibilityStatement:Block:sourceEnd
ASTConverter:recordNodes:Block:Block:Block:Block:Block:Block:Block:type
ASTConverter:createBaseType:Block:Block:Block:nameQualifiedType
ASTConverter:getAbstractTypeDeclarationDetails:Block:Block:Block:fieldDeclaration
ASTConverter:createModifier:Block:end
ASTConverter:setTypeForVariableDeclarationStatement:Block:Block:Block:Block:elementType
ASTConverter:convertType:Block:Block:Block:Block:Block:type2
ASTConverter:setExtraAnnotatedDimensions
ASTConverter:setSourceRangeAnnotationsAndRecordNodes:Block:annotations
ASTConverter:convert:Block:Block:elseStatement
ASTConverter:convert:Block:Block:Block:recoveryScanner
ASTConverter:convertToSingleVariableDeclaration:Block:name
ASTConverter:removeLeadingAndTrailingCommentsFromLiteral:Block:Block:Block:end
ASTConverter:convert:Block:Block:Block:end
ASTConverter:convertType:Block:length
ASTConverter:convertToEnumDeclaration:Block:enumDeclaration2
ASTConverter:createSimpleName:Block:simpleName
ASTConverter:lookupScope:Block:abstractMethodDeclaration
ASTConverter:updateInnerPositions
ASTConverter:createModifier
ASTConverter:convert:Block:thrownExceptions
ASTConverter:buildBodyDeclarations:Block:membersLength
ASTConverter:convertToArray:Block:Block:index
ASTConverter:convertToSingleVariableDeclaration:Block:typeReference
ASTConverter:setQualifiedNameNameAndSourceRanges:Block:name
ASTConverter:convert:Block:normalAnnotation
ASTConverter:convert:Block:methodName
ASTConverter:retrieveEndOfPotentialExtendedDimensions:Block:Block:lParenCount
ASTConverter:convert:Block:Block:Block:resizedProblems
ASTConverter:adjustSourcePositionsForParent:Block:rightParentCount
ASTConverter:retrieveProperRightBracketPosition:Block:Block:token
ASTConverter:convert:Block:Block:Block:packageDeclaration
ASTConverter:convert:Block:Block:Block:Block:Block:type
ASTConverter:convert:Block:Block:Block:Block:astStatement
ASTConverter:recordNodes:Block:Block:Block:Block:Block:Block:argExpr
ASTConverter:setModifiers:Block:Block:Block:Block:annotation
ASTConverter:convertPackage:Block:length
ASTConverter:convertPackage:Block:packageDeclaration
ASTConverter:convertToModuleDeclaration:Block:Block:usesRef
ASTConverter:convertToModuleDeclaration:Block:moduleDecl
ASTConverter:convert:Block:Block:leftOperand
ASTConverter:convert:Block:pair
ASTConverter:convert:Block:action
ASTConverter:convert:Block:throwStatement
ASTConverter:setTypeForField:Block:Block:Block:arrayType
ASTConverter:checkAndAddMultipleFieldDeclaration:Block:Block:fieldDeclaration
ASTConverter:convertToModuleDeclaration:Block:end
ASTConverter:convertToSingleVariableDeclaration
ASTConverter:convertToArray
ASTConverter:convert:Block:Block:Block:Block:Block:annotation
ASTConverter:convertToVariableDeclarationExpression:Block:variableDeclarationFragment
ASTConverter:extractSubArrayType:Block:subArrayType
ASTConverter:getPackageVisibilityStatement:Block:Block:modules
ASTConverter:convert:Block:Block:Block:simpleType
ASTConverter:convert:Block:arguments
ASTConverter:convert:Block:Block:expr
ASTConverter:convert:Block:Block:Block:Block:statement2
ASTConverter:setTypeForVariableDeclarationExpression:Block:Block:Block:arrayType
ASTConverter:setQualifiedNameNameAndSourceRanges:Block:secondToken
ASTConverter:retrieveStartingCatchPosition:Block:Block:token
ASTConverter:createModuleModifier:Block:end
ASTConverter:convertToModuleDeclaration
ASTConverter:convert:Block:Block:Block:Block:convertType
ASTConverter:retrieveEndOfPotentialExtendedDimensions
ASTConverter:setSourceRangeAnnotationsAndRecordNodes:Block:length
ASTConverter:setTypeForVariableDeclarationExpression:Block:Block:Block:remainingDimensions
ASTConverter:retrieveInitAndSetPositions:Block:token
ASTConverter:convertToModuleDeclaration:Block:Block:impls
ASTConverter:convertType:Block:dimensions
ASTConverter:convert:Block:name
ASTConverter:convertToVariableDeclarationExpression:Block:variableDeclarationExpression
ASTConverter:convertToModuleDeclaration:Block:compare
ASTConverter:removeLeadingAndTrailingCommentsFromLiteral
ASTConverter:checkAndAddMultipleLocalDeclaration:Block:Block:Block:variableDeclarationStatement
ASTConverter:setTypeAnnotationsOnDimension
ASTConverter:recordName
ASTConverter:setQualifiedNameNameAndSourceRanges
ASTConverter:convertType:Block:Block:Block:currentType
ASTConverter:convertToModuleDeclaration:Block:Block:moduleRef
ASTConverter:convert
ASTConverter:convert:Block:statements
ASTConverter:retrieveIdentifierEndPosition:Block:Block:token
ASTConverter:convert:Block:Block:Block:argument
ASTConverter:convert:Block:assignment
ASTConverter:buildCommentsTable
ASTConverter:retrieveInitAndSetPositions:Block:Block:Block:Block:endName
ASTConverter:commentsTable
ASTConverter:convert:Block:Block:constantExpressions
ASTConverter:convert:Block:Block:Block:Block:end
ASTConverter:convert:Block:arrayAccess
ASTConverter:retrieveProperRightBracketPosition
ASTConverter:convert:Block:labeledStatement
ASTConverter:convertToEnumDeclaration:Block:superInterfaces
ASTConverter:retrieveRightBrace:Block:Block:token
ASTConverter:convert:Block:Block:comment
ASTConverter:convert:Block:Block:sourceStart
ASTConverter:recordNodes:Block:Block:Block:Block:Block:Block:moduleQualifiedName
ASTConverter:buildBodyDeclarations:Block:methods
ASTConverter:buildBodyDeclarations:Block:methodsIndex
ASTConverter:convertToModuleDeclaration:Block:Block:pStmt
ASTConverter:convert:Block:statement2
ASTConverter:convert:Block:Block:catchBlocks
ASTConverter:convert:Block:Block:Block:anonymousType
ASTConverter:createBaseType:Block:Block:Block:simpleType
ASTConverter:setTypeForSingleVariableDeclaration
ASTConverter:convertPackage:Block:Block:name
ASTConverter:convert:Block:Block:methodInvocation
ASTConverter:convertToModuleDeclaration:Block:Block:req
ASTConverter:retrieveEndOfElementTypeNamePosition:Block:Block:count
ASTConverter:retrieveIdentifierAndSetPositions
ASTConverter:checkAndAddMultipleFieldDeclaration:Block:Block:initializer
ASTConverter:annotateTypeParameter:Block:annotationsLength
ASTConverter:recordNodes:Block:Block:Block:Block:modRef
ASTConverter:convert:Block:Block:start
ASTConverter:convert:Block:Block:startPosition
ASTConverter:convert:Block:searchingNode
ASTConverter:convert:Block:tryStatement
ASTConverter:createModifier:Block:modifier
ASTConverter:convertType:Block:Block:Block:Block:Block:arglen
ASTConverter:convert:Block:Block:Block:memberValuePair
ASTConverter:convertAndSetReceiver:Block:type
ASTConverter:convert:Block:Block:Block:Block:expri
ASTConverter:convert:Block:stringLiterals
ASTConverter:convert:Block:Block:Block:initializationsLength
ASTConverter:setQualifiedNameNameAndSourceRanges:Block:newPart
ASTConverter:checkAndAddMultipleLocalDeclaration:Block:Block:local1
ASTConverter:recordNodes:Block:Block:node
ASTConverter:convert:Block:isConstructor
ASTConverter:convert:Block:Block:result
ASTConverter:retrieveProperRightBracketPosition:Block:Block:count
ASTConverter:convertType:Block:Block:Block:Block:baseStart
ASTConverter:checkAndAddMultipleLocalDeclaration:Block:Block:local2
ASTConverter:lookupScope:Block:Block:Block:typeDecl
ASTConverter:convert:Block:Block:name
ASTConverter:setModuleModifiers:Block:Block:token
ASTConverter:convert:Block:Block:Block:Block:block
ASTConverter:convertToRecord:Block:typeDecl
ASTConverter:convert:Block:Block:qualifiedTypeReference
ASTConverter:convertPackage:Block:Block:end
ASTConverter:setTypeForVariableDeclarationStatement:Block:Block:Block:remainingDimensions
ASTConverter:convert:Block:typeDecl
ASTConverter:convertType:Block:Block:Block:parameterizedType
ASTConverter:convertType:Block:Block:Block:endPosition
ASTConverter:trimWhiteSpacesAndComments:Block:start
ASTConverter:retrieveInitAndSetPositions
ASTConverter:convert:Block:Block:anonymousClassDeclaration
ASTConverter:convert:Block:continueStatement
ASTConverter:convertType:Block:Block:Block:isTypeArgumentBased
ASTConverter:convert:Block:Block:Block:Block:typeRef
ASTConverter:retrieveProperRightBracketPosition:Block:Block:balance
ASTConverter:convertType:Block:Block:Block:castType
ASTConverter:createModifier:Block:start
ASTConverter:convert:Block:newStatement
ASTConverter:commentMapper
ASTConverter:convert:Block:Block:typeMethodReference
ASTConverter:convertToVariableDeclarationFragment:Block:variableDeclarationFragment
ASTConverter:createFakeNullLiteral
ASTConverter:convert:Block:Block:lineDelimiter
ASTConverter:convertType:Block:Block:Block:typeReferences
ASTConverter:updateInnerPositions:Block:Block:rightBracketEndPosition
ASTConverter:convert:Block:memberValuePairs
ASTConverter:convert:Block:Block:Block:Block:variableDeclarationExpression
ASTConverter:convert:Block:kind
ASTConverter:retrieveClosingAngleBracketPosition
ASTConverter:retrieveIdentifierAndSetPositions:Block:Block:Block:Block:endName
ASTConverter:convertToArray:Block:arrayType
ASTConverter:convertType:Block:Block:annotationsEnd
ASTConverter:setTypeForField
ASTConverter:getAbstractTypeDeclarationDetails:Block:Block:Block:Block:currentFieldDeclaration
ASTConverter:convert:Block:prefixExpression
ASTConverter:convert:Block:Block:exceptionMessage
ASTConverter:convert:Block:enumConstantDeclaration
ASTConverter:getName:Block:Block:end
ASTConverter:convert:Block:Block:Block:start
ASTConverter:createQualifiedType
ASTConverter:convert:Block:assertExpression
ASTConverter:convertToRecordDeclaration:Block:typeParameters
ASTConverter:setTypeForField:Block:Block:Block:remainingDimensions
ASTConverter:convert:Block:Block:Block:Block:extendedOperands
ASTConverter:setModifiers:Block:Block:token
ASTConverter:getPackageVisibilityStatement:Block:Block:Block:target
ASTConverter:convertType:Block:Block:pqtr
ASTConverter:convertPackage
ASTConverter:lookupScope
ASTConverter:trimWhiteSpacesAndComments:Block:trimLeftPosition
ASTConverter:convert:Block:Block:incrementsLength
ASTConverter:convertType:Block:Block:Block:firstTypeIndex
ASTConverter:convert:Block:breakStatement
ASTConverter:pendingNameScopeResolution
ASTConverter:retrieveDimensionAndSetPositions:Block:startSet
ASTConverter:setInfixSourcePositions:Block:infixSourceEnd
ASTConverter:setModifiers
ASTConverter:lookupScope:Block:Block:fieldDeclaration
ASTConverter:retrieveEllipsisStartPosition
ASTConverter:convert:Block:Block:Block:Block:Block:expr
ASTConverter:convert:Block:Block:Block:Block:initializer
ASTConverter:lookupScope:Block:Block:initializer
ASTConverter:annotateType
ASTConverter:convert:Block:variableDecl
ASTConverter:convertType:Block:Block:Block:size
ASTConverter:convertToVariableDeclarationFragment:Block:start
ASTConverter:setNodeSourceEndPosition:Block:start
ASTConverter:createComment:Block:comment
ASTConverter:convert:Block:Block:Block:Block:dimensions
ASTConverter:retrieveEndOfPotentialExtendedDimensions:Block:pos
ASTConverter:convert:Block:declarationSourceStart
ASTConverter:convert:Block:Block:Block:catchClauseSourceStart
ASTConverter:setModifiers:Block:indexInAnnotations
ASTConverter:convert:Block:Block:type
ASTConverter:convert:Block:declarationSourceEnd
ASTConverter:buildBodyDeclarations:Block:Block:nextMethodDeclaration
ASTConverter:convertToArray:Block:Block:arrayEnd
ASTConverter:setTypeNameForAnnotation:Block:Block:singleTypeReference
ASTConverter:createSimpleName:Block:end
ASTConverter:convertToAnnotationDeclaration
ASTConverter:convertToDimensions:Block:dimension
ASTConverter:convert:Block:Block:fieldAccess
ASTConverter:retrieveIdentifierAndSetPositions:Block:Block:Block:Block:startName
ASTConverter:convert:Block:Block:compilationUnit
ASTConverter:lookupScope:Block:Block:typeDecl
ASTConverter:convertToVariableDeclarationStatement
ASTConverter:convertType:Block:Block:Block:Block:qualifiedType
ASTConverter:extractSubArrayType
ASTConverter:insideComments
ASTConverter:createFakeNullPattern
ASTConverter:convertType:Block:Block:pstr
ASTConverter:recordPendingThisExpressionScopeResolution
ASTConverter:convert:Block:Block:nameSourceStart
ASTConverter:retrieveSemiColonPosition:Block:Block:token
ASTConverter:annotateType:Block:start
ASTConverter:convertType:Block:Block:wildcard
ASTConverter:convertPackage:Block:Block:start
ASTConverter:convert:Block:expressionOperatorID
ASTConverter:convert:Block:isVarArgs
ASTConverter:getPrimitiveTypeCode
ASTConverter:recordNodes:Block:Block:Block:Block:Block:expression
ASTConverter:convert:Block:Block:Block:initialization
ASTConverter:createFakeNullLiteral:Block:nullLiteral
ASTConverter:getName:Block:Block:start
ASTConverter:extractSubArrayType:Block:Block:dimensions
ASTConverter:updateInnerPositions:Block:Block:start
ASTConverter:convertToModuleDeclaration:Block:Block:name
ASTConverter:convert:Block:length
ASTConverter:buildCommentsTable:Block:nbr
ASTConverter:convert:Block:methodDecl
ASTConverter:convertType:Block:Block:Block:parameterizedSingleTypeReference
ASTConverter:setTypeNameForAnnotation:Block:Block:tokens
ASTConverter:createSimpleType:Block:start
ASTConverter:convert:Block:Block:mod
ASTConverter:convert:Block:Block:typeDecl
ASTConverter:convert:Block:Block:Block:realProblemLength
ASTConverter:convert:Block:Block:stmt
ASTConverter:convert:Block:block
ASTConverter:createModuleModifier:Block:start
ASTConverter:recordNodes:Block:Block:Block:Block:internalNode
ASTConverter:convertType:Block:annotations
ASTConverter:setModuleModifiers:Block:fakeInModule
ASTConverter:convert:Block:lhs
ASTConverter:createSimpleType
ASTConverter:convertToFieldDeclaration:Block:type
ASTConverter:convertImport:Block:name
ASTConverter:setTypeNameForAnnotation
ASTConverter:checkAndSetMalformed
ASTConverter:retrieveEndOfRightParenthesisPosition:Block:Block:count
ASTConverter:convertToFieldDeclaration:Block:variableDeclarationFragment
ASTConverter:convertType:Block:Block:Block:Block:simpleName
ASTConverter:getAbstractTypeDeclarationDetails:Block:Block:node
ASTConverter:createModuleModifier
ASTConverter:convertToFieldDeclaration
ASTConverter:convertToVariableDeclarationStatement:Block:variableDeclarationStatement
ASTConverter:setQualifiedNameNameAndSourceRanges:Block:start0
ASTConverter:convertToVariableDeclarationFragment
ASTConverter:convertToModuleDeclaration:Block:compare:Block:p2
ASTConverter:convert:Block:startPosition
ASTConverter:convertToModuleDeclaration:Block:compare:Block:p1
ASTConverter:convertAndSetReceiver:Block:Block:start
ASTConverter:convert:Block:Block:leftExpression
ASTConverter:createFakeNullPattern:Block:nullPattern
ASTConverter:createComment:Block:start
ASTConverter:convert:Block:typeReference
ASTConverter:convertType:Block:Block:Block:simpleType
ASTConverter:convert:Block:Block:Block:qualifier
ASTConverter:convert:Block:Block:argumentsLength
ASTConverter:convert:Block:Block:literal
ASTConverter:convert:Block:Block:Block:problems
ASTConverter:convert:Block:typeArguments
ASTConverter:convertToSingleVariableDeclaration:Block:variableDecl
ASTConverter:convert:Block:typeName
ASTConverter:convert:Block:end
ASTConverter:getAbstractTypeDeclarationDetails:Block:Block:Block:nextMethodDeclaration
ASTConverter:recordNodes:Block:Block:Block:name
ASTConverter:setTypeForField:Block:Block:Block:Block:subarrayType
ASTConverter:convert:Block:resourcesLength
ASTConverter:compilationUnitSourceLength
ASTConverter:convert:Block:Block:Block:Block:size
ASTConverter:recordNodes:Block:Block:Block:Block:Block:Block:typeRef
ASTConverter:convert:Block:infixExpression
ASTConverter:convertType:Block:Block:Block:Block:Block:nextPosition
ASTConverter:convert:Block:rightHandSide
ASTConverter:setTypeForMethodDeclaration:Block:Block:Block:remainingDimensions
ASTConverter:docParser
ASTConverter:annotateType:Block:Block:Block:annotation
ASTConverter:setModifiers:Block:Block:indexInAnnotations
ASTConverter:convert:Block:markerAnnotation
ASTConverter:retrieveIdentifierEndPosition
ASTConverter:convertToArray:Block:Block:Block:end
ASTConverter:convert:Block:extraDimensions
ASTConverter:convert:Block:guardedPattern
ASTConverter:convert:Block:Block:Block:Block:lineDelimiter
ASTConverter:convert:Block:returnStatement
ASTConverter:setTypeAnnotationsAndSourceRangeOnArray:Block:elementType
ASTConverter:convert:Block:enhancedForStatement
ASTConverter:getPackageVisibilityStatement:Block:tmp
ASTConverter:setTypeNameForAnnotation:Block:Block:positions
ASTConverter:setSourceRangeAnnotationsAndRecordNodes:Block:start
ASTConverter:setModifiers:Block:annotations
ASTConverter:trimWhiteSpacesAndComments:Block:end
ASTConverter:convertType:Block:Block:Block:start
ASTConverter:setExtraAnnotatedDimensions:Block:Block:annotationsOnDims
ASTConverter:convert:Block:start
ASTConverter:buildBodyDeclarations:Block:fieldsIndex
ASTConverter:convert:Block:Block:Block:Block:Block:startPosition
ASTConverter:annotateType:Block:length
ASTConverter:convertType:Block:Block:Block:Block:name
ASTConverter:convert:Block:typeParameter2
ASTConverter:trimWhiteSpacesAndComments:Block:first
ASTConverter:lookupForScopes
ASTConverter:convertPackage:Block:positions
ASTConverter:setTypeForField:Block:Block:Block:dimensions
ASTConverter:convertToRecordDeclaration
ASTConverter:setTypeAnnotationsOnDimension:Block:Block:Block:annotation
ASTConverter:trimWhiteSpacesAndComments:Block:token
ASTConverter:convert:Block:Block:constantExpression
ASTConverter:convert:Block:Block:Block:bugs
ASTConverter:annotateType:Block:annotationsLength
ASTConverter:convert:Block:ifStatement
ASTConverter:convert:Block:yieldStatement
ASTConverter:convert:Block:Block:rightOperand
ASTConverter:createModuleModifier:Block:modifier
ASTConverter:convert:Block:Block:Block:Block:currentStatement
ASTConverter:retrieveEllipsisStartPosition:Block:Block:token
ASTConverter:convert:Block:Block:imports
ASTConverter:convertToVariableDeclarationFragment:Block:name
ASTConverter:createComment:Block:end
ASTConverter:setTypeForField:Block:Block:Block:Block:elementType
ASTConverter:convert:Block:convertType
ASTConverter:convert:Block:typeParameters
ASTConverter:ISetJavaDoc:setJavadoc
ASTConverter:setTypeNameForAnnotation:Block:Block:start
ASTConverter:retrieveClosingAngleBracketPosition:Block:Block:token
ASTConverter:convert:Block:Block:Block:recoveryPropagator
ASTConverter:convert:Block:type
ASTConverter:retrieveRightBraceOrSemiColonPosition
ASTConverter:convertType:Block:Block:Block:Block:type2
ASTConverter:convert:Block:Block:catchArgumentsLength
ASTConverter:convert:Block:permittedTypes
ASTConverter:convert:Block:Block:Block:resource
ASTConverter:convert:Block:Block:statementsLength
ASTConverter:convert:Block:switchExpression
ASTConverter:checkLength:Block:len
ASTConverter:convert:Block:parameters
ASTConverter:createBaseType:Block:Block:createNameQualifiedType
ASTConverter:convertToParenthesizedExpression
ASTConverter:convert:Block:result
ASTConverter:createQualifiedType:Block:qualifiedType
ASTConverter:convertToDimensions:Block:Block:annot
ASTConverter:createQualifiedType:Block:end
ASTConverter:adjustSourcePositionsForParent
ASTConverter:buildBodyDeclarations:Block:methodsLength
ASTConverter:convert:Block:collection
ASTConverter:convert:Block:arrayType
ASTConverter:annotateType:Block:Block:typeAnnotation
ASTConverter:setTypeForMethodDeclaration
ASTConverter:setTypeForMethodDeclaration:Block:Block:Block:Block:subarrayType
ASTConverter:convert:Block:dimensionsLength
ASTConverter:annotateTypeParameter:Block:Block:typeAnnotation
ASTConverter:convert:Block:Block:Block:variableDeclarationExpression
ASTConverter:buildBodyDeclarations:Block:fieldsLength
ASTConverter:checkAndAddMultipleFieldDeclaration:Block:Block:oldInitializer
ASTConverter:setTypeNameForAnnotation:Block:Block:name
ASTConverter:createSimpleName
ASTConverter:convert:Block:rightBraceOrSemiColonPositionStart
ASTConverter:convert:Block:expressions
ASTConverter:convert:Block:Block:Block:localDeclaration
ASTConverter:removeLeadingAndTrailingCommentsFromLiteral:Block:token
ASTConverter:convertType:Block:Block:Block:arguments
ASTConverter:convertToRecordDeclaration:Block:recComps
ASTConverter:convertType:Block:Block:Block:newSourceStart
ASTConverter:convert:Block:explicitConstructorCall
ASTConverter:convert:Block:castExpression
ASTConverter:convert:Block:conditionalExpression
ASTConverter:buildBodyDeclarations:Block:fields
ASTConverter:convert:Block:Block:Block:Block:iter
ASTConverter:convertToFieldDeclaration:Block:fieldDeclaration
ASTConverter:convertType:Block:Block:name
ASTConverter:convert:Block:Block:Block:expr
ASTConverter:createComment
ASTConverter:convert:Block:Block:docComment
ASTConverter:setSourceRangeAnnotationsAndRecordNodes:Block:end
ASTConverter:convert:Block:Block:constructorInvocation
ASTConverter:setModuleModifiers:Block:Block:modifier
ASTConverter:convertImport:Block:modifiers
ASTConverter:pendingThisExpressionScopeResolution
ASTConverter:setModifiers:Block:modifiers
ASTConverter:setNodeSourceEndPosition:Block:end
ASTConverter:buildBodyDeclarations:Block:Block:node
ASTConverter:convert:Block:dimensions
ASTConverter:convert:Block:assertStatement
ASTConverter:setTypeForVariableDeclarationExpression:Block:Block:Block:Block:subarrayType
ASTConverter:convert:Block:Block:Block:Block:Block:statement
ASTConverter:setNodeSourceEndPosition:Block:Block:token
ASTConverter:convertType:Block:Block:wildcardType
ASTConverter:convert:Block:arrayCreation
ASTConverter:convertToVariableDeclarationStatement:Block:variableDeclarationFragment
ASTConverter:setTypeForSingleVariableDeclaration:Block:Block:Block:Block:subarrayType
ASTConverter:setTypeForVariableDeclarationStatement
ASTConverter:setQualifiedNameNameAndSourceRanges:Block:length
ASTConverter:retrieveInitAndSetPositions:Block:Block:Block:Block:startName
ASTConverter:convertType:Block:Block:Block:lastType
ASTConverter:convertImport:Block:importDeclaration
ASTConverter:createQualifiedType:Block:start
ASTConverter:convertToVariableDeclarationFragment:Block:Block:expression
ASTConverter:convertType:Block:Block:Block:parameterizedQualifiedTypeReference
ASTConverter:internalSetExtraDimensions
ASTConverter:convert:Block:Block:Block:Block:singleVariableDeclaration
ASTConverter:annotateType:Block:annotationsEnd
ASTConverter:getImportName
ASTConverter:recordNodes:Block:Block:Block:start
ASTConverter:convertToSingleVariableDeclaration:Block:extraDimensions
ASTConverter:convert:Block:Block:Block:Block:simpleName
ASTConverter:setTypeForVariableDeclarationExpression
ASTConverter:convert:Block:Block:Block:Block:message
ASTConverter:convert:Block:Block:nameSourceLength
ASTConverter:retrieveSemiColonPosition:Block:start
ASTConverter:convert:Block:Block:Block:Block:annotations
ASTConverter:convertImport:Block:onDemand
ASTConverter:convert:Block:Block:Block:Block:anonymousClassDeclaration
ASTConverter:retrieveStartBlockPosition
ASTConverter:convert:Block:catchArguments
ASTConverter:convert:Block:Block:expressionMethodReference
ASTConverter:convertType:Block:Block:Block:Block:nameLength
ASTConverter:recordPendingNameScopeResolution
ASTConverter:retrieveDimensionAndSetPositions:Block:Block:Block:Block:endDim
ASTConverter:convert:Block:annotationTypeMemberDeclaration2
ASTConverter:convert:Block:Block:simpleName
ASTConverter:retrieveEndOfRightParenthesisPosition:Block:Block:token
ASTConverter:convertToSingleVariableDeclaration:Block:sourceEnd
ASTConverter:convert:Block:Block:sourceEnd
ASTConverter:IGetJavaDoc:getJavaDoc
ASTConverter:getAbstractTypeDeclarationDetails:Block:Block:Block:oldInitializer
ASTConverter:convertToVariableDeclarationFragment:Block:Block:possibleEnd
ASTConverter:lookupForScopes:Block:Block:Block:thisExpression
ASTConverter:convert:Block:whileStatement
ASTConverter:convert:Block:Block:localDeclaration
ASTConverter:setTypeAnnotationsAndSourceRangeOnArray:Block:Block:currentDimension
ASTConverter:getPackageVisibilityStatement:Block:name
ASTConverter:convert:Block:Block:Block:Block:variableDeclarationFragment
ASTConverter:convert:Block:Block:Block:typeName
ASTConverter:retrieveEndOfElementTypeNamePosition
ASTConverter:convert:Block:Block:Block:Block:start
ASTConverter:setQualifiedNameNameAndSourceRanges:Block:qualifiedName
ASTConverter:retrieveSemiColonPosition:Block:end
ASTConverter:retrieveProperRightBracketPosition:Block:Block:lParentCount
ASTConverter:recordNodes:Block:Block:Block:Block:typeRef
ASTConverter:convert:Block:rightEnd
ASTConverter:convert:Block:Block:Block:dimension
ASTConverter:convert:Block:Block:Block:parameter
ASTConverter:convert:Block:superInterfaces
ASTConverter:buildBodyDeclarations
ASTConverter:getOperatorFor
ASTConverter:recordNodes:Block:Block:Block:methodRef
ASTConverter:setQualifiedNameNameAndSourceRanges:Block:firstToken
ASTConverter:convertType:Block:Block:Block:typeAnnotations
ASTConverter:convertToPatternInstanceOfExpression:Block:patternInstanceOfExpression
ASTConverter:setModifiers:Block:Block:Block:modifier
ASTConverter:extractSubArrayType:Block:end
ASTConverter:convert:Block:increments
ASTConverter:setTypeNameForAnnotation:Block:typeReference
ASTConverter:convertToModuleDeclaration:Block:Block:stmt
ASTConverter:convert:Block:bounds
ASTConverter:ASTConverter
ASTConverter:convert:Block:typeSourceEnd
ASTConverter:convertToSingleVariableDeclaration:Block:typeEnd
ASTConverter:componentType
ASTConverter:setExtraAnnotatedDimensions:Block:Block:length
ASTConverter:buildBodyDeclarations:Block:Block:position
ASTConverter:createFakeEmptyStatement:Block:start
ASTConverter:convert:Block:Block:comments
ASTConverter:updateInnerPositions:Block:Block:searchedDimension
ASTConverter:convertToModuleDeclaration:Block:Block:usesStatement
ASTConverter:convert:Block:memberValue
ASTConverter:setAST
ASTConverter:convert:Block:oldReferenceContext
ASTConverter:buildCommentsTable:Block:Block:comment
ASTConverter:convert:Block:arrayInitializer
ASTConverter:convertToAnnotationDeclaration:Block:typeDecl
ASTConverter:extractSubArrayType:Block:start
ASTConverter:convert:Block:Block:Block:extraDimensions
ASTConverter:convertPackage:Block:importReference
ASTConverter:convertType:Block:Block:Block:lenth
ASTConverter:createBaseType:Block:currentType
ASTConverter:convert:Block:methodHeaderEnd
ASTConverter:annotateType:Block:annotationsStart
ASTConverter:convert:Block:Block:positions
ASTConverter:convert:Block:Block:lastDimension
ASTConverter:convertToRecord
ASTConverter:retrieveEndOfRightParenthesisPosition
ASTConverter:convertToVariableDeclarationFragment:Block:extraDimension
ASTConverter:convertAndSetReceiver:Block:receiver
ASTConverter:convertToVariableDeclarationFragment:Block:end
ASTConverter:retrieveRightBraceOrSemiColonPosition:Block:Block:token
ASTConverter:retrieveColonPosition
ASTConverter:setTypeForMethodDeclaration:Block:Block:Block:Block:elementType
ASTConverter:convert:Block:Block:Block:thrownException
ASTConverter:getAbstractTypeDeclarationDetails
ASTConverter:retrieveEndOfPotentialExtendedDimensions:Block:Block:token
ASTConverter:convert:Block:Block:Block:startPosition
ASTConverter:convert:Block:Block:receiver
ASTConverter:convert:Block:literal
ASTConverter:completeRecord
ASTConverter:convert:Block:Block:qualifier
ASTConverter:convert:Block:Block:superConstructorInvocation
ASTConverter:retrieveDimensionAndSetPositions:Block:count
ASTConverter:convertToSingleVariableDeclaration:Block:nameEnd
ASTConverter:setExtraAnnotatedDimensions:Block:Block:Block:dim
ASTConverter:convert:Block:Block:Block:types
ASTConverter:buildBodyDeclarations:Block:membersIndex
ASTConverter:convert:Block:Block:Block:Block:Block:declaration
ASTConverter:convertType:Block:Block:Block:primitiveType
ASTConverter:convert:Block:Block:Block:declaration
ASTConverter:convertType:Block:Block:Block:simpleName
ASTConverter:convert:Block:switchStatement
ASTConverter:convertType:Block:Block:Block:Block:Block:parameterizedType
ASTConverter:convertToEnumDeclaration:Block:typeName
ASTConverter:convert:Block:Block:stringLiterals
ASTConverter:convert:Block:simpleName
ASTConverter:setTypeForMethodDeclaration:Block:Block:Block:arrayType
ASTConverter:retrieveDimensionAndSetPositions:Block:token
ASTConverter:getPackageVisibilityStatement
ASTConverter:setSourceRangeAnnotationsAndRecordNodes
ASTConverter:convert:Block:Block:statements
ASTConverter:convert:Block:sourceEnd
ASTConverter:convert:Block:thrownExceptionsLength
ASTConverter:convert:Block:Block:Block:i
ASTConverter:convertType:Block:Block:Block:tokens
ASTConverter:convertToVariableDeclarationStatement:Block:type
ASTConverter:convert:Block:annotationsStart
ASTConverter:scanner
ASTConverter:convertType:Block:Block:Block:typeArguments
ASTConverter:setTypeForSingleVariableDeclaration:Block:Block:Block:arrayType
ASTConverter:convert:Block:Block:thisExpression
ASTConverter:retrieveStartBlockPosition:Block:Block:token
ASTConverter:getName:Block:name
ASTConverter:convert:Block:Block:Block:thrownExceptionType
ASTConverter:convertToVariableDeclarationFragment:Block:extraDimensions
ASTConverter:createFakeEmptyStatement:Block:end
ASTConverter:convert:Block:Block:Block:catchClause
ASTConverter:convert:Block:Block:method
ASTConverter:monitor
ASTConverter:convert:Block:initializations
ASTConverter:convert:Block:Block:Block:Block:typesLength
ASTConverter:convertToRecordDeclaration:Block:typeName
ASTConverter:annotateTypeParameter:Block:Block:Block:annotation
ASTConverter:convert:Block:Block:typeDeclarationStatement
ASTConverter:trimWhiteSpacesAndComments:Block:trimRightPosition
ASTConverter:setNodeSourceEndPosition
ASTConverter:setTypeAnnotationsAndSourceRangeOnArray:Block:end
ASTConverter:setAnnotations:Block:modifiers
ASTConverter:getAbstractTypeDeclarationDetails:Block:nodesLength
ASTConverter:convert:Block:classInstanceCreation
ASTConverter:compilationUnitSource
ASTConverter:convert:Block:bodyEnd
ASTConverter:lookupScope:Block:currentNode
ASTConverter:checkCanceled
ASTConverter:convertType:Block:Block:Block:Block:qualifiedName
ASTConverter:convert:Block:doStatement
ASTConverter:convertAndSetReceiver
ASTConverter:getAbstractTypeDeclarationDetails:Block:Block:Block:nextMemberDeclarationNode
ASTConverter:referenceContext
ASTConverter:convert:Block:Block:problemLength
ASTConverter:recordNodes:Block:Block:Block:Block:mQual
ASTConverter:setTypeForVariableDeclarationExpression:Block:Block:Block:Block:elementType
ASTConverter:getName
ASTConverter:convert:Block:switchCase
ASTConverter:convertType:Block:Block:Block:qualifiedTypeReference
ASTConverter:ASTConverter:Block:sourceLevel
ASTConverter:getKnownEnd
ASTConverter:internalSetExpression
ASTConverter:convert:Block:Block:length
ASTConverter:convertToPatternInstanceOfExpression:Block:startPosition
ASTConverter:convertType:Block:type
ASTConverter:convert:Block:nameEnd
ASTConverter:setInfixSourcePositions
ASTConverter:convert:Block:emptyStatement
ASTConverter:annotateTypeParameter
ASTConverter:convert:Block:caseDefaultExpression
ASTConverter:ASTConverter:Block:sourceModeSetting
ASTConverter:convertToDimensions:Block:length
ASTConverter:convert:Block:Block:Block:memberValuePairEnd
ASTConverter:convert:Block:Block:message
ASTConverter:adjustSourcePositionsForParent:Block:end
ASTConverter:lookupForScopes:Block:Block:Block:name
ASTConverter:convert:Block:Block:expressions
ASTConverter:completeRecord:Block:dimensions
ASTConverter:convert:Block:singleMemberAnnotation
ASTConverter:convertToVariableDeclarationFragment:Block:hasInitialization
ASTConverter:trimWhiteSpacesAndComments:Block:positions
ASTConverter:convert:Block:Block:constructorDeclaration
ASTConverter:createComment:Block:Block:docComment
ASTConverter:setTypeForVariableDeclarationStatement:Block:Block:Block:arrayType
ASTConverter:convert:Block:value
ASTConverter:convert:Block:Block:Block:rightParenthesisPosition
ASTConverter:convertToModuleDeclaration:Block:moduleName
ASTConverter:convert:Block:Block:Block:syntaxErrorPropagator
ASTConverter:convert:Block:forStatement
ASTConverter:convert:Block:annotations
ASTConverter:retrieveSemiColonPosition:Block:length
ASTConverter:convert:Block:Block:Block:Block:localDeclaration
ASTConverter:adjustSourcePositionsForParent:Block:start
ASTConverter:convert:Block:Block:Block:Block:Block:extendedOperand
ASTConverter:convert:Block:Block:statement2
ASTConverter:resolveBindings
ASTConverter:convert:Block:Block:superMethodInvocation
ASTConverter:recordNodes:Block:Block:Block:Block:expression
ASTConverter:updateInnerPositions:Block:Block:currentComponentType
ASTConverter:convert:Block:Block:creationReference
ASTConverter:recordNodes:Block:Block:Block:compilerNode
ASTConverter:convert:Block:closingPosition
ASTConverter:convertToModuleDeclaration:Block:tSet
ASTConverter:convert:Block:parametersLength
ASTConverter:setQualifiedNameNameAndSourceRanges:Block:end
ASTConverter:recordNodes:Block:fragments
ASTConverter:setTypeNameForAnnotation:Block:Block:end
ASTConverter:convert:Block:synchronizedStatement
ASTConverter:setTypeAnnotationsOnDimension:Block:annotations
ASTConverter:recordNodes:Block:Block:Block:parameters
ASTConverter:convertToPatternInstanceOfExpression
ASTConverter:recordNodes:Block:Block:Block:mqName
ASTConverter:convert:Block:Block:superFieldAccess
ASTConverter:convertToSingleVariableDeclaration:Block:type
ASTConverter:retrieveStartingCatchPosition
ASTConverter:buildBodyDeclarations:Block:Block:nextDeclarationType
ASTConverter:removeLeadingAndTrailingCommentsFromLiteral:Block:startPosition
ASTConverter:convert:Block:typeLiteral
ASTConverter:convert:Block:initialization
ASTConverter:retrieveDimensionAndSetPositions
ASTConverter:convertType:Block:Block:Block:end
ASTConverter:setModuleModifiers
ASTConverter:createSimpleType:Block:end
ASTConverter:convert:Block:Block:Block:Block:leftSide
ASTConverter:convertType:Block:sawDiamond
ASTConverter:convert:Block:docComment
ASTConverter:convert:Block:lambdaExpression
ASTConverter:buildBodyDeclarations:Block:Block:nextFieldDeclaration
ASTConverter:convertToDimensions
ASTConverter:buildBodyDeclarations:Block:members
ASTConverter:recordNodes:Block:Block:Block:token
ASTConverter:retrieveRightBrace
ASTConverter:convert:Block:Block:typeDeclAST3
ASTConverter:convertToModuleDeclaration:Block:stmts
ASTConverter:convert:Block:expr
ASTConverter:retrieveSemiColonPosition
ASTConverter:convert:Block:Block:returnType
ASTConverter:retrieveEndOfElementTypeNamePosition:Block:Block:token
ASTConverter:convert:Block:superType
ASTConverter:getKnownEnd:Block:end
ASTConverter:convert:Block:thisExpression
ASTConverter:convertToSingleVariableDeclaration:Block:rightEnd
ASTConverter:setAnnotations
ASTConverter:completeRecord:Block:array
ASTConverter:retrieveEndOfPotentialExtendedDimensions:Block:hasTokens
ASTConverter:createBaseType
ASTConverter:recordName:Block:Block:Block:typeRef
ASTConverter:convertToArray:Block:Block:subarrayType
ASTConverter:convertImport
ASTConverter:convertToRecordDeclaration:Block:recordDeclaration
ASTConverter:convertToVariableDeclarationExpression:Block:type
ASTConverter:checkAndAddMultipleLocalDeclaration
ASTConverter:convert:Block:Block:typeArguments
ASTConverter:getAbstractTypeDeclarationDetails:Block:Block:Block:nextMemberDeclaration
ASTConverter:trimWhiteSpacesAndComments
ASTConverter:convertToPatternInstanceOfExpression:Block:sourceEnd
ASTConverter:convert:Block:Block:Block:Block:tags
ASTConverter:convert:Block:Block:typeReference
ASTConverter:getName:Block:length
ASTConverter:convertType:Block:sourceStart
ASTConverter:recordNodes
ASTConverter:getAbstractTypeDeclarationDetails:Block:Block:Block:initializer
ASTConverter:convert:Block:Block:declarationSourceStart
ASTConverter:recordNodes:Block:Block:Block:Block:param
ASTConverter:setTypeForSingleVariableDeclaration:Block:Block:Block:Block:elementType
ASTConverter:checkAndAddMultipleFieldDeclaration
ASTConverter:completeRecord:Block:Block:componentType
ASTConverter:convert:Block:Block:superMethodReference
ASTConverter:setInfixSourcePositions:Block:n
ASTConverter:convertType:Block:Block:Block:bound
ASTConverter:convertPackage:Block:annotations
ASTConverter:setInfixSourcePositions:Block:rightSourceEnd
ASTConverter:convert:Block:exceptionArgument
ASTConverter:ast
ASTConverter:setTypeAnnotationsAndSourceRangeOnArray
ASTConverter:checkLength
ASTConverter:createFakeEmptyStatement
ASTConverter:convert:Block:Block:Block:Block:temp
ASTConverter:convert:Block:Block:arguments
ASTConverter:convertToVariableDeclarationFragment:Block:initialization
ASTConverter:convertType:Block:Block:Block:indexOfEnclosingType
ASTConverter:convertType:Block:Block:Block:types
ASTConverter:setTypeForSingleVariableDeclaration:Block:Block:Block:remainingDimensions
ASTConverter:convert:Block:postfixExpression
ASTConverter:convert:Block:Block:Block:Block:Block:currentProblem
ASTConverter:convert:Block:Block:Block:typeDeclaration
ASTConverter:convert:Block:Block:Block:statementsLength
ASTConverter:recordName:Block:Block:Block:tName
ASTConverter:retrieveDimensionAndSetPositions:Block:lParenCount
ASTConverter:convertToSingleVariableDeclaration:Block:start
ASTConverter:convertType:Block:Block:Block:Block:parameterizedType
ASTConverter:retrieveIdentifierAndSetPositions:Block:token
ASTConverter:convertToVariableDeclarationStatement:Block:Block:Block:varName
ASTConverter:convertType:Block:Block:Block:positions
ASTConverter:buildCommentsTable:Block:Block:newCommentsTable
ASTConverter:convert:Block:thenStatement
ASTConverter:setQualifiedNameNameAndSourceRanges:Block:start
ASTConverter:createBaseType:Block:name
ASTConverter:buildBodyDeclarations:Block:Block:nextMemberDeclaration
ASTConverter:convertToRecord:Block:oldReferenceContext
ASTConverter:setTypeAnnotationsAndSourceRangeOnArray:Block:start
ASTConverter:convertAndSetReceiver:Block:Block:name
ASTConverter:convert:Block:Block:Block:recordDeclaration
ASTConverter:setTypeNameForAnnotation:Block:Block:qualifiedTypeReference
ASTConverter:removeLeadingAndTrailingCommentsFromLiteral:Block:start
ASTConverter:convertToParenthesizedExpression:Block:numberOfParenthesis
ASTConverter:convertToPatternInstanceOfExpression:Block:leftExpression
ASTConverter:createFakeEmptyStatement:Block:emptyStatement
ASTConverter:isPrimitiveType
ASTConverter:convertAndSetReceiver:Block:Block:nameEnd
ASTConverter:convertType:Block:Block:Block:Block:simpleType
ASTConverter:adjustSourcePositionsForParent:Block:leftParentCount
ASTConverter:convert:Block:body
ASTConverter:setInfixSourcePositions:Block:rightMostExp
ASTConverter:setTypeAnnotationsAndSourceRangeOnArray:Block:dimensions
ASTConverter:convertType
ASTConverter:convertPackage:Block:tokens
ASTConverter:convert:Block:Block:Block:argumentsLength
ASTConverter:convertToEnumDeclaration
ASTConverter:recordName:Block:Block:Block:Block:simpleName
ASTConverter:convertToAnnotationDeclaration:Block:typeName
ASTConverter:convertType:Block:Block:Block:Block:arglen
ASTConverter:retrieveEndOfPotentialExtendedDimensions:Block:balance
ASTConverter:convert:Block:elseExpression
Members
X