1 /*******************************************************************************
2  * Copyright (c) 2000, 2020 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  *     Tom Tromey - patch for readTable(String) as described in http://bugs.eclipse.org/bugs/show_bug.cgi?id=32196
14  *     Stephan Herrmann - Contributions for
15  *								bug 366003 - CCE in ASTNode.resolveAnnotations(ASTNode.java:639)
16  *								bug 374605 - Unreasonable warning for enum-based switch statements
17  *								bug 393719 - [compiler] inconsistent warnings on iteration variables
18  *								bug 382353 - [1.8][compiler] Implementation property modifiers should be accepted on default methods.
19  *								bug 383973 - [1.8][compiler] syntax recovery in the presence of default methods
20  *								bug 401035 - [1.8] A few tests have started failing recently
21  *     Jesper S Moller - Contributions for
22  *							bug 382701 - [1.8][compiler] Implement semantic analysis of Lambda expressions & Reference expression
23  *							bug 399695 - [1.8][compiler] [1.8][compiler] migrate parser to other syntax for default methods
24  *							bug 384567 - [1.5][compiler] Compiler accepts illegal modifiers on package declaration
25  *							bug 393192 - Incomplete type hierarchy with > 10 annotations
26  *							bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
27  *        Andy Clement - Contributions for
28  *                          Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work)
29  *                          Bug 409250 - [1.8][compiler] Various loose ends in 308 code generation
30  *                          Bug 415821 - [1.8][compiler] CLASS_EXTENDS target type annotation missing for anonymous classes
31  *******************************************************************************/
32 package org.eclipse.jdt.internal.compiler.parser;
33 
34 import java.io.BufferedInputStream;
35 import java.io.BufferedWriter;
36 import java.io.File;
37 import java.io.FileWriter;
38 import java.io.IOException;
39 import java.io.InputStream;
40 import java.util.ArrayList;
41 import java.util.Collections;
42 import java.util.HashMap;
43 import java.util.HashSet;
44 import java.util.Iterator;
45 import java.util.List;
46 import java.util.Map;
47 import java.util.Properties;
48 import java.util.Set;
49 import java.util.Stack;
50 
51 import org.eclipse.jdt.core.compiler.CharOperation;
52 import org.eclipse.jdt.core.compiler.InvalidInputException;
53 import org.eclipse.jdt.internal.compiler.ASTVisitor;
54 import org.eclipse.jdt.internal.compiler.CompilationResult;
55 import org.eclipse.jdt.internal.compiler.ast.*;
56 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
57 import org.eclipse.jdt.internal.compiler.codegen.ConstantPool;
58 import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
59 import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
60 import org.eclipse.jdt.internal.compiler.impl.IrritantSet;
61 import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
62 import org.eclipse.jdt.internal.compiler.lookup.Binding;
63 import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
64 import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
65 import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
66 import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
67 import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
68 import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
69 import org.eclipse.jdt.internal.compiler.parser.diagnose.DiagnoseParser;
70 import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
71 import org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit;
72 import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
73 import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
74 import org.eclipse.jdt.internal.compiler.util.Messages;
75 import org.eclipse.jdt.internal.compiler.util.Util;
76 
77 @SuppressWarnings({"rawtypes", "unchecked"})
78 public class Parser implements TerminalTokens, ParserBasicInformation, ConflictedParser, OperatorIds, TypeIds {
79 
80 	protected static final int THIS_CALL = ExplicitConstructorCall.This;
81 	protected static final int SUPER_CALL = ExplicitConstructorCall.Super;
82 	public static final char[] FALL_THROUGH_TAG = "$FALL-THROUGH$".toCharArray(); //$NON-NLS-1$
83 	public static final char[] CASES_OMITTED_TAG = "$CASES-OMITTED$".toCharArray(); //$NON-NLS-1$
84 
85 	public static char asb[] = null;
86 	public static char asr[] = null;
87 	//ast stack
88 	protected final static int AstStackIncrement = 100;
89 	public static char base_action[] = null;
90 	public static final int BracketKinds = 3;
91 
92 	public static short check_table[] = null;
93 	public static final int CurlyBracket = 2;
94 	private static final boolean DEBUG = false;
95 	private static final boolean DEBUG_AUTOMATON = false;
96 	private static final String EOF_TOKEN = "$eof" ; //$NON-NLS-1$
97 	private static final String ERROR_TOKEN = "$error" ; //$NON-NLS-1$
98 	//expression stack
99 	protected final static int ExpressionStackIncrement = 100;
100 
101 	protected final static int GenericsStackIncrement = 10;
102 
103 	private final static String FILEPREFIX = "parser"; //$NON-NLS-1$
104     public static char in_symb[] = null;
105 	private static final String INVALID_CHARACTER = "Invalid Character" ; //$NON-NLS-1$
106 	public static char lhs[] =  null;
107 
108 	public static String name[] = null;
109 	public static char nasb[] = null;
110 	public static char nasr[] = null;
111 	public static char non_terminal_index[] = null;
112 	private final static String READABLE_NAMES_FILE = "readableNames"; //$NON-NLS-1$
113 
114 	public static String readableName[] = null;
115 
116 	public static byte rhs[] = null;
117 
118 	public static int[] reverse_index = null;
119 	public static char[] recovery_templates_index = null;
120 	public static char[] recovery_templates = null;
121 	public static char[] statements_recovery_filter = null;
122 
123 	public static long rules_compliance[] =  null;
124 
125 	public static final int RoundBracket = 0;
126 
127     public static char scope_la[] = null;
128     public static char scope_lhs[] = null;
129 
130 	public static char scope_prefix[] = null;
131     public static char scope_rhs[] = null;
132     public static char scope_state[] = null;
133 
134     public static char scope_state_set[] = null;
135     public static char scope_suffix[] = null;
136 	public static final int SquareBracket = 1;
137 
138 	//internal data for the automat
139 	protected final static int StackIncrement = 255;
140 
141 	public static char term_action[] = null;
142 	public static char term_check[] = null;
143 
144 	public static char terminal_index[] = null;
145 
146 	private static final String UNEXPECTED_EOF = "Unexpected End Of File" ; //$NON-NLS-1$
147 	public static boolean VERBOSE_RECOVERY = false;
148 
149 	private static enum LocalTypeKind {
150 		LOCAL,
151 		METHOD_REFERENCE,
152 		LAMBDA,
153 	}
154 
155 	// resumeOnSyntaxError codes:
156 	protected static final int HALT = 0;     // halt and throw up hands.
157 	protected static final int RESTART = 1;  // stacks adjusted, alternate goal from check point.
158 	protected static final int RESUME = 2;   // stacks untouched, just continue from where left off.
159 
160 	public Scanner scanner;
161 	public int currentToken;
162 
163 	static {
164 		try{
initTables()165 			initTables();
166 		} catch(java.io.IOException ex){
167 			throw new ExceptionInInitializerError(ex.getMessage());
168 		}
169 	}
asi(int state)170 	public static int asi(int state) {
171 
172 		return asb[original_state(state)];
173 	}
base_check(int i)174 	public final static short base_check(int i) {
175 		return check_table[i - (NUM_RULES + 1)];
176 	}
buildFile(String filename, List listToDump)177 	private final static void buildFile(String filename, List listToDump) {
178 		BufferedWriter writer = null;
179 		try {
180 			writer = new BufferedWriter(new FileWriter(filename));
181 	    	for (Iterator iterator = listToDump.iterator(); iterator.hasNext(); ) {
182 	    		writer.write(String.valueOf(iterator.next()));
183 	    	}
184 	    	writer.flush();
185 		} catch(IOException e) {
186 			// ignore
187 		} finally {
188 			if (writer != null) {
189 	        	try {
190 					writer.close();
191 				} catch (IOException e1) {
192 					// ignore
193 				}
194 			}
195 		}
196 		System.out.println(filename + " creation complete"); //$NON-NLS-1$
197 	}
buildFileForCompliance( String file, int length, String[] tokens)198 	private static void buildFileForCompliance(
199 			String file,
200 			int length,
201 			String[] tokens) {
202 
203 			byte[] result = new byte[length * 8];
204 
205 			for (int i = 0; i < tokens.length; i = i + 3) {
206 				if("2".equals(tokens[i])) { //$NON-NLS-1$
207 					int index = Integer.parseInt(tokens[i + 1]);
208 					String token = tokens[i + 2].trim();
209 					long compliance = 0;
210 					if("1.4".equals(token)) { //$NON-NLS-1$
211 						compliance = ClassFileConstants.JDK1_4;
212 					} else if("1.5".equals(token)) { //$NON-NLS-1$
213 						compliance = ClassFileConstants.JDK1_5;
214 					} else if("1.6".equals(token)) { //$NON-NLS-1$
215 						compliance = ClassFileConstants.JDK1_6;
216 					} else if("1.7".equals(token)) { //$NON-NLS-1$
217 						compliance = ClassFileConstants.JDK1_7;
218 					} else if("1.8".equals(token)) { //$NON-NLS-1$
219 						compliance = ClassFileConstants.JDK1_8;
220 					}  else if("9".equals(token)) { //$NON-NLS-1$
221 						compliance = ClassFileConstants.JDK9;
222 					}  else if("10".equals(token)) { //$NON-NLS-1$
223 						compliance = ClassFileConstants.JDK10;
224 					}  else if("11".equals(token)) { //$NON-NLS-1$
225 						compliance = ClassFileConstants.JDK11;
226 					}  else if("12".equals(token)) { //$NON-NLS-1$
227 						compliance = ClassFileConstants.JDK12;
228 					}  else if("13".equals(token)) { //$NON-NLS-1$
229 						compliance = ClassFileConstants.JDK13;
230 					}  else if("14".equals(token)) { //$NON-NLS-1$
231 						compliance = ClassFileConstants.JDK14;
232 					} else if("recovery".equals(token)) { //$NON-NLS-1$
233 						compliance = ClassFileConstants.JDK_DEFERRED;
234 					}
235 
236 					int j = index * 8;
237 					result[j] = 	(byte)(compliance >>> 56);
238 					result[j + 1] = (byte)(compliance >>> 48);
239 					result[j + 2] = (byte)(compliance >>> 40);
240 					result[j + 3] = (byte)(compliance >>> 32);
241 					result[j + 4] = (byte)(compliance >>> 24);
242 					result[j + 5] = (byte)(compliance >>> 16);
243 					result[j + 6] = (byte)(compliance >>> 8);
244 					result[j + 7] = (byte)(compliance);
245 				}
246 			}
247 
248 			buildFileForTable(file, result);
249 		}
buildFileForName(String filename, String contents)250 	private final static String[] buildFileForName(String filename, String contents) {
251 		String[] result = new String[contents.length()];
252 		result[0] = null;
253 		int resultCount = 1;
254 
255 		StringBuffer buffer = new StringBuffer();
256 
257 		int start = contents.indexOf("name[]"); //$NON-NLS-1$
258 		start = contents.indexOf('\"', start);
259 		int end = contents.indexOf("};", start); //$NON-NLS-1$
260 
261 		contents = contents.substring(start, end);
262 
263 		boolean addLineSeparator = false;
264 		int tokenStart = -1;
265 		StringBuffer currentToken = new StringBuffer();
266 		for (int i = 0; i < contents.length(); i++) {
267 			char c = contents.charAt(i);
268 			if(c == '\"') {
269 				if(tokenStart == -1) {
270 					tokenStart = i + 1;
271 				} else {
272 					if(addLineSeparator) {
273 						buffer.append('\n');
274 						result[resultCount++] = currentToken.toString();
275 						currentToken = new StringBuffer();
276 					}
277 					String token = contents.substring(tokenStart, i);
278 					if(token.equals(ERROR_TOKEN)){
279 						token = INVALID_CHARACTER;
280 					} else if(token.equals(EOF_TOKEN)) {
281 						token = UNEXPECTED_EOF;
282 					}
283 					buffer.append(token);
284 					currentToken.append(token);
285 					addLineSeparator = true;
286 					tokenStart = -1;
287 				}
288 			}
289 			if(tokenStart == -1 && c == '+'){
290 				addLineSeparator = false;
291 			}
292 		}
293 		if(currentToken.length() > 0) {
294 			result[resultCount++] = currentToken.toString();
295 		}
296 
297 		buildFileForTable(filename, buffer.toString().toCharArray());
298 
299 		System.arraycopy(result, 0, result = new String[resultCount], 0, resultCount);
300 		return result;
301 	}
buildFileForReadableName( String file, char[] newLhs, char[] newNonTerminalIndex, String[] newName, String[] tokens)302 	private static void buildFileForReadableName(
303 		String file,
304 		char[] newLhs,
305 		char[] newNonTerminalIndex,
306 		String[] newName,
307 		String[] tokens) {
308 
309 		ArrayList entries = new ArrayList();
310 
311 		boolean[] alreadyAdded = new boolean[newName.length];
312 
313 		for (int i = 0; i < tokens.length; i = i + 3) {
314 			if("1".equals(tokens[i])) { //$NON-NLS-1$
315 				int index = newNonTerminalIndex[newLhs[Integer.parseInt(tokens[i + 1])]];
316 				StringBuffer buffer = new StringBuffer();
317 				if(!alreadyAdded[index]) {
318 					alreadyAdded[index] = true;
319 					buffer.append(newName[index]);
320 					buffer.append('=');
321 					buffer.append(tokens[i+2].trim());
322 					buffer.append('\n');
323 					entries.add(String.valueOf(buffer));
324 				}
325 			}
326 		}
327 		int i = 1;
328 		while(!INVALID_CHARACTER.equals(newName[i])) i++;
329 		i++;
330 		for (; i < alreadyAdded.length; i++) {
331 			if(!alreadyAdded[i]) {
332 				System.out.println(newName[i] + " has no readable name"); //$NON-NLS-1$
333 			}
334 		}
335 		Collections.sort(entries);
336 		buildFile(file, entries);
337 	}
buildFileForTable(String filename, byte[] bytes)338 	private final static void buildFileForTable(String filename, byte[] bytes) {
339 		java.io.FileOutputStream stream = null;
340 		try {
341 			stream = new java.io.FileOutputStream(filename);
342 			stream.write(bytes);
343 		} catch(IOException e) {
344 			// ignore
345 		} finally {
346 			if (stream != null) {
347 				try {
348 					stream.close();
349 				} catch (IOException e) {
350 					// ignore
351 				}
352 			}
353 		}
354 		System.out.println(filename + " creation complete"); //$NON-NLS-1$
355 	}
buildFileForTable(String filename, char[] chars)356 	private final static void buildFileForTable(String filename, char[] chars) {
357 		byte[] bytes = new byte[chars.length * 2];
358 		for (int i = 0; i < chars.length; i++) {
359 			bytes[2 * i] = (byte) (chars[i] >>> 8);
360 			bytes[2 * i + 1] = (byte) (chars[i] & 0xFF);
361 		}
362 
363 		java.io.FileOutputStream stream = null;
364 		try {
365 			stream = new java.io.FileOutputStream(filename);
366 			stream.write(bytes);
367 		} catch(IOException e) {
368 			// ignore
369 		} finally {
370 			if (stream != null) {
371 				try {
372 					stream.close();
373 				} catch (IOException e) {
374 					// ignore
375 				}
376 			}
377 		}
378 		System.out.println(filename + " creation complete"); //$NON-NLS-1$
379 	}
buildFileOfByteFor(String filename, String tag, String[] tokens)380 	private final static byte[] buildFileOfByteFor(String filename, String tag, String[] tokens) {
381 
382 		//transform the String tokens into chars before dumping then into file
383 
384 		int i = 0;
385 		//read upto the tag
386 		while (!tokens[i++].equals(tag)){/*empty*/}
387 		//read upto the }
388 
389 		byte[] bytes = new byte[tokens.length]; //can't be bigger
390 		int ic = 0;
391 		String token;
392 		while (!(token = tokens[i++]).equals("}")) { //$NON-NLS-1$
393 			int c = Integer.parseInt(token);
394 			bytes[ic++] = (byte) c;
395 		}
396 
397 		//resize
398 		System.arraycopy(bytes, 0, bytes = new byte[ic], 0, ic);
399 
400 		buildFileForTable(filename, bytes);
401 		return bytes;
402 	}
buildFileOfIntFor(String filename, String tag, String[] tokens)403 	private final static char[] buildFileOfIntFor(String filename, String tag, String[] tokens) {
404 
405 		//transform the String tokens into chars before dumping then into file
406 
407 		int i = 0;
408 		//read upto the tag
409 		while (!tokens[i++].equals(tag)){/*empty*/}
410 		//read upto the }
411 
412 		char[] chars = new char[tokens.length]; //can't be bigger
413 		int ic = 0;
414 		String token;
415 		while (!(token = tokens[i++]).equals("}")) { //$NON-NLS-1$
416 			int c = Integer.parseInt(token);
417 			chars[ic++] = (char) c;
418 		}
419 
420 		//resize
421 		System.arraycopy(chars, 0, chars = new char[ic], 0, ic);
422 
423 		buildFileForTable(filename, chars);
424 		return chars;
425 	}
buildFileOfShortFor(String filename, String tag, String[] tokens)426 	private final static void buildFileOfShortFor(String filename, String tag, String[] tokens) {
427 
428 		//transform the String tokens into chars before dumping then into file
429 
430 		int i = 0;
431 		//read upto the tag
432 		while (!tokens[i++].equals(tag)){/*empty*/}
433 		//read upto the }
434 
435 		char[] chars = new char[tokens.length]; //can't be bigger
436 		int ic = 0;
437 		String token;
438 		while (!(token = tokens[i++]).equals("}")) { //$NON-NLS-1$
439 			int c = Integer.parseInt(token);
440 			chars[ic++] = (char) (c + 32768);
441 		}
442 
443 		//resize
444 		System.arraycopy(chars, 0, chars = new char[ic], 0, ic);
445 
446 		buildFileForTable(filename, chars);
447 	}
buildFilesForRecoveryTemplates( String indexFilename, String templatesFilename, char[] newTerminalIndex, char[] newNonTerminalIndex, String[] newName, char[] newLhs, String[] tokens)448 	private static void buildFilesForRecoveryTemplates(
449 		String indexFilename,
450 		String templatesFilename,
451 		char[] newTerminalIndex,
452 		char[] newNonTerminalIndex,
453 		String[] newName,
454 		char[] newLhs,
455 		String[] tokens) {
456 
457 		int[] newReverse = computeReverseTable(newTerminalIndex, newNonTerminalIndex, newName);
458 
459 		char[] newRecoveyTemplatesIndex = new char[newNonTerminalIndex.length];
460 		char[] newRecoveyTemplates = new char[newNonTerminalIndex.length];
461 		int newRecoveyTemplatesPtr = 0;
462 
463 		for (int i = 0; i < tokens.length; i = i + 3) {
464 			if("3".equals(tokens[i])) { //$NON-NLS-1$
465 				int length = newRecoveyTemplates.length;
466 				if(length == newRecoveyTemplatesPtr + 1) {
467 					System.arraycopy(newRecoveyTemplates, 0, newRecoveyTemplates = new char[length * 2], 0, length);
468 				}
469 				newRecoveyTemplates[newRecoveyTemplatesPtr++] = 0;
470 
471 				int index = newLhs[Integer.parseInt(tokens[i + 1])];
472 
473 				newRecoveyTemplatesIndex[index] = (char)newRecoveyTemplatesPtr;
474 
475 				String token = tokens[i + 2].trim();
476 				java.util.StringTokenizer st = new java.util.StringTokenizer(token, " ");  //$NON-NLS-1$
477 				String[] terminalNames = new String[st.countTokens()];
478 				int t = 0;
479 				while (st.hasMoreTokens()) {
480 					terminalNames[t++] = st.nextToken();
481 				}
482 
483 				for (int j = 0; j < terminalNames.length; j++) {
484 					int symbol = getSymbol(terminalNames[j], newName, newReverse);
485 					if(symbol > -1) {
486 						length = newRecoveyTemplates.length;
487 						if(length == newRecoveyTemplatesPtr + 1) {
488 							System.arraycopy(newRecoveyTemplates, 0, newRecoveyTemplates = new char[length * 2], 0, length);
489 						}
490 						newRecoveyTemplates[newRecoveyTemplatesPtr++] = (char)symbol;
491 					}
492 				}
493 			}
494 		}
495 		newRecoveyTemplates[newRecoveyTemplatesPtr++] = 0;
496 		System.arraycopy(newRecoveyTemplates, 0, newRecoveyTemplates = new char[newRecoveyTemplatesPtr], 0, newRecoveyTemplatesPtr);
497 
498 		buildFileForTable(indexFilename, newRecoveyTemplatesIndex);
499 		buildFileForTable(templatesFilename, newRecoveyTemplates);
500 	}
buildFilesForStatementsRecoveryFilter( String filename, char[] newNonTerminalIndex, char[] newLhs, String[] tokens)501 	private static void buildFilesForStatementsRecoveryFilter(
502 			String filename,
503 			char[] newNonTerminalIndex,
504 			char[] newLhs,
505 			String[] tokens) {
506 
507 			char[] newStatementsRecoveryFilter = new char[newNonTerminalIndex.length];
508 
509 			for (int i = 0; i < tokens.length; i = i + 3) {
510 				if("4".equals(tokens[i])) { //$NON-NLS-1$
511 					int index = newLhs[Integer.parseInt(tokens[i + 1])];
512 
513 					newStatementsRecoveryFilter[index] = 1;
514 				}
515 			}
516 			buildFileForTable(filename, newStatementsRecoveryFilter);
517 		}
buildFilesFromLPG(String dataFilename, String dataFilename2)518 	public final static void buildFilesFromLPG(String dataFilename, String dataFilename2) {
519 
520 		//RUN THIS METHOD TO GENERATE PARSER*.RSC FILES
521 
522 		//build from the lpg javadcl.java files that represents the parser tables
523 		//lhs check_table asb asr symbol_index
524 
525 		//[org.eclipse.jdt.internal.compiler.parser.Parser.buildFilesFromLPG("d:/leapfrog/grammar/javadcl.java")]
526 		char[] contents = CharOperation.NO_CHAR;
527 		try {
528 			contents = Util.getFileCharContent(new File(dataFilename), null);
529 		} catch (IOException ex) {
530 			System.out.println(Messages.parser_incorrectPath);
531 			return;
532 		}
533 		java.util.StringTokenizer st =
534 			new java.util.StringTokenizer(new String(contents), " \t\n\r[]={,;");  //$NON-NLS-1$
535 		String[] tokens = new String[st.countTokens()];
536 		int j = 0;
537 		while (st.hasMoreTokens()) {
538 			tokens[j++] = st.nextToken();
539 		}
540 		final String prefix = FILEPREFIX;
541 		int i = 0;
542 
543 		char[] newLhs = buildFileOfIntFor(prefix + (++i) + ".rsc", "lhs", tokens); //$NON-NLS-1$ //$NON-NLS-2$
544 		buildFileOfShortFor(prefix + (++i) + ".rsc", "check_table", tokens); //$NON-NLS-2$ //$NON-NLS-1$
545 		buildFileOfIntFor(prefix + (++i) + ".rsc", "asb", tokens); //$NON-NLS-2$ //$NON-NLS-1$
546 		buildFileOfIntFor(prefix + (++i) + ".rsc", "asr", tokens); //$NON-NLS-2$ //$NON-NLS-1$
547 		buildFileOfIntFor(prefix + (++i) + ".rsc", "nasb", tokens); //$NON-NLS-2$ //$NON-NLS-1$
548 		buildFileOfIntFor(prefix + (++i) + ".rsc", "nasr", tokens); //$NON-NLS-2$ //$NON-NLS-1$
549 		char[] newTerminalIndex = buildFileOfIntFor(prefix + (++i) + ".rsc", "terminal_index", tokens); //$NON-NLS-2$ //$NON-NLS-1$
550 		char[] newNonTerminalIndex = buildFileOfIntFor(prefix + (++i) + ".rsc", "non_terminal_index", tokens); //$NON-NLS-1$ //$NON-NLS-2$
551 		buildFileOfIntFor(prefix + (++i) + ".rsc", "term_action", tokens); //$NON-NLS-2$ //$NON-NLS-1$
552 
553 		buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_prefix", tokens); //$NON-NLS-2$ //$NON-NLS-1$
554 		buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_suffix", tokens); //$NON-NLS-2$ //$NON-NLS-1$
555 		buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_lhs", tokens); //$NON-NLS-2$ //$NON-NLS-1$
556 		buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_state_set", tokens); //$NON-NLS-2$ //$NON-NLS-1$
557 		buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_rhs", tokens); //$NON-NLS-2$ //$NON-NLS-1$
558 		buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_state", tokens); //$NON-NLS-2$ //$NON-NLS-1$
559 		buildFileOfIntFor(prefix + (++i) + ".rsc", "in_symb", tokens); //$NON-NLS-2$ //$NON-NLS-1$
560 
561 		byte[] newRhs = buildFileOfByteFor(prefix + (++i) + ".rsc", "rhs", tokens); //$NON-NLS-2$ //$NON-NLS-1$
562 		buildFileOfIntFor(prefix + (++i) + ".rsc", "term_check", tokens); //$NON-NLS-2$ //$NON-NLS-1$
563 		buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_la", tokens); //$NON-NLS-2$ //$NON-NLS-1$
564 
565 		String[] newName = buildFileForName(prefix + (++i) + ".rsc", new String(contents)); //$NON-NLS-1$
566 
567 		contents = CharOperation.NO_CHAR;
568 		try {
569 			contents = Util.getFileCharContent(new File(dataFilename2), null);
570 		} catch (IOException ex) {
571 			System.out.println(Messages.parser_incorrectPath);
572 			return;
573 		}
574 		st = new java.util.StringTokenizer(new String(contents), "\t\n\r#");  //$NON-NLS-1$
575 		tokens = new String[st.countTokens()];
576 		j = 0;
577 		while (st.hasMoreTokens()) {
578 			tokens[j++] = st.nextToken();
579 		}
580 
581 		buildFileForCompliance(prefix + (++i) + ".rsc", newRhs.length, tokens);//$NON-NLS-1$
582 		buildFileForReadableName(READABLE_NAMES_FILE+".props", newLhs, newNonTerminalIndex, newName, tokens);//$NON-NLS-1$
583 
584 		buildFilesForRecoveryTemplates(
585 				prefix + (++i) + ".rsc", //$NON-NLS-1$
586 				prefix + (++i) + ".rsc", //$NON-NLS-1$
587 				newTerminalIndex,
588 				newNonTerminalIndex,
589 				newName,
590 				newLhs,
591 				tokens);
592 
593 		buildFilesForStatementsRecoveryFilter(
594 				prefix + (++i) + ".rsc", //$NON-NLS-1$
595 				newNonTerminalIndex,
596 				newLhs,
597 				tokens);
598 
599 
600 		System.out.println(Messages.parser_moveFiles);
601 	}
computeReverseTable(char[] newTerminalIndex, char[] newNonTerminalIndex, String[] newName)602 	protected static int[] computeReverseTable(char[] newTerminalIndex, char[] newNonTerminalIndex, String[] newName) {
603 		int[] newReverseTable = new int[newName.length];
604 		for (int j = 0; j < newName.length; j++) {
605 			found : {
606 				for (int k = 0; k < newTerminalIndex.length; k++) {
607 					if(newTerminalIndex[k] == j) {
608 						newReverseTable[j] = k;
609 						break found;
610 					}
611 				}
612 				for (int k = 0; k < newNonTerminalIndex.length; k++) {
613 					if(newNonTerminalIndex[k] == j) {
614 						newReverseTable[j] = -k;
615 						break found;
616 					}
617 				}
618 			}
619 		}
620 		return newReverseTable;
621 	}
622 
getSymbol(String terminalName, String[] newName, int[] newReverse)623 	private static int getSymbol(String terminalName, String[] newName, int[] newReverse) {
624 		for (int j = 0; j < newName.length; j++) {
625 			if(terminalName.equals(newName[j])) {
626 				return newReverse[j];
627 			}
628 		}
629 		return -1;
630 	}
in_symbol(int state)631 	public static int in_symbol(int state) {
632 		return in_symb[original_state(state)];
633 	}
initTables()634 	public final static void initTables() throws java.io.IOException {
635 
636 		final String prefix = FILEPREFIX;
637 		int i = 0;
638 		lhs = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
639 		char[] chars = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
640 		check_table = new short[chars.length];
641 		for (int c = chars.length; c-- > 0;) {
642 			check_table[c] = (short) (chars[c] - 32768);
643 		}
644 		asb = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
645 		asr = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
646 		nasb = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
647 		nasr = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
648 		terminal_index = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
649 		non_terminal_index = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
650 		term_action = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
651 
652 		scope_prefix = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
653 		scope_suffix = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
654 		scope_lhs = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
655 		scope_state_set = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
656 		scope_rhs = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
657 		scope_state = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
658 		in_symb = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
659 
660 		rhs = readByteTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
661 		term_check = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
662 		scope_la = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
663 
664 		name = readNameTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
665 
666 		rules_compliance = readLongTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
667 
668 		readableName = readReadableNameTable(READABLE_NAMES_FILE + ".props"); //$NON-NLS-1$
669 
670 		reverse_index = computeReverseTable(terminal_index, non_terminal_index, name);
671 
672 		recovery_templates_index = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
673 		recovery_templates = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
674 
675 		statements_recovery_filter = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
676 
677 		base_action = lhs;
678 	}
nasi(int state)679 	public static int nasi(int state) {
680 		return nasb[original_state(state)];
681 	}
ntAction(int state, int sym)682 	public static int ntAction(int state, int sym) {
683 		return base_action[state + sym];
684 	}
original_state(int state)685 	protected static int original_state(int state) {
686 		return -base_check(state);
687 	}
688 
readByteTable(String filename)689 	protected static byte[] readByteTable(String filename) throws java.io.IOException {
690 
691 		//files are located at Parser.class directory
692 
693 		InputStream stream = Parser.class.getResourceAsStream(filename);
694 		if (stream == null) {
695 			throw new java.io.IOException(Messages.bind(Messages.parser_missingFile, filename));
696 		}
697 		byte[] bytes = null;
698 		try {
699 			stream = new BufferedInputStream(stream);
700 			bytes = Util.getInputStreamAsByteArray(stream, -1);
701 		} finally {
702 			try {
703 				stream.close();
704 			} catch (IOException e) {
705 				// ignore
706 			}
707 		}
708 		return bytes;
709 	}
readLongTable(String filename)710 	protected static long[] readLongTable(String filename) throws java.io.IOException {
711 
712 		//files are located at Parser.class directory
713 
714 		InputStream stream = Parser.class.getResourceAsStream(filename);
715 		if (stream == null) {
716 			throw new java.io.IOException(Messages.bind(Messages.parser_missingFile, filename));
717 		}
718 		byte[] bytes = null;
719 		try {
720 			stream = new BufferedInputStream(stream);
721 			bytes = Util.getInputStreamAsByteArray(stream, -1);
722 		} finally {
723 			try {
724 				stream.close();
725 			} catch (IOException e) {
726 				// ignore
727 			}
728 		}
729 
730 		//minimal integrity check (even size expected)
731 		int length = bytes.length;
732 		if (length % 8 != 0)
733 			throw new java.io.IOException(Messages.bind(Messages.parser_corruptedFile, filename));
734 
735 		// convert bytes into longs
736 		long[] longs = new long[length / 8];
737 		int i = 0;
738 		int longIndex = 0;
739 
740 		while (true) {
741 			longs[longIndex++] =
742 			  (((long) (bytes[i++] & 0xFF)) << 56)
743 			+ (((long) (bytes[i++] & 0xFF)) << 48)
744 			+ (((long) (bytes[i++] & 0xFF)) << 40)
745 			+ (((long) (bytes[i++] & 0xFF)) << 32)
746 			+ (((long) (bytes[i++] & 0xFF)) << 24)
747 			+ (((long) (bytes[i++] & 0xFF)) << 16)
748 			+ (((long) (bytes[i++] & 0xFF)) << 8)
749 			+ (bytes[i++] & 0xFF);
750 
751 			if (i == length)
752 				break;
753 		}
754 		return longs;
755 	}
756 
readNameTable(String filename)757 	protected static String[] readNameTable(String filename) throws java.io.IOException {
758 		char[] contents = readTable(filename);
759 		char[][] nameAsChar = CharOperation.splitOn('\n', contents);
760 
761 		String[] result = new String[nameAsChar.length + 1];
762 		result[0] = null;
763 		for (int i = 0; i < nameAsChar.length; i++) {
764 			result[i + 1] = new String(nameAsChar[i]);
765 		}
766 
767 		return result;
768 	}
readReadableNameTable(String filename)769 	protected static String[] readReadableNameTable(String filename){
770 		String[] result = new String[name.length];
771 
772 		InputStream is = Parser.class.getResourceAsStream(filename);
773 		Properties props = new Properties();
774 		try {
775 			props.load(is);
776 		} catch (IOException e) {
777 			result = name;
778 			return result;
779 		}
780 		System.arraycopy(name, 0, result, 0, NT_OFFSET + 1);
781 		for (int i = NT_OFFSET; i < name.length; i++) {
782 			String n = props.getProperty(name[i]);
783 			if (n != null && n.length() > 0) {
784 				result[i] = n;
785 			} else {
786 				result[i] = name[i];
787 			}
788 		}
789 		return result;
790 	}
readTable(String filename)791 	protected static char[] readTable(String filename) throws java.io.IOException {
792 
793 		//files are located at Parser.class directory
794 
795 		InputStream stream = Parser.class.getResourceAsStream(filename);
796 		if (stream == null) {
797 			throw new java.io.IOException(Messages.bind(Messages.parser_missingFile, filename));
798 		}
799 		byte[] bytes = null;
800 		try {
801 			stream = new BufferedInputStream(stream);
802 			bytes = Util.getInputStreamAsByteArray(stream, -1);
803 		} finally {
804 			try {
805 				stream.close();
806 			} catch (IOException e) {
807 				// ignore
808 			}
809 		}
810 
811 		//minimal integrity check (even size expected)
812 		int length = bytes.length;
813 		if ((length & 1) != 0)
814 			throw new java.io.IOException(Messages.bind(Messages.parser_corruptedFile, filename));
815 
816 		// convert bytes into chars
817 		char[] chars = new char[length / 2];
818 		int i = 0;
819 		int charIndex = 0;
820 
821 		while (true) {
822 			chars[charIndex++] = (char) (((bytes[i++] & 0xFF) << 8) + (bytes[i++] & 0xFF));
823 			if (i == length)
824 				break;
825 		}
826 		return chars;
827 	}
tAction(int state, int sym)828 	public static int tAction(int state, int sym) {
829 		return term_action[term_check[base_action[state]+sym] == sym ? base_action[state] + sym : base_action[state]];
830 	}
831 	/** Overridable hook, to allow CompletionParser to synthesize a few trailing tokens at (faked) EOF. */
actFromTokenOrSynthetic(int previousAct)832 	protected int actFromTokenOrSynthetic(int previousAct) {
833 		return tAction(previousAct, this.currentToken);
834 	}
835 	protected int astLengthPtr;
836 
837 	protected int[] astLengthStack;
838 	protected int astPtr;
839 	protected ASTNode[] astStack = new ASTNode[AstStackIncrement];
840 
841 	protected int patternLengthPtr;
842 
843 	protected int[] patternLengthStack;
844 	protected int patternPtr;
845 	protected ASTNode[] patternStack = new ASTNode[AstStackIncrement];
846 	public CompilationUnitDeclaration compilationUnit; /*the result from parse()*/
847 
848 	protected RecoveredElement currentElement;
849 
850 	protected boolean diet = false; //tells the scanner to jump over some parts of the code/expressions like method bodies
851 	protected int dietInt = 0; // if > 0 force the none-diet-parsing mode (even if diet if requested) [field parsing with anonymous inner classes...]
852 	protected int endPosition; //accurate only when used ! (the start position is pushed into intStack while the end the current one)
853 	protected int endStatementPosition;
854 	protected int expressionLengthPtr;
855 	protected int[] expressionLengthStack;
856 	protected int expressionPtr;
857 	protected Expression[] expressionStack = new Expression[ExpressionStackIncrement];
858 	protected int rBracketPosition;
859 	public int firstToken ; // handle for multiple parsing goals
860 
861 	/* jsr308 -- Type annotation management, we now maintain type annotations in a separate stack
862 	   as otherwise they get interspersed with other expressions and some of the code is not prepared
863 	   to handle such interleaving and will look ugly if changed.
864 
865 	   See consumeArrayCreationExpressionWithoutInitializer for example.
866 
867 	   Where SE8 annotations occur in a place SE5 annotations are legal, the SE8 annotations end up in
868 	   the expression stack as we have no way of distinguishing between the two.
869 	*/
870 	protected int typeAnnotationPtr;
871 	protected int typeAnnotationLengthPtr;
872 	protected Annotation [] typeAnnotationStack = new Annotation[TypeAnnotationStackIncrement];
873 	protected int [] typeAnnotationLengthStack;
874 	// annotation stack
875 	protected final static int TypeAnnotationStackIncrement = 100;
876 
877 	// generics management
878 	protected int genericsIdentifiersLengthPtr;
879 	protected int[] genericsIdentifiersLengthStack = new int[GenericsStackIncrement];
880 	protected int genericsLengthPtr;
881 	protected int[] genericsLengthStack = new int[GenericsStackIncrement];
882 	protected int genericsPtr;
883 	protected ASTNode[] genericsStack = new ASTNode[GenericsStackIncrement];
884 	protected boolean hasError;
885 	protected boolean hasReportedError;
886 	//identifiers stacks
887 	protected int identifierLengthPtr;
888 	protected int[] identifierLengthStack;
889 	protected long[] identifierPositionStack;
890 	protected int identifierPtr;
891 	protected char[][] identifierStack;
892 	protected boolean ignoreNextOpeningBrace;
893 	protected boolean ignoreNextClosingBrace;
894 
895 	//positions , dimensions , .... (int stacks)
896 	protected int intPtr;
897 
898 	protected int[] intStack;
899 	public int lastAct ; //handle for multiple parsing goals
900 	//error recovery management
901 	protected int lastCheckPoint;
902 	protected int lastErrorEndPosition;
903 	protected int lastErrorEndPositionBeforeRecovery = -1;
904 	protected int lastIgnoredToken, nextIgnoredToken;
905 
906 	protected int listLength; // for recovering some incomplete list (interfaces, throws or parameters)
907 
908 	protected int listTypeParameterLength; // for recovering some incomplete list (type parameters)
909 	protected int lParenPos,rParenPos; //accurate only when used !
910 	protected int modifiers;
911 	protected int modifiersSourceStart;
912 	protected int colonColonStart = -1;
913 	protected int[] nestedMethod; //the ptr is nestedType
914 	protected int forStartPosition = 0;
915 
916 	protected int nestedType, dimensions, switchNestingLevel;
917 	ASTNode [] noAstNodes = new ASTNode[AstStackIncrement];
918 	public boolean switchWithTry = false;
919 
920 	Expression [] noExpressions = new Expression[ExpressionStackIncrement];
921 	//modifiers dimensions nestedType etc.......
922 	protected boolean optimizeStringLiterals =true;
923 	protected CompilerOptions options;
924 
925 	protected ProblemReporter problemReporter;
926 
927 	protected int rBraceStart, rBraceEnd, rBraceSuccessorStart; //accurate only when used !
928 protected int realBlockPtr;
929 protected int[] realBlockStack;
930 protected int recoveredStaticInitializerStart;
931 public ReferenceContext referenceContext;
932 public boolean reportOnlyOneSyntaxError = false;
933 public boolean reportSyntaxErrorIsRequired = true;
934 protected boolean restartRecovery;
935 protected boolean annotationRecoveryActivated = true;
936 protected int lastPosistion;
937 // statement recovery
938 public boolean methodRecoveryActivated = false;
939 protected boolean statementRecoveryActivated = false;
940 protected TypeDeclaration[] recoveredTypes;
941 protected int recoveredTypePtr;
942 protected int nextTypeStart;
943 protected TypeDeclaration pendingRecoveredType;
944 public RecoveryScanner recoveryScanner;
945 
946 protected int[] stack = new int[StackIncrement];
947 protected int stateStackTop;
948 protected int synchronizedBlockSourceStart;
949 
950 protected int[] variablesCounter;
951 
952 protected boolean checkExternalizeStrings;
953 
954 protected boolean recordStringLiterals;
955 // javadoc
956 public Javadoc javadoc;
957 public JavadocParser javadocParser;
958 // used for recovery
959 protected int lastJavadocEnd;
960 public org.eclipse.jdt.internal.compiler.ReadManager readManager;
961 protected int valueLambdaNestDepth = -1;
962 private int stateStackLengthStack[] = new int[0];
963 protected boolean parsingJava8Plus;
964 protected boolean parsingJava9Plus;
965 protected boolean parsingJava14Plus;
966 protected boolean parsingJava11Plus;
967 protected int unstackedAct = ERROR_ACTION;
968 private boolean haltOnSyntaxError = false;
969 private boolean tolerateDefaultClassMethods = false;
970 private boolean processingLambdaParameterList = false;
971 private boolean expectTypeAnnotation = false;
972 private boolean reparsingLambdaExpression = false;
973 
974 private Map<TypeDeclaration, Integer[]> recordNestedMethodLevels;
975 
Parser()976 public Parser () {
977 	// Caveat Emptor: For inheritance purposes and then only in very special needs. Only minimal state is initialized !
978 }
Parser(ProblemReporter problemReporter, boolean optimizeStringLiterals)979 public Parser(ProblemReporter problemReporter, boolean optimizeStringLiterals) {
980 
981 	this.problemReporter = problemReporter;
982 	this.options = problemReporter.options;
983 	this.optimizeStringLiterals = optimizeStringLiterals;
984 	initializeScanner();
985 	this.parsingJava8Plus = this.options.sourceLevel >= ClassFileConstants.JDK1_8;
986 	this.parsingJava9Plus = this.options.sourceLevel >= ClassFileConstants.JDK9;
987 	this.parsingJava14Plus = this.options.sourceLevel >= ClassFileConstants.JDK14;
988 	this.parsingJava11Plus = this.options.sourceLevel >= ClassFileConstants.JDK11;
989 	this.astLengthStack = new int[50];
990 	this.patternLengthStack = new int[20];
991 	this.expressionLengthStack = new int[30];
992 	this.typeAnnotationLengthStack = new int[30];
993 	this.intStack = new int[50];
994 	this.identifierStack = new char[30][];
995 	this.identifierLengthStack = new int[30];
996 	this.nestedMethod = new int[30];
997 	this.realBlockStack = new int[30];
998 	this.identifierPositionStack = new long[30];
999 	this.variablesCounter = new int[30];
1000 
1001 	this.recordNestedMethodLevels = new HashMap<>();
1002 
1003 	// javadoc support
1004 	this.javadocParser = createJavadocParser();
1005 }
annotationRecoveryCheckPoint(int start, int end)1006 protected void annotationRecoveryCheckPoint(int start, int end) {
1007 	if(this.lastCheckPoint < end) {
1008 		this.lastCheckPoint = end + 1;
1009 	}
1010 }
arrayInitializer(int length)1011 public void arrayInitializer(int length) {
1012 	//length is the size of the array Initializer
1013 	//expressionPtr points on the last elt of the arrayInitializer,
1014 	// in other words, it has not been decremented yet.
1015 
1016 	ArrayInitializer ai = new ArrayInitializer();
1017 	if (length != 0) {
1018 		this.expressionPtr -= length;
1019 		System.arraycopy(this.expressionStack, this.expressionPtr + 1, ai.expressions = new Expression[length], 0, length);
1020 	}
1021 	pushOnExpressionStack(ai);
1022 	//positionning
1023 	ai.sourceEnd = this.endStatementPosition;
1024 	ai.sourceStart = this.intStack[this.intPtr--];
1025 }
blockReal()1026 protected void blockReal() {
1027 	// See consumeLocalVariableDeclarationStatement in case of change: duplicated code
1028 	// increment the amount of declared variables for this block
1029 	this.realBlockStack[this.realBlockPtr]++;
1030 }
1031 /*
1032  * Build initial recovery state.
1033  * Recovery state is inferred from the current state of the parser (reduced node stack).
1034  */
buildInitialRecoveryState()1035 public RecoveredElement buildInitialRecoveryState(){
1036 
1037 	/* initialize recovery by retrieving available reduced nodes
1038 	 * also rebuild bracket balance
1039 	 */
1040 	this.lastCheckPoint = 0;
1041 	this.lastErrorEndPositionBeforeRecovery = this.scanner.currentPosition;
1042 
1043 	RecoveredElement element = null;
1044 	if (this.referenceContext instanceof CompilationUnitDeclaration){
1045 		element = new RecoveredUnit(this.compilationUnit, 0, this);
1046 
1047 		/* ignore current stack state, since restarting from the beginnning
1048 		   since could not trust simple brace count */
1049 		// restart recovery from scratch
1050 		this.compilationUnit.currentPackage = null;
1051 		this.compilationUnit.imports = null;
1052 		this.compilationUnit.types = null;
1053 		this.currentToken = 0;
1054 		this.listLength = 0;
1055 		this.listTypeParameterLength = 0;
1056 		this.endPosition = 0;
1057 		this.endStatementPosition = 0;
1058 		return element;
1059 	} else {
1060 		if (this.referenceContext instanceof AbstractMethodDeclaration){
1061 			element = new RecoveredMethod((AbstractMethodDeclaration) this.referenceContext, null, 0, this);
1062 			this.lastCheckPoint = ((AbstractMethodDeclaration) this.referenceContext).bodyStart;
1063 			if(this.statementRecoveryActivated) {
1064 				element = element.add(new Block(0), 0);
1065 			}
1066 		} else {
1067 			/* Initializer bodies are parsed in the context of the type declaration, we must thus search it inside */
1068 			if (this.referenceContext instanceof TypeDeclaration){
1069 				TypeDeclaration type = (TypeDeclaration) this.referenceContext;
1070 				FieldDeclaration[] fieldDeclarations = type.fields;
1071 				int length = fieldDeclarations == null ? 0 : fieldDeclarations.length;
1072 				for (int i = 0; i < length; i++){
1073 					FieldDeclaration field = fieldDeclarations[i];
1074 					if (field != null
1075 						&& field.getKind() == AbstractVariableDeclaration.INITIALIZER
1076 						&& ((Initializer) field).block != null
1077 						&& field.declarationSourceStart <= this.scanner.initialPosition
1078 						&& this.scanner.initialPosition <= field.declarationSourceEnd
1079 						&& this.scanner.eofPosition <= field.declarationSourceEnd+1){
1080 						element = new RecoveredInitializer(field, null, 1, this);
1081 						this.lastCheckPoint = field.declarationSourceStart;
1082 						break;
1083 					}
1084 				}
1085 			}
1086 		}
1087 	}
1088 
1089 	if (element == null) return element;
1090 
1091 	for(int i = 0; i <= this.astPtr; i++){
1092 		ASTNode node = this.astStack[i];
1093 		if (node instanceof AbstractMethodDeclaration){
1094 			AbstractMethodDeclaration method = (AbstractMethodDeclaration) node;
1095 			if (method.declarationSourceEnd == 0){
1096 				element = element.add(method, 0);
1097 				this.lastCheckPoint = method.bodyStart;
1098 			} else {
1099 				element = element.add(method, 0);
1100 				this.lastCheckPoint = method.declarationSourceEnd + 1;
1101 			}
1102 			continue;
1103 		}
1104 		if (node instanceof Initializer){
1105 			Initializer initializer = (Initializer) node;
1106 			// ignore initializer with no block
1107 			if (initializer.block == null) continue;
1108 			if (initializer.declarationSourceEnd == 0){
1109 				element = element.add(initializer, 1);
1110 				this.lastCheckPoint = initializer.sourceStart;
1111 			} else {
1112 				element = element.add(initializer, 0);
1113 				this.lastCheckPoint = initializer.declarationSourceEnd + 1;
1114 			}
1115 			continue;
1116 		}
1117 		if (node instanceof FieldDeclaration){
1118 			FieldDeclaration field = (FieldDeclaration) node;
1119 			if (field.declarationSourceEnd == 0){
1120 				element = element.add(field, 0);
1121 				if (field.initialization == null){
1122 					this.lastCheckPoint = field.sourceEnd + 1;
1123 				} else {
1124 					this.lastCheckPoint = field.initialization.sourceEnd + 1;
1125 				}
1126 			} else {
1127 				element = element.add(field, 0);
1128 				this.lastCheckPoint = field.declarationSourceEnd + 1;
1129 			}
1130 			continue;
1131 		}
1132 		if (node instanceof TypeDeclaration){
1133 			TypeDeclaration type = (TypeDeclaration) node;
1134 			if ((type.modifiers & ClassFileConstants.AccEnum) != 0) {
1135 				// do not allow enums to be build as recovery types
1136 				// https://bugs.eclipse.org/bugs/show_bug.cgi?id=340691
1137 				continue;
1138 			}
1139 			if (type.declarationSourceEnd == 0){
1140 				element = element.add(type, 0);
1141 				this.lastCheckPoint = type.bodyStart;
1142 			} else {
1143 				element = element.add(type, 0);
1144 				this.lastCheckPoint = type.declarationSourceEnd + 1;
1145 			}
1146 			continue;
1147 		}
1148 		if (node instanceof ImportReference){
1149 			ImportReference importRef = (ImportReference) node;
1150 			element = element.add(importRef, 0);
1151 			this.lastCheckPoint = importRef.declarationSourceEnd + 1;
1152 		}
1153 		if(this.statementRecoveryActivated) {
1154 			if(node instanceof Block) {
1155 				Block block = (Block) node;
1156 				element = element.add(block, 0);
1157 				this.lastCheckPoint = block.sourceEnd + 1;
1158 			} else if(node instanceof LocalDeclaration) {
1159 				LocalDeclaration statement = (LocalDeclaration) node;
1160 				element = element.add(statement, 0);
1161 				this.lastCheckPoint = statement.sourceEnd + 1;
1162 			} else if(node instanceof Expression &&  ((Expression) node).isTrulyExpression()) {
1163 				if(node instanceof Assignment ||
1164 						node instanceof PrefixExpression ||
1165 						node instanceof PostfixExpression ||
1166 						node instanceof MessageSend ||
1167 						node instanceof AllocationExpression) {
1168 					// recover only specific expressions
1169 					Expression statement = (Expression) node;
1170 					element = element.add(statement, 0);
1171 					if(statement.statementEnd != -1) {
1172 						this.lastCheckPoint = statement.statementEnd + 1;
1173 					} else {
1174 						this.lastCheckPoint = statement.sourceEnd + 1;
1175 					}
1176 				}
1177 			} else if(node instanceof Statement) {
1178 				Statement statement = (Statement) node;
1179 				element = element.add(statement, 0);
1180 				this.lastCheckPoint = statement.sourceEnd + 1;
1181 			}
1182 		}
1183 	}
1184 
1185 	if (this.statementRecoveryActivated) {
1186 		if (this.pendingRecoveredType != null &&
1187 				this.scanner.startPosition - 1 <= this.pendingRecoveredType.declarationSourceEnd) {
1188 			// Add the pending type to the AST if this type isn't already added in the AST.
1189 			element = element.add(this.pendingRecoveredType, 0);
1190 			this.lastCheckPoint = this.pendingRecoveredType.declarationSourceEnd + 1;
1191 			this.pendingRecoveredType = null;
1192 		}
1193 	}
1194 	return element;
1195 }
1196 
checkAndSetModifiers(int flag)1197 protected void checkAndSetModifiers(int flag){
1198 	/*modify the current modifiers buffer.
1199 	When the startPosition of the modifiers is 0
1200 	it means that the modifier being parsed is the first
1201 	of a list of several modifiers. The startPosition
1202 	is zeroed when a copy of modifiers-buffer is push
1203 	onto the this.astStack. */
1204 
1205 	if ((this.modifiers & flag) != 0){ // duplicate modifier
1206 		this.modifiers |= ExtraCompilerModifiers.AccAlternateModifierProblem;
1207 	}
1208 	this.modifiers |= flag;
1209 
1210 	if (this.modifiersSourceStart < 0) this.modifiersSourceStart = this.scanner.startPosition;
1211 
1212 	if (this.currentElement != null) {
1213 		this.currentElement.addModifier(flag, this.modifiersSourceStart);
1214 	}
1215 }
checkComment()1216 public void checkComment() {
1217 
1218 	// discard obsolete comments while inside methods or fields initializer (see bug 74369)
1219 	if (!(this.diet && this.dietInt==0) && this.scanner.commentPtr >= 0) {
1220 		flushCommentsDefinedPriorTo(this.endStatementPosition);
1221 	}
1222 
1223 	int lastComment = this.scanner.commentPtr;
1224 
1225 	if (this.modifiersSourceStart >= 0) {
1226 		// eliminate comments located after modifierSourceStart if positioned
1227 		while (lastComment >= 0) {
1228 			int commentSourceStart = this.scanner.commentStarts[lastComment];
1229 			if (commentSourceStart < 0) commentSourceStart = -commentSourceStart;
1230 			if (commentSourceStart <= this.modifiersSourceStart) break;
1231 			lastComment--;
1232 		}
1233 	}
1234 	if (lastComment >= 0) {
1235 		// consider all remaining leading comments to be part of current declaration
1236 		int lastCommentStart = this.scanner.commentStarts[0];
1237 		if (lastCommentStart < 0) lastCommentStart = -lastCommentStart;
1238 		if (this.forStartPosition != 0 || this.forStartPosition  < lastCommentStart) {// if there is no 'for' in-between.
1239 			this.modifiersSourceStart = lastCommentStart;
1240 		}
1241 
1242 		// check deprecation in last comment if javadoc (can be followed by non-javadoc comments which are simply ignored)
1243 		while (lastComment >= 0 && this.scanner.commentStops[lastComment] < 0) lastComment--; // non javadoc comment have negative end positions
1244 		if (lastComment >= 0 && this.javadocParser != null) {
1245 			int commentEnd = this.scanner.commentStops[lastComment] - 1; //stop is one over,
1246 			// do not report problem before last parsed comment while recovering code...
1247 			if (this.javadocParser.shouldReportProblems) {
1248 				this.javadocParser.reportProblems = this.currentElement == null || commentEnd > this.lastJavadocEnd;
1249 			} else {
1250 				this.javadocParser.reportProblems = false;
1251 			}
1252 			if (this.javadocParser.checkDeprecation(lastComment)) {
1253 				checkAndSetModifiers(ClassFileConstants.AccDeprecated);
1254 			}
1255 			this.javadoc = this.javadocParser.docComment;	// null if check javadoc is not activated
1256 			if (this.currentElement == null) this.lastJavadocEnd = commentEnd;
1257 		}
1258 	}
1259 }
checkNonNLSAfterBodyEnd(int declarationEnd)1260 protected void checkNonNLSAfterBodyEnd(int declarationEnd){
1261 	if(this.scanner.currentPosition - 1 <= declarationEnd) {
1262 		this.scanner.eofPosition = declarationEnd < Integer.MAX_VALUE ? declarationEnd + 1 : declarationEnd;
1263 		try {
1264 			while(this.scanner.getNextToken() != TokenNameEOF){/*empty*/}
1265 		} catch (InvalidInputException e) {
1266 			// Nothing to do
1267 		}
1268 	}
1269 }
1270 protected void classInstanceCreation(boolean isQualified) {
1271 	// ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt
1272 
1273 	// ClassBodyopt produces a null item on the astStak if it produces NO class body
1274 	// An empty class body produces a 0 on the length stack.....
1275 
1276 	AllocationExpression alloc;
1277 	int length;
1278 	if (((length = this.astLengthStack[this.astLengthPtr--]) == 1)
1279 		&& (this.astStack[this.astPtr] == null)) {
1280 		//NO ClassBody
1281 		this.astPtr--;
1282 		if (isQualified) {
1283 			alloc = new QualifiedAllocationExpression();
1284 		} else {
1285 			alloc = new AllocationExpression();
1286 		}
1287 		alloc.sourceEnd = this.endPosition; //the position has been stored explicitly
1288 
1289 		if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
1290 			this.expressionPtr -= length;
1291 			System.arraycopy(
1292 				this.expressionStack,
1293 				this.expressionPtr + 1,
1294 				alloc.arguments = new Expression[length],
1295 				0,
1296 				length);
1297 		}
1298 		alloc.type = getTypeReference(0);
1299 		checkForDiamond(alloc.type);
1300 
1301 		//the default constructor with the correct number of argument
1302 		//will be created and added by the TC (see createsInternalConstructorWithBinding)
1303 		alloc.sourceStart = this.intStack[this.intPtr--];
1304 		pushOnExpressionStack(alloc);
1305 	} else {
1306 		dispatchDeclarationInto(length);
1307 		TypeDeclaration anonymousTypeDeclaration = (TypeDeclaration)this.astStack[this.astPtr];
1308 		anonymousTypeDeclaration.declarationSourceEnd = this.endStatementPosition;
1309 		anonymousTypeDeclaration.bodyEnd = this.endStatementPosition;
1310 		if (anonymousTypeDeclaration.allocation != null) {
1311 			anonymousTypeDeclaration.allocation.sourceEnd = this.endStatementPosition;
1312 			checkForDiamond(anonymousTypeDeclaration.allocation.type);
1313 		}
1314 		if (length == 0 && !containsComment(anonymousTypeDeclaration.bodyStart, anonymousTypeDeclaration.bodyEnd)) {
1315 			anonymousTypeDeclaration.bits |= ASTNode.UndocumentedEmptyBlock;
1316 		}
1317 		this.astPtr--;
1318 		this.astLengthPtr--;
1319 	}
1320 }
1321 protected void checkForDiamond(TypeReference allocType) {
1322 	if (allocType instanceof ParameterizedSingleTypeReference) {
1323 		ParameterizedSingleTypeReference type = (ParameterizedSingleTypeReference) allocType;
1324 		if (type.typeArguments == TypeReference.NO_TYPE_ARGUMENTS) {
1325 			if (this.options.sourceLevel < ClassFileConstants.JDK1_7) {
1326 				problemReporter().diamondNotBelow17(allocType);
1327 			}
1328 			if (this.options.sourceLevel > ClassFileConstants.JDK1_4) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=351965
1329 				type.bits |= ASTNode.IsDiamond;
1330 			} // else don't even bother to recognize this as <>
1331 		}
1332 	}
1333 	else if (allocType instanceof ParameterizedQualifiedTypeReference) {
1334 		ParameterizedQualifiedTypeReference type = (ParameterizedQualifiedTypeReference) allocType;
1335 		if (type.typeArguments[type.typeArguments.length - 1] == TypeReference.NO_TYPE_ARGUMENTS) { // Don't care for X<>.Y<> and X<>.Y<String>
1336 			if (this.options.sourceLevel < ClassFileConstants.JDK1_7) {
1337 				problemReporter().diamondNotBelow17(allocType, type.typeArguments.length - 1);
1338 			}
1339 			if (this.options.sourceLevel > ClassFileConstants.JDK1_4) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=351965
1340 				type.bits |= ASTNode.IsDiamond;
1341 			} // else don't even bother to recognize this as <>
1342 		}
1343 	}
1344 }
1345 protected ParameterizedQualifiedTypeReference computeQualifiedGenericsFromRightSide(TypeReference rightSide, int dim, Annotation [][] annotationsOnDimensions) {
1346 	int nameSize = this.identifierLengthStack[this.identifierLengthPtr];
1347 	int tokensSize = nameSize;
1348 	if (rightSide instanceof ParameterizedSingleTypeReference) {
1349 		tokensSize ++;
1350 	} else if (rightSide instanceof SingleTypeReference) {
1351 		tokensSize ++;
1352 	} else if (rightSide instanceof ParameterizedQualifiedTypeReference) {
1353 		tokensSize += ((QualifiedTypeReference) rightSide).tokens.length;
1354 	} else if (rightSide instanceof QualifiedTypeReference) {
1355 		tokensSize += ((QualifiedTypeReference) rightSide).tokens.length;
1356 	}
1357 	TypeReference[][] typeArguments = new TypeReference[tokensSize][];
1358 	char[][] tokens = new char[tokensSize][];
1359 	long[] positions = new long[tokensSize];
1360 	Annotation [][] typeAnnotations = null;
1361 	if (rightSide instanceof ParameterizedSingleTypeReference) {
1362 		ParameterizedSingleTypeReference singleParameterizedTypeReference = (ParameterizedSingleTypeReference) rightSide;
1363 		tokens[nameSize] = singleParameterizedTypeReference.token;
1364 		positions[nameSize] = (((long) singleParameterizedTypeReference.sourceStart) << 32) + singleParameterizedTypeReference.sourceEnd;
1365 		typeArguments[nameSize] = singleParameterizedTypeReference.typeArguments;
1366 		if (singleParameterizedTypeReference.annotations != null) {
1367 			typeAnnotations = new Annotation[tokensSize][];
1368 		    typeAnnotations[nameSize] = singleParameterizedTypeReference.annotations[0];
1369 		}
1370 	} else if (rightSide instanceof SingleTypeReference) {
1371 		SingleTypeReference singleTypeReference = (SingleTypeReference) rightSide;
1372 		tokens[nameSize] = singleTypeReference.token;
1373 		positions[nameSize] = (((long) singleTypeReference.sourceStart) << 32) + singleTypeReference.sourceEnd;
1374 		if (singleTypeReference.annotations != null) {
1375 			typeAnnotations = new Annotation[tokensSize][];
1376 			typeAnnotations[nameSize] =  singleTypeReference.annotations[0];
1377 		}
1378 	} else if (rightSide instanceof ParameterizedQualifiedTypeReference) {
1379 		ParameterizedQualifiedTypeReference parameterizedTypeReference = (ParameterizedQualifiedTypeReference) rightSide;
1380 		TypeReference[][] rightSideTypeArguments = parameterizedTypeReference.typeArguments;
1381 		System.arraycopy(rightSideTypeArguments, 0, typeArguments, nameSize, rightSideTypeArguments.length);
1382 		char[][] rightSideTokens = parameterizedTypeReference.tokens;
1383 		System.arraycopy(rightSideTokens, 0, tokens, nameSize, rightSideTokens.length);
1384 		long[] rightSidePositions = parameterizedTypeReference.sourcePositions;
1385 		System.arraycopy(rightSidePositions, 0, positions, nameSize, rightSidePositions.length);
1386 		Annotation [][] rightSideAnnotations = parameterizedTypeReference.annotations;
1387 		if (rightSideAnnotations != null) {
1388 			typeAnnotations = new Annotation[tokensSize][];
1389 			System.arraycopy(rightSideAnnotations, 0, typeAnnotations, nameSize, rightSideAnnotations.length);
1390 		}
1391 	} else if (rightSide instanceof QualifiedTypeReference) {
1392 		QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReference) rightSide;
1393 		char[][] rightSideTokens = qualifiedTypeReference.tokens;
1394 		System.arraycopy(rightSideTokens, 0, tokens, nameSize, rightSideTokens.length);
1395 		long[] rightSidePositions = qualifiedTypeReference.sourcePositions;
1396 		System.arraycopy(rightSidePositions, 0, positions, nameSize, rightSidePositions.length);
1397 		Annotation [][] rightSideAnnotations = qualifiedTypeReference.annotations;
1398 		if (rightSideAnnotations != null) {
1399 			typeAnnotations = new Annotation[tokensSize][];
1400 			System.arraycopy(rightSideAnnotations, 0, typeAnnotations, nameSize, rightSideAnnotations.length);
1401 		}
1402 	}
1403 
1404 	int currentTypeArgumentsLength = this.genericsLengthStack[this.genericsLengthPtr--];
1405 	TypeReference[] currentTypeArguments = new TypeReference[currentTypeArgumentsLength];
1406 	this.genericsPtr -= currentTypeArgumentsLength;
1407 	System.arraycopy(this.genericsStack, this.genericsPtr + 1, currentTypeArguments, 0, currentTypeArgumentsLength);
1408 
1409 	if (nameSize == 1) {
1410 		tokens[0] = this.identifierStack[this.identifierPtr];
1411 		positions[0] = this.identifierPositionStack[this.identifierPtr--];
1412 		typeArguments[0] = currentTypeArguments;
1413 	} else {
1414 		this.identifierPtr -= nameSize;
1415 		System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, nameSize);
1416 		System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, nameSize);
1417 		typeArguments[nameSize - 1] = currentTypeArguments;
1418 	}
1419 	this.identifierLengthPtr--;
1420 	ParameterizedQualifiedTypeReference typeRef = new ParameterizedQualifiedTypeReference(tokens, typeArguments, dim, annotationsOnDimensions, positions);
1421 
1422 	while (nameSize > 0) {
1423 		int length;
1424 		if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
1425 			if (typeAnnotations == null)
1426 				typeAnnotations = new Annotation[tokensSize][];
1427 			System.arraycopy(
1428 					this.typeAnnotationStack,
1429 					(this.typeAnnotationPtr -= length) + 1,
1430 					typeAnnotations[nameSize - 1] = new Annotation[length],
1431 					0,
1432 					length);
1433 			if (nameSize == 1) {
1434 				typeRef.sourceStart = typeAnnotations[0][0].sourceStart;
1435 			}
1436 		}
1437 		nameSize--;
1438 	}
1439 
1440 	if ((typeRef.annotations = typeAnnotations) != null) {
1441 		typeRef.bits |= ASTNode.HasTypeAnnotations;
1442 	}
1443 	return typeRef;
1444 }
1445 protected void concatExpressionLists() {
1446 	this.expressionLengthStack[--this.expressionLengthPtr]++;
1447 }
1448 protected void concatGenericsLists() {
1449 	this.genericsLengthStack[this.genericsLengthPtr - 1] += this.genericsLengthStack[this.genericsLengthPtr--];
1450 }
1451 protected void concatNodeLists() {
1452 	/*
1453 	 * This is a case where you have two sublists into the this.astStack that you want
1454 	 * to merge in one list. There is no action required on the this.astStack. The only
1455 	 * thing you need to do is merge the two lengths specified on the astStackLength.
1456 	 * The top two length are for example:
1457 	 * ... p   n
1458 	 * and you want to result in a list like:
1459 	 * ... n+p
1460 	 * This means that the p could be equals to 0 in case there is no astNode pushed
1461 	 * on the this.astStack.
1462 	 * Look at the InterfaceMemberDeclarations for an example.
1463 	 */
1464 
1465 	this.astLengthStack[this.astLengthPtr - 1] += this.astLengthStack[this.astLengthPtr--];
1466 }
1467 protected void consumeAdditionalBound() {
1468 	pushOnGenericsStack(getTypeReference(this.intStack[this.intPtr--]));
1469 }
1470 protected void consumeAdditionalBound1() {
1471 	// nothing to be done.
1472 	// The reference type1 is consumed by consumeReferenceType1 method.
1473 }
1474 protected void consumeAdditionalBoundList() {
1475 	concatGenericsLists();
1476 }
1477 protected void consumeAdditionalBoundList1() {
1478 	concatGenericsLists();
1479 }
1480 protected boolean isIndirectlyInsideLambdaExpression() {
1481 	return false;
1482 }
1483 protected void consumeAllocationHeader() {
1484 	// ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt
1485 
1486 	// ClassBodyopt produces a null item on the astStak if it produces NO class body
1487 	// An empty class body produces a 0 on the length stack.....
1488 
1489 	if (this.currentElement == null){
1490 		return; // should never occur, this consumeRule is only used in recovery mode
1491 	}
1492 	if (this.currentToken == TokenNameLBRACE){
1493 		// beginning of an anonymous type
1494 		TypeDeclaration anonymousType = new TypeDeclaration(this.compilationUnit.compilationResult);
1495 		anonymousType.name = CharOperation.NO_CHAR;
1496 		anonymousType.bits |= (ASTNode.IsAnonymousType|ASTNode.IsLocalType);
1497 		anonymousType.sourceStart = this.intStack[this.intPtr--];
1498 		anonymousType.declarationSourceStart = anonymousType.sourceStart;
1499 		anonymousType.sourceEnd = this.rParenPos; // closing parenthesis
1500 		QualifiedAllocationExpression alloc = new QualifiedAllocationExpression(anonymousType);
1501 		alloc.type = getTypeReference(0);
1502 		alloc.sourceStart = anonymousType.sourceStart;
1503 		alloc.sourceEnd = anonymousType.sourceEnd ;
1504 		this.lastCheckPoint = anonymousType.bodyStart = this.scanner.currentPosition;
1505 		this.currentElement = this.currentElement.add(anonymousType, 0);
1506 		this.lastIgnoredToken = -1;
1507 		if (isIndirectlyInsideLambdaExpression())
1508 			this.ignoreNextOpeningBrace = true;
1509 		else
1510 			this.currentToken = 0; // opening brace already taken into account
1511 		return;
1512 	}
1513 	this.lastCheckPoint = this.scanner.startPosition; // force to restart at this exact position
1514 	this.restartRecovery = true; // request to restart from here on
1515 }
1516 protected void consumeAnnotationAsModifier() {
1517 	Expression expression = this.expressionStack[this.expressionPtr];
1518 	int sourceStart = expression.sourceStart;
1519 	if (this.modifiersSourceStart < 0) {
1520 		this.modifiersSourceStart = sourceStart;
1521 	}
1522 }
1523 protected void consumeAnnotationName() {
1524 	if(this.currentElement != null && !this.expectTypeAnnotation) {
1525 		int start = this.intStack[this.intPtr];
1526 		int end = (int) (this.identifierPositionStack[this.identifierPtr] & 0x00000000FFFFFFFFL);
1527 		annotationRecoveryCheckPoint(start, end);
1528 
1529 		if (this.annotationRecoveryActivated) {
1530 			this.currentElement = this.currentElement.addAnnotationName(this.identifierPtr, this.identifierLengthPtr, start, 0);
1531 		}
1532 	}
1533 	this.recordStringLiterals = false;
1534 	this.expectTypeAnnotation = false;
1535 }
1536 protected void consumeAnnotationTypeDeclaration() {
1537 	int length;
1538 	if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
1539 		//there are length declarations
1540 		//dispatch according to the type of the declarations
1541 		dispatchDeclarationInto(length);
1542 	}
1543 
1544 	TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
1545 
1546 	//convert constructor that do not have the type's name into methods
1547 	typeDecl.checkConstructors(this);
1548 
1549 	//always add <clinit> (will be remove at code gen time if empty)
1550 	if (this.scanner.containsAssertKeyword) {
1551 		typeDecl.bits |= ASTNode.ContainsAssertion;
1552 	}
1553 	typeDecl.addClinit();
1554 	typeDecl.bodyEnd = this.endStatementPosition;
1555 	if (length == 0 && !containsComment(typeDecl.bodyStart, typeDecl.bodyEnd)) {
1556 		typeDecl.bits |= ASTNode.UndocumentedEmptyBlock;
1557 	}
1558 	typeDecl.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
1559 }
1560 protected void consumeAnnotationTypeDeclarationHeader() {
1561 	TypeDeclaration annotationTypeDeclaration = (TypeDeclaration) this.astStack[this.astPtr];
1562 	if (this.currentToken == TokenNameLBRACE) {
1563 		annotationTypeDeclaration.bodyStart = this.scanner.currentPosition;
1564 	}
1565 	if (this.currentElement != null) {
1566 		this.restartRecovery = true; // used to avoid branching back into the regular automaton
1567 	}
1568 	// flush the comments related to the annotation type header
1569 	this.scanner.commentPtr = -1;
1570 }
1571 protected void consumeAnnotationTypeDeclarationHeaderName() {
1572 	// consumeAnnotationTypeDeclarationHeader ::= Modifiers '@' PushModifiers interface Identifier
1573 	// consumeAnnotationTypeDeclarationHeader ::= '@' PushModifiers interface Identifier
1574 	TypeDeclaration annotationTypeDeclaration = new TypeDeclaration(this.compilationUnit.compilationResult);
1575 	if (this.nestedMethod[this.nestedType] == 0) {
1576 		if (this.nestedType != 0) {
1577 			annotationTypeDeclaration.bits |= ASTNode.IsMemberType;
1578 		}
1579 	} else {
1580 		// Record that the block has a declaration for local types
1581 		annotationTypeDeclaration.bits |= ASTNode.IsLocalType;
1582 		markEnclosingMemberWithLocalType();
1583 		blockReal();
1584 	}
1585 
1586 	//highlight the name of the type
1587 	long pos = this.identifierPositionStack[this.identifierPtr];
1588 	annotationTypeDeclaration.sourceEnd = (int) pos;
1589 	annotationTypeDeclaration.sourceStart = (int) (pos >>> 32);
1590 	annotationTypeDeclaration.name = this.identifierStack[this.identifierPtr--];
1591 	this.identifierLengthPtr--;
1592 
1593 	//compute the declaration source too
1594 	// 'interface' push two int positions: the beginning of the class token and its end.
1595 	// we want to keep the beginning position but get rid of the end position
1596 	// it is only used for the ClassLiteralAccess positions.
1597 	this.intPtr--; // remove the start position of the interface token
1598 	this.intPtr--; // remove the end position of the interface token
1599 
1600 	annotationTypeDeclaration.modifiersSourceStart = this.intStack[this.intPtr--];
1601 	annotationTypeDeclaration.modifiers = this.intStack[this.intPtr--] | ClassFileConstants.AccAnnotation | ClassFileConstants.AccInterface;
1602 	if (annotationTypeDeclaration.modifiersSourceStart >= 0) {
1603 		annotationTypeDeclaration.declarationSourceStart = annotationTypeDeclaration.modifiersSourceStart;
1604 		this.intPtr--; // remove the position of the '@' token as we have modifiers
1605 	} else {
1606 		int atPosition = this.intStack[this.intPtr--];
1607 		// remove the position of the '@' token as we don't have modifiers
1608 		annotationTypeDeclaration.declarationSourceStart = atPosition;
1609 	}
1610 
1611 	// Store secondary info
1612 	if ((annotationTypeDeclaration.bits & ASTNode.IsMemberType) == 0 && (annotationTypeDeclaration.bits & ASTNode.IsLocalType) == 0) {
1613 		if (this.compilationUnit != null && !CharOperation.equals(annotationTypeDeclaration.name, this.compilationUnit.getMainTypeName())) {
1614 			annotationTypeDeclaration.bits |= ASTNode.IsSecondaryType;
1615 		}
1616 	}
1617 
1618 	// consume annotations
1619 	int length;
1620 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
1621 		System.arraycopy(
1622 			this.expressionStack,
1623 			(this.expressionPtr -= length) + 1,
1624 			annotationTypeDeclaration.annotations = new Annotation[length],
1625 			0,
1626 			length);
1627 	}
1628 	annotationTypeDeclaration.bodyStart = annotationTypeDeclaration.sourceEnd + 1;
1629 
1630 	// javadoc
1631 	annotationTypeDeclaration.javadoc = this.javadoc;
1632 	this.javadoc = null;
1633 	pushOnAstStack(annotationTypeDeclaration);
1634 	if(!this.statementRecoveryActivated &&
1635 			this.options.sourceLevel < ClassFileConstants.JDK1_5 &&
1636 			this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
1637 		problemReporter().invalidUsageOfAnnotationDeclarations(annotationTypeDeclaration);
1638 	}
1639 
1640 	// recovery
1641 	if (this.currentElement != null){
1642 		this.lastCheckPoint = annotationTypeDeclaration.bodyStart;
1643 		this.currentElement = this.currentElement.add(annotationTypeDeclaration, 0);
1644 		this.lastIgnoredToken = -1;
1645 	}
1646 }
1647 protected void consumeAnnotationTypeDeclarationHeaderNameWithTypeParameters() {
1648 	// consumeAnnotationTypeDeclarationHeader ::= Modifiers '@' PushModifiers interface Identifier TypeParameters
1649 	// consumeAnnotationTypeDeclarationHeader ::= '@' PushModifiers interface Identifier TypeParameters
1650 	TypeDeclaration annotationTypeDeclaration = new TypeDeclaration(this.compilationUnit.compilationResult);
1651 	// consume type parameters
1652 	int length = this.genericsLengthStack[this.genericsLengthPtr--];
1653 	this.genericsPtr -= length;
1654 	System.arraycopy(this.genericsStack, this.genericsPtr + 1, annotationTypeDeclaration.typeParameters = new TypeParameter[length], 0, length);
1655 
1656 	problemReporter().invalidUsageOfTypeParametersForAnnotationDeclaration(annotationTypeDeclaration);
1657 
1658 	annotationTypeDeclaration.bodyStart = annotationTypeDeclaration.typeParameters[length-1].declarationSourceEnd + 1;
1659 
1660 //	annotationTypeDeclaration.typeParameters = null;
1661 
1662 	this.listTypeParameterLength = 0;
1663 
1664 	if (this.nestedMethod[this.nestedType] == 0) {
1665 		if (this.nestedType != 0) {
1666 			annotationTypeDeclaration.bits |= ASTNode.IsMemberType;
1667 		}
1668 	} else {
1669 		// Record that the block has a declaration for local types
1670 		annotationTypeDeclaration.bits |= ASTNode.IsLocalType;
1671 		markEnclosingMemberWithLocalType();
1672 		blockReal();
1673 	}
1674 
1675 	//highlight the name of the type
1676 	long pos = this.identifierPositionStack[this.identifierPtr];
1677 	annotationTypeDeclaration.sourceEnd = (int) pos;
1678 	annotationTypeDeclaration.sourceStart = (int) (pos >>> 32);
1679 	annotationTypeDeclaration.name = this.identifierStack[this.identifierPtr--];
1680 	this.identifierLengthPtr--;
1681 
1682 	//compute the declaration source too
1683 	// 'interface' push two int positions: the beginning of the class token and its end.
1684 	// we want to keep the beginning position but get rid of the end position
1685 	// it is only used for the ClassLiteralAccess positions.
1686 	this.intPtr--; // remove the start position of the interface token
1687 	this.intPtr--; // remove the end position of the interface token
1688 
1689 	annotationTypeDeclaration.modifiersSourceStart = this.intStack[this.intPtr--];
1690 	annotationTypeDeclaration.modifiers = this.intStack[this.intPtr--] | ClassFileConstants.AccAnnotation | ClassFileConstants.AccInterface;
1691 	if (annotationTypeDeclaration.modifiersSourceStart >= 0) {
1692 		annotationTypeDeclaration.declarationSourceStart = annotationTypeDeclaration.modifiersSourceStart;
1693 		this.intPtr--; // remove the position of the '@' token as we have modifiers
1694 	} else {
1695 		int atPosition = this.intStack[this.intPtr--];
1696 		// remove the position of the '@' token as we don't have modifiers
1697 		annotationTypeDeclaration.declarationSourceStart = atPosition;
1698 	}
1699 
1700 	// Store secondary info
1701 	if ((annotationTypeDeclaration.bits & ASTNode.IsMemberType) == 0 && (annotationTypeDeclaration.bits & ASTNode.IsLocalType) == 0) {
1702 		if (this.compilationUnit != null && !CharOperation.equals(annotationTypeDeclaration.name, this.compilationUnit.getMainTypeName())) {
1703 			annotationTypeDeclaration.bits |= ASTNode.IsSecondaryType;
1704 		}
1705 	}
1706 
1707 	// consume annotations
1708 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
1709 		System.arraycopy(
1710 			this.expressionStack,
1711 			(this.expressionPtr -= length) + 1,
1712 			annotationTypeDeclaration.annotations = new Annotation[length],
1713 			0,
1714 			length);
1715 	}
1716 	// javadoc
1717 	annotationTypeDeclaration.javadoc = this.javadoc;
1718 	this.javadoc = null;
1719 	pushOnAstStack(annotationTypeDeclaration);
1720 	if(!this.statementRecoveryActivated &&
1721 			this.options.sourceLevel < ClassFileConstants.JDK1_5 &&
1722 			this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
1723 		problemReporter().invalidUsageOfAnnotationDeclarations(annotationTypeDeclaration);
1724 	}
1725 
1726 	// recovery
1727 	if (this.currentElement != null){
1728 		this.lastCheckPoint = annotationTypeDeclaration.bodyStart;
1729 		this.currentElement = this.currentElement.add(annotationTypeDeclaration, 0);
1730 		this.lastIgnoredToken = -1;
1731 	}
1732 }
consumeAnnotationTypeMemberDeclaration()1733 protected void consumeAnnotationTypeMemberDeclaration() {
1734 	// AnnotationTypeMemberDeclaration ::= AnnotationTypeMemberDeclarationHeader AnnotationTypeMemberHeaderExtendedDims DefaultValueopt ';'
1735 	AnnotationMethodDeclaration annotationTypeMemberDeclaration = (AnnotationMethodDeclaration) this.astStack[this.astPtr];
1736 	annotationTypeMemberDeclaration.modifiers |= ExtraCompilerModifiers.AccSemicolonBody;
1737 	// store the this.endPosition (position just before the '}') in case there is
1738 	// a trailing comment behind the end of the method
1739 	int declarationEndPosition = flushCommentsDefinedPriorTo(this.endStatementPosition);
1740 	annotationTypeMemberDeclaration.bodyStart = this.endStatementPosition;
1741 	annotationTypeMemberDeclaration.bodyEnd = declarationEndPosition;
1742 	annotationTypeMemberDeclaration.declarationSourceEnd = declarationEndPosition;
1743 }
consumeAnnotationTypeMemberDeclarations()1744 protected void consumeAnnotationTypeMemberDeclarations() {
1745 	// AnnotationTypeMemberDeclarations ::= AnnotationTypeMemberDeclarations AnnotationTypeMemberDeclaration
1746 	concatNodeLists();
1747 }
consumeAnnotationTypeMemberDeclarationsopt()1748 protected void consumeAnnotationTypeMemberDeclarationsopt() {
1749 	this.nestedType-- ;
1750 }
consumeArgumentList()1751 protected void consumeArgumentList() {
1752 	// ArgumentList ::= ArgumentList ',' Expression
1753 	concatExpressionLists();
1754 }
consumeArguments()1755 protected void consumeArguments() {
1756 	// Arguments ::= '(' ArgumentListopt ')'
1757 	// nothing to do, the expression stack is already updated
1758 	pushOnIntStack(this.rParenPos);
1759 }
consumeArrayAccess(boolean unspecifiedReference)1760 protected void consumeArrayAccess(boolean unspecifiedReference) {
1761 	// ArrayAccess ::= Name '[' Expression ']' ==> true
1762 	// ArrayAccess ::= PrimaryNoNewArray '[' Expression ']' ==> false
1763 
1764 
1765 	//optimize push/pop
1766 	Expression exp;
1767 	if (unspecifiedReference) {
1768 		exp =
1769 			this.expressionStack[this.expressionPtr] =
1770 				new ArrayReference(
1771 					getUnspecifiedReferenceOptimized(),
1772 					this.expressionStack[this.expressionPtr]);
1773 	} else {
1774 		this.expressionPtr--;
1775 		this.expressionLengthPtr--;
1776 		exp =
1777 			this.expressionStack[this.expressionPtr] =
1778 				new ArrayReference(
1779 					this.expressionStack[this.expressionPtr],
1780 					this.expressionStack[this.expressionPtr + 1]);
1781 	}
1782 	exp.sourceEnd = this.endStatementPosition;
1783 }
consumeArrayCreationExpressionWithInitializer()1784 protected void consumeArrayCreationExpressionWithInitializer() {
1785 	// ArrayCreationWithArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializer
1786 	// ArrayCreationWithArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs ArrayInitializer
1787 
1788 	int length;
1789 	ArrayAllocationExpression arrayAllocation = new ArrayAllocationExpression();
1790 	this.expressionLengthPtr -- ;
1791 	arrayAllocation.initializer = (ArrayInitializer) this.expressionStack[this.expressionPtr--];
1792 
1793 	length = (this.expressionLengthStack[this.expressionLengthPtr--]);
1794 	this.expressionPtr -= length ;
1795 	System.arraycopy(
1796 		this.expressionStack,
1797 		this.expressionPtr+1,
1798 		arrayAllocation.dimensions = new Expression[length],
1799 		0,
1800 		length);
1801 	Annotation[][] annotationsOnDimensions = getAnnotationsOnDimensions(length);
1802 	arrayAllocation.annotationsOnDimensions = annotationsOnDimensions;
1803 
1804 	arrayAllocation.type = getTypeReference(0);
1805 	arrayAllocation.type.bits |= ASTNode.IgnoreRawTypeCheck; // no need to worry about raw type usage
1806 	if (annotationsOnDimensions != null) {
1807 		arrayAllocation.bits |= ASTNode.HasTypeAnnotations;
1808 		arrayAllocation.type.bits |= ASTNode.HasTypeAnnotations;
1809 	}
1810 
1811 	arrayAllocation.sourceStart = this.intStack[this.intPtr--];
1812 	if (arrayAllocation.initializer == null) {
1813 		arrayAllocation.sourceEnd = this.endStatementPosition;
1814 	} else {
1815 		arrayAllocation.sourceEnd = arrayAllocation.initializer.sourceEnd ;
1816 	}
1817 	pushOnExpressionStack(arrayAllocation);
1818 }
consumeArrayCreationExpressionWithoutInitializer()1819 protected void consumeArrayCreationExpressionWithoutInitializer() {
1820 	// ArrayCreationWithoutArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs
1821 	// ArrayCreationWithoutArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs
1822 
1823 	int length;
1824 	ArrayAllocationExpression arrayAllocation = new ArrayAllocationExpression();
1825 	length = (this.expressionLengthStack[this.expressionLengthPtr--]);
1826 	this.expressionPtr -= length ;
1827 	System.arraycopy(
1828 		this.expressionStack,
1829 		this.expressionPtr+1,
1830 		arrayAllocation.dimensions = new Expression[length],
1831 		0,
1832 		length);
1833 	Annotation[][] annotationsOnDimensions = getAnnotationsOnDimensions(length);
1834 	arrayAllocation.annotationsOnDimensions = annotationsOnDimensions;
1835 	arrayAllocation.type = getTypeReference(0);
1836 	arrayAllocation.type.bits |= ASTNode.IgnoreRawTypeCheck; // no need to worry about raw type usage
1837 	if (annotationsOnDimensions != null) {
1838 		arrayAllocation.bits |= ASTNode.HasTypeAnnotations;
1839 		arrayAllocation.type.bits |= ASTNode.HasTypeAnnotations;
1840 	}
1841 	arrayAllocation.sourceStart = this.intStack[this.intPtr--];
1842 	if (arrayAllocation.initializer == null) {
1843 		arrayAllocation.sourceEnd = this.endStatementPosition;
1844 	} else {
1845 		arrayAllocation.sourceEnd = arrayAllocation.initializer.sourceEnd ;
1846 	}
1847 	pushOnExpressionStack(arrayAllocation);
1848 }
consumeArrayCreationHeader()1849 protected void consumeArrayCreationHeader() {
1850 	// nothing to do
1851 }
consumeArrayInitializer()1852 protected void consumeArrayInitializer() {
1853 	// ArrayInitializer ::= '{' VariableInitializers '}'
1854 	// ArrayInitializer ::= '{' VariableInitializers , '}'
1855 
1856 	arrayInitializer(this.expressionLengthStack[this.expressionLengthPtr--]);
1857 }
consumeArrayTypeWithTypeArgumentsName()1858 protected void consumeArrayTypeWithTypeArgumentsName() {
1859 	this.genericsIdentifiersLengthStack[this.genericsIdentifiersLengthPtr] += this.identifierLengthStack[this.identifierLengthPtr];
1860 	pushOnGenericsLengthStack(0); // handle type arguments
1861 }
consumeAssertStatement()1862 protected void consumeAssertStatement() {
1863 	// AssertStatement ::= 'assert' Expression ':' Expression ';'
1864 	this.expressionLengthPtr-=2;
1865 	pushOnAstStack(new AssertStatement(this.expressionStack[this.expressionPtr--], this.expressionStack[this.expressionPtr--], this.intStack[this.intPtr--]));
1866 }
consumeAssignment()1867 protected void consumeAssignment() {
1868 	// Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression
1869 	//optimize the push/pop
1870 
1871 	int op = this.intStack[this.intPtr--] ; //<--the encoded operator
1872 
1873 	this.expressionPtr -- ; this.expressionLengthPtr -- ;
1874 	Expression expression = this.expressionStack[this.expressionPtr+1];
1875 	this.expressionStack[this.expressionPtr] =
1876 		(op != EQUAL ) ?
1877 			new CompoundAssignment(
1878 				this.expressionStack[this.expressionPtr] ,
1879 				expression,
1880 				op,
1881 				expression.sourceEnd):
1882 			new Assignment(
1883 				this.expressionStack[this.expressionPtr] ,
1884 				expression,
1885 				expression.sourceEnd);
1886 
1887 	if (this.pendingRecoveredType != null) {
1888 		// Used only in statements recovery.
1889 		// This is not a real assignment but a placeholder for an existing anonymous type.
1890 		// The assignment must be replace by the anonymous type.
1891 		if (this.pendingRecoveredType.allocation != null &&
1892 				this.scanner.startPosition - 1 <= this.pendingRecoveredType.declarationSourceEnd) {
1893 			this.expressionStack[this.expressionPtr] = this.pendingRecoveredType.allocation;
1894 			this.pendingRecoveredType = null;
1895 			return;
1896 		}
1897 		this.pendingRecoveredType = null;
1898 	}
1899 }
consumeAssignmentOperator(int pos)1900 protected void consumeAssignmentOperator(int pos) {
1901 	// AssignmentOperator ::= '='
1902 	// AssignmentOperator ::= '*='
1903 	// AssignmentOperator ::= '/='
1904 	// AssignmentOperator ::= '%='
1905 	// AssignmentOperator ::= '+='
1906 	// AssignmentOperator ::= '-='
1907 	// AssignmentOperator ::= '<<='
1908 	// AssignmentOperator ::= '>>='
1909 	// AssignmentOperator ::= '>>>='
1910 	// AssignmentOperator ::= '&='
1911 	// AssignmentOperator ::= '^='
1912 	// AssignmentOperator ::= '|='
1913 
1914 	pushOnIntStack(pos);
1915 }
consumeBinaryExpression(int op)1916 protected void consumeBinaryExpression(int op) {
1917 	// MultiplicativeExpression ::= MultiplicativeExpression '*' UnaryExpression
1918 	// MultiplicativeExpression ::= MultiplicativeExpression '/' UnaryExpression
1919 	// MultiplicativeExpression ::= MultiplicativeExpression '%' UnaryExpression
1920 	// AdditiveExpression ::= AdditiveExpression '+' MultiplicativeExpression
1921 	// AdditiveExpression ::= AdditiveExpression '-' MultiplicativeExpression
1922 	// ShiftExpression ::= ShiftExpression '<<'  AdditiveExpression
1923 	// ShiftExpression ::= ShiftExpression '>>'  AdditiveExpression
1924 	// ShiftExpression ::= ShiftExpression '>>>' AdditiveExpression
1925 	// RelationalExpression ::= RelationalExpression '<'  ShiftExpression
1926 	// RelationalExpression ::= RelationalExpression '>'  ShiftExpression
1927 	// RelationalExpression ::= RelationalExpression '<=' ShiftExpression
1928 	// RelationalExpression ::= RelationalExpression '>=' ShiftExpression
1929 	// AndExpression ::= AndExpression '&' EqualityExpression
1930 	// ExclusiveOrExpression ::= ExclusiveOrExpression '^' AndExpression
1931 	// InclusiveOrExpression ::= InclusiveOrExpression '|' ExclusiveOrExpression
1932 	// ConditionalAndExpression ::= ConditionalAndExpression '&&' InclusiveOrExpression
1933 	// ConditionalOrExpression ::= ConditionalOrExpression '||' ConditionalAndExpression
1934 
1935 	//optimize the push/pop
1936 
1937 	this.expressionPtr--;
1938 	this.expressionLengthPtr--;
1939 	Expression expr1 = this.expressionStack[this.expressionPtr];
1940 	Expression expr2 = this.expressionStack[this.expressionPtr + 1];
1941 	switch(op) {
1942 		case OR_OR :
1943 			this.expressionStack[this.expressionPtr] =
1944 				new OR_OR_Expression(
1945 					expr1,
1946 					expr2,
1947 					op);
1948 			break;
1949 		case AND_AND :
1950 			this.expressionStack[this.expressionPtr] =
1951 				new AND_AND_Expression(
1952 					expr1,
1953 					expr2,
1954 					op);
1955 			break;
1956 		case PLUS :
1957 			// look for "string1" + "string2"
1958 			if (this.optimizeStringLiterals) {
1959 				if (expr1 instanceof StringLiteral) {
1960 					if (((expr1.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) == 0) {
1961 						if (expr2 instanceof CharLiteral) { // string+char
1962 							this.expressionStack[this.expressionPtr] =
1963 								((StringLiteral) expr1).extendWith((CharLiteral) expr2);
1964 						} else if (expr2 instanceof StringLiteral) { //string+string
1965 							this.expressionStack[this.expressionPtr] =
1966 								((StringLiteral) expr1).extendWith((StringLiteral) expr2);
1967 						} else {
1968 							this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
1969 						}
1970 					} else {
1971 						this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
1972 					}
1973 				} else if (expr1 instanceof CombinedBinaryExpression) {
1974 					CombinedBinaryExpression cursor;
1975 					// left branch is comprised of PLUS BEs
1976 					// cursor is shifted upwards, while needed BEs are added
1977 					// on demand; past the arityMax-th
1978 					// consecutive BE, a CBE is inserted that holds a
1979 					// full-fledged references table
1980 					if ((cursor = (CombinedBinaryExpression)expr1).arity < cursor.arityMax) {
1981 						cursor.left = new BinaryExpression(cursor);
1982 						cursor.arity++;
1983 					} else {
1984 						cursor.left = new CombinedBinaryExpression(cursor);
1985 						cursor.arity = 0;
1986 						cursor.tuneArityMax();
1987 					}
1988 					cursor.right = expr2;
1989 					cursor.sourceEnd = expr2.sourceEnd;
1990 					this.expressionStack[this.expressionPtr] = cursor;
1991 					// BE_INSTRUMENTATION: neutralized in the released code
1992 //					cursor.depthTracker = ((BinaryExpression)cursor.left).
1993 //						depthTracker + 1;
1994 				} else if (expr1 instanceof BinaryExpression &&
1995 							// single out the a + b case, which is a BE
1996 							// instead of a CBE (slightly more than a half of
1997 							// strings concatenation are one-deep binary
1998 							// expressions)
1999 						((expr1.bits & ASTNode.OperatorMASK) >>
2000 							ASTNode.OperatorSHIFT) == OperatorIds.PLUS) {
2001 					this.expressionStack[this.expressionPtr] =
2002 						new CombinedBinaryExpression(expr1, expr2, PLUS, 1);
2003 				} else {
2004 					this.expressionStack[this.expressionPtr] =
2005 						new BinaryExpression(expr1, expr2, PLUS);
2006 				}
2007 			} else if (expr1 instanceof StringLiteral) {
2008 				if (expr2 instanceof StringLiteral
2009 						&& ((expr1.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) == 0) {
2010 					// string + string
2011 					this.expressionStack[this.expressionPtr] =
2012 						((StringLiteral) expr1).extendsWith((StringLiteral) expr2);
2013 				} else {
2014 					// single out the a + b case
2015 					this.expressionStack[this.expressionPtr] =
2016 						new BinaryExpression(expr1, expr2, PLUS);
2017 				}
2018 			} else if (expr1 instanceof CombinedBinaryExpression) {
2019 					CombinedBinaryExpression cursor;
2020 					// shift cursor; create BE/CBE as needed
2021 					if ((cursor = (CombinedBinaryExpression)expr1).arity < cursor.arityMax) {
2022 						cursor.left = new BinaryExpression(cursor);
2023 						// clear the bits on cursor
2024 						cursor.bits &= ~ASTNode.ParenthesizedMASK;
2025 						cursor.arity++;
2026 					} else {
2027 						cursor.left = new CombinedBinaryExpression(cursor);
2028 						// clear the bits on cursor
2029 						cursor.bits &= ~ASTNode.ParenthesizedMASK;
2030 						cursor.arity = 0;
2031 						cursor.tuneArityMax();
2032 					}
2033 					cursor.right = expr2;
2034 					cursor.sourceEnd = expr2.sourceEnd;
2035 					// BE_INSTRUMENTATION: neutralized in the released code
2036 //					cursor.depthTracker = ((BinaryExpression)cursor.left).
2037 //						depthTracker + 1;
2038 					this.expressionStack[this.expressionPtr] = cursor;
2039 			} else if (expr1 instanceof BinaryExpression
2040 					&& ((expr1.bits & ASTNode.OperatorMASK) >>
2041 							ASTNode.OperatorSHIFT) == OperatorIds.PLUS) {
2042 				// single out the a + b case
2043 				this.expressionStack[this.expressionPtr] =
2044 					new CombinedBinaryExpression(expr1, expr2, PLUS, 1);
2045 			} else {
2046 				this.expressionStack[this.expressionPtr] =
2047 					new BinaryExpression(expr1, expr2, PLUS);
2048 			}
2049 			break;
2050 		case LESS :
2051 		case MULTIPLY :
2052 			this.intPtr--; // star end position or starting position of angle bracket
2053 			this.expressionStack[this.expressionPtr] =
2054 				new BinaryExpression(
2055 					expr1,
2056 					expr2,
2057 					op);
2058 			break;
2059 		default :
2060 			this.expressionStack[this.expressionPtr] =
2061 				new BinaryExpression(
2062 					expr1,
2063 					expr2,
2064 					op);
2065 	}
2066 }
2067 /**
2068  * @param op binary operator
2069  */
consumeBinaryExpressionWithName(int op)2070 protected void consumeBinaryExpressionWithName(int op) {
2071 	pushOnExpressionStack(getUnspecifiedReferenceOptimized());
2072 	this.expressionPtr--;
2073 	this.expressionLengthPtr--;
2074 	/*
2075 	if (op == OR_OR) {
2076 		this.expressionStack[this.expressionPtr] =
2077 			new OR_OR_Expression(
2078 				this.expressionStack[this.expressionPtr + 1],
2079 				this.expressionStack[this.expressionPtr],
2080 				op);
2081 	} else {
2082 		if (op == AND_AND) {
2083 			this.expressionStack[this.expressionPtr] =
2084 				new AND_AND_Expression(
2085 					this.expressionStack[this.expressionPtr + 1],
2086 					this.expressionStack[this.expressionPtr],
2087 					op);
2088 		} else {
2089 			// look for "string1" + "string2"
2090 			if ((op == PLUS) && this.optimizeStringLiterals) {
2091 				Expression expr1, expr2;
2092 				expr1 = this.expressionStack[this.expressionPtr + 1];
2093 				expr2 = this.expressionStack[this.expressionPtr];
2094 				if (expr1 instanceof StringLiteral) {
2095 					if (expr2 instanceof CharLiteral) { // string+char
2096 						this.expressionStack[this.expressionPtr] =
2097 							((StringLiteral) expr1).extendWith((CharLiteral) expr2);
2098 					} else if (expr2 instanceof StringLiteral) { //string+string
2099 						this.expressionStack[this.expressionPtr] =
2100 							((StringLiteral) expr1).extendWith((StringLiteral) expr2);
2101 					} else {
2102 						this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
2103 					}
2104 				} else {
2105 					this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
2106 				}
2107 			} else {
2108 				this.expressionStack[this.expressionPtr] =
2109 					new BinaryExpression(
2110 						this.expressionStack[this.expressionPtr + 1],
2111 						this.expressionStack[this.expressionPtr],
2112 						op);
2113 			}
2114 		}
2115 	}
2116 	*/
2117 	Expression expr1 = this.expressionStack[this.expressionPtr + 1];
2118 	Expression expr2 = this.expressionStack[this.expressionPtr];
2119 	// Note: we do not attempt to promote BinaryExpression-s to
2120 	//       IndexedBinaryExpression-s here since expr1 always holds a name
2121 	switch(op) {
2122 		case OR_OR :
2123 			this.expressionStack[this.expressionPtr] =
2124 				new OR_OR_Expression(
2125 					expr1,
2126 					expr2,
2127 					op);
2128 			break;
2129 		case AND_AND :
2130 			this.expressionStack[this.expressionPtr] =
2131 				new AND_AND_Expression(
2132 					expr1,
2133 					expr2,
2134 					op);
2135 			break;
2136 		case PLUS :
2137 			// look for "string1" + "string2"
2138 			if (this.optimizeStringLiterals) {
2139 				if (expr1 instanceof StringLiteral
2140 						&& ((expr1.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) == 0) {
2141 					if (expr2 instanceof CharLiteral) { // string+char
2142 						this.expressionStack[this.expressionPtr] =
2143 							((StringLiteral) expr1).extendWith((CharLiteral) expr2);
2144 					} else if (expr2 instanceof StringLiteral) { //string+string
2145 						this.expressionStack[this.expressionPtr] =
2146 							((StringLiteral) expr1).extendWith((StringLiteral) expr2);
2147 					} else {
2148 						this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
2149 					}
2150 				} else {
2151 					this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
2152 				}
2153 			} else if (expr1 instanceof StringLiteral) {
2154 				if (expr2 instanceof StringLiteral
2155 						&& ((expr1.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) == 0) {
2156 					// string + string
2157 					this.expressionStack[this.expressionPtr] =
2158 						((StringLiteral) expr1).extendsWith((StringLiteral) expr2);
2159 				} else {
2160 					this.expressionStack[this.expressionPtr] =
2161 						new BinaryExpression(
2162 							expr1,
2163 							expr2,
2164 							op);
2165 				}
2166 			} else {
2167 				this.expressionStack[this.expressionPtr] =
2168 					new BinaryExpression(
2169 						expr1,
2170 						expr2,
2171 						op);
2172 			}
2173 			break;
2174 		case LESS :
2175 		case MULTIPLY :
2176 			this.intPtr--; // star end position or starting position of angle bracket
2177 			this.expressionStack[this.expressionPtr] =
2178 				new BinaryExpression(
2179 					expr1,
2180 					expr2,
2181 					op);
2182 			break;
2183 		default :
2184 			this.expressionStack[this.expressionPtr] =
2185 				new BinaryExpression(
2186 					expr1,
2187 					expr2,
2188 					op);
2189 	}
2190 }
consumeBlock()2191 protected void consumeBlock() {
2192 	// Block ::= OpenBlock '{' BlockStatementsopt '}'
2193 	// LambdaBody ::= NestedType NestedMethod  '{' BlockStatementsopt '}'
2194 	// simpler action for empty blocks
2195 
2196 	int statementsLength = this.astLengthStack[this.astLengthPtr--];
2197 	Block block;
2198 	if (statementsLength == 0) { // empty block
2199 		block = new Block(0);
2200 		block.sourceStart = this.intStack[this.intPtr--];
2201 		block.sourceEnd = this.endStatementPosition;
2202 		// check whether this block at least contains some comment in it
2203 		if (!containsComment(block.sourceStart, block.sourceEnd)) {
2204 			block.bits |= ASTNode.UndocumentedEmptyBlock;
2205 		}
2206 		this.realBlockPtr--; // still need to pop the block variable counter
2207 	} else {
2208 		block = new Block(this.realBlockStack[this.realBlockPtr--]);
2209 		this.astPtr -= statementsLength;
2210 		System.arraycopy(
2211 			this.astStack,
2212 			this.astPtr + 1,
2213 			block.statements = new Statement[statementsLength],
2214 			0,
2215 			statementsLength);
2216 		block.sourceStart = this.intStack[this.intPtr--];
2217 		block.sourceEnd = this.endStatementPosition;
2218 	}
2219 	pushOnAstStack(block);
2220 }
consumeBlockStatement()2221 protected void consumeBlockStatement() {
2222 	// for assist parsers.
2223 }
consumeBlockStatements()2224 protected void consumeBlockStatements() {
2225 	// BlockStatements ::= BlockStatements BlockStatement
2226 	concatNodeLists();
2227 }
consumeCaseLabel()2228 protected void consumeCaseLabel() {
2229 //	// SwitchLabel ::= 'case' ConstantExpression ':'
2230 //	this.expressionLengthPtr--;
2231 //	Expression expression = this.expressionStack[this.expressionPtr--];
2232 //	CaseStatement caseStatement = new CaseStatement(expression, expression.sourceEnd, this.intStack[this.intPtr--]);
2233 //	// Look for $fall-through$ tag in leading comment for case statement
2234 //	if (hasLeadingTagComment(FALL_THROUGH_TAG, caseStatement.sourceStart)) {
2235 //		caseStatement.bits |= ASTNode.DocumentedFallthrough;
2236 //	}
2237 //	pushOnAstStack(caseStatement);
2238 	Expression[] constantExpressions = null;
2239 	int length = 0;
2240 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2241 		this.expressionPtr -= length;
2242 		System.arraycopy(
2243 			this.expressionStack,
2244 			this.expressionPtr + 1,
2245 			constantExpressions = new Expression[length],
2246 			0,
2247 			length);
2248 	} else {
2249 		// TODO : ERROR
2250 	}
2251 	CaseStatement caseStatement = new CaseStatement(constantExpressions[0], constantExpressions[length - 1].sourceEnd, this.intStack[this.intPtr--]);
2252 	if (constantExpressions.length > 1) {
2253 		if (!this.parsingJava14Plus) {
2254 			problemReporter().multiConstantCaseLabelsNotSupported(caseStatement);
2255 		}
2256 	}
2257 	caseStatement.constantExpressions = constantExpressions;
2258 	// Look for $fall-through$ tag in leading comment for case statement
2259 	if (hasLeadingTagComment(FALL_THROUGH_TAG, caseStatement.sourceStart)) {
2260 		caseStatement.bits |= ASTNode.DocumentedFallthrough;
2261 	}
2262 
2263 	pushOnAstStack(caseStatement);
2264 }
consumeCastExpressionLL1()2265 protected void consumeCastExpressionLL1() {
2266 	//CastExpression ::= '(' Name ')' InsideCastExpressionLL1 UnaryExpressionNotPlusMinus
2267 
2268 
2269 	//optimize push/pop
2270 
2271 	Expression cast;
2272 	Expression exp;
2273 	this.expressionPtr--;
2274 	this.expressionStack[this.expressionPtr] =
2275 		cast = new CastExpression(
2276 			exp=this.expressionStack[this.expressionPtr+1] ,
2277 			(TypeReference) this.expressionStack[this.expressionPtr]);
2278 	this.expressionLengthPtr -- ;
2279 	updateSourcePosition(cast);
2280 	cast.sourceEnd=exp.sourceEnd;
2281 }
createIntersectionCastTypeReference(TypeReference[] typeReferences)2282 public IntersectionCastTypeReference createIntersectionCastTypeReference(TypeReference[] typeReferences) {
2283 	if (this.options.sourceLevel < ClassFileConstants.JDK1_8) {
2284 		problemReporter().intersectionCastNotBelow18(typeReferences);
2285 	}
2286 	return new IntersectionCastTypeReference(typeReferences);
2287 }
consumeCastExpressionLL1WithBounds()2288 protected void consumeCastExpressionLL1WithBounds() {
2289 	//CastExpression ::= '(' Name AdditionalBoundsList ')' UnaryExpressionNotPlusMinus
2290 	Expression cast;
2291 	Expression exp;
2292 	int length;
2293 	exp = this.expressionStack[this.expressionPtr--];
2294 	this.expressionLengthPtr --;
2295 	TypeReference[] bounds = new TypeReference[length = this.expressionLengthStack[this.expressionLengthPtr]];
2296 	System.arraycopy(this.expressionStack, this.expressionPtr -= (length - 1), bounds, 0, length);
2297 	this.expressionStack[this.expressionPtr] =
2298 		cast = new CastExpression(
2299 			exp,
2300 			createIntersectionCastTypeReference(bounds));
2301 	this.expressionLengthStack[this.expressionLengthPtr] = 1;
2302 	updateSourcePosition(cast);
2303 	cast.sourceEnd=exp.sourceEnd;
2304 }
consumeCastExpressionWithGenericsArray()2305 protected void consumeCastExpressionWithGenericsArray() {
2306 	// CastExpression ::= PushLPAREN Name TypeArguments Dimsopt AdditionalBoundsListOpt PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
2307 
2308 	TypeReference[] bounds = null;
2309 	int additionalBoundsLength = this.genericsLengthStack[this.genericsLengthPtr--];
2310 	if (additionalBoundsLength > 0) {
2311 		bounds = new TypeReference[additionalBoundsLength + 1];
2312 		this.genericsPtr -= additionalBoundsLength;
2313 		System.arraycopy(this.genericsStack, this.genericsPtr + 1, bounds, 1, additionalBoundsLength);
2314 	}
2315 	Expression exp;
2316 	Expression cast;
2317 	TypeReference castType;
2318 	int end = this.intStack[this.intPtr--];
2319 
2320 	int dim = this.intStack[this.intPtr--];
2321 	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
2322 	if (additionalBoundsLength > 0) {
2323 		bounds[0] = getTypeReference(dim);
2324 		castType = createIntersectionCastTypeReference(bounds);
2325 	} else {
2326 		castType = getTypeReference(dim);
2327 	}
2328 	this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr], castType);
2329 	this.intPtr--;  // pop position of '<'
2330 	castType.sourceEnd = end - 1;
2331 	castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
2332 	cast.sourceEnd = exp.sourceEnd;
2333 }
consumeCastExpressionWithNameArray()2334 protected void consumeCastExpressionWithNameArray() {
2335 	// CastExpression ::= PushLPAREN Name Dims AdditionalBoundsListOpt PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
2336 
2337 	Expression exp;
2338 	Expression cast;
2339 	TypeReference castType;
2340 	int end = this.intStack[this.intPtr--];
2341 
2342 	TypeReference[] bounds = null;
2343 	int additionalBoundsLength = this.genericsLengthStack[this.genericsLengthPtr--];
2344 	if (additionalBoundsLength > 0) {
2345 		bounds = new TypeReference[additionalBoundsLength + 1];
2346 		this.genericsPtr -= additionalBoundsLength;
2347 		System.arraycopy(this.genericsStack, this.genericsPtr + 1, bounds, 1, additionalBoundsLength);
2348 	}
2349 	// handle type arguments
2350 	pushOnGenericsLengthStack(0);
2351 	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
2352 
2353 	if (additionalBoundsLength > 0) {
2354 		bounds[0] = getTypeReference(this.intStack[this.intPtr--]);
2355 		castType = createIntersectionCastTypeReference(bounds);
2356 	} else {
2357 		castType = getTypeReference(this.intStack[this.intPtr--]);
2358 	}
2359 	this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr], castType);
2360 	castType.sourceEnd = end - 1;
2361 	castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
2362 	cast.sourceEnd = exp.sourceEnd;
2363 }
consumeCastExpressionWithPrimitiveType()2364 protected void consumeCastExpressionWithPrimitiveType() {
2365 	// CastExpression ::= PushLPAREN PrimitiveType Dimsopt AdditionalBoundsListOpt PushRPAREN InsideCastExpression UnaryExpression
2366 
2367 	//this.intStack : posOfLeftParen dim posOfRightParen
2368 
2369 	TypeReference[] bounds = null;
2370 	int additionalBoundsLength = this.genericsLengthStack[this.genericsLengthPtr--];
2371 	if (additionalBoundsLength > 0) {
2372 		bounds = new TypeReference[additionalBoundsLength + 1];
2373 		this.genericsPtr -= additionalBoundsLength;
2374 		System.arraycopy(this.genericsStack, this.genericsPtr + 1, bounds, 1, additionalBoundsLength);
2375 	}
2376 
2377 	//optimize the push/pop
2378 	Expression exp;
2379 	Expression cast;
2380 	TypeReference castType;
2381 	int end = this.intStack[this.intPtr--];
2382 	if (additionalBoundsLength > 0) {
2383 		bounds[0] = getTypeReference(this.intStack[this.intPtr--]);
2384 		castType = createIntersectionCastTypeReference(bounds);
2385 	} else {
2386 		castType = getTypeReference(this.intStack[this.intPtr--]);
2387 	}
2388 	this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr], castType);
2389 	castType.sourceEnd = end - 1;
2390 	castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
2391 	cast.sourceEnd = exp.sourceEnd;
2392 }
consumeCastExpressionWithQualifiedGenericsArray()2393 protected void consumeCastExpressionWithQualifiedGenericsArray() {
2394 	// CastExpression ::= PushLPAREN Name OnlyTypeArguments '.' ClassOrInterfaceType Dimsopt AdditionalBoundsOpt PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
2395 
2396 	TypeReference[] bounds = null;
2397 	int additionalBoundsLength = this.genericsLengthStack[this.genericsLengthPtr--];
2398 	if (additionalBoundsLength > 0) {
2399 		bounds = new TypeReference[additionalBoundsLength + 1];
2400 		this.genericsPtr -= additionalBoundsLength;
2401 		System.arraycopy(this.genericsStack, this.genericsPtr + 1, bounds, 1, additionalBoundsLength);
2402 	}
2403 
2404 	Expression exp;
2405 	Expression cast;
2406 	TypeReference castType;
2407 	int end = this.intStack[this.intPtr--];
2408 	int dim = this.intStack[this.intPtr--];
2409 	Annotation [][] annotationsOnDimensions = dim == 0 ? null : getAnnotationsOnDimensions(dim);
2410 	TypeReference rightSide = getTypeReference(0);
2411     castType = computeQualifiedGenericsFromRightSide(rightSide, dim, annotationsOnDimensions);
2412 
2413     if (additionalBoundsLength > 0) {
2414 		bounds[0] = castType;
2415 		castType = createIntersectionCastTypeReference(bounds);
2416 	}
2417 
2418     this.intPtr--;
2419 	this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr], castType);
2420 	castType.sourceEnd = end - 1;
2421 	castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
2422 	cast.sourceEnd = exp.sourceEnd;
2423 }
consumeCatches()2424 protected void consumeCatches() {
2425 	// Catches ::= Catches CatchClause
2426 	optimizedConcatNodeLists();
2427 }
consumeCatchFormalParameter()2428 protected void consumeCatchFormalParameter() {
2429 	// CatchFormalParameter ::= Modifiersopt CatchType VariableDeclaratorId
2430 	this.identifierLengthPtr--;
2431 	char[] identifierName = this.identifierStack[this.identifierPtr];
2432 	long namePositions = this.identifierPositionStack[this.identifierPtr--];
2433 	int extendedDimensions = this.intStack[this.intPtr--]; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=348369
2434 	TypeReference type = (TypeReference) this.astStack[this.astPtr--];
2435 	if (extendedDimensions > 0) {
2436 		type = augmentTypeWithAdditionalDimensions(type, extendedDimensions, null, false);
2437 		type.sourceEnd = this.endPosition;
2438 		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=391092
2439 		if (type instanceof UnionTypeReference) {
2440 			this.problemReporter().illegalArrayOfUnionType(identifierName, type);
2441 		}
2442 	}
2443 	this.astLengthPtr--;
2444 	int modifierPositions = this.intStack[this.intPtr--];
2445 	this.intPtr--;
2446 	Argument arg =
2447 		new Argument(
2448 			identifierName,
2449 			namePositions,
2450 			type,
2451 			this.intStack[this.intPtr + 1] & ~ClassFileConstants.AccDeprecated); // modifiers
2452 	arg.bits &= ~ASTNode.IsArgument;
2453 	arg.declarationSourceStart = modifierPositions;
2454 	// consume annotations
2455 	int length;
2456 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2457 		System.arraycopy(
2458 			this.expressionStack,
2459 			(this.expressionPtr -= length) + 1,
2460 			arg.annotations = new Annotation[length],
2461 			0,
2462 			length);
2463 	}
2464 	pushOnAstStack(arg);
2465 	/* if incomplete method header, this.listLength counter will not have been reset,
2466 		indicating that some arguments are available on the stack */
2467 	this.listLength++;
2468 }
consumeCatchHeader()2469 protected void consumeCatchHeader() {
2470 	// CatchDeclaration ::= 'catch' '(' FormalParameter ')' '{'
2471 
2472 	if (this.currentElement == null){
2473 		return; // should never occur, this consumeRule is only used in recovery mode
2474 	}
2475 	// current element should be a block due to the presence of the opening brace
2476 	if (!(this.currentElement instanceof RecoveredBlock)){
2477 		if(!(this.currentElement instanceof RecoveredMethod)) {
2478 			return;
2479 		}
2480 		RecoveredMethod rMethod = (RecoveredMethod) this.currentElement;
2481 		if(!(rMethod.methodBody == null && rMethod.bracketBalance > 0)) {
2482 			return;
2483 		}
2484 	}
2485 
2486 	Argument arg = (Argument)this.astStack[this.astPtr--];
2487 	// convert argument to local variable
2488 	LocalDeclaration localDeclaration = new LocalDeclaration(arg.name, arg.sourceStart, arg.sourceEnd);
2489 	localDeclaration.type = arg.type;
2490 	localDeclaration.declarationSourceStart = arg.declarationSourceStart;
2491 	localDeclaration.declarationSourceEnd = arg.declarationSourceEnd;
2492 
2493 	this.currentElement = this.currentElement.add(localDeclaration, 0);
2494 	this.lastCheckPoint = this.scanner.startPosition; // force to restart at this exact position
2495 	this.restartRecovery = true; // request to restart from here on
2496 	this.lastIgnoredToken = -1;
2497 }
consumeCatchType()2498 protected void consumeCatchType() {
2499 	// CatchType ::= UnionType
2500 	int length = this.astLengthStack[this.astLengthPtr--];
2501 	if (length != 1) {
2502 		TypeReference[] typeReferences;
2503 		System.arraycopy(
2504 				this.astStack,
2505 				(this.astPtr -= length) + 1,
2506 				(typeReferences = new TypeReference[length]),
2507 				0,
2508 				length);
2509 		UnionTypeReference typeReference = new UnionTypeReference(typeReferences);
2510 		pushOnAstStack(typeReference);
2511 		if (this.options.sourceLevel < ClassFileConstants.JDK1_7) {
2512 			problemReporter().multiCatchNotBelow17(typeReference);
2513 		}
2514 	} else {
2515 		// push back the type reference
2516 		pushOnAstLengthStack(1);
2517 	}
2518 }
consumeClassBodyDeclaration()2519 protected void consumeClassBodyDeclaration() {
2520 	// ClassBodyDeclaration ::= Diet NestedMethod CreateInitializer Block
2521 	//push an Initializer
2522 	//optimize the push/pop
2523 	this.nestedMethod[this.nestedType]--;
2524 	Block block = (Block) this.astStack[this.astPtr--];
2525 	this.astLengthPtr--;
2526 	if (this.diet) block.bits &= ~ASTNode.UndocumentedEmptyBlock; // clear bit since was diet
2527 	Initializer initializer = (Initializer) this.astStack[this.astPtr];
2528 	initializer.declarationSourceStart = initializer.sourceStart = block.sourceStart;
2529 	initializer.block = block;
2530 	this.intPtr--; // pop sourcestart left on the stack by consumeNestedMethod.
2531 	initializer.bodyStart = this.intStack[this.intPtr--];
2532 	this.realBlockPtr--; // pop the block variable counter left on the stack by consumeNestedMethod
2533 	int javadocCommentStart = this.intStack[this.intPtr--];
2534 	if (javadocCommentStart != -1) {
2535 		initializer.declarationSourceStart = javadocCommentStart;
2536 		initializer.javadoc = this.javadoc;
2537 		this.javadoc = null;
2538 	}
2539 	initializer.bodyEnd = this.endPosition;
2540 	initializer.sourceEnd = this.endStatementPosition;
2541 	initializer.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
2542 }
consumeClassBodyDeclarations()2543 protected void consumeClassBodyDeclarations() {
2544 	// ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration
2545 	concatNodeLists();
2546 }
consumeClassBodyDeclarationsopt()2547 protected void consumeClassBodyDeclarationsopt() {
2548 	// ClassBodyDeclarationsopt ::= NestedType ClassBodyDeclarations
2549 	this.nestedType-- ;
2550 }
consumeClassBodyopt()2551 protected void consumeClassBodyopt() {
2552 	// ClassBodyopt ::= $empty
2553 	pushOnAstStack(null);
2554 	this.endPosition = this.rParenPos;
2555 }
consumeClassDeclaration()2556 protected void consumeClassDeclaration() {
2557 	// ClassDeclaration ::= ClassHeader ClassBody
2558 
2559 	int length;
2560 	if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
2561 		//there are length declarations
2562 		//dispatch according to the type of the declarations
2563 		dispatchDeclarationInto(length);
2564 	}
2565 
2566 	TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
2567 
2568 	//convert constructor that do not have the type's name into methods
2569 	boolean hasConstructor = typeDecl.checkConstructors(this);
2570 
2571 	//add the default constructor when needed (interface don't have it)
2572 	if (!hasConstructor) {
2573 		switch(TypeDeclaration.kind(typeDecl.modifiers)) {
2574 			case TypeDeclaration.CLASS_DECL :
2575 			case TypeDeclaration.ENUM_DECL :
2576 				boolean insideFieldInitializer = false;
2577 				if (this.diet) {
2578 					for (int i = this.nestedType; i > 0; i--){
2579 						if (this.variablesCounter[i] > 0) {
2580 							insideFieldInitializer = true;
2581 							break;
2582 						}
2583 					}
2584 				}
2585 				typeDecl.createDefaultConstructor(!(this.diet && this.dietInt == 0) || insideFieldInitializer, true);
2586 		}
2587 	}
2588 	//always add <clinit> (will be remove at code gen time if empty)
2589 	if (this.scanner.containsAssertKeyword) {
2590 		typeDecl.bits |= ASTNode.ContainsAssertion;
2591 	}
2592 	typeDecl.addClinit();
2593 	typeDecl.bodyEnd = this.endStatementPosition;
2594 	if (length == 0 && !containsComment(typeDecl.bodyStart, typeDecl.bodyEnd)) {
2595 		typeDecl.bits |= ASTNode.UndocumentedEmptyBlock;
2596 	}
2597 
2598 	typeDecl.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
2599 }
consumeClassHeader()2600 protected void consumeClassHeader() {
2601 	// ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt ClassHeaderImplementsopt
2602 
2603 	TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
2604 	if (this.currentToken == TokenNameLBRACE) {
2605 		typeDecl.bodyStart = this.scanner.currentPosition;
2606 	}
2607 	if (this.currentElement != null) {
2608 		this.restartRecovery = true; // used to avoid branching back into the regular automaton
2609 	}
2610 	// flush the comments related to the class header
2611 	this.scanner.commentPtr = -1;
2612 }
consumeClassHeaderExtends()2613 protected void consumeClassHeaderExtends() {
2614 	// ClassHeaderExtends ::= 'extends' ClassType
2615 	//superclass
2616 	TypeReference superClass = getTypeReference(0);
2617 	// There is a class declaration on the top of stack
2618 	TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
2619 	typeDecl.bits |= (superClass.bits & ASTNode.HasTypeAnnotations);
2620 	typeDecl.superclass = superClass;
2621 	superClass.bits |= ASTNode.IsSuperType;
2622 	typeDecl.bodyStart = typeDecl.superclass.sourceEnd + 1;
2623 	// recovery
2624 	if (this.currentElement != null){
2625 		this.lastCheckPoint = typeDecl.bodyStart;
2626 	}
2627 }
consumeClassHeaderImplements()2628 protected void consumeClassHeaderImplements() {
2629 	// ClassHeaderImplements ::= 'implements' InterfaceTypeList
2630 	int length = this.astLengthStack[this.astLengthPtr--];
2631 	//super interfaces
2632 	this.astPtr -= length;
2633 	// There is a class declaration on the top of stack
2634 	TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
2635 	System.arraycopy(
2636 		this.astStack,
2637 		this.astPtr + 1,
2638 		typeDecl.superInterfaces = new TypeReference[length],
2639 		0,
2640 		length);
2641 	TypeReference[] superinterfaces = typeDecl.superInterfaces;
2642 	for (int i = 0, max = superinterfaces.length; i < max; i++) {
2643 		TypeReference typeReference = superinterfaces[i];
2644 		typeDecl.bits |= (typeReference.bits & ASTNode.HasTypeAnnotations);
2645 		typeReference.bits |= ASTNode.IsSuperType;
2646 	}
2647 	typeDecl.bodyStart = typeDecl.superInterfaces[length-1].sourceEnd + 1;
2648 	this.listLength = 0; // reset after having read super-interfaces
2649 	// recovery
2650 	if (this.currentElement != null) { // is recovering
2651 		this.lastCheckPoint = typeDecl.bodyStart;
2652 	}
2653 }
consumeClassOrRecordHeaderName1(boolean isRecord)2654 private void consumeClassOrRecordHeaderName1(boolean isRecord) {
2655 	TypeDeclaration typeDecl = new TypeDeclaration(this.compilationUnit.compilationResult);
2656 	if (this.nestedMethod[this.nestedType] == 0) {
2657 		if (this.nestedType != 0) {
2658 			typeDecl.bits |= ASTNode.IsMemberType;
2659 		}
2660 	} else {
2661 		// Record that the block has a declaration for local types
2662 		typeDecl.bits |= ASTNode.IsLocalType;
2663 		markEnclosingMemberWithLocalType();
2664 		blockReal();
2665 	}
2666 
2667 	//highlight the name of the type
2668 	long pos = this.identifierPositionStack[this.identifierPtr];
2669 	typeDecl.sourceEnd = (int) pos;
2670 	typeDecl.sourceStart = (int) (pos >>> 32);
2671 	typeDecl.name = this.identifierStack[this.identifierPtr--];
2672 	this.identifierLengthPtr--;
2673 
2674 	//compute the declaration source too
2675 	// 'class' and 'interface' push two int positions: the beginning of the class token and its end.
2676 	// we want to keep the beginning position but get rid of the end position
2677 	// it is only used for the ClassLiteralAccess positions.
2678 	typeDecl.declarationSourceStart = this.intStack[this.intPtr--];
2679 	typeDecl.restrictedIdentifierStart = typeDecl.declarationSourceStart;
2680 	this.intPtr--; // remove the end position of the class token
2681 
2682 	typeDecl.modifiersSourceStart = this.intStack[this.intPtr--];
2683 	typeDecl.modifiers = this.intStack[this.intPtr--];
2684 	if (typeDecl.modifiersSourceStart >= 0) {
2685 		typeDecl.declarationSourceStart = typeDecl.modifiersSourceStart;
2686 	}
2687 
2688 	// Store secondary info
2689 	if ((typeDecl.bits & ASTNode.IsMemberType) == 0 && (typeDecl.bits & ASTNode.IsLocalType) == 0) {
2690 		if (this.compilationUnit != null && !CharOperation.equals(typeDecl.name, this.compilationUnit.getMainTypeName())) {
2691 			typeDecl.bits |= ASTNode.IsSecondaryType;
2692 		}
2693 	}
2694 
2695 	// consume annotations
2696 	int length;
2697 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2698 		System.arraycopy(
2699 			this.expressionStack,
2700 			(this.expressionPtr -= length) + 1,
2701 			typeDecl.annotations = new Annotation[length],
2702 			0,
2703 			length);
2704 	}
2705 	typeDecl.bodyStart = typeDecl.sourceEnd + 1;
2706 	if (isRecord) {
2707 		typeDecl.modifiers |= ExtraCompilerModifiers.AccRecord;
2708 	}
2709 	pushOnAstStack(typeDecl);
2710 
2711 	this.listLength = 0; // will be updated when reading super-interfaces
2712 	// recovery
2713 	if (this.currentElement != null){
2714 		this.lastCheckPoint = typeDecl.bodyStart;
2715 		this.currentElement = this.currentElement.add(typeDecl, 0);
2716 		this.lastIgnoredToken = -1;
2717 	}
2718 	// javadoc
2719 	typeDecl.javadoc = this.javadoc;
2720 	this.javadoc = null;
2721 }
consumeClassHeaderName1()2722 protected void consumeClassHeaderName1() {
2723 	// ClassHeaderName1 ::= Modifiersopt 'class' 'Identifier'
2724 	consumeClassOrRecordHeaderName1(false);
2725 }
consumeClassInstanceCreationExpression()2726 protected void consumeClassInstanceCreationExpression() {
2727 	// ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt
2728 	classInstanceCreation(false);
2729 	consumeInvocationExpression();
2730 }
consumeClassInstanceCreationExpressionName()2731 protected void consumeClassInstanceCreationExpressionName() {
2732 	// ClassInstanceCreationExpressionName ::= Name '.'
2733 	pushOnExpressionStack(getUnspecifiedReferenceOptimized());
2734 }
consumeClassInstanceCreationExpressionQualified()2735 protected void consumeClassInstanceCreationExpressionQualified() {
2736 	// ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
2737 	// ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
2738 	classInstanceCreation(true);
2739 
2740 	QualifiedAllocationExpression qae =
2741 		(QualifiedAllocationExpression) this.expressionStack[this.expressionPtr];
2742 
2743 	if (qae.anonymousType == null) {
2744 		this.expressionLengthPtr--;
2745 		this.expressionPtr--;
2746 		qae.enclosingInstance = this.expressionStack[this.expressionPtr];
2747 		this.expressionStack[this.expressionPtr] = qae;
2748 	}
2749 	qae.sourceStart = qae.enclosingInstance.sourceStart;
2750 	consumeInvocationExpression();
2751 }
consumeClassInstanceCreationExpressionQualifiedWithTypeArguments()2752 protected void consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() {
2753 	// ClassInstanceCreationExpression ::= Primary '.' 'new' TypeArguments SimpleName '(' ArgumentListopt ')' ClassBodyopt
2754 	// ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' TypeArguments SimpleName '(' ArgumentListopt ')' ClassBodyopt
2755 
2756 	QualifiedAllocationExpression alloc;
2757 	int length;
2758 	if (((length = this.astLengthStack[this.astLengthPtr--]) == 1) && (this.astStack[this.astPtr] == null)) {
2759 		//NO ClassBody
2760 		this.astPtr--;
2761 		alloc = new QualifiedAllocationExpression();
2762 		alloc.sourceEnd = this.endPosition; //the position has been stored explicitly
2763 
2764 		if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2765 			this.expressionPtr -= length;
2766 			System.arraycopy(
2767 				this.expressionStack,
2768 				this.expressionPtr + 1,
2769 				alloc.arguments = new Expression[length],
2770 				0,
2771 				length);
2772 		}
2773 		alloc.type = getTypeReference(0);
2774 		checkForDiamond(alloc.type);
2775 		length = this.genericsLengthStack[this.genericsLengthPtr--];
2776 		this.genericsPtr -= length;
2777 		System.arraycopy(this.genericsStack, this.genericsPtr + 1, alloc.typeArguments = new TypeReference[length], 0, length);
2778 		this.intPtr--;
2779 
2780 		//the default constructor with the correct number of argument
2781 		//will be created and added by the TC (see createsInternalConstructorWithBinding)
2782 		alloc.sourceStart = this.intStack[this.intPtr--];
2783 		pushOnExpressionStack(alloc);
2784 	} else {
2785 		dispatchDeclarationInto(length);
2786 		TypeDeclaration anonymousTypeDeclaration = (TypeDeclaration)this.astStack[this.astPtr];
2787 		anonymousTypeDeclaration.declarationSourceEnd = this.endStatementPosition;
2788 		anonymousTypeDeclaration.bodyEnd = this.endStatementPosition;
2789 		if (length == 0 && !containsComment(anonymousTypeDeclaration.bodyStart, anonymousTypeDeclaration.bodyEnd)) {
2790 			anonymousTypeDeclaration.bits |= ASTNode.UndocumentedEmptyBlock;
2791 		}
2792 		this.astPtr--;
2793 		this.astLengthPtr--;
2794 
2795 		QualifiedAllocationExpression allocationExpression = anonymousTypeDeclaration.allocation;
2796 		if (allocationExpression != null) {
2797 			allocationExpression.sourceEnd = this.endStatementPosition;
2798 			// handle type arguments
2799 			length = this.genericsLengthStack[this.genericsLengthPtr--];
2800 			this.genericsPtr -= length;
2801 			System.arraycopy(this.genericsStack, this.genericsPtr + 1, allocationExpression.typeArguments = new TypeReference[length], 0, length);
2802 			allocationExpression.sourceStart = this.intStack[this.intPtr--];
2803 			checkForDiamond(allocationExpression.type);
2804 		}
2805 	}
2806 
2807 	QualifiedAllocationExpression qae =
2808 		(QualifiedAllocationExpression) this.expressionStack[this.expressionPtr];
2809 
2810 	if (qae.anonymousType == null) {
2811 		this.expressionLengthPtr--;
2812 		this.expressionPtr--;
2813 		qae.enclosingInstance = this.expressionStack[this.expressionPtr];
2814 		this.expressionStack[this.expressionPtr] = qae;
2815 	}
2816 	qae.sourceStart = qae.enclosingInstance.sourceStart;
2817 	consumeInvocationExpression();
2818 }
consumeClassInstanceCreationExpressionWithTypeArguments()2819 protected void consumeClassInstanceCreationExpressionWithTypeArguments() {
2820 	// ClassInstanceCreationExpression ::= 'new' TypeArguments ClassType '(' ArgumentListopt ')' ClassBodyopt
2821 	AllocationExpression alloc;
2822 	int length;
2823 	if (((length = this.astLengthStack[this.astLengthPtr--]) == 1)
2824 		&& (this.astStack[this.astPtr] == null)) {
2825 		//NO ClassBody
2826 		this.astPtr--;
2827 		alloc = new AllocationExpression();
2828 		alloc.sourceEnd = this.endPosition; //the position has been stored explicitly
2829 
2830 		if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2831 			this.expressionPtr -= length;
2832 			System.arraycopy(
2833 				this.expressionStack,
2834 				this.expressionPtr + 1,
2835 				alloc.arguments = new Expression[length],
2836 				0,
2837 				length);
2838 		}
2839 		alloc.type = getTypeReference(0);
2840 		checkForDiamond(alloc.type);
2841 
2842 		length = this.genericsLengthStack[this.genericsLengthPtr--];
2843 		this.genericsPtr -= length;
2844 		System.arraycopy(this.genericsStack, this.genericsPtr + 1, alloc.typeArguments = new TypeReference[length], 0, length);
2845 		this.intPtr--;
2846 
2847 		//the default constructor with the correct number of argument
2848 		//will be created and added by the TC (see createsInternalConstructorWithBinding)
2849 		alloc.sourceStart = this.intStack[this.intPtr--];
2850 		pushOnExpressionStack(alloc);
2851 	} else {
2852 		dispatchDeclarationInto(length);
2853 		TypeDeclaration anonymousTypeDeclaration = (TypeDeclaration)this.astStack[this.astPtr];
2854 		anonymousTypeDeclaration.declarationSourceEnd = this.endStatementPosition;
2855 		anonymousTypeDeclaration.bodyEnd = this.endStatementPosition;
2856 		if (length == 0 && !containsComment(anonymousTypeDeclaration.bodyStart, anonymousTypeDeclaration.bodyEnd)) {
2857 			anonymousTypeDeclaration.bits |= ASTNode.UndocumentedEmptyBlock;
2858 		}
2859 		this.astPtr--;
2860 		this.astLengthPtr--;
2861 
2862 		QualifiedAllocationExpression allocationExpression = anonymousTypeDeclaration.allocation;
2863 		if (allocationExpression != null) {
2864 			allocationExpression.sourceEnd = this.endStatementPosition;
2865 			// handle type arguments
2866 			length = this.genericsLengthStack[this.genericsLengthPtr--];
2867 			this.genericsPtr -= length;
2868 			System.arraycopy(this.genericsStack, this.genericsPtr + 1, allocationExpression.typeArguments = new TypeReference[length], 0, length);
2869 			allocationExpression.sourceStart = this.intStack[this.intPtr--];
2870 			checkForDiamond(allocationExpression.type);
2871 		}
2872 	}
2873 	consumeInvocationExpression();
2874 }
consumeClassOrInterface()2875 protected void consumeClassOrInterface() {
2876 	this.genericsIdentifiersLengthStack[this.genericsIdentifiersLengthPtr] += this.identifierLengthStack[this.identifierLengthPtr];
2877 	pushOnGenericsLengthStack(0); // handle type arguments
2878 }
consumeClassOrInterfaceName()2879 protected void consumeClassOrInterfaceName() {
2880 	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
2881 	pushOnGenericsLengthStack(0); // handle type arguments
2882 }
consumeClassTypeElt()2883 protected void consumeClassTypeElt() {
2884 	// ClassTypeElt ::= ClassType
2885 	pushOnAstStack(getTypeReference(0));
2886 	/* if incomplete thrown exception list, this.listLength counter will not have been reset,
2887 		indicating that some items are available on the stack */
2888 	this.listLength++;
2889 }
consumeClassTypeList()2890 protected void consumeClassTypeList() {
2891 	// ClassTypeList ::= ClassTypeList ',' ClassTypeElt
2892 	optimizedConcatNodeLists();
2893 }
consumeCompilationUnit()2894 protected void consumeCompilationUnit() {
2895 	// CompilationUnit ::= EnterCompilationUnit InternalCompilationUnit
2896 	// do nothing by default
2897 }
consumeConditionalExpression(int op)2898 protected void consumeConditionalExpression(int op) {
2899 	// ConditionalExpression ::= ConditionalOrExpression '?' Expression ':' ConditionalExpression
2900 	//optimize the push/pop
2901 	this.intPtr -= 2;//consume position of the question mark
2902 	this.expressionPtr -= 2;
2903 	this.expressionLengthPtr -= 2;
2904 	this.expressionStack[this.expressionPtr] =
2905 		new ConditionalExpression(
2906 			this.expressionStack[this.expressionPtr],
2907 			this.expressionStack[this.expressionPtr + 1],
2908 			this.expressionStack[this.expressionPtr + 2]);
2909 }
2910 /**
2911  * @param op
2912  */
consumeConditionalExpressionWithName(int op)2913 protected void consumeConditionalExpressionWithName(int op) {
2914 	// ConditionalExpression ::= Name '?' Expression ':' ConditionalExpression
2915 	this.intPtr -= 2;//consume position of the question mark
2916 	pushOnExpressionStack(getUnspecifiedReferenceOptimized());
2917 	this.expressionPtr -= 2;
2918 	this.expressionLengthPtr -= 2;
2919 	this.expressionStack[this.expressionPtr] =
2920 		new ConditionalExpression(
2921 			this.expressionStack[this.expressionPtr + 2],
2922 			this.expressionStack[this.expressionPtr],
2923 			this.expressionStack[this.expressionPtr + 1]);
2924 }
consumeConstructorBlockStatements()2925 protected void consumeConstructorBlockStatements() {
2926 	// ConstructorBody ::= NestedMethod '{' ExplicitConstructorInvocation BlockStatements '}'
2927 	concatNodeLists(); // explictly add the first statement into the list of statements
2928 }
consumeConstructorBody()2929 protected void consumeConstructorBody() {
2930 	// ConstructorBody ::= NestedMethod  '{' BlockStatementsopt '}'
2931 	// ConstructorBody ::= NestedMethod  '{' ExplicitConstructorInvocation '}'
2932 	this.nestedMethod[this.nestedType] --;
2933 }
consumeConstructorDeclaration()2934 protected void consumeConstructorDeclaration() {
2935 	// ConstructorDeclaration ::= ConstructorHeader ConstructorBody
2936 
2937 	/*
2938 	this.astStack : MethodDeclaration statements
2939 	this.identifierStack : name
2940 	 ==>
2941 	this.astStack : MethodDeclaration
2942 	this.identifierStack :
2943 	*/
2944 
2945 	//must provide a default constructor call when needed
2946 
2947 	int length;
2948 
2949 	// pop the position of the {  (body of the method) pushed in block decl
2950 	this.intPtr--;
2951 	this.intPtr--;
2952 
2953 	//statements
2954 	this.realBlockPtr--;
2955 	ExplicitConstructorCall constructorCall = null;
2956 	Statement[] statements = null;
2957 	if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
2958 		this.astPtr -= length;
2959 		if (!this.options.ignoreMethodBodies) {
2960 			if (this.astStack[this.astPtr + 1] instanceof ExplicitConstructorCall) {
2961 				//avoid a isSomeThing that would only be used here BUT what is faster between two alternatives ?
2962 				System.arraycopy(
2963 					this.astStack,
2964 					this.astPtr + 2,
2965 					statements = new Statement[length - 1],
2966 					0,
2967 					length - 1);
2968 				constructorCall = (ExplicitConstructorCall) this.astStack[this.astPtr + 1];
2969 			} else { //need to add explicitly the super();
2970 				System.arraycopy(
2971 					this.astStack,
2972 					this.astPtr + 1,
2973 					statements = new Statement[length],
2974 					0,
2975 					length);
2976 				constructorCall = SuperReference.implicitSuperConstructorCall();
2977 			}
2978 		}
2979 	} else {
2980 		boolean insideFieldInitializer = false;
2981 		if (this.diet) {
2982 			for (int i = this.nestedType; i > 0; i--){
2983 				if (this.variablesCounter[i] > 0) {
2984 					insideFieldInitializer = true;
2985 					break;
2986 				}
2987 			}
2988 		}
2989 
2990 		if (!this.options.ignoreMethodBodies) {
2991 			if (!this.diet || insideFieldInitializer){
2992 				// add it only in non-diet mode, if diet_bodies, then constructor call will be added elsewhere.
2993 				constructorCall = SuperReference.implicitSuperConstructorCall();
2994 			}
2995 		}
2996 	}
2997 
2998 	// now we know that the top of stack is a constructorDeclaration
2999 	ConstructorDeclaration cd = (ConstructorDeclaration) this.astStack[this.astPtr];
3000 	cd.constructorCall = constructorCall;
3001 	cd.statements = statements;
3002 
3003 	//highlight of the implicit call on the method name
3004 	if (constructorCall != null && cd.constructorCall.sourceEnd == 0) {
3005 		cd.constructorCall.sourceEnd = cd.sourceEnd;
3006 		cd.constructorCall.sourceStart = cd.sourceStart;
3007 	}
3008 
3009 	if (!(this.diet && this.dietInt == 0)
3010 			&& statements == null
3011 			&& (constructorCall == null || constructorCall.isImplicitSuper())
3012 			&& !containsComment(cd.bodyStart, this.endPosition)) {
3013 		cd.bits |= ASTNode.UndocumentedEmptyBlock;
3014 	}
3015 
3016 	//watch for } that could be given as a unicode ! ( u007D is '}' )
3017 	// store the this.endPosition (position just before the '}') in case there is
3018 	// a trailing comment behind the end of the method
3019 	cd.bodyEnd = this.endPosition;
3020 	cd.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
3021 }
consumeConstructorHeader()3022 protected void consumeConstructorHeader() {
3023 	// ConstructorHeader ::= ConstructorHeaderName MethodHeaderParameters MethodHeaderThrowsClauseopt
3024 
3025 	AbstractMethodDeclaration method = (AbstractMethodDeclaration)this.astStack[this.astPtr];
3026 
3027 	if (this.currentToken == TokenNameLBRACE){
3028 		method.bodyStart = this.scanner.currentPosition;
3029 	}
3030 	// recovery
3031 	if (this.currentElement != null){
3032 		if (this.currentToken == TokenNameSEMICOLON){ // for invalid constructors
3033 			method.modifiers |= ExtraCompilerModifiers.AccSemicolonBody;
3034 			method.declarationSourceEnd = this.scanner.currentPosition-1;
3035 			method.bodyEnd = this.scanner.currentPosition-1;
3036 			if (this.currentElement.parseTree() == method && this.currentElement.parent != null) {
3037 				this.currentElement = this.currentElement.parent;
3038 			}
3039 		}
3040 		this.restartRecovery = true; // used to avoid branching back into the regular automaton
3041 	}
3042 }
consumeConstructorHeaderName()3043 protected void consumeConstructorHeaderName() {
3044 
3045 	/* recovering - might be an empty message send */
3046 	if (this.currentElement != null){
3047 		if (this.lastIgnoredToken == TokenNamenew){ // was an allocation expression
3048 			this.lastCheckPoint = this.scanner.startPosition; // force to restart at this exact position
3049 			this.restartRecovery = true;
3050 			return;
3051 		}
3052 	}
3053 
3054 	// ConstructorHeaderName ::=  Modifiersopt 'Identifier' '('
3055 	ConstructorDeclaration cd = new ConstructorDeclaration(this.compilationUnit.compilationResult);
3056 
3057 	//name -- this is not really revelant but we do .....
3058 	cd.selector = this.identifierStack[this.identifierPtr];
3059 	long selectorSource = this.identifierPositionStack[this.identifierPtr--];
3060 	this.identifierLengthPtr--;
3061 
3062 	//modifiers
3063 	cd.declarationSourceStart = this.intStack[this.intPtr--];
3064 	cd.modifiers = this.intStack[this.intPtr--];
3065 	// consume annotations
3066 	int length;
3067 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3068 		System.arraycopy(
3069 			this.expressionStack,
3070 			(this.expressionPtr -= length) + 1,
3071 			cd.annotations = new Annotation[length],
3072 			0,
3073 			length);
3074 	}
3075 	// javadoc
3076 	cd.javadoc = this.javadoc;
3077 	this.javadoc = null;
3078 
3079 	//highlight starts at the selector starts
3080 	cd.sourceStart = (int) (selectorSource >>> 32);
3081 	pushOnAstStack(cd);
3082 	cd.sourceEnd = this.lParenPos;
3083 	cd.bodyStart = this.lParenPos+1;
3084 	this.listLength = 0; // initialize this.listLength before reading parameters/throws
3085 
3086 	// recovery
3087 	if (this.currentElement != null){
3088 		this.lastCheckPoint = cd.bodyStart;
3089 		if ((this.currentElement instanceof RecoveredType && this.lastIgnoredToken != TokenNameDOT)
3090 			|| cd.modifiers != 0){
3091 			this.currentElement = this.currentElement.add(cd, 0);
3092 			this.lastIgnoredToken = -1;
3093 		}
3094 	}
3095 }
3096 // TODO: Refactor code for constructor and compact one once records are standardized.
populateCompactConstructor(CompactConstructorDeclaration ccd)3097 private void populateCompactConstructor(CompactConstructorDeclaration ccd) {
3098 	//name -- this is not really revelant but we do .....
3099 	ccd.selector = this.identifierStack[this.identifierPtr];
3100 	long selectorSource = this.identifierPositionStack[this.identifierPtr--];
3101 	this.identifierLengthPtr--;
3102 
3103 	//modifiers
3104 	ccd.declarationSourceStart = this.intStack[this.intPtr--];
3105 	ccd.modifiers = this.intStack[this.intPtr--];
3106 	// consume annotations
3107 	int length;
3108 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3109 		System.arraycopy(
3110 			this.expressionStack,
3111 			(this.expressionPtr -= length) + 1,
3112 			ccd.annotations = new Annotation[length],
3113 			0,
3114 			length);
3115 	}
3116 	// javadoc
3117 	ccd.javadoc = this.javadoc;
3118 	this.javadoc = null;
3119 
3120 	//highlight starts at the selector starts
3121 	ccd.sourceStart = (int) (selectorSource >>> 32);
3122 	pushOnAstStack(ccd);
3123 	ccd.sourceEnd = ccd.sourceStart + ccd.selector.length - 1; // no lParen for compact constructor
3124 	ccd.bodyStart = ccd.sourceStart + ccd.selector.length;
3125 	this.listLength = 0; // initialize this.listLength before reading parameters/throws
3126 
3127 	// recovery
3128 	if (this.currentElement != null){
3129 		this.lastCheckPoint = ccd.bodyStart;
3130 		if ((this.currentElement instanceof RecoveredType && this.lastIgnoredToken != TokenNameDOT)
3131 			|| ccd.modifiers != 0){
3132 			this.currentElement = this.currentElement.add(ccd, 0);
3133 			this.lastIgnoredToken = -1;
3134 		}
3135 	}
3136 }
consumeConstructorHeaderNameWithTypeParameters()3137 protected void consumeConstructorHeaderNameWithTypeParameters() {
3138 
3139 	/* recovering - might be an empty message send */
3140 	if (this.currentElement != null){
3141 		if (this.lastIgnoredToken == TokenNamenew){ // was an allocation expression
3142 			this.lastCheckPoint = this.scanner.startPosition; // force to restart at this exact position
3143 			this.restartRecovery = true;
3144 			return;
3145 		}
3146 	}
3147 
3148 	// ConstructorHeaderName ::=  Modifiersopt TypeParameters 'Identifier' '('
3149 	ConstructorDeclaration cd = new ConstructorDeclaration(this.compilationUnit.compilationResult);
3150 
3151 	helperConstructorHeaderNameWithTypeParameters(cd);
3152 }
helperConstructorHeaderNameWithTypeParameters(ConstructorDeclaration cd)3153 private void helperConstructorHeaderNameWithTypeParameters(ConstructorDeclaration cd) {
3154 	//name -- this is not really revelant but we do .....
3155 	cd.selector = this.identifierStack[this.identifierPtr];
3156 	long selectorSource = this.identifierPositionStack[this.identifierPtr--];
3157 	this.identifierLengthPtr--;
3158 
3159 	// consume type parameters
3160 	int length = this.genericsLengthStack[this.genericsLengthPtr--];
3161 	this.genericsPtr -= length;
3162 	System.arraycopy(this.genericsStack, this.genericsPtr + 1, cd.typeParameters = new TypeParameter[length], 0, length);
3163 
3164 	//modifiers
3165 	cd.declarationSourceStart = this.intStack[this.intPtr--];
3166 	cd.modifiers = this.intStack[this.intPtr--];
3167 	// consume annotations
3168 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3169 		System.arraycopy(
3170 			this.expressionStack,
3171 			(this.expressionPtr -= length) + 1,
3172 			cd.annotations = new Annotation[length],
3173 			0,
3174 			length);
3175 	}
3176 	// javadoc
3177 	cd.javadoc = this.javadoc;
3178 	this.javadoc = null;
3179 
3180 	//highlight starts at the selector starts
3181 	cd.sourceStart = (int) (selectorSource >>> 32);
3182 	pushOnAstStack(cd);
3183 	cd.sourceEnd = this.lParenPos;
3184 	cd.bodyStart = this.lParenPos+1;
3185 	this.listLength = 0; // initialize this.listLength before reading parameters/throws
3186 
3187 	// recovery
3188 	if (this.currentElement != null){
3189 		this.lastCheckPoint = cd.bodyStart;
3190 		if ((this.currentElement instanceof RecoveredType && this.lastIgnoredToken != TokenNameDOT)
3191 			|| cd.modifiers != 0){
3192 			this.currentElement = this.currentElement.add(cd, 0);
3193 			this.lastIgnoredToken = -1;
3194 		}
3195 	}
3196 }
consumeCreateInitializer()3197 protected void consumeCreateInitializer() {
3198 	pushOnAstStack(new Initializer(null, 0));
3199 }
consumeDefaultLabel()3200 protected void consumeDefaultLabel() {
3201 	// SwitchLabel ::= 'default' ':'
3202 	CaseStatement defaultStatement = new CaseStatement(null, this.intStack[this.intPtr--], this.intStack[this.intPtr--]);
3203 	// Look for $fall-through$ and $CASES-OMITTED$ tags in leading comment for case statement
3204 	if (hasLeadingTagComment(FALL_THROUGH_TAG, defaultStatement.sourceStart)) {
3205 		defaultStatement.bits |= ASTNode.DocumentedFallthrough;
3206 	}
3207 	if (hasLeadingTagComment(CASES_OMITTED_TAG, defaultStatement.sourceStart)) {
3208 		defaultStatement.bits |= ASTNode.DocumentedCasesOmitted;
3209 	}
3210 	pushOnAstStack(defaultStatement);
3211 }
consumeDefaultModifiers()3212 protected void consumeDefaultModifiers() {
3213 	checkComment(); // might update modifiers with AccDeprecated
3214 	pushOnIntStack(this.modifiers); // modifiers
3215 	pushOnIntStack(
3216 		this.modifiersSourceStart >= 0 ? this.modifiersSourceStart : this.scanner.startPosition);
3217 	resetModifiers();
3218 	pushOnExpressionStackLengthStack(0); // no annotation
3219 }
consumeDiet()3220 protected void consumeDiet() {
3221 	// Diet ::= $empty
3222 	checkComment();
3223 	pushOnIntStack(this.modifiersSourceStart); // push the start position of a javadoc comment if there is one
3224 	resetModifiers();
3225 	jumpOverMethodBody();
3226 }
consumeDims()3227 protected void consumeDims() {
3228 	// Dims ::= DimsLoop
3229 	pushOnIntStack(this.dimensions);
3230 	this.dimensions = 0;
3231 }
consumeDimWithOrWithOutExpr()3232 protected void consumeDimWithOrWithOutExpr() {
3233 	// DimWithOrWithOutExpr ::= TypeAnnotationsopt '[' ']'
3234 	// DimWithOrWithOutExpr ::= TypeAnnotationsopt '[' Expression ']'
3235 	pushOnExpressionStack(null);
3236 
3237 	if(this.currentElement != null && this.currentToken == TokenNameLBRACE) {
3238 		this.ignoreNextOpeningBrace = true;
3239 		this.currentElement.bracketBalance++;
3240 	}
3241 }
consumeDimWithOrWithOutExprs()3242 protected void consumeDimWithOrWithOutExprs() {
3243 	// DimWithOrWithOutExprs ::= DimWithOrWithOutExprs DimWithOrWithOutExpr
3244 	concatExpressionLists();
3245 }
consumeUnionType()3246 protected void consumeUnionType() {
3247 	// UnionType ::= UnionType '|' Type
3248 	pushOnAstStack(getTypeReference(this.intStack[this.intPtr--]));
3249 	optimizedConcatNodeLists();
3250 }
consumeUnionTypeAsClassType()3251 protected void consumeUnionTypeAsClassType() {
3252 	// UnionType ::= Type
3253 	pushOnAstStack(getTypeReference(this.intStack[this.intPtr--]));
3254 }
consumeEmptyAnnotationTypeMemberDeclarationsopt()3255 protected void consumeEmptyAnnotationTypeMemberDeclarationsopt() {
3256 	// AnnotationTypeMemberDeclarationsopt ::= $empty
3257 	pushOnAstLengthStack(0);
3258 }
consumeEmptyArgumentListopt()3259 protected void consumeEmptyArgumentListopt() {
3260 	// ArgumentListopt ::= $empty
3261 	pushOnExpressionStackLengthStack(0);
3262 }
consumeEmptyArguments()3263 protected void consumeEmptyArguments() {
3264 	// Argumentsopt ::= $empty
3265 	final FieldDeclaration fieldDeclaration = (FieldDeclaration) this.astStack[this.astPtr];
3266 	pushOnIntStack(fieldDeclaration.sourceEnd);
3267 	pushOnExpressionStackLengthStack(0);
3268 }
consumeEmptyArrayInitializer()3269 protected void consumeEmptyArrayInitializer() {
3270 	// ArrayInitializer ::= '{' ,opt '}'
3271 	arrayInitializer(0);
3272 }
consumeEmptyArrayInitializeropt()3273 protected void consumeEmptyArrayInitializeropt() {
3274 	// ArrayInitializeropt ::= $empty
3275 	pushOnExpressionStackLengthStack(0);
3276 }
consumeEmptyBlockStatementsopt()3277 protected void consumeEmptyBlockStatementsopt() {
3278 	// BlockStatementsopt ::= $empty
3279 	pushOnAstLengthStack(0);
3280 }
consumeEmptyCatchesopt()3281 protected void consumeEmptyCatchesopt() {
3282 	// Catchesopt ::= $empty
3283 	pushOnAstLengthStack(0);
3284 }
consumeEmptyClassBodyDeclarationsopt()3285 protected void consumeEmptyClassBodyDeclarationsopt() {
3286 	// ClassBodyDeclarationsopt ::= $empty
3287 	pushOnAstLengthStack(0);
3288 }
consumeEmptyDimsopt()3289 protected void consumeEmptyDimsopt() {
3290 	// Dimsopt ::= $empty
3291 	pushOnIntStack(0);
3292 }
consumeEmptyEnumDeclarations()3293 protected void consumeEmptyEnumDeclarations() {
3294 	// EnumBodyDeclarationsopt ::= $empty
3295 	pushOnAstLengthStack(0);
3296 }
consumeEmptyExpression()3297 protected void consumeEmptyExpression() {
3298 	// Expressionopt ::= $empty
3299 	pushOnExpressionStackLengthStack(0);
3300 }
consumeEmptyForInitopt()3301 protected void consumeEmptyForInitopt() {
3302 	// ForInitopt ::= $empty
3303 	pushOnAstLengthStack(0);
3304 	this.forStartPosition = 0;
3305 }
consumeEmptyForUpdateopt()3306 protected void consumeEmptyForUpdateopt() {
3307 	// ForUpdateopt ::= $empty
3308 	pushOnExpressionStackLengthStack(0);
3309 }
consumeEmptyInterfaceMemberDeclarationsopt()3310 protected void consumeEmptyInterfaceMemberDeclarationsopt() {
3311 	// InterfaceMemberDeclarationsopt ::= $empty
3312 	pushOnAstLengthStack(0);
3313 }
consumeEmptyInternalCompilationUnit()3314 protected void consumeEmptyInternalCompilationUnit() {
3315 	// InternalCompilationUnit ::= $empty
3316 	// nothing to do by default
3317 	if (this.compilationUnit.isPackageInfo()) {
3318 		this.compilationUnit.types = new TypeDeclaration[1];
3319 		this.compilationUnit.createPackageInfoType();
3320 	}
3321 }
consumeEmptyMemberValueArrayInitializer()3322 protected void consumeEmptyMemberValueArrayInitializer() {
3323 	// MemberValueArrayInitializer ::= '{' ',' '}'
3324 	// MemberValueArrayInitializer ::= '{' '}'
3325 	arrayInitializer(0);
3326 }
consumeEmptyMemberValuePairsopt()3327 protected void consumeEmptyMemberValuePairsopt() {
3328 	// MemberValuePairsopt ::= $empty
3329 	pushOnAstLengthStack(0);
3330 }
consumeEmptyMethodHeaderDefaultValue()3331 protected void consumeEmptyMethodHeaderDefaultValue() {
3332 	// DefaultValueopt ::= $empty
3333 	AbstractMethodDeclaration method = (AbstractMethodDeclaration)this.astStack[this.astPtr];
3334 	if(method.isAnnotationMethod()) { //'method' can be a MethodDeclaration when recovery is started
3335 		pushOnExpressionStackLengthStack(0);
3336 	}
3337 	this.recordStringLiterals = true;
3338 }
consumeEmptyStatement()3339 protected void consumeEmptyStatement() {
3340 	// EmptyStatement ::= ';'
3341 	char[] source = this.scanner.source;
3342 	if (source[this.endStatementPosition] == ';') {
3343 		pushOnAstStack(new EmptyStatement(this.endStatementPosition, this.endStatementPosition));
3344 	} else {
3345 		if(source.length > 5) {
3346 			int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
3347 			int pos = this.endStatementPosition - 4;
3348 			while (source[pos] == 'u') {
3349 				pos--;
3350 			}
3351 			if (source[pos] == '\\' &&
3352 					!((c1 = ScannerHelper.getHexadecimalValue(source[this.endStatementPosition - 3])) > 15
3353 						|| c1 < 0
3354 						|| (c2 = ScannerHelper.getHexadecimalValue(source[this.endStatementPosition - 2])) > 15
3355 						|| c2 < 0
3356 						|| (c3 = ScannerHelper.getHexadecimalValue(source[this.endStatementPosition - 1])) > 15
3357 						|| c3 < 0
3358 						|| (c4 = ScannerHelper.getHexadecimalValue(source[this.endStatementPosition])) > 15
3359 						|| c4 < 0) &&
3360 					((char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4)) == ';'){
3361 				// we have a Unicode for the ';' (/u003B)
3362 				pushOnAstStack(new EmptyStatement(pos, this.endStatementPosition));
3363 				return;
3364 			}
3365 		}
3366 		pushOnAstStack(new EmptyStatement(this.endPosition + 1, this.endStatementPosition));
3367 	}
3368 }
consumeEmptySwitchBlock()3369 protected void consumeEmptySwitchBlock() {
3370 	// SwitchBlock ::= '{' '}'
3371 	pushOnAstLengthStack(0);
3372 }
consumeEmptyTypeDeclaration()3373 protected void consumeEmptyTypeDeclaration() {
3374 	// ClassMemberDeclaration ::= ';'
3375 	// InterfaceMemberDeclaration ::= ';'
3376 	// TypeDeclaration ::= ';'
3377 	pushOnAstLengthStack(0);
3378 	if(!this.statementRecoveryActivated) problemReporter().superfluousSemicolon(this.endPosition+1, this.endStatementPosition);
3379 	flushCommentsDefinedPriorTo(this.endStatementPosition);
3380 }
consumeEnhancedForStatement()3381 protected void consumeEnhancedForStatement() {
3382 	// EnhancedForStatement ::= EnhancedForStatementHeader Statement
3383 	// EnhancedForStatementNoShortIf ::= EnhancedForStatementHeader StatementNoShortIf
3384 
3385 	//statements
3386 	this.astLengthPtr--;
3387 	Statement statement = (Statement) this.astStack[this.astPtr--];
3388 
3389 	// foreach statement is on the ast stack
3390 	ForeachStatement foreachStatement = (ForeachStatement) this.astStack[this.astPtr];
3391 	foreachStatement.action = statement;
3392 	// remember useful empty statement
3393 	if (statement instanceof EmptyStatement) statement.bits |= ASTNode.IsUsefulEmptyStatement;
3394 
3395 	foreachStatement.sourceEnd = this.endStatementPosition;
3396 }
consumeEnhancedForStatementHeader()3397 protected void consumeEnhancedForStatementHeader(){
3398 	// EnhancedForStatementHeader ::= EnhancedForStatementHeaderInit ':' Expression ')'
3399 	final ForeachStatement statement = (ForeachStatement) this.astStack[this.astPtr];
3400 	//updates are on the expression stack
3401 	this.expressionLengthPtr--;
3402 	final Expression collection = this.expressionStack[this.expressionPtr--];
3403 	statement.collection = collection;
3404 	// https://bugs.eclipse.org/393719 - [compiler] inconsistent warnings on iteration variables
3405 	// let declaration(Source)End include the collection to achieve that @SuppressWarnings affects this part, too:
3406 	statement.elementVariable.declarationSourceEnd = collection.sourceEnd;
3407 	statement.elementVariable.declarationEnd = collection.sourceEnd;
3408 	statement.sourceEnd = this.rParenPos;
3409 
3410 	if(!this.statementRecoveryActivated &&
3411 			this.options.sourceLevel < ClassFileConstants.JDK1_5 &&
3412 			this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
3413 		problemReporter().invalidUsageOfForeachStatements(statement.elementVariable, collection);
3414 	}
3415 }
consumeEnhancedForStatementHeaderInit(boolean hasModifiers)3416 protected void consumeEnhancedForStatementHeaderInit(boolean hasModifiers) {
3417 	TypeReference type;
3418 
3419 	char[] identifierName = this.identifierStack[this.identifierPtr];
3420 	long namePosition = this.identifierPositionStack[this.identifierPtr];
3421 
3422 	LocalDeclaration localDeclaration = createLocalDeclaration(identifierName, (int) (namePosition >>> 32), (int) namePosition);
3423 	localDeclaration.declarationSourceEnd = localDeclaration.declarationEnd;
3424 	localDeclaration.bits |= ASTNode.IsForeachElementVariable;
3425 
3426 	int extraDims = this.intStack[this.intPtr--];
3427 	Annotation [][] annotationsOnExtendedDimensions = extraDims == 0 ? null : getAnnotationsOnDimensions(extraDims);
3428 	this.identifierPtr--;
3429 	this.identifierLengthPtr--;
3430 	// remove fake modifiers/modifiers start
3431 	int declarationSourceStart = 0;
3432 	int modifiersValue  = 0;
3433 	if (hasModifiers) {
3434 		declarationSourceStart = this.intStack[this.intPtr--];
3435 		modifiersValue = this.intStack[this.intPtr--];
3436 	} else {
3437 		this.intPtr-=2;
3438 	}
3439 
3440 	type = getTypeReference(this.intStack[this.intPtr--]); // type dimension
3441 
3442 	// consume annotations
3443 	int length;
3444 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--])!= 0) {
3445 		System.arraycopy(
3446 			this.expressionStack,
3447 			(this.expressionPtr -= length) + 1,
3448 			localDeclaration.annotations = new Annotation[length],
3449 			0,
3450 			length);
3451 		localDeclaration.bits |= ASTNode.HasTypeAnnotations;
3452 	}
3453 	if (extraDims != 0) {
3454 		type = augmentTypeWithAdditionalDimensions(type, extraDims, annotationsOnExtendedDimensions, false);
3455 	}
3456 	if (hasModifiers) {
3457 		localDeclaration.declarationSourceStart = declarationSourceStart;
3458 		localDeclaration.modifiers = modifiersValue;
3459 	} else {
3460 		localDeclaration.declarationSourceStart = type.sourceStart;
3461 	}
3462 	localDeclaration.type = type;
3463 	localDeclaration.bits |= (type.bits & ASTNode.HasTypeAnnotations);
3464 
3465 	ForeachStatement iteratorForStatement =
3466 		new ForeachStatement(
3467 			localDeclaration,
3468 			this.intStack[this.intPtr--]);
3469 	pushOnAstStack(iteratorForStatement);
3470 
3471 	iteratorForStatement.sourceEnd = localDeclaration.declarationSourceEnd;
3472 	this.forStartPosition = 0;
3473 }
consumeEnterAnonymousClassBody(boolean qualified)3474 protected void consumeEnterAnonymousClassBody(boolean qualified) {
3475 	// EnterAnonymousClassBody ::= $empty
3476 	TypeReference typeReference = getTypeReference(0);
3477 
3478 	TypeDeclaration anonymousType = new TypeDeclaration(this.compilationUnit.compilationResult);
3479 	anonymousType.name = CharOperation.NO_CHAR;
3480 	anonymousType.bits |= (ASTNode.IsAnonymousType|ASTNode.IsLocalType);
3481 	anonymousType.bits |= (typeReference.bits & ASTNode.HasTypeAnnotations);
3482 	QualifiedAllocationExpression alloc = new QualifiedAllocationExpression(anonymousType);
3483 	markEnclosingMemberWithLocalType();
3484 	pushOnAstStack(anonymousType);
3485 
3486 	alloc.sourceEnd = this.rParenPos; //the position has been stored explicitly
3487 	int argumentLength;
3488 	if ((argumentLength = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3489 		this.expressionPtr -= argumentLength;
3490 		System.arraycopy(
3491 			this.expressionStack,
3492 			this.expressionPtr + 1,
3493 			alloc.arguments = new Expression[argumentLength],
3494 			0,
3495 			argumentLength);
3496 	}
3497 
3498 	if (qualified) {
3499 		this.expressionLengthPtr--;
3500 		alloc.enclosingInstance = this.expressionStack[this.expressionPtr--];
3501 	}
3502 
3503 	alloc.type = typeReference;
3504 
3505 	anonymousType.sourceEnd = alloc.sourceEnd;
3506 	//position at the type while it impacts the anonymous declaration
3507 	anonymousType.sourceStart = anonymousType.declarationSourceStart = alloc.type.sourceStart;
3508 	alloc.sourceStart = this.intStack[this.intPtr--];
3509 	pushOnExpressionStack(alloc);
3510 
3511 	anonymousType.bodyStart = this.scanner.currentPosition;
3512 	this.listLength = 0; // will be updated when reading super-interfaces
3513 
3514 	// flush the comments related to the anonymous
3515 	this.scanner.commentPtr = -1;
3516 
3517 	// recovery
3518 	if (this.currentElement != null){
3519 		this.lastCheckPoint = anonymousType.bodyStart;
3520 		this.currentElement = this.currentElement.add(anonymousType, 0);
3521 		if (!(this.currentElement instanceof RecoveredAnnotation)) {
3522 			if (isIndirectlyInsideLambdaExpression())
3523 				this.ignoreNextOpeningBrace = true;
3524 			else
3525 				this.currentToken = 0; // opening brace already taken into account
3526 		} else {
3527 			this.ignoreNextOpeningBrace = true;
3528 			this.currentElement.bracketBalance++;
3529 		}
3530 		this.lastIgnoredToken = -1;
3531 	}
3532 }
consumeEnterCompilationUnit()3533 protected void consumeEnterCompilationUnit() {
3534 	// EnterCompilationUnit ::= $empty
3535 	// do nothing by default
3536 }
consumeEnterMemberValue()3537 protected void consumeEnterMemberValue() {
3538 	// EnterMemberValue ::= $empty
3539 	if (this.currentElement != null && this.currentElement instanceof RecoveredAnnotation) {
3540 		RecoveredAnnotation recoveredAnnotation = (RecoveredAnnotation)this.currentElement;
3541 		recoveredAnnotation.hasPendingMemberValueName = true;
3542 	}
3543 }
consumeEnterMemberValueArrayInitializer()3544 protected void consumeEnterMemberValueArrayInitializer() {
3545 	// EnterMemberValueArrayInitializer ::= $empty
3546 	if(this.currentElement != null) {
3547 		this.ignoreNextOpeningBrace = true;
3548 		this.currentElement.bracketBalance++;
3549 	}
3550 }
isAFieldDeclarationInRecord()3551 private boolean isAFieldDeclarationInRecord() {
3552 	if (this.options.sourceLevel < ClassFileConstants.JDK14)
3553 		return false;
3554 	int recordIndex = -1;
3555 	Integer[] nestingTypeAndMethod = null;
3556 	for (int i = this.astPtr; i >= 0; --i) {
3557 		if (this.astStack[i] instanceof TypeDeclaration) {
3558 			TypeDeclaration node = (TypeDeclaration) this.astStack[i];
3559 			if (!node.isRecord())
3560 				continue;
3561 			nestingTypeAndMethod = this.recordNestedMethodLevels.get(node);
3562 			if (nestingTypeAndMethod != null) { // record declaration is done yet
3563 				recordIndex = i;
3564 				break;
3565 			}
3566 		}
3567 	}
3568 	if (recordIndex < 0)
3569 		return false;
3570 	for (int i = recordIndex + 1; i <= this.astPtr; ++i) {
3571 		ASTNode node = this.astStack[i];
3572 		if (node instanceof TypeDeclaration) {
3573 			if (node.sourceEnd < 0) {
3574 				return false;
3575 			}
3576 		} else if (node instanceof AbstractMethodDeclaration) {
3577 			if (this.nestedType != nestingTypeAndMethod[0] ||
3578 					this.nestedMethod[this.nestedType] != nestingTypeAndMethod[1])
3579 				return false;
3580 		} else if (node instanceof FieldDeclaration) {
3581 			continue;
3582 		} else {
3583 			return false;
3584 		}
3585 	}
3586 	return true;
3587 }
consumeEnterVariable()3588 protected void consumeEnterVariable() {
3589 	// EnterVariable ::= $empty
3590 	// do nothing by default
3591 
3592 	char[] identifierName = this.identifierStack[this.identifierPtr];
3593 	long namePosition = this.identifierPositionStack[this.identifierPtr];
3594 	int extendedDimensions = this.intStack[this.intPtr--];
3595 	// pop any annotations on extended dimensions now, so they don't pollute the base dimensions.
3596 	Annotation [][] annotationsOnExtendedDimensions = extendedDimensions == 0 ? null : getAnnotationsOnDimensions(extendedDimensions);
3597 	AbstractVariableDeclaration declaration;
3598 	// create the ast node
3599 	boolean isLocalDeclaration = this.nestedMethod[this.nestedType] != 0 &&
3600 									!isAFieldDeclarationInRecord();
3601 	if (isLocalDeclaration) {
3602 		// create the local variable declarations
3603 		declaration =
3604 			createLocalDeclaration(identifierName, (int) (namePosition >>> 32), (int) namePosition);
3605 	} else {
3606 		// create the field declaration
3607 		declaration =
3608 			createFieldDeclaration(identifierName, (int) (namePosition >>> 32), (int) namePosition);
3609 	}
3610 
3611 	this.identifierPtr--;
3612 	this.identifierLengthPtr--;
3613 	TypeReference type;
3614 	int variableIndex = this.variablesCounter[this.nestedType];
3615 	if (variableIndex == 0) {
3616 		// first variable of the declaration (FieldDeclaration or LocalDeclaration)
3617 		if (isLocalDeclaration) {
3618 			declaration.declarationSourceStart = this.intStack[this.intPtr--];
3619 			declaration.modifiers = this.intStack[this.intPtr--];
3620 			// consume annotations
3621 			int length;
3622 			if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3623 				System.arraycopy(
3624 					this.expressionStack,
3625 					(this.expressionPtr -= length) + 1,
3626 					declaration.annotations = new Annotation[length],
3627 					0,
3628 					length);
3629 			}
3630 			type = getTypeReference(this.intStack[this.intPtr--]); // type dimension
3631 			if (declaration.declarationSourceStart == -1) {
3632 				// this is true if there is no modifiers for the local variable declaration
3633 				declaration.declarationSourceStart = type.sourceStart;
3634 			}
3635 			pushOnAstStack(type);
3636 		} else {
3637 			type = getTypeReference(this.intStack[this.intPtr--]); // type dimension
3638 			pushOnAstStack(type);
3639 			declaration.declarationSourceStart = this.intStack[this.intPtr--];
3640 			declaration.modifiers = this.intStack[this.intPtr--];
3641 			// consume annotations
3642 			int length;
3643 			if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3644 				System.arraycopy(
3645 					this.expressionStack,
3646 					(this.expressionPtr -= length) + 1,
3647 					declaration.annotations = new Annotation[length],
3648 					0,
3649 					length);
3650 			}
3651 			// Store javadoc only on first declaration as it is the same for all ones
3652 			FieldDeclaration fieldDeclaration = (FieldDeclaration) declaration;
3653 			fieldDeclaration.javadoc = this.javadoc;
3654 		}
3655 		this.javadoc = null;
3656 	} else {
3657 		type = (TypeReference) this.astStack[this.astPtr - variableIndex];
3658 		AbstractVariableDeclaration previousVariable =
3659 			(AbstractVariableDeclaration) this.astStack[this.astPtr];
3660 		declaration.declarationSourceStart = previousVariable.declarationSourceStart;
3661 		declaration.modifiers = previousVariable.modifiers;
3662 		final Annotation[] annotations = previousVariable.annotations;
3663 		if (annotations != null) {
3664 			final int annotationsLength = annotations.length;
3665 			System.arraycopy(annotations, 0, declaration.annotations = new Annotation[annotationsLength], 0, annotationsLength);
3666 		}
3667 		declaration.bits |= ASTNode.IsAdditionalDeclarator;
3668 	}
3669 
3670 	declaration.type = extendedDimensions == 0 ? type : augmentTypeWithAdditionalDimensions(type, extendedDimensions, annotationsOnExtendedDimensions, false);
3671 	declaration.bits |= (type.bits & ASTNode.HasTypeAnnotations);
3672 
3673 	this.variablesCounter[this.nestedType]++;
3674 	pushOnAstStack(declaration);
3675 	// recovery
3676 	if (this.currentElement != null) {
3677 		if (!(this.currentElement instanceof RecoveredType)
3678 			&& (this.currentToken == TokenNameDOT
3679 				//|| declaration.modifiers != 0
3680 				|| (Util.getLineNumber(declaration.type.sourceStart, this.scanner.lineEnds, 0, this.scanner.linePtr)
3681 						!= Util.getLineNumber((int) (namePosition >>> 32), this.scanner.lineEnds, 0, this.scanner.linePtr)))){
3682 			this.lastCheckPoint = (int) (namePosition >>> 32);
3683 			this.restartRecovery = true;
3684 			return;
3685 		}
3686 		if (isLocalDeclaration){
3687 			LocalDeclaration localDecl = (LocalDeclaration) this.astStack[this.astPtr];
3688 			this.lastCheckPoint = localDecl.sourceEnd + 1;
3689 			this.currentElement = this.currentElement.add(localDecl, 0);
3690 		} else {
3691 			FieldDeclaration fieldDecl = (FieldDeclaration) this.astStack[this.astPtr];
3692 			this.lastCheckPoint = fieldDecl.sourceEnd + 1;
3693 			this.currentElement = this.currentElement.add(fieldDecl, 0);
3694 		}
3695 		this.lastIgnoredToken = -1;
3696 	}
3697 }
consumeEnumBodyNoConstants()3698 protected void consumeEnumBodyNoConstants() {
3699 	// nothing to do
3700 	// The 0 on the astLengthStack has been pushed by EnumBodyDeclarationsopt
3701 }
consumeEnumBodyWithConstants()3702 protected void consumeEnumBodyWithConstants() {
3703 	// merge the constants values with the class body
3704 	concatNodeLists();
3705 }
consumeEnumConstantHeader()3706 protected void consumeEnumConstantHeader() {
3707    FieldDeclaration enumConstant = (FieldDeclaration) this.astStack[this.astPtr];
3708    boolean foundOpeningBrace = this.currentToken == TokenNameLBRACE;
3709    if (foundOpeningBrace){
3710       // qualified allocation expression
3711       TypeDeclaration anonymousType = new TypeDeclaration(this.compilationUnit.compilationResult);
3712       anonymousType.name = CharOperation.NO_CHAR;
3713       anonymousType.bits |= (ASTNode.IsAnonymousType|ASTNode.IsLocalType);
3714       final int start = this.scanner.startPosition;
3715       anonymousType.declarationSourceStart = start;
3716       anonymousType.sourceStart = start;
3717       anonymousType.sourceEnd = start; // closing parenthesis
3718       anonymousType.modifiers = 0;
3719       anonymousType.bodyStart = this.scanner.currentPosition;
3720       markEnclosingMemberWithLocalType();
3721       consumeNestedType();
3722       this.variablesCounter[this.nestedType]++;
3723       pushOnAstStack(anonymousType);
3724       QualifiedAllocationExpression allocationExpression = new QualifiedAllocationExpression(anonymousType);
3725       allocationExpression.enumConstant = enumConstant;
3726 
3727       // fill arguments if needed
3728       int length;
3729       if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3730          this.expressionPtr -= length;
3731          System.arraycopy(
3732                this.expressionStack,
3733                this.expressionPtr + 1,
3734                allocationExpression.arguments = new Expression[length],
3735                0,
3736                length);
3737       }
3738       enumConstant.initialization = allocationExpression;
3739    } else {
3740       AllocationExpression allocationExpression = new AllocationExpression();
3741       allocationExpression.enumConstant = enumConstant;
3742       // fill arguments if needed
3743       int length;
3744       if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3745          this.expressionPtr -= length;
3746          System.arraycopy(
3747                this.expressionStack,
3748                this.expressionPtr + 1,
3749                allocationExpression.arguments = new Expression[length],
3750                0,
3751                length);
3752       }
3753       enumConstant.initialization = allocationExpression;
3754    }
3755    // initialize the starting position of the allocation expression
3756    enumConstant.initialization.sourceStart = enumConstant.declarationSourceStart;
3757 
3758    // recovery
3759    if (this.currentElement != null) {
3760 	  if(foundOpeningBrace) {
3761 	  	TypeDeclaration anonymousType = (TypeDeclaration) this.astStack[this.astPtr];
3762 	  	this.currentElement = this.currentElement.add(anonymousType, 0);
3763       	this.lastCheckPoint = anonymousType.bodyStart;
3764         this.lastIgnoredToken = -1;
3765         if (isIndirectlyInsideLambdaExpression())
3766 			this.ignoreNextOpeningBrace = true;
3767 		else
3768 			this.currentToken = 0; // opening brace already taken into account
3769 	  } else {
3770 	  	  if(this.currentToken == TokenNameSEMICOLON) {
3771 		  	RecoveredType currentType = currentRecoveryType();
3772 			if(currentType != null) {
3773 				currentType.insideEnumConstantPart = false;
3774 			}
3775 		  }
3776 		  this.lastCheckPoint = this.scanner.startPosition; // force to restart at this exact position
3777 	      this.lastIgnoredToken = -1;
3778 	      this.restartRecovery = true;
3779 	  }
3780    }
3781 }
consumeEnumConstantHeaderName()3782 protected void consumeEnumConstantHeaderName() {
3783 	if (this.currentElement != null) {
3784 		if (!(this.currentElement instanceof RecoveredType
3785 					|| (this.currentElement instanceof RecoveredField && ((RecoveredField)this.currentElement).fieldDeclaration.type == null))
3786 				|| (this.lastIgnoredToken == TokenNameDOT)) {
3787 			this.lastCheckPoint = this.scanner.startPosition;
3788 			this.restartRecovery = true;
3789 			return;
3790 		}
3791 	}
3792    long namePosition = this.identifierPositionStack[this.identifierPtr];
3793    char[] constantName = this.identifierStack[this.identifierPtr];
3794    final int sourceEnd = (int) namePosition;
3795    FieldDeclaration enumConstant = createFieldDeclaration(constantName, (int) (namePosition >>> 32), sourceEnd);
3796    this.identifierPtr--;
3797    this.identifierLengthPtr--;
3798    enumConstant.modifiersSourceStart = this.intStack[this.intPtr--];
3799    enumConstant.modifiers = this.intStack[this.intPtr--];
3800    enumConstant.declarationSourceStart = enumConstant.modifiersSourceStart;
3801 
3802 	// consume annotations
3803    int length;
3804    if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3805       System.arraycopy(
3806          this.expressionStack,
3807          (this.expressionPtr -= length) + 1,
3808          enumConstant.annotations = new Annotation[length],
3809          0,
3810          length);
3811 		enumConstant.bits |= ASTNode.HasTypeAnnotations;
3812    }
3813    pushOnAstStack(enumConstant);
3814 	if (this.currentElement != null){
3815 		this.lastCheckPoint = enumConstant.sourceEnd + 1;
3816 		this.currentElement = this.currentElement.add(enumConstant, 0);
3817 	}
3818 	// javadoc
3819 	enumConstant.javadoc = this.javadoc;
3820 	this.javadoc = null;
3821 }
consumeEnumConstantNoClassBody()3822 protected void consumeEnumConstantNoClassBody() {
3823 	// set declarationEnd and declarationSourceEnd
3824 	int endOfEnumConstant = this.intStack[this.intPtr--];
3825 	final FieldDeclaration fieldDeclaration = (FieldDeclaration) this.astStack[this.astPtr];
3826 	fieldDeclaration.declarationEnd = endOfEnumConstant;
3827 	fieldDeclaration.declarationSourceEnd = endOfEnumConstant;
3828 	// initialize the starting position of the allocation expression
3829 	ASTNode initialization = fieldDeclaration.initialization;
3830 	if (initialization != null) {
3831 		initialization.sourceEnd = endOfEnumConstant;
3832 	}
3833 }
consumeEnumConstants()3834 protected void consumeEnumConstants() {
3835 	concatNodeLists();
3836 }
consumeEnumConstantWithClassBody()3837 protected void consumeEnumConstantWithClassBody() {
3838 	dispatchDeclarationInto(this.astLengthStack[this.astLengthPtr--]);
3839 	TypeDeclaration anonymousType = (TypeDeclaration) this.astStack[this.astPtr--]; // pop type
3840 	this.astLengthPtr--;
3841 	anonymousType.bodyEnd = this.endPosition;
3842 	anonymousType.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
3843 	final FieldDeclaration fieldDeclaration = ((FieldDeclaration) this.astStack[this.astPtr]);
3844 	fieldDeclaration.declarationEnd = this.endStatementPosition;
3845 	int declarationSourceEnd = anonymousType.declarationSourceEnd;
3846 	fieldDeclaration.declarationSourceEnd = declarationSourceEnd;
3847 	this.intPtr --; // remove end position of the arguments
3848 	this.variablesCounter[this.nestedType] = 0;
3849 	this.nestedType--;
3850 	ASTNode initialization = fieldDeclaration.initialization;
3851 	if (initialization != null) {
3852 		initialization.sourceEnd = declarationSourceEnd;
3853 	}
3854 }
consumeEnumDeclaration()3855 protected void consumeEnumDeclaration() {
3856 	// EnumDeclaration ::= EnumHeader ClassHeaderImplementsopt EnumBody
3857 	int length;
3858 	if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
3859 		//there are length declarations
3860 		//dispatch according to the type of the declarations
3861 		dispatchDeclarationIntoEnumDeclaration(length);
3862 	}
3863 
3864 	TypeDeclaration enumDeclaration = (TypeDeclaration) this.astStack[this.astPtr];
3865 
3866 	//convert constructor that do not have the type's name into methods
3867 	boolean hasConstructor = enumDeclaration.checkConstructors(this);
3868 
3869 	//add the default constructor when needed
3870 	if (!hasConstructor) {
3871 		boolean insideFieldInitializer = false;
3872 		if (this.diet) {
3873 			for (int i = this.nestedType; i > 0; i--){
3874 				if (this.variablesCounter[i] > 0) {
3875 					insideFieldInitializer = true;
3876 					break;
3877 				}
3878 			}
3879 		}
3880 		enumDeclaration.createDefaultConstructor(!this.diet || insideFieldInitializer, true);
3881 	}
3882 
3883 	//always add <clinit> (will be remove at code gen time if empty)
3884 	if (this.scanner.containsAssertKeyword) {
3885 		enumDeclaration.bits |= ASTNode.ContainsAssertion;
3886 	}
3887 	enumDeclaration.addClinit();
3888 	enumDeclaration.bodyEnd = this.endStatementPosition;
3889 	if (length == 0 && !containsComment(enumDeclaration.bodyStart, enumDeclaration.bodyEnd)) {
3890 		enumDeclaration.bits |= ASTNode.UndocumentedEmptyBlock;
3891 	}
3892 
3893 	enumDeclaration.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
3894 }
consumeEnumDeclarations()3895 protected void consumeEnumDeclarations() {
3896 	// Do nothing by default
3897 }
consumeEnumHeader()3898 protected void consumeEnumHeader() {
3899 	TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
3900 	if (this.currentToken == TokenNameLBRACE) {
3901 		typeDecl.bodyStart = this.scanner.currentPosition;
3902 	}
3903 
3904 	if (this.currentElement != null) {
3905 		this.restartRecovery = true; // used to avoid branching back into the regular automaton
3906 	}
3907 
3908 	// flush the comments related to the enum header
3909 	this.scanner.commentPtr = -1;
3910 }
consumeEnumHeaderName()3911 protected void consumeEnumHeaderName() {
3912 	// EnumHeaderName ::= Modifiersopt 'enum' Identifier
3913 	TypeDeclaration enumDeclaration = new TypeDeclaration(this.compilationUnit.compilationResult);
3914 	if (this.nestedMethod[this.nestedType] == 0) {
3915 		if (this.nestedType != 0) {
3916 			enumDeclaration.bits |= ASTNode.IsMemberType;
3917 		}
3918 	} else {
3919 		// Record that the block has a declaration for local types
3920 //		markEnclosingMemberWithLocalType();
3921 		blockReal();
3922 	}
3923 	//highlight the name of the type
3924 	long pos = this.identifierPositionStack[this.identifierPtr];
3925 	enumDeclaration.sourceEnd = (int) pos;
3926 	enumDeclaration.sourceStart = (int) (pos >>> 32);
3927 	enumDeclaration.name = this.identifierStack[this.identifierPtr--];
3928 	this.identifierLengthPtr--;
3929 
3930 	//compute the declaration source too
3931 	// 'class' and 'interface' push two int positions: the beginning of the class token and its end.
3932 	// we want to keep the beginning position but get rid of the end position
3933 	// it is only used for the ClassLiteralAccess positions.
3934 	enumDeclaration.declarationSourceStart = this.intStack[this.intPtr--];
3935 	this.intPtr--; // remove the end position of the class token
3936 
3937 	enumDeclaration.modifiersSourceStart = this.intStack[this.intPtr--];
3938 	enumDeclaration.modifiers = this.intStack[this.intPtr--] | ClassFileConstants.AccEnum;
3939 	if (enumDeclaration.modifiersSourceStart >= 0) {
3940 		enumDeclaration.declarationSourceStart = enumDeclaration.modifiersSourceStart;
3941 	}
3942 
3943 	// Store secondary info
3944 	if ((enumDeclaration.bits & ASTNode.IsMemberType) == 0 && (enumDeclaration.bits & ASTNode.IsLocalType) == 0) {
3945 		if (this.compilationUnit != null && !CharOperation.equals(enumDeclaration.name, this.compilationUnit.getMainTypeName())) {
3946 			enumDeclaration.bits |= ASTNode.IsSecondaryType;
3947 		}
3948 	}
3949 
3950 	// consume annotations
3951 	int length;
3952 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3953 		System.arraycopy(
3954 			this.expressionStack,
3955 			(this.expressionPtr -= length) + 1,
3956 			enumDeclaration.annotations = new Annotation[length],
3957 			0,
3958 			length);
3959 	}
3960 //	if (this.currentToken == TokenNameLBRACE) {
3961 //		enumDeclaration.bodyStart = this.scanner.currentPosition;
3962 //	}
3963 	enumDeclaration.bodyStart = enumDeclaration.sourceEnd + 1;
3964 	pushOnAstStack(enumDeclaration);
3965 
3966 	this.listLength = 0; // will be updated when reading super-interfaces
3967 
3968 	if(!this.statementRecoveryActivated &&
3969 			this.options.sourceLevel < ClassFileConstants.JDK1_5 &&
3970 			this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
3971 		//TODO this code will be never run while 'enum' is an identifier in 1.3 scanner
3972 		problemReporter().invalidUsageOfEnumDeclarations(enumDeclaration);
3973 	}
3974 
3975 	// recovery
3976 	if (this.currentElement != null){
3977 		this.lastCheckPoint = enumDeclaration.bodyStart;
3978 		this.currentElement = this.currentElement.add(enumDeclaration, 0);
3979 		this.lastIgnoredToken = -1;
3980 	}
3981 	// javadoc
3982 	enumDeclaration.javadoc = this.javadoc;
3983 	this.javadoc = null;
3984 }
consumeEnumHeaderNameWithTypeParameters()3985 protected void consumeEnumHeaderNameWithTypeParameters() {
3986 	// EnumHeaderNameWithTypeParameters ::= Modifiersopt 'enum' Identifier TypeParameters
3987 	TypeDeclaration enumDeclaration = new TypeDeclaration(this.compilationUnit.compilationResult);
3988 	// consume type parameters
3989 	int length = this.genericsLengthStack[this.genericsLengthPtr--];
3990 	this.genericsPtr -= length;
3991 	System.arraycopy(this.genericsStack, this.genericsPtr + 1, enumDeclaration.typeParameters = new TypeParameter[length], 0, length);
3992 
3993 	problemReporter().invalidUsageOfTypeParametersForEnumDeclaration(enumDeclaration);
3994 
3995 	enumDeclaration.bodyStart = enumDeclaration.typeParameters[length-1].declarationSourceEnd + 1;
3996 
3997 //	enumDeclaration.typeParameters = null;
3998 
3999 	this.listTypeParameterLength = 0;
4000 
4001 	if (this.nestedMethod[this.nestedType] == 0) {
4002 		if (this.nestedType != 0) {
4003 			enumDeclaration.bits |= ASTNode.IsMemberType;
4004 		}
4005 	} else {
4006 		// Record that the block has a declaration for local types
4007 //		markEnclosingMemberWithLocalType();
4008 		blockReal();
4009 	}
4010 	//highlight the name of the type
4011 	long pos = this.identifierPositionStack[this.identifierPtr];
4012 	enumDeclaration.sourceEnd = (int) pos;
4013 	enumDeclaration.sourceStart = (int) (pos >>> 32);
4014 	enumDeclaration.name = this.identifierStack[this.identifierPtr--];
4015 	this.identifierLengthPtr--;
4016 
4017 	//compute the declaration source too
4018 	// 'class' and 'interface' push two int positions: the beginning of the class token and its end.
4019 	// we want to keep the beginning position but get rid of the end position
4020 	// it is only used for the ClassLiteralAccess positions.
4021 	enumDeclaration.declarationSourceStart = this.intStack[this.intPtr--];
4022 	this.intPtr--; // remove the end position of the class token
4023 
4024 	enumDeclaration.modifiersSourceStart = this.intStack[this.intPtr--];
4025 	enumDeclaration.modifiers = this.intStack[this.intPtr--] | ClassFileConstants.AccEnum;
4026 	if (enumDeclaration.modifiersSourceStart >= 0) {
4027 		enumDeclaration.declarationSourceStart = enumDeclaration.modifiersSourceStart;
4028 	}
4029 
4030 	// Store secondary info
4031 	if ((enumDeclaration.bits & ASTNode.IsMemberType) == 0 && (enumDeclaration.bits & ASTNode.IsLocalType) == 0) {
4032 		if (this.compilationUnit != null && !CharOperation.equals(enumDeclaration.name, this.compilationUnit.getMainTypeName())) {
4033 			enumDeclaration.bits |= ASTNode.IsSecondaryType;
4034 		}
4035 	}
4036 
4037 	// consume annotations
4038 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
4039 		System.arraycopy(
4040 			this.expressionStack,
4041 			(this.expressionPtr -= length) + 1,
4042 			enumDeclaration.annotations = new Annotation[length],
4043 			0,
4044 			length);
4045 	}
4046 //	if (this.currentToken == TokenNameLBRACE) {
4047 //		enumDeclaration.bodyStart = this.scanner.currentPosition;
4048 //	}
4049 	enumDeclaration.bodyStart = enumDeclaration.sourceEnd + 1;
4050 	pushOnAstStack(enumDeclaration);
4051 
4052 	this.listLength = 0; // will be updated when reading super-interfaces
4053 
4054 	if(!this.statementRecoveryActivated &&
4055 			this.options.sourceLevel < ClassFileConstants.JDK1_5 &&
4056 			this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
4057 		//TODO this code will be never run while 'enum' is an identifier in 1.3 scanner
4058 		problemReporter().invalidUsageOfEnumDeclarations(enumDeclaration);
4059 	}
4060 
4061 	// recovery
4062 	if (this.currentElement != null){
4063 		this.lastCheckPoint = enumDeclaration.bodyStart;
4064 		this.currentElement = this.currentElement.add(enumDeclaration, 0);
4065 		this.lastIgnoredToken = -1;
4066 	}
4067 	// javadoc
4068 	enumDeclaration.javadoc = this.javadoc;
4069 	this.javadoc = null;
4070 }
consumeEqualityExpression(int op)4071 protected void consumeEqualityExpression(int op) {
4072 	// EqualityExpression ::= EqualityExpression '==' RelationalExpression
4073 	// EqualityExpression ::= EqualityExpression '!=' RelationalExpression
4074 
4075 	//optimize the push/pop
4076 
4077 	this.expressionPtr--;
4078 	this.expressionLengthPtr--;
4079 	this.expressionStack[this.expressionPtr] =
4080 		new EqualExpression(
4081 			this.expressionStack[this.expressionPtr],
4082 			this.expressionStack[this.expressionPtr + 1],
4083 			op);
4084 }
4085 /*
4086  * @param op
4087  */
consumeEqualityExpressionWithName(int op)4088 protected void consumeEqualityExpressionWithName(int op) {
4089 	// EqualityExpression ::= Name '==' RelationalExpression
4090 	// EqualityExpression ::= Name '!=' RelationalExpression
4091 	pushOnExpressionStack(getUnspecifiedReferenceOptimized());
4092 	this.expressionPtr--;
4093 	this.expressionLengthPtr--;
4094 	this.expressionStack[this.expressionPtr] =
4095 		new EqualExpression(
4096 			this.expressionStack[this.expressionPtr + 1],
4097 			this.expressionStack[this.expressionPtr],
4098 			op);
4099 }
consumeExitMemberValue()4100 protected void consumeExitMemberValue() {
4101 	// ExitMemberValue ::= $empty
4102 	if (this.currentElement != null && this.currentElement instanceof RecoveredAnnotation) {
4103 		RecoveredAnnotation recoveredAnnotation = (RecoveredAnnotation)this.currentElement;
4104 		recoveredAnnotation.hasPendingMemberValueName = false;
4105 		recoveredAnnotation.memberValuPairEqualEnd = -1;
4106 	}
4107 }
consumeExitTryBlock()4108 protected void consumeExitTryBlock() {
4109 	//ExitTryBlock ::= $empty
4110 	if(this.currentElement != null) {
4111 		this.restartRecovery = true;
4112 	}
4113 }
consumeExitVariableWithInitialization()4114 protected void consumeExitVariableWithInitialization() {
4115 	// ExitVariableWithInitialization ::= $empty
4116 	// do nothing by default
4117 	this.expressionLengthPtr--;
4118 	AbstractVariableDeclaration variableDecl = (AbstractVariableDeclaration) this.astStack[this.astPtr];
4119 	variableDecl.initialization = this.expressionStack[this.expressionPtr--];
4120 	// we need to update the declarationSourceEnd of the local variable declaration to the
4121 	// source end position of the initialization expression
4122 	variableDecl.declarationSourceEnd = variableDecl.initialization.sourceEnd;
4123 	variableDecl.declarationEnd = variableDecl.initialization.sourceEnd;
4124 
4125 	recoveryExitFromVariable();
4126 }
consumeExitVariableWithoutInitialization()4127 protected void consumeExitVariableWithoutInitialization() {
4128 	// ExitVariableWithoutInitialization ::= $empty
4129 	// do nothing by default
4130 
4131 	AbstractVariableDeclaration variableDecl = (AbstractVariableDeclaration) this.astStack[this.astPtr];
4132 	variableDecl.declarationSourceEnd = variableDecl.declarationEnd;
4133 	if(this.currentElement != null && this.currentElement instanceof RecoveredField) {
4134 		if(this.endStatementPosition > variableDecl.sourceEnd) {
4135 			this.currentElement.updateSourceEndIfNecessary(this.endStatementPosition);
4136 		}
4137 	}
4138 	recoveryExitFromVariable();
4139 }
consumeExplicitConstructorInvocation(int flag, int recFlag)4140 protected void consumeExplicitConstructorInvocation(int flag, int recFlag) {
4141 
4142 	/* flag allows to distinguish 3 cases :
4143 	(0) :
4144 	ExplicitConstructorInvocation ::= 'this' '(' ArgumentListopt ')' ';'
4145 	ExplicitConstructorInvocation ::= 'super' '(' ArgumentListopt ')' ';'
4146 	(1) :
4147 	ExplicitConstructorInvocation ::= Primary '.' 'super' '(' ArgumentListopt ')' ';'
4148 	ExplicitConstructorInvocation ::= Primary '.' 'this' '(' ArgumentListopt ')' ';'
4149 	(2) :
4150 	ExplicitConstructorInvocation ::= Name '.' 'super' '(' ArgumentListopt ')' ';'
4151 	ExplicitConstructorInvocation ::= Name '.' 'this' '(' ArgumentListopt ')' ';'
4152 	*/
4153 	int startPosition = this.intStack[this.intPtr--];
4154 	ExplicitConstructorCall ecc = new ExplicitConstructorCall(recFlag);
4155 	int length;
4156 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
4157 		this.expressionPtr -= length;
4158 		System.arraycopy(this.expressionStack, this.expressionPtr + 1, ecc.arguments = new Expression[length], 0, length);
4159 	}
4160 	switch (flag) {
4161 		case 0 :
4162 			ecc.sourceStart = startPosition;
4163 			break;
4164 		case 1 :
4165 			this.expressionLengthPtr--;
4166 			ecc.sourceStart = (ecc.qualification = this.expressionStack[this.expressionPtr--]).sourceStart;
4167 			break;
4168 		case 2 :
4169 			ecc.sourceStart = (ecc.qualification = getUnspecifiedReferenceOptimized()).sourceStart;
4170 			break;
4171 	}
4172 	pushOnAstStack(ecc);
4173 	ecc.sourceEnd = this.endStatementPosition;
4174 }
consumeExplicitConstructorInvocationWithTypeArguments(int flag, int recFlag)4175 protected void consumeExplicitConstructorInvocationWithTypeArguments(int flag, int recFlag) {
4176 
4177 	/* flag allows to distinguish 3 cases :
4178 	(0) :
4179 	ExplicitConstructorInvocation ::= TypeArguments 'this' '(' ArgumentListopt ')' ';'
4180 	ExplicitConstructorInvocation ::= TypeArguments 'super' '(' ArgumentListopt ')' ';'
4181 	(1) :
4182 	ExplicitConstructorInvocation ::= Primary '.' TypeArguments 'super' '(' ArgumentListopt ')' ';'
4183 	ExplicitConstructorInvocation ::= Primary '.' TypeArguments 'this' '(' ArgumentListopt ')' ';'
4184 	(2) :
4185 	ExplicitConstructorInvocation ::= Name '.' TypeArguments 'super' '(' ArgumentListopt ')' ';'
4186 	ExplicitConstructorInvocation ::= Name '.' TypeArguments 'this' '(' ArgumentListopt ')' ';'
4187 	*/
4188 	int startPosition = this.intStack[this.intPtr--];
4189 	ExplicitConstructorCall ecc = new ExplicitConstructorCall(recFlag);
4190 	int length;
4191 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
4192 		this.expressionPtr -= length;
4193 		System.arraycopy(this.expressionStack, this.expressionPtr + 1, ecc.arguments = new Expression[length], 0, length);
4194 	}
4195 	length = this.genericsLengthStack[this.genericsLengthPtr--];
4196 	this.genericsPtr -= length;
4197 	System.arraycopy(this.genericsStack, this.genericsPtr + 1, ecc.typeArguments = new TypeReference[length], 0, length);
4198 	ecc.typeArgumentsSourceStart = this.intStack[this.intPtr--];
4199 
4200 	switch (flag) {
4201 		case 0 :
4202 			ecc.sourceStart = startPosition;
4203 			break;
4204 		case 1 :
4205 			this.expressionLengthPtr--;
4206 			ecc.sourceStart = (ecc.qualification = this.expressionStack[this.expressionPtr--]).sourceStart;
4207 			break;
4208 		case 2 :
4209 			ecc.sourceStart = (ecc.qualification = getUnspecifiedReferenceOptimized()).sourceStart;
4210 			break;
4211 	}
4212 
4213 	pushOnAstStack(ecc);
4214 	ecc.sourceEnd = this.endStatementPosition;
4215 }
consumeExpressionStatement()4216 protected void consumeExpressionStatement() {
4217 	// ExpressionStatement ::= StatementExpression ';'
4218 	this.expressionLengthPtr--;
4219 	Expression expression = this.expressionStack[this.expressionPtr--];
4220 	expression.statementEnd = this.endStatementPosition;
4221 	expression.bits |= ASTNode.InsideExpressionStatement;
4222 	pushOnAstStack(expression);
4223 }
consumeFieldAccess(boolean isSuperAccess)4224 protected void consumeFieldAccess(boolean isSuperAccess) {
4225 	// FieldAccess ::= Primary '.' 'Identifier'
4226 	// FieldAccess ::= 'super' '.' 'Identifier'
4227 
4228 	FieldReference fr =
4229 		new FieldReference(
4230 			this.identifierStack[this.identifierPtr],
4231 			this.identifierPositionStack[this.identifierPtr--]);
4232 	this.identifierLengthPtr--;
4233 	if (isSuperAccess) {
4234 		//considers the fieldReference beginning at the 'super' ....
4235 		fr.sourceStart = this.intStack[this.intPtr--];
4236 		fr.receiver = new SuperReference(fr.sourceStart, this.endPosition);
4237 		pushOnExpressionStack(fr);
4238 	} else {
4239 		//optimize push/pop
4240 		fr.receiver = this.expressionStack[this.expressionPtr];
4241 		//field reference begins at the receiver
4242 		fr.sourceStart = fr.receiver.sourceStart;
4243 		this.expressionStack[this.expressionPtr] = fr;
4244 	}
4245 }
consumeFieldDeclaration()4246 protected void consumeFieldDeclaration() {
4247 	// See consumeLocalVariableDeclarationDefaultModifier() in case of change: duplicated code
4248 	// FieldDeclaration ::= Modifiersopt Type VariableDeclarators ';'
4249 
4250 	/*
4251 	this.astStack :
4252 	this.expressionStack: Expression Expression ...... Expression
4253 	this.identifierStack : type  identifier identifier ...... identifier
4254 	this.intStack : typeDim      dim        dim               dim
4255 	 ==>
4256 	this.astStack : FieldDeclaration FieldDeclaration ...... FieldDeclaration
4257 	this.expressionStack :
4258 	this.identifierStack :
4259 	this.intStack :
4260 
4261 	*/
4262 	int variableDeclaratorsCounter = this.astLengthStack[this.astLengthPtr];
4263 
4264 	for (int i = variableDeclaratorsCounter - 1; i >= 0; i--) {
4265 		FieldDeclaration fieldDeclaration = (FieldDeclaration) this.astStack[this.astPtr - i];
4266 		fieldDeclaration.declarationSourceEnd = this.endStatementPosition;
4267 		fieldDeclaration.declarationEnd = this.endStatementPosition;	// semi-colon included
4268 	}
4269 
4270 	updateSourceDeclarationParts(variableDeclaratorsCounter);
4271 	int endPos = flushCommentsDefinedPriorTo(this.endStatementPosition);
4272 	if (endPos != this.endStatementPosition) {
4273 		for (int i = 0; i < variableDeclaratorsCounter; i++) {
4274 			FieldDeclaration fieldDeclaration = (FieldDeclaration) this.astStack[this.astPtr - i];
4275 			fieldDeclaration.declarationSourceEnd = endPos;
4276 		}
4277 	}
4278 	// update the this.astStack, this.astPtr and this.astLengthStack
4279 	int startIndex = this.astPtr - this.variablesCounter[this.nestedType] + 1;
4280 	System.arraycopy(
4281 		this.astStack,
4282 		startIndex,
4283 		this.astStack,
4284 		startIndex - 1,
4285 		variableDeclaratorsCounter);
4286 	this.astPtr--; // remove the type reference
4287 	this.astLengthStack[--this.astLengthPtr] = variableDeclaratorsCounter;
4288 
4289 	// recovery
4290 	if (this.currentElement != null) {
4291 		this.lastCheckPoint = endPos + 1;
4292 		if (this.currentElement.parent != null && this.currentElement instanceof RecoveredField){
4293 			if (!(this.currentElement instanceof RecoveredInitializer)) {
4294 				this.currentElement = this.currentElement.parent;
4295 			}
4296 		}
4297 		this.restartRecovery = true;
4298 	}
4299 	this.variablesCounter[this.nestedType] = 0;
4300 }
consumeForceNoDiet()4301 protected void consumeForceNoDiet() {
4302 	// ForceNoDiet ::= $empty
4303 	this.dietInt++;
4304 }
consumeForInit()4305 protected void consumeForInit() {
4306 	// ForInit ::= StatementExpressionList
4307 	pushOnAstLengthStack(-1);
4308 	this.forStartPosition = 0;
4309 }
consumeFormalParameter(boolean isVarArgs)4310 protected void consumeFormalParameter(boolean isVarArgs) {
4311 	// FormalParameter ::= Modifiersopt Type VariableDeclaratorIdOrThis
4312 	// FormalParameter ::= Modifiersopt Type PushZeroTypeAnnotations '...' VariableDeclaratorIdOrThis
4313 	// FormalParameter ::= Modifiersopt Type @308... TypeAnnotations '...' VariableDeclaratorIdOrThis
4314 	/*
4315 	this.astStack :
4316 	this.identifierStack : type identifier
4317 	this.intStack : dim dim 1||0  // 1 => normal parameter, 0 => this parameter
4318 	 ==>
4319 	this.astStack : Argument
4320 	this.identifierStack :
4321 	this.intStack :
4322 	*/
4323 	NameReference qualifyingNameReference = null;
4324     boolean isReceiver = this.intStack[this.intPtr--] == 0;  // flag pushed in consumeExplicitThisParameter -> 0, consumeVariableDeclaratorIdParameter -> 1
4325     if (isReceiver) {
4326     	qualifyingNameReference = (NameReference) this.expressionStack[this.expressionPtr--];
4327     	this.expressionLengthPtr --;
4328     }
4329 	this.identifierLengthPtr--;
4330 	char[] identifierName = this.identifierStack[this.identifierPtr];
4331 	long namePositions = this.identifierPositionStack[this.identifierPtr--];
4332 	int extendedDimensions = this.intStack[this.intPtr--];
4333 	Annotation [][] annotationsOnExtendedDimensions = extendedDimensions == 0 ? null : getAnnotationsOnDimensions(extendedDimensions);
4334 	Annotation [] varArgsAnnotations = null;
4335 	int endOfEllipsis = 0;
4336 	int length;
4337 	if (isVarArgs) {
4338 		endOfEllipsis = this.intStack[this.intPtr--];
4339 		if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
4340 			System.arraycopy(
4341 				this.typeAnnotationStack,
4342 				(this.typeAnnotationPtr -= length) + 1,
4343 				varArgsAnnotations = new Annotation[length],
4344 				0,
4345 				length);
4346 		}
4347 	}
4348 	int firstDimensions = this.intStack[this.intPtr--];
4349 	TypeReference type = getTypeReference(firstDimensions);
4350 	if (isVarArgs || extendedDimensions != 0) {
4351 		if (isVarArgs) {
4352 			type = augmentTypeWithAdditionalDimensions(type, 1, varArgsAnnotations != null ? new Annotation[][] { varArgsAnnotations } : null, true);
4353 		}
4354 		if (extendedDimensions != 0) {
4355 			type = augmentTypeWithAdditionalDimensions(type, extendedDimensions, annotationsOnExtendedDimensions, false);
4356 		}
4357 		type.sourceEnd = type.isParameterizedTypeReference() ? this.endStatementPosition : this.endPosition;
4358 	}
4359 	if (isVarArgs) {
4360 		if (extendedDimensions == 0) {
4361 			type.sourceEnd = endOfEllipsis;
4362 		}
4363 		type.bits |= ASTNode.IsVarArgs; // set isVarArgs
4364 	}
4365 	int modifierPositions = this.intStack[this.intPtr--];
4366 	Argument arg;
4367 	if (isReceiver) {
4368 		arg = new Receiver(
4369 				identifierName,
4370 				namePositions,
4371 				type,
4372 				qualifyingNameReference,
4373 				this.intStack[this.intPtr--] & ~ClassFileConstants.AccDeprecated);
4374 	} else {
4375 		arg = new Argument(
4376 			identifierName,
4377 			namePositions,
4378 			type,
4379 			this.intStack[this.intPtr--] & ~ClassFileConstants.AccDeprecated); // modifiers
4380 	}
4381 	arg.declarationSourceStart = modifierPositions;
4382 	arg.bits |= (type.bits & ASTNode.HasTypeAnnotations);
4383 	// consume annotations
4384 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
4385 		System.arraycopy(
4386 			this.expressionStack,
4387 			(this.expressionPtr -= length) + 1,
4388 			arg.annotations = new Annotation[length],
4389 			0,
4390 			length);
4391 		arg.bits |= ASTNode.HasTypeAnnotations;
4392 		RecoveredType currentRecoveryType = this.currentRecoveryType();
4393 		if (currentRecoveryType != null)
4394 			currentRecoveryType.annotationsConsumed(arg.annotations);
4395 	}
4396 	pushOnAstStack(arg);
4397 
4398 	/* if incomplete method header, this.listLength counter will not have been reset,
4399 		indicating that some arguments are available on the stack */
4400 	this.listLength++;
4401 
4402 	if(isVarArgs) {
4403 		if (!this.statementRecoveryActivated &&
4404 				this.options.sourceLevel < ClassFileConstants.JDK1_5 &&
4405 				this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
4406 				problemReporter().invalidUsageOfVarargs(arg);
4407 		} else if (!this.statementRecoveryActivated &&
4408 				extendedDimensions > 0) {
4409 			problemReporter().illegalExtendedDimensions(arg);
4410 		}
4411 	}
4412 }
getAnnotationsOnDimensions(int dimensionsCount)4413 protected Annotation[][] getAnnotationsOnDimensions(int dimensionsCount) {
4414 	Annotation [][] dimensionsAnnotations = null;
4415 	if (dimensionsCount > 0) {
4416 		for (int i = 0; i < dimensionsCount; i++) {
4417 			Annotation [] annotations = null;
4418 			int length;
4419 			if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
4420 				System.arraycopy(
4421 						this.typeAnnotationStack,
4422 						(this.typeAnnotationPtr -= length) + 1,
4423 						annotations = new Annotation[length],
4424 						0,
4425 						length);
4426 				if (dimensionsAnnotations == null) {
4427 					dimensionsAnnotations = new Annotation[dimensionsCount][];
4428 				}
4429 				dimensionsAnnotations[dimensionsCount - i - 1] = annotations;
4430 			}
4431 		}
4432 	}
4433 	return dimensionsAnnotations;
4434 }
consumeFormalParameterList()4435 protected void consumeFormalParameterList() {
4436 	// FormalParameterList ::= FormalParameterList ',' FormalParameter
4437 	// TypeElidedFormalParameterList ::= TypeElidedFormalParameterList ',' TypeElidedFormalParameter
4438 	optimizedConcatNodeLists();
4439 }
consumeFormalParameterListopt()4440 protected void consumeFormalParameterListopt() {
4441 	// FormalParameterListopt ::= $empty
4442 	pushOnAstLengthStack(0);
4443 }
consumeGenericType()4444 protected void consumeGenericType() {
4445 	// GenericType ::= ClassOrInterface TypeArguments
4446 	// nothing to do
4447 	// Will be consume by a getTypeReference call
4448 }
consumeGenericTypeArrayType()4449 protected void consumeGenericTypeArrayType() {
4450 	// nothing to do
4451 	// Will be consume by a getTypeReference call
4452 }
consumeGenericTypeNameArrayType()4453 protected void consumeGenericTypeNameArrayType() {
4454 	// nothing to do
4455 	// Will be consume by a getTypeReference call
4456 }
consumeGenericTypeWithDiamond()4457 protected void consumeGenericTypeWithDiamond() {
4458 	// GenericType ::= ClassOrInterface '<' '>'
4459 	// zero type arguments == <>
4460 	pushOnGenericsLengthStack(-1);
4461 	concatGenericsLists();
4462 	this.intPtr--;	// pop the null dimension pushed in by consumeReferenceType, as we have no type between <>, getTypeReference won't kick in
4463 }
consumeImportDeclaration()4464 protected void consumeImportDeclaration() {
4465 	// SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName ';'
4466 	ImportReference impt = (ImportReference) this.astStack[this.astPtr];
4467 	// flush annotations defined prior to import statements
4468 	impt.declarationEnd = this.endStatementPosition;
4469 	impt.declarationSourceEnd =
4470 		flushCommentsDefinedPriorTo(impt.declarationSourceEnd);
4471 
4472 	// recovery
4473 	if (this.currentElement != null) {
4474 		this.lastCheckPoint = impt.declarationSourceEnd + 1;
4475 		this.currentElement = this.currentElement.add(impt, 0);
4476 		this.lastIgnoredToken = -1;
4477 		this.restartRecovery = true;
4478 		// used to avoid branching back into the regular automaton
4479 	}
4480 }
consumeImportDeclarations()4481 protected void consumeImportDeclarations() {
4482 	// ImportDeclarations ::= ImportDeclarations ImportDeclaration
4483 	optimizedConcatNodeLists();
4484 }
consumeInsideCastExpression()4485 protected void consumeInsideCastExpression() {
4486 	// InsideCastExpression ::= $empty
4487 }
consumeInsideCastExpressionLL1()4488 protected void consumeInsideCastExpressionLL1() {
4489 	// InsideCastExpressionLL1 ::= $empty
4490 	pushOnGenericsLengthStack(0); // handle type arguments
4491 	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
4492 	pushOnExpressionStack(getTypeReference(0));
4493 }
consumeInsideCastExpressionLL1WithBounds()4494 protected void consumeInsideCastExpressionLL1WithBounds() {
4495 	// InsideCastExpressionLL1WithBounds ::= $empty
4496 	int additionalBoundsLength = this.genericsLengthStack[this.genericsLengthPtr--];
4497 	TypeReference[] bounds = new TypeReference[additionalBoundsLength + 1];
4498 	this.genericsPtr -= additionalBoundsLength;
4499 	System.arraycopy(this.genericsStack, this.genericsPtr + 1, bounds, 1, additionalBoundsLength);
4500 
4501 	pushOnGenericsLengthStack(0); // handle type arguments
4502 	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
4503 	bounds[0] = getTypeReference(0);
4504 
4505 	for (int i = 0; i <= additionalBoundsLength; i++) {
4506 		pushOnExpressionStack(bounds[i]);
4507 		if (i > 0)
4508 			this.expressionLengthStack[--this.expressionLengthPtr]++;
4509 	}
4510 }
consumeInsideCastExpressionWithQualifiedGenerics()4511 protected void consumeInsideCastExpressionWithQualifiedGenerics() {
4512 	// InsideCastExpressionWithQualifiedGenerics ::= $empty
4513 }
consumeTypeTestPattern()4514 private void consumeTypeTestPattern() {
4515 	TypeReference type;
4516 	char[] identifierName = this.identifierStack[this.identifierPtr];
4517 	long namePosition = this.identifierPositionStack[this.identifierPtr];
4518 
4519 	LocalDeclaration local = createLocalDeclaration(identifierName, (int) (namePosition >>> 32), (int) namePosition);
4520 	local.declarationSourceEnd = local.declarationEnd;
4521 
4522 	this.identifierPtr--;
4523 	this.identifierLengthPtr--;
4524 
4525 	type = getTypeReference(this.intStack[this.intPtr--]); //getTypeReference(0); // no type dimension
4526 	local.declarationSourceStart = type.sourceStart;
4527 	local.type = type;
4528 	if (!this.parsingJava14Plus) {
4529 		problemReporter().previewFeatureNotSupported(type.sourceStart, local.declarationEnd, "Instanceof Pattern", CompilerOptions.VERSION_13); //$NON-NLS-1$
4530 	} else if (!this.options.enablePreviewFeatures){
4531 		problemReporter().previewFeatureNotEnabled(type.sourceStart, local.declarationEnd, "Instanceof Pattern"); //$NON-NLS-1$
4532 	} else {
4533 		if (this.options.isAnyEnabled(IrritantSet.PREVIEW)) {
4534 			problemReporter().previewFeatureUsed(type.sourceStart, local.declarationEnd);
4535 		}
4536 	}
4537 	local.modifiers |= ClassFileConstants.AccFinal;
4538 	pushOnPatternStack(local);
4539 }
consumeInstanceOfExpression()4540 protected void consumeInstanceOfExpression() {
4541 	// RelationalExpression ::= RelationalExpression 'instanceof' ReferenceType
4542 	//optimize the push/pop
4543 
4544 	//by construction, no base type may be used in getTypeReference
4545 	int length = this.patternLengthPtr >= 0 ?
4546 			this.patternLengthStack[this.patternLengthPtr--] : 0;
4547 	Expression exp;
4548 	if (length > 0) {
4549 		LocalDeclaration typeDecl = (LocalDeclaration) this.patternStack[this.patternPtr--];
4550 		this.expressionStack[this.expressionPtr] = exp =
4551 				new InstanceOfExpression(
4552 					this.expressionStack[this.expressionPtr],
4553 					typeDecl);
4554 	} else {
4555 		this.expressionStack[this.expressionPtr] = exp =
4556 				new InstanceOfExpression(
4557 					this.expressionStack[this.expressionPtr],
4558 					getTypeReference(this.intStack[this.intPtr--]));
4559 	}
4560 
4561 	if (exp.sourceEnd == 0) {
4562 		//array on base type....
4563 		exp.sourceEnd = this.scanner.startPosition - 1;
4564 	}
4565 	//the scanner is on the next token already....
4566 }
consumeInstanceOfExpressionWithName()4567 protected void consumeInstanceOfExpressionWithName() {
4568 	// RelationalExpression_NotName ::= Name instanceof ReferenceType
4569 	//optimize the push/pop
4570 
4571 	int length = this.patternLengthPtr >= 0 ?
4572 			this.patternLengthStack[this.patternLengthPtr--] : 0;
4573 	Expression exp;
4574 	if (length != 0) {
4575 		LocalDeclaration typeDecl = (LocalDeclaration) this.patternStack[this.patternPtr--];
4576 		pushOnExpressionStack(getUnspecifiedReferenceOptimized());
4577 		this.expressionStack[this.expressionPtr] = exp =
4578 				new InstanceOfExpression(
4579 					this.expressionStack[this.expressionPtr],
4580 					typeDecl);
4581 	} else {
4582 	//by construction, no base type may be used in getTypeReference
4583 		TypeReference reference = getTypeReference(this.intStack[this.intPtr--]);
4584 		pushOnExpressionStack(getUnspecifiedReferenceOptimized());
4585 		this.expressionStack[this.expressionPtr] = exp =
4586 				new InstanceOfExpression(
4587 						this.expressionStack[this.expressionPtr],
4588 						reference);
4589 	}
4590 	if (exp.sourceEnd == 0) {
4591 		//array on base type....
4592 		exp.sourceEnd = this.scanner.startPosition - 1;
4593 	}
4594 	//the scanner is on the next token already....
4595 }
consumeInterfaceDeclaration()4596 protected void consumeInterfaceDeclaration() {
4597 	// see consumeClassDeclaration in case of changes: duplicated code
4598 	// InterfaceDeclaration ::= InterfaceHeader InterfaceBody
4599 	int length;
4600 	if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
4601 		//there are length declarations
4602 		//dispatch.....according to the type of the declarations
4603 		dispatchDeclarationInto(length);
4604 	}
4605 
4606 	TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
4607 
4608 	//convert constructor that do not have the type's name into methods
4609 	typeDecl.checkConstructors(this);
4610 
4611 	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=212713,
4612 	// reject initializers that have been tolerated by the grammar.
4613 	FieldDeclaration [] fields = typeDecl.fields;
4614 	int fieldCount = fields == null ? 0 : fields.length;
4615 	for (int i = 0; i < fieldCount; i++) {
4616 		FieldDeclaration field = fields[i];
4617 		if (field instanceof Initializer) {
4618 			problemReporter().interfaceCannotHaveInitializers(typeDecl.name, field);
4619 		}
4620 	}
4621 
4622 	//always add <clinit> (will be remove at code gen time if empty)
4623 	if (this.scanner.containsAssertKeyword) {
4624 		typeDecl.bits |= ASTNode.ContainsAssertion;
4625 	}
4626 	typeDecl.addClinit();
4627 	typeDecl.bodyEnd = this.endStatementPosition;
4628 	if (length == 0 && !containsComment(typeDecl.bodyStart, typeDecl.bodyEnd)) {
4629 		typeDecl.bits |= ASTNode.UndocumentedEmptyBlock;
4630 	}
4631 	typeDecl.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
4632 }
consumeInterfaceHeader()4633 protected void consumeInterfaceHeader() {
4634 	// InterfaceHeader ::= InterfaceHeaderName InterfaceHeaderExtendsopt
4635 
4636 	TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
4637 	if (this.currentToken == TokenNameLBRACE){
4638 		typeDecl.bodyStart = this.scanner.currentPosition;
4639 	}
4640 	if (this.currentElement != null){
4641 		this.restartRecovery = true; // used to avoid branching back into the regular automaton
4642 	}
4643 	// flush the comments related to the interface header
4644 	this.scanner.commentPtr = -1;
4645 }
consumeInterfaceHeaderExtends()4646 protected void consumeInterfaceHeaderExtends() {
4647 	// InterfaceHeaderExtends ::= 'extends' InterfaceTypeList
4648 	int length = this.astLengthStack[this.astLengthPtr--];
4649 	//super interfaces
4650 	this.astPtr -= length;
4651 	TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
4652 	System.arraycopy(
4653 		this.astStack,
4654 		this.astPtr + 1,
4655 		typeDecl.superInterfaces = new TypeReference[length],
4656 		0,
4657 		length);
4658 	TypeReference[] superinterfaces = typeDecl.superInterfaces;
4659 	for (int i = 0, max = superinterfaces.length; i < max; i++) {
4660 		TypeReference typeReference = superinterfaces[i];
4661 		typeDecl.bits |= (typeReference.bits & ASTNode.HasTypeAnnotations);
4662 		typeReference.bits |= ASTNode.IsSuperType;
4663 	}
4664 	typeDecl.bodyStart = typeDecl.superInterfaces[length-1].sourceEnd + 1;
4665 	this.listLength = 0; // reset after having read super-interfaces
4666 	// recovery
4667 	if (this.currentElement != null) {
4668 		this.lastCheckPoint = typeDecl.bodyStart;
4669 	}
4670 }
consumeInterfaceHeaderName1()4671 protected void consumeInterfaceHeaderName1() {
4672 	// InterfaceHeaderName ::= Modifiersopt 'interface' 'Identifier'
4673 	TypeDeclaration typeDecl = new TypeDeclaration(this.compilationUnit.compilationResult);
4674 
4675 	if (this.nestedMethod[this.nestedType] == 0) {
4676 		if (this.nestedType != 0) {
4677 			typeDecl.bits |= ASTNode.IsMemberType;
4678 		}
4679 	} else {
4680 		// Record that the block has a declaration for local types
4681 		typeDecl.bits |= ASTNode.IsLocalType;
4682 		markEnclosingMemberWithLocalType();
4683 		blockReal();
4684 	}
4685 
4686 	//highlight the name of the type
4687 	long pos = this.identifierPositionStack[this.identifierPtr];
4688 	typeDecl.sourceEnd = (int) pos;
4689 	typeDecl.sourceStart = (int) (pos >>> 32);
4690 	typeDecl.name = this.identifierStack[this.identifierPtr--];
4691 	this.identifierLengthPtr--;
4692 
4693 	//compute the declaration source too
4694 	// 'class' and 'interface' push two int positions: the beginning of the class token and its end.
4695 	// we want to keep the beginning position but get rid of the end position
4696 	// it is only used for the ClassLiteralAccess positions.
4697 	typeDecl.declarationSourceStart = this.intStack[this.intPtr--];
4698 	this.intPtr--; // remove the end position of the class token
4699 	typeDecl.modifiersSourceStart = this.intStack[this.intPtr--];
4700 	typeDecl.modifiers = this.intStack[this.intPtr--] | ClassFileConstants.AccInterface;
4701 	if (typeDecl.modifiersSourceStart >= 0) {
4702 		typeDecl.declarationSourceStart = typeDecl.modifiersSourceStart;
4703 	}
4704 
4705 	// Store secondary info
4706 	if ((typeDecl.bits & ASTNode.IsMemberType) == 0 && (typeDecl.bits & ASTNode.IsLocalType) == 0) {
4707 		if (this.compilationUnit != null && !CharOperation.equals(typeDecl.name, this.compilationUnit.getMainTypeName())) {
4708 			typeDecl.bits |= ASTNode.IsSecondaryType;
4709 		}
4710 	}
4711 
4712 	// consume annotations
4713 	int length;
4714 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
4715 		System.arraycopy(
4716 			this.expressionStack,
4717 			(this.expressionPtr -= length) + 1,
4718 			typeDecl.annotations = new Annotation[length],
4719 			0,
4720 			length);
4721 	}
4722 	typeDecl.bodyStart = typeDecl.sourceEnd + 1;
4723 	pushOnAstStack(typeDecl);
4724 	this.listLength = 0; // will be updated when reading super-interfaces
4725 	// recovery
4726 	if (this.currentElement != null){ // is recovering
4727 		this.lastCheckPoint = typeDecl.bodyStart;
4728 		this.currentElement = this.currentElement.add(typeDecl, 0);
4729 		this.lastIgnoredToken = -1;
4730 	}
4731 	// javadoc
4732 	typeDecl.javadoc = this.javadoc;
4733 	this.javadoc = null;
4734 }
consumeInterfaceMemberDeclarations()4735 protected void consumeInterfaceMemberDeclarations() {
4736 	// InterfaceMemberDeclarations ::= InterfaceMemberDeclarations InterfaceMemberDeclaration
4737 	concatNodeLists();
4738 }
consumeInterfaceMemberDeclarationsopt()4739 protected void consumeInterfaceMemberDeclarationsopt() {
4740 	// InterfaceMemberDeclarationsopt ::= NestedType InterfaceMemberDeclarations
4741 	this.nestedType--;
4742 }
consumeInterfaceType()4743 protected void consumeInterfaceType() {
4744 	// InterfaceType ::= ClassOrInterfaceType
4745 	pushOnAstStack(getTypeReference(0));
4746 	/* if incomplete type header, this.listLength counter will not have been reset,
4747 		indicating that some interfaces are available on the stack */
4748 	this.listLength++;
4749 }
consumeInterfaceTypeList()4750 protected void consumeInterfaceTypeList() {
4751 	// InterfaceTypeList ::= InterfaceTypeList ',' InterfaceType
4752 	optimizedConcatNodeLists();
4753 }
consumeInternalCompilationUnit()4754 protected void consumeInternalCompilationUnit() {
4755 	// InternalCompilationUnit ::= PackageDeclaration
4756 	// InternalCompilationUnit ::= PackageDeclaration ImportDeclarations ReduceImports
4757 	// InternalCompilationUnit ::= ImportDeclarations ReduceImports
4758 	if (this.compilationUnit.isPackageInfo()) {
4759 		this.compilationUnit.types = new TypeDeclaration[1];
4760 		this.compilationUnit.createPackageInfoType();
4761 	}
4762 }
consumeInternalCompilationUnitWithTypes()4763 protected void consumeInternalCompilationUnitWithTypes() {
4764 	// InternalCompilationUnit ::= PackageDeclaration ImportDeclarations ReduceImports TypeDeclarations
4765 	// InternalCompilationUnit ::= PackageDeclaration TypeDeclarations
4766 	// InternalCompilationUnit ::= TypeDeclarations
4767 	// InternalCompilationUnit ::= ImportDeclarations ReduceImports TypeDeclarations
4768 	// consume type declarations
4769 	int length;
4770 	if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
4771 		if (this.compilationUnit.isPackageInfo()) {
4772 			this.compilationUnit.types = new TypeDeclaration[length + 1];
4773 			this.astPtr -= length;
4774 			System.arraycopy(this.astStack, this.astPtr + 1, this.compilationUnit.types, 1, length);
4775 			this.compilationUnit.createPackageInfoType();
4776 		} else {
4777 			this.compilationUnit.types = new TypeDeclaration[length];
4778 			this.astPtr -= length;
4779 			System.arraycopy(this.astStack, this.astPtr + 1, this.compilationUnit.types, 0, length);
4780 		}
4781 	}
4782 }
consumeInvalidAnnotationTypeDeclaration()4783 protected void consumeInvalidAnnotationTypeDeclaration() {
4784 	// BlockStatement ::= AnnotationTypeDeclaration
4785 	TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
4786 	if(!this.statementRecoveryActivated) problemReporter().illegalLocalTypeDeclaration(typeDecl);
4787 	// remove the ast node created in interface header
4788 	this.astPtr--;
4789 	pushOnAstLengthStack(-1);
4790 	concatNodeLists();
4791 }
consumeInvalidConstructorDeclaration()4792 protected void consumeInvalidConstructorDeclaration() {
4793 	// ConstructorDeclaration ::= ConstructorHeader ';'
4794 	// now we know that the top of stack is a constructorDeclaration
4795 	ConstructorDeclaration cd = (ConstructorDeclaration) this.astStack[this.astPtr];
4796 
4797 	cd.bodyEnd = this.endPosition; // position just before the trailing semi-colon
4798 	cd.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
4799 	// report the problem and continue the parsing - narrowing the problem onto the method
4800 
4801 	cd.modifiers |= ExtraCompilerModifiers.AccSemicolonBody; // remember semi-colon body
4802 }
consumeInvalidConstructorDeclaration(boolean hasBody)4803 protected void consumeInvalidConstructorDeclaration(boolean hasBody) {
4804 	// InvalidConstructorDeclaration ::= ConstructorHeader ConstructorBody ==> true
4805 	// InvalidConstructorDeclaration ::= ConstructorHeader ';' ==> false
4806 
4807 	/*
4808 	this.astStack : modifiers arguments throws statements
4809 	this.identifierStack : name
4810 	 ==>
4811 	this.astStack : MethodDeclaration
4812 	this.identifierStack :
4813 	*/
4814 	if (hasBody) {
4815 		// pop the position of the {  (body of the method) pushed in block decl
4816 		this.intPtr--;
4817 	}
4818 
4819 	//statements
4820 	if (hasBody) {
4821 		this.realBlockPtr--;
4822 	}
4823 
4824 	int length;
4825 	if (hasBody && ((length = this.astLengthStack[this.astLengthPtr--]) != 0)) {
4826 		this.astPtr -= length;
4827 	}
4828 	ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) this.astStack[this.astPtr];
4829 	constructorDeclaration.bodyEnd = this.endStatementPosition;
4830 	constructorDeclaration.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
4831 	if (!hasBody) {
4832 		constructorDeclaration.modifiers |= ExtraCompilerModifiers.AccSemicolonBody;
4833 	}
4834 }
consumeInvalidEnumDeclaration()4835 protected void consumeInvalidEnumDeclaration() {
4836 	// BlockStatement ::= EnumDeclaration
4837 	TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
4838 	if(!this.statementRecoveryActivated) problemReporter().illegalLocalTypeDeclaration(typeDecl);
4839 	// remove the ast node created in interface header
4840 	this.astPtr--;
4841 	pushOnAstLengthStack(-1);
4842 	concatNodeLists();
4843 }
consumeInvalidInterfaceDeclaration()4844 protected void consumeInvalidInterfaceDeclaration() {
4845 	// BlockStatement ::= InvalidInterfaceDeclaration
4846 	//InterfaceDeclaration ::= Modifiersopt 'interface' 'Identifier' ExtendsInterfacesopt InterfaceHeader InterfaceBody
4847 	TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
4848 	if(!this.statementRecoveryActivated) problemReporter().illegalLocalTypeDeclaration(typeDecl);
4849 	// remove the ast node created in interface header
4850 	this.astPtr--;
4851 	pushOnAstLengthStack(-1);
4852 	concatNodeLists();
4853 }
consumeInterfaceMethodDeclaration(boolean hasSemicolonBody)4854 protected void consumeInterfaceMethodDeclaration(boolean hasSemicolonBody) {
4855 	// InterfaceMemberDeclaration ::= DefaultMethodHeader MethodBody
4856 	// InterfaceMemberDeclaration ::= MethodHeader MethodBody
4857 	// -- the next rule is illegal but allows to give a more canonical error message from inside consumeInterfaceMethodDeclaration():
4858 	// InterfaceMemberDeclaration ::= DefaultMethodHeader ';'
4859 
4860 
4861 	/*
4862 	this.astStack : modifiers arguments throws statements
4863 	this.identifierStack : type name
4864 	this.intStack : dim dim dim
4865 	 ==>
4866 	this.astStack : MethodDeclaration
4867 	this.identifierStack :
4868 	this.intStack :
4869 	*/
4870 
4871 	int explicitDeclarations = 0;
4872 	Statement[] statements = null;
4873 	if (!hasSemicolonBody) {
4874 		// pop the position of the {  (body of the method) pushed in block decl
4875 		this.intPtr--;
4876 		this.intPtr--;
4877 
4878 		explicitDeclarations = this.realBlockStack[this.realBlockPtr--];
4879 
4880 		//statements
4881 		int length;
4882 		if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
4883 			if (this.options.ignoreMethodBodies) {
4884 				this.astPtr -= length;
4885 			} else {
4886 				System.arraycopy(
4887 					this.astStack,
4888 					(this.astPtr -= length) + 1,
4889 					statements = new Statement[length],
4890 					0,
4891 					length);
4892 			}
4893 		}
4894 	}
4895 
4896 	//watch for } that could be given as a unicode ! ( u007D is '}' )
4897 	MethodDeclaration md = (MethodDeclaration) this.astStack[this.astPtr];
4898 	md.statements = statements;
4899 	md.explicitDeclarations = explicitDeclarations;
4900 	md.bodyEnd = this.endPosition;
4901 	md.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
4902 
4903 	boolean isDefault = (md.modifiers & ExtraCompilerModifiers.AccDefaultMethod) != 0;
4904 	boolean isStatic = (md.modifiers & ClassFileConstants.AccStatic) != 0;
4905 	boolean isPrivate = (md.modifiers & ClassFileConstants.AccPrivate) != 0;
4906 	boolean bodyAllowed = (this.parsingJava9Plus && isPrivate) || isDefault || isStatic;
4907 	if (this.parsingJava8Plus) {
4908 		if (bodyAllowed && hasSemicolonBody) {
4909 			md.modifiers |= ExtraCompilerModifiers.AccSemicolonBody; // avoid complaints regarding undocumented empty body
4910 		}
4911 	} else {
4912 		if (isDefault) problemReporter().defaultMethodsNotBelow18(md);
4913 		if (isStatic) problemReporter().staticInterfaceMethodsNotBelow18(md);
4914 	}
4915 	if (!bodyAllowed && !this.statementRecoveryActivated && !hasSemicolonBody) {
4916 		problemReporter().abstractMethodNeedingNoBody(md);
4917 	}
4918 }
consumeLabel()4919 protected void consumeLabel() {
4920 	// Do nothing
4921 }
consumeLeftParen()4922 protected void consumeLeftParen() {
4923 	// PushLPAREN ::= '('
4924 	pushOnIntStack(this.lParenPos);
4925 }
consumeLocalVariableDeclaration()4926 protected void consumeLocalVariableDeclaration() {
4927 	// LocalVariableDeclaration ::= Modifiers Type VariableDeclarators ';'
4928 
4929 	/*
4930 	this.astStack :
4931 	this.expressionStack: Expression Expression ...... Expression
4932 	this.identifierStack : type  identifier identifier ...... identifier
4933 	this.intStack : typeDim      dim        dim               dim
4934 	 ==>
4935 	this.astStack : FieldDeclaration FieldDeclaration ...... FieldDeclaration
4936 	this.expressionStack :
4937 	this.identifierStack :
4938 	this.intStack :
4939 
4940 	*/
4941 	int variableDeclaratorsCounter = this.astLengthStack[this.astLengthPtr];
4942 
4943 	// update the this.astStack, this.astPtr and this.astLengthStack
4944 	int startIndex = this.astPtr - this.variablesCounter[this.nestedType] + 1;
4945 	System.arraycopy(
4946 		this.astStack,
4947 		startIndex,
4948 		this.astStack,
4949 		startIndex - 1,
4950 		variableDeclaratorsCounter);
4951 	this.astPtr--; // remove the type reference
4952 	this.astLengthStack[--this.astLengthPtr] = variableDeclaratorsCounter;
4953 	this.variablesCounter[this.nestedType] = 0;
4954 	this.forStartPosition = 0;
4955 }
consumeLocalVariableDeclarationStatement()4956 protected void consumeLocalVariableDeclarationStatement() {
4957 
4958 	int variableDeclaratorsCounter = this.astLengthStack[this.astLengthPtr];
4959 	if (variableDeclaratorsCounter == 1) {
4960 		LocalDeclaration localDeclaration = (LocalDeclaration) this.astStack[this.astPtr];
4961 		if (localDeclaration.isRecoveredFromLoneIdentifier()) {
4962 			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=430336, [1.8][compiler] Bad syntax error recovery: Lonely identifier should be variable name, not type
4963 			// Mutate foo $missing; into foo = $missing$;
4964 			Expression left;
4965 			if (localDeclaration.type instanceof QualifiedTypeReference) {
4966 				QualifiedTypeReference qtr = (QualifiedTypeReference) localDeclaration.type;
4967 				left = new QualifiedNameReference(qtr.tokens, qtr.sourcePositions, 0, 0);
4968 			} else {
4969 				left = new SingleNameReference(localDeclaration.type.getLastToken(), 0L);
4970 			}
4971 			left.sourceStart = localDeclaration.type.sourceStart;
4972 			left.sourceEnd = localDeclaration.type.sourceEnd;
4973 
4974 			Expression right = new SingleNameReference(localDeclaration.name, 0L);
4975 			right.sourceStart = localDeclaration.sourceStart;
4976 			right.sourceEnd = localDeclaration.sourceEnd;
4977 
4978 			Assignment assignment = new Assignment(left, right, 0);
4979 			int end = this.endStatementPosition;
4980 			assignment.sourceEnd = (end == localDeclaration.sourceEnd) ? ++end : end;
4981 			assignment.statementEnd = end;
4982 			this.astStack[this.astPtr] = assignment;
4983 
4984 			// also massage recovery scanner data.
4985 			if (this.recoveryScanner != null) {
4986 				RecoveryScannerData data = this.recoveryScanner.getData();
4987 				int position = data.insertedTokensPtr;
4988 				while (position > 0) {
4989 					if (data.insertedTokensPosition[position] != data.insertedTokensPosition[position - 1])
4990 						break;
4991 					position--;
4992 				}
4993 				if (position >= 0)
4994 					this.recoveryScanner.insertTokenAhead(TerminalTokens.TokenNameEQUAL, position);
4995 			}
4996 
4997 			if (this.currentElement != null) {
4998 				this.lastCheckPoint = assignment.sourceEnd + 1;
4999 				this.currentElement = this.currentElement.add(assignment, 0);
5000 			}
5001 			return;
5002 		}
5003 	}
5004 	// LocalVariableDeclarationStatement ::= LocalVariableDeclaration ';'
5005 	// see blockReal in case of change: duplicated code
5006 	// increment the amount of declared variables for this block
5007 	this.realBlockStack[this.realBlockPtr]++;
5008 
5009 	// update source end to include the semi-colon
5010 	for (int i = variableDeclaratorsCounter - 1; i >= 0; i--) {
5011 		LocalDeclaration localDeclaration = (LocalDeclaration) this.astStack[this.astPtr - i];
5012 		localDeclaration.declarationSourceEnd = this.endStatementPosition;
5013 		localDeclaration.declarationEnd = this.endStatementPosition;	// semi-colon included
5014 	}
5015 
5016 }
consumeMarkerAnnotation(boolean isTypeAnnotation)5017 protected void consumeMarkerAnnotation(boolean isTypeAnnotation) {
5018 	// MarkerAnnotation ::= AnnotationName
5019 	// MarkerTypeAnnotation ::= TypeAnnotationName
5020 	MarkerAnnotation markerAnnotation = null;
5021 
5022 	int oldIndex = this.identifierPtr;
5023 
5024 	TypeReference typeReference = getAnnotationType();
5025 	markerAnnotation = new MarkerAnnotation(typeReference, this.intStack[this.intPtr--]);
5026 	markerAnnotation.declarationSourceEnd = markerAnnotation.sourceEnd;
5027 	if (isTypeAnnotation) {
5028 		pushOnTypeAnnotationStack(markerAnnotation);
5029 	} else {
5030 		pushOnExpressionStack(markerAnnotation);
5031 	}
5032 	if(!this.statementRecoveryActivated &&
5033 			this.options.sourceLevel < ClassFileConstants.JDK1_5 &&
5034 			this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
5035 		problemReporter().invalidUsageOfAnnotation(markerAnnotation);
5036 	}
5037 	this.recordStringLiterals = true;
5038 
5039 	if (this.currentElement != null && this.currentElement instanceof RecoveredAnnotation) {
5040 		this.currentElement = ((RecoveredAnnotation)this.currentElement).addAnnotation(markerAnnotation, oldIndex);
5041 	}
5042 }
consumeMemberValueArrayInitializer()5043 protected void consumeMemberValueArrayInitializer() {
5044 	// MemberValueArrayInitializer ::= '{' MemberValues ',' '}'
5045 	// MemberValueArrayInitializer ::= '{' MemberValues '}'
5046 	arrayInitializer(this.expressionLengthStack[this.expressionLengthPtr--]);
5047 }
consumeMemberValueAsName()5048 protected void consumeMemberValueAsName() {
5049 	pushOnExpressionStack(getUnspecifiedReferenceOptimized());
5050 }
consumeMemberValuePair()5051 protected void consumeMemberValuePair() {
5052 	// MemberValuePair ::= SimpleName '=' MemberValue
5053 	char[] simpleName = this.identifierStack[this.identifierPtr];
5054 	long position = this.identifierPositionStack[this.identifierPtr--];
5055 	this.identifierLengthPtr--;
5056 	int end = (int) position;
5057 	int start = (int) (position >>> 32);
5058 	Expression value = this.expressionStack[this.expressionPtr--];
5059 	this.expressionLengthPtr--;
5060 	MemberValuePair memberValuePair = new MemberValuePair(simpleName, start, end, value);
5061 	pushOnAstStack(memberValuePair);
5062 
5063 	if (this.currentElement != null && this.currentElement instanceof RecoveredAnnotation) {
5064 		RecoveredAnnotation recoveredAnnotation = (RecoveredAnnotation) this.currentElement;
5065 
5066 		recoveredAnnotation.setKind(RecoveredAnnotation.NORMAL);
5067 	}
5068 }
consumeMemberValuePairs()5069 protected void consumeMemberValuePairs() {
5070 	// MemberValuePairs ::= MemberValuePairs ',' MemberValuePair
5071 	concatNodeLists();
5072 }
consumeMemberValues()5073 protected void consumeMemberValues() {
5074 	// MemberValues ::= MemberValues ',' MemberValue
5075 	concatExpressionLists();
5076 }
consumeMethodBody()5077 protected void consumeMethodBody() {
5078 	// MethodBody ::= NestedMethod '{' BlockStatementsopt '}'
5079 	this.nestedMethod[this.nestedType] --;
5080 }
consumeMethodDeclaration(boolean isNotAbstract, boolean isDefaultMethod)5081 protected void consumeMethodDeclaration(boolean isNotAbstract, boolean isDefaultMethod) {
5082 	// MethodDeclaration ::= MethodHeader MethodBody
5083 	// AbstractMethodDeclaration ::= MethodHeader ';'
5084 
5085 	/*
5086 	this.astStack : modifiers arguments throws statements
5087 	this.identifierStack : type name
5088 	this.intStack : dim dim dim
5089 	 ==>
5090 	this.astStack : MethodDeclaration
5091 	this.identifierStack :
5092 	this.intStack :
5093 	*/
5094 
5095 	int length;
5096 	if (isNotAbstract) {
5097 		// pop the position of the {  (body of the method) pushed in block decl
5098 		this.intPtr--;
5099 		this.intPtr--;
5100 	}
5101 
5102 	int explicitDeclarations = 0;
5103 	Statement[] statements = null;
5104 	if (isNotAbstract) {
5105 		//statements
5106 		explicitDeclarations = this.realBlockStack[this.realBlockPtr--];
5107 		if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
5108 			if (this.options.ignoreMethodBodies) {
5109 				this.astPtr -= length;
5110 			} else {
5111 				System.arraycopy(
5112 					this.astStack,
5113 					(this.astPtr -= length) + 1,
5114 					statements = new Statement[length],
5115 					0,
5116 					length);
5117 			}
5118 		}
5119 	}
5120 
5121 	// now we know that we have a method declaration at the top of the ast stack
5122 	MethodDeclaration md = (MethodDeclaration) this.astStack[this.astPtr];
5123 	md.statements = statements;
5124 	md.explicitDeclarations = explicitDeclarations;
5125 
5126 	// cannot be done in consumeMethodHeader because we have no idea whether or not there
5127 	// is a body when we reduce the method header
5128 	if (!isNotAbstract) { //remember the fact that the method has a semicolon body
5129 		md.modifiers |= ExtraCompilerModifiers.AccSemicolonBody;
5130 	} else if (!(this.diet && this.dietInt == 0) && statements == null && !containsComment(md.bodyStart, this.endPosition)) {
5131 		md.bits |= ASTNode.UndocumentedEmptyBlock;
5132 	}
5133 	// store the this.endPosition (position just before the '}') in case there is
5134 	// a trailing comment behind the end of the method
5135 	md.bodyEnd = this.endPosition;
5136 	md.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
5137 	if (isDefaultMethod && !this.tolerateDefaultClassMethods) {
5138 		if (this.options.sourceLevel >= ClassFileConstants.JDK1_8) {
5139 			problemReporter().defaultModifierIllegallySpecified(md.sourceStart, md.sourceEnd);
5140 		} else {
5141 			problemReporter().illegalModifierForMethod(md);
5142 		}
5143 	}
5144 }
consumeMethodHeader()5145 protected void consumeMethodHeader() {
5146 	// MethodHeader ::= MethodHeaderName MethodHeaderParameters MethodHeaderExtendedDims ThrowsClauseopt
5147 	// AnnotationMethodHeader ::= AnnotationMethodHeaderName FormalParameterListopt MethodHeaderRightParen MethodHeaderExtendedDims AnnotationMethodHeaderDefaultValueopt
5148 	// RecoveryMethodHeader ::= RecoveryMethodHeaderName FormalParameterListopt MethodHeaderRightParen MethodHeaderExtendedDims AnnotationMethodHeaderDefaultValueopt
5149 	// RecoveryMethodHeader ::= RecoveryMethodHeaderName FormalParameterListopt MethodHeaderRightParen MethodHeaderExtendedDims MethodHeaderThrowsClause
5150 
5151 	// retrieve end position of method declarator
5152 	AbstractMethodDeclaration method = (AbstractMethodDeclaration)this.astStack[this.astPtr];
5153 
5154 	if (this.currentToken == TokenNameLBRACE){
5155 		method.bodyStart = this.scanner.currentPosition;
5156 	}
5157 	// recovery
5158 	if (this.currentElement != null){
5159 //		if(method.isAnnotationMethod()) {
5160 //			method.modifiers |= AccSemicolonBody;
5161 //			method.declarationSourceEnd = this.scanner.currentPosition-1;
5162 //			method.bodyEnd = this.scanner.currentPosition-1;
5163 //			this.currentElement = this.currentElement.parent;
5164 //		} else
5165 		if (this.currentToken == TokenNameSEMICOLON /*&& !method.isAnnotationMethod()*/){
5166 			method.modifiers |= ExtraCompilerModifiers.AccSemicolonBody;
5167 			method.declarationSourceEnd = this.scanner.currentPosition-1;
5168 			method.bodyEnd = this.scanner.currentPosition-1;
5169 			if (this.currentElement.parseTree() == method && this.currentElement.parent != null) {
5170 				this.currentElement = this.currentElement.parent;
5171 			}
5172 		} else if(this.currentToken == TokenNameLBRACE) {
5173 			if (this.currentElement instanceof RecoveredMethod &&
5174 					((RecoveredMethod)this.currentElement).methodDeclaration != method) {
5175 				this.ignoreNextOpeningBrace = true;
5176 				this.currentElement.bracketBalance++;
5177 			}
5178 		}
5179 		this.restartRecovery = true; // used to avoid branching back into the regular automaton
5180 	}
5181 }
consumeMethodHeaderDefaultValue()5182 protected void consumeMethodHeaderDefaultValue() {
5183 	// MethodHeaderDefaultValue ::= DefaultValue
5184 	MethodDeclaration md = (MethodDeclaration) this.astStack[this.astPtr];
5185 
5186 
5187 	int length = this.expressionLengthStack[this.expressionLengthPtr--];
5188 	if (length == 1) {
5189 		this.intPtr--; // we get rid of the position of the default keyword
5190 		this.intPtr--; // we get rid of the position of the default keyword
5191 		if(md.isAnnotationMethod()) {
5192 			((AnnotationMethodDeclaration)md).defaultValue = this.expressionStack[this.expressionPtr];
5193 			md.modifiers |=  ClassFileConstants.AccAnnotationDefault;
5194 		}
5195 		this.expressionPtr--;
5196 		this.recordStringLiterals = true;
5197 	}
5198 
5199 	if(this.currentElement != null) {
5200 		if(md.isAnnotationMethod()) {
5201 			this.currentElement.updateSourceEndIfNecessary(((AnnotationMethodDeclaration)md).defaultValue.sourceEnd);
5202 		}
5203 	}
5204 }
consumeMethodHeaderExtendedDims()5205 protected void consumeMethodHeaderExtendedDims() {
5206 	// MethodHeaderExtendedDims ::= Dimsopt
5207 	// now we update the returnType of the method
5208 	MethodDeclaration md = (MethodDeclaration) this.astStack[this.astPtr];
5209 	int extendedDimensions = this.intStack[this.intPtr--];
5210 	if(md.isAnnotationMethod()) {
5211 		((AnnotationMethodDeclaration)md).extendedDimensions = extendedDimensions;
5212 	}
5213 	if (extendedDimensions != 0) {
5214 		md.sourceEnd = this.endPosition;
5215 		md.returnType = augmentTypeWithAdditionalDimensions(md.returnType, extendedDimensions, getAnnotationsOnDimensions(extendedDimensions), false);
5216 		md.bits |= (md.returnType.bits & ASTNode.HasTypeAnnotations);
5217 		if (this.currentToken == TokenNameLBRACE){
5218 			md.bodyStart = this.endPosition + 1;
5219 		}
5220 		// recovery
5221 		if (this.currentElement != null){
5222 			this.lastCheckPoint = md.bodyStart;
5223 		}
5224 	}
5225 }
consumeMethodHeaderName(boolean isAnnotationMethod)5226 protected void consumeMethodHeaderName(boolean isAnnotationMethod) {
5227 	// MethodHeaderName ::= Modifiersopt Type 'Identifier' '('
5228 	// AnnotationMethodHeaderName ::= Modifiersopt Type 'Identifier' '('
5229 	// RecoveryMethodHeaderName ::= Modifiersopt Type 'Identifier' '('
5230 	MethodDeclaration md = null;
5231 	if(isAnnotationMethod) {
5232 		md = new AnnotationMethodDeclaration(this.compilationUnit.compilationResult);
5233 		this.recordStringLiterals = false;
5234 	} else {
5235 		md = new MethodDeclaration(this.compilationUnit.compilationResult);
5236 	}
5237 
5238 	//name
5239 	md.selector = this.identifierStack[this.identifierPtr];
5240 	long selectorSource = this.identifierPositionStack[this.identifierPtr--];
5241 	this.identifierLengthPtr--;
5242 	//type
5243 	md.returnType = getTypeReference(this.intStack[this.intPtr--]);
5244 	md.bits |= (md.returnType.bits & ASTNode.HasTypeAnnotations);
5245 	//modifiers
5246 	md.declarationSourceStart = this.intStack[this.intPtr--];
5247 	md.modifiers = this.intStack[this.intPtr--];
5248 	// consume annotations
5249 	int length;
5250 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
5251 		System.arraycopy(
5252 			this.expressionStack,
5253 			(this.expressionPtr -= length) + 1,
5254 			md.annotations = new Annotation[length],
5255 			0,
5256 			length);
5257 	}
5258 	// javadoc
5259 	md.javadoc = this.javadoc;
5260 	this.javadoc = null;
5261 
5262 	//highlight starts at selector start
5263 	md.sourceStart = (int) (selectorSource >>> 32);
5264 	pushOnAstStack(md);
5265 	md.sourceEnd = this.lParenPos;
5266 	md.bodyStart = this.lParenPos+1;
5267 	this.listLength = 0; // initialize this.listLength before reading parameters/throws
5268 
5269 	// recovery
5270 	if (this.currentElement != null){
5271 		if (this.currentElement instanceof RecoveredType
5272 			//|| md.modifiers != 0
5273 			|| (Util.getLineNumber(md.returnType.sourceStart, this.scanner.lineEnds, 0, this.scanner.linePtr)
5274 					== Util.getLineNumber(md.sourceStart, this.scanner.lineEnds, 0, this.scanner.linePtr))){
5275 			this.lastCheckPoint = md.bodyStart;
5276 			this.currentElement = this.currentElement.add(md, 0);
5277 			this.lastIgnoredToken = -1;
5278 		} else {
5279 			this.lastCheckPoint = md.sourceStart;
5280 			this.restartRecovery = true;
5281 		}
5282 	}
5283 }
consumeMethodHeaderNameWithTypeParameters(boolean isAnnotationMethod)5284 protected void consumeMethodHeaderNameWithTypeParameters(boolean isAnnotationMethod) {
5285 	// MethodHeaderName ::= Modifiersopt TypeParameters Type 'Identifier' '('
5286 	// AnnotationMethodHeaderName ::= Modifiersopt TypeParameters Type 'Identifier' '('
5287 	// RecoveryMethodHeaderName ::= Modifiersopt TypeParameters Type 'Identifier' '('
5288 	MethodDeclaration md = null;
5289 	if(isAnnotationMethod) {
5290 		md = new AnnotationMethodDeclaration(this.compilationUnit.compilationResult);
5291 		this.recordStringLiterals = false;
5292 	} else {
5293 		md = new MethodDeclaration(this.compilationUnit.compilationResult);
5294 	}
5295 
5296 	//name
5297 	md.selector = this.identifierStack[this.identifierPtr];
5298 	long selectorSource = this.identifierPositionStack[this.identifierPtr--];
5299 	this.identifierLengthPtr--;
5300 	//type
5301 	TypeReference returnType = getTypeReference(this.intStack[this.intPtr--]);
5302 	if (isAnnotationMethod)
5303 		rejectIllegalLeadingTypeAnnotations(returnType);
5304 	md.returnType = returnType;
5305 	md.bits |= (returnType.bits & ASTNode.HasTypeAnnotations);
5306 
5307 	// consume type parameters
5308 	int length = this.genericsLengthStack[this.genericsLengthPtr--];
5309 	this.genericsPtr -= length;
5310 	System.arraycopy(this.genericsStack, this.genericsPtr + 1, md.typeParameters = new TypeParameter[length], 0, length);
5311 
5312 	//modifiers
5313 	md.declarationSourceStart = this.intStack[this.intPtr--];
5314 	md.modifiers = this.intStack[this.intPtr--];
5315 	// consume annotations
5316 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
5317 		System.arraycopy(
5318 			this.expressionStack,
5319 			(this.expressionPtr -= length) + 1,
5320 			md.annotations = new Annotation[length],
5321 			0,
5322 			length);
5323 	}
5324 	// javadoc
5325 	md.javadoc = this.javadoc;
5326 	this.javadoc = null;
5327 
5328 	//highlight starts at selector start
5329 	md.sourceStart = (int) (selectorSource >>> 32);
5330 	pushOnAstStack(md);
5331 	md.sourceEnd = this.lParenPos;
5332 	md.bodyStart = this.lParenPos+1;
5333 	this.listLength = 0; // initialize this.listLength before reading parameters/throws
5334 
5335 	// recovery
5336 	if (this.currentElement != null){
5337 		boolean isType;
5338 		if ((isType = this.currentElement instanceof RecoveredType)
5339 			//|| md.modifiers != 0
5340 			|| (Util.getLineNumber(md.returnType.sourceStart, this.scanner.lineEnds, 0, this.scanner.linePtr)
5341 					== Util.getLineNumber(md.sourceStart, this.scanner.lineEnds, 0, this.scanner.linePtr))){
5342 			if(isType) {
5343 				((RecoveredType) this.currentElement).pendingTypeParameters = null;
5344 			}
5345 			this.lastCheckPoint = md.bodyStart;
5346 			this.currentElement = this.currentElement.add(md, 0);
5347 			this.lastIgnoredToken = -1;
5348 		} else {
5349 			this.lastCheckPoint = md.sourceStart;
5350 			this.restartRecovery = true;
5351 		}
5352 	}
5353 }
consumeMethodHeaderRightParen()5354 protected void consumeMethodHeaderRightParen() {
5355 	// MethodHeaderParameters ::= FormalParameterListopt ')'
5356 	int length = this.astLengthStack[this.astLengthPtr--];
5357 	this.astPtr -= length;
5358 	AbstractMethodDeclaration md = (AbstractMethodDeclaration) this.astStack[this.astPtr];
5359 	md.sourceEnd = 	this.rParenPos;
5360 	//arguments
5361 	if (length != 0) {
5362 		Argument arg = (Argument) this.astStack[this.astPtr + 1];
5363 		if (arg.isReceiver()) {
5364 			md.receiver = (Receiver) arg;
5365 			if (length > 1) {
5366 				System.arraycopy(
5367 					this.astStack,
5368 					this.astPtr + 2,
5369 					md.arguments = new Argument[length - 1],
5370 					0,
5371 					length - 1);
5372 			}
5373 			// Receiver annotations can only be type annotations; move to the type
5374 			Annotation[] annotations = arg.annotations;
5375 			if (annotations != null && annotations.length > 0) {
5376 				// The code assumes that receiver.type.annotations[0] will be null/empty
5377 				TypeReference type = arg.type;
5378 				if (type.annotations == null) {
5379 					type.bits |= ASTNode.HasTypeAnnotations;
5380 					type.annotations = new Annotation[type.getAnnotatableLevels()][];
5381 					md.bits |= ASTNode.HasTypeAnnotations;
5382 				}
5383 				type.annotations[0] = annotations;
5384 				int annotationSourceStart = annotations[0].sourceStart;
5385 				if (type.sourceStart > annotationSourceStart)
5386 					type.sourceStart = annotationSourceStart;
5387 				arg.annotations = null;
5388 			}
5389 			md.bits |= (arg.type.bits & ASTNode.HasTypeAnnotations);
5390 		} else {
5391 			System.arraycopy(
5392 					this.astStack,
5393 					this.astPtr + 1,
5394 					md.arguments = new Argument[length],
5395 					0,
5396 					length);
5397 			for (int i = 0, max = md.arguments.length; i < max; i++) {
5398 				if ((md.arguments[i].bits & ASTNode.HasTypeAnnotations) != 0) {
5399 					md.bits |= ASTNode.HasTypeAnnotations;
5400 					break;
5401 				}
5402 			}
5403 		}
5404 	}
5405 	md.bodyStart = this.rParenPos+1;
5406 	this.listLength = 0; // reset this.listLength after having read all parameters
5407 	// recovery
5408 	if (this.currentElement != null){
5409 		this.lastCheckPoint = md.bodyStart;
5410 		if (this.currentElement.parseTree() == md) return;
5411 
5412 		// might not have been attached yet - in some constructor scenarii
5413 		if (md.isConstructor()){
5414 			if ((length != 0)
5415 				|| (this.currentToken == TokenNameLBRACE)
5416 				|| (this.currentToken == TokenNamethrows)){
5417 				this.currentElement = this.currentElement.add(md, 0);
5418 				this.lastIgnoredToken = -1;
5419 			}
5420 		}
5421 	}
5422 }
consumeMethodHeaderThrowsClause()5423 protected void consumeMethodHeaderThrowsClause() {
5424 	// MethodHeaderThrowsClause ::= 'throws' ClassTypeList
5425 	int length = this.astLengthStack[this.astLengthPtr--];
5426 	this.astPtr -= length;
5427 	AbstractMethodDeclaration md = (AbstractMethodDeclaration) this.astStack[this.astPtr];
5428 	System.arraycopy(
5429 		this.astStack,
5430 		this.astPtr + 1,
5431 		md.thrownExceptions = new TypeReference[length],
5432 		0,
5433 		length);
5434 	md.sourceEnd = md.thrownExceptions[length-1].sourceEnd;
5435 	md.bodyStart = md.thrownExceptions[length-1].sourceEnd + 1;
5436 	this.listLength = 0; // reset this.listLength after having read all thrown exceptions
5437 	// recovery
5438 	if (this.currentElement != null){
5439 		this.lastCheckPoint = md.bodyStart;
5440 	}
5441 }
consumeInvocationExpression()5442 protected void consumeInvocationExpression() {
5443 	// Trap all forms of invocation expressions. Note: Explicit constructor calls are not expressions. Top of expression stack has the MessageSend or AllocationExpression.
5444 }
consumeMethodInvocationName()5445 protected void consumeMethodInvocationName() {
5446 	// MethodInvocation ::= Name '(' ArgumentListopt ')'
5447 
5448 	// when the name is only an identifier...we have a message send to "this" (implicit)
5449 
5450 	MessageSend m = newMessageSend();
5451 	m.sourceEnd = this.rParenPos;
5452 	m.sourceStart =
5453 		(int) ((m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr]) >>> 32);
5454 	m.selector = this.identifierStack[this.identifierPtr--];
5455 	if (this.identifierLengthStack[this.identifierLengthPtr] == 1) {
5456 		m.receiver = ThisReference.implicitThis();
5457 		this.identifierLengthPtr--;
5458 	} else {
5459 		this.identifierLengthStack[this.identifierLengthPtr]--;
5460 		m.receiver = getUnspecifiedReference();
5461 		m.sourceStart = m.receiver.sourceStart;
5462 	}
5463 	int length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--];
5464 	Annotation [] typeAnnotations;
5465 	if (length != 0) {
5466 		System.arraycopy(
5467 				this.typeAnnotationStack,
5468 				(this.typeAnnotationPtr -= length) + 1,
5469 				typeAnnotations = new Annotation[length],
5470 				0,
5471 				length);
5472 		problemReporter().misplacedTypeAnnotations(typeAnnotations[0], typeAnnotations[typeAnnotations.length - 1]);
5473 	}
5474 	pushOnExpressionStack(m);
5475 	consumeInvocationExpression();
5476 }
consumeMethodInvocationNameWithTypeArguments()5477 protected void consumeMethodInvocationNameWithTypeArguments() {
5478 	// MethodInvocation ::= Name '.' TypeArguments 'Identifier' '(' ArgumentListopt ')'
5479 
5480 	// when the name is only an identifier...we have a message send to "this" (implicit)
5481 
5482 	MessageSend m = newMessageSendWithTypeArguments();
5483 	m.sourceEnd = this.rParenPos;
5484 	m.sourceStart =
5485 		(int) ((m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr]) >>> 32);
5486 	m.selector = this.identifierStack[this.identifierPtr--];
5487 	this.identifierLengthPtr--;
5488 
5489 	// handle type arguments
5490 	int length = this.genericsLengthStack[this.genericsLengthPtr--];
5491 	this.genericsPtr -= length;
5492 	System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length);
5493 	this.intPtr--;  // consume position of '<'
5494 
5495 	m.receiver = getUnspecifiedReference();
5496 	m.sourceStart = m.receiver.sourceStart;
5497 	pushOnExpressionStack(m);
5498 	consumeInvocationExpression();
5499 }
consumeMethodInvocationPrimary()5500 protected void consumeMethodInvocationPrimary() {
5501 	//optimize the push/pop
5502 	//MethodInvocation ::= Primary '.' 'Identifier' '(' ArgumentListopt ')'
5503 
5504 	MessageSend m = newMessageSend();
5505 	m.sourceStart =
5506 		(int) ((m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr]) >>> 32);
5507 	m.selector = this.identifierStack[this.identifierPtr--];
5508 	this.identifierLengthPtr--;
5509 	m.receiver = this.expressionStack[this.expressionPtr];
5510 	m.sourceStart = m.receiver.sourceStart;
5511 	m.sourceEnd = this.rParenPos;
5512 	this.expressionStack[this.expressionPtr] = m;
5513 	consumeInvocationExpression();
5514 }
consumeMethodInvocationPrimaryWithTypeArguments()5515 protected void consumeMethodInvocationPrimaryWithTypeArguments() {
5516 	//optimize the push/pop
5517 	//MethodInvocation ::= Primary '.' TypeArguments 'Identifier' '(' ArgumentListopt ')'
5518 
5519 	MessageSend m = newMessageSendWithTypeArguments();
5520 	m.sourceStart =
5521 		(int) ((m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr]) >>> 32);
5522 	m.selector = this.identifierStack[this.identifierPtr--];
5523 	this.identifierLengthPtr--;
5524 
5525 	// handle type arguments
5526 	int length = this.genericsLengthStack[this.genericsLengthPtr--];
5527 	this.genericsPtr -= length;
5528 	System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length);
5529 	this.intPtr--; // consume position of '<'
5530 
5531 	m.receiver = this.expressionStack[this.expressionPtr];
5532 	m.sourceStart = m.receiver.sourceStart;
5533 	m.sourceEnd = this.rParenPos;
5534 	this.expressionStack[this.expressionPtr] = m;
5535 	consumeInvocationExpression();
5536 }
consumeMethodInvocationSuper()5537 protected void consumeMethodInvocationSuper() {
5538 	// MethodInvocation ::= 'super' '.' 'Identifier' '(' ArgumentListopt ')'
5539 
5540 	MessageSend m = newMessageSend();
5541 	m.sourceStart = this.intStack[this.intPtr--]; // start position of the super keyword
5542 	m.sourceEnd = this.rParenPos;
5543 	m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr];
5544 	m.selector = this.identifierStack[this.identifierPtr--];
5545 	this.identifierLengthPtr--;
5546 	m.receiver = new SuperReference(m.sourceStart, this.endPosition);
5547 	pushOnExpressionStack(m);
5548 	consumeInvocationExpression();
5549 }
consumeMethodInvocationSuperWithTypeArguments()5550 protected void consumeMethodInvocationSuperWithTypeArguments() {
5551 	// MethodInvocation ::= 'super' '.' TypeArguments 'Identifier' '(' ArgumentListopt ')'
5552 
5553 	MessageSend m = newMessageSendWithTypeArguments();
5554 	this.intPtr--; // start position of the typeArguments
5555 	m.sourceEnd = this.rParenPos;
5556 	m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr];
5557 	m.selector = this.identifierStack[this.identifierPtr--];
5558 	this.identifierLengthPtr--;
5559 
5560 	// handle type arguments
5561 	int length = this.genericsLengthStack[this.genericsLengthPtr--];
5562 	this.genericsPtr -= length;
5563 	System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length);
5564 	m.sourceStart = this.intStack[this.intPtr--]; // start position of the super keyword
5565 
5566 	m.receiver = new SuperReference(m.sourceStart, this.endPosition);
5567 	pushOnExpressionStack(m);
5568 	consumeInvocationExpression();
5569 }
consumeModifiers()5570 protected void consumeModifiers() {
5571 	int savedModifiersSourceStart = this.modifiersSourceStart;
5572 	checkComment(); // might update modifiers with AccDeprecated
5573 	pushOnIntStack(this.modifiers); // modifiers
5574 	if (this.modifiersSourceStart >= savedModifiersSourceStart) {
5575 		this.modifiersSourceStart = savedModifiersSourceStart;
5576 	}
5577 	pushOnIntStack(this.modifiersSourceStart);
5578 	resetModifiers();
5579 }
consumeModifiers2()5580 protected void consumeModifiers2() {
5581 	this.expressionLengthStack[this.expressionLengthPtr - 1] += this.expressionLengthStack[this.expressionLengthPtr--];
5582 }
consumeMultipleResources()5583 protected void consumeMultipleResources() {
5584 	// Resources ::= Resources ';' Resource
5585 	concatNodeLists();
5586 }
consumeTypeAnnotation()5587 protected void consumeTypeAnnotation() {
5588 	// TypeAnnotation ::= NormalTypeAnnotation
5589 	// TypeAnnotation ::= MarkerTypeAnnotation
5590 	// TypeAnnotation ::= SingleMemberTypeAnnotation
5591 
5592 	if (!this.statementRecoveryActivated &&
5593 			this.options.sourceLevel < ClassFileConstants.JDK1_8 &&
5594 			this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
5595 		Annotation annotation = this.typeAnnotationStack[this.typeAnnotationPtr];
5596 		problemReporter().invalidUsageOfTypeAnnotations(annotation);
5597 	}
5598 	this.dimensions = this.intStack[this.intPtr--]; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=417660
5599 }
consumeOneMoreTypeAnnotation()5600 protected void consumeOneMoreTypeAnnotation() {
5601 	// TypeAnnotations ::= TypeAnnotations TypeAnnotation
5602 	this.typeAnnotationLengthStack[--this.typeAnnotationLengthPtr]++;
5603 }
consumeNameArrayType()5604 protected void consumeNameArrayType() {
5605 	pushOnGenericsLengthStack(0); // handle type arguments
5606 	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
5607 }
consumeNestedMethod()5608 protected void consumeNestedMethod() {
5609 	// NestedMethod ::= $empty
5610 	jumpOverMethodBody();
5611 	this.nestedMethod[this.nestedType] ++;
5612 	pushOnIntStack(this.scanner.currentPosition);
5613 	consumeOpenBlock();
5614 }
consumeNestedType()5615 protected void consumeNestedType() {
5616 	// NestedType ::= $empty
5617 	int length = this.nestedMethod.length;
5618 	if (++this.nestedType >= length) {
5619 		System.arraycopy(
5620 			this.nestedMethod, 0,
5621 			this.nestedMethod = new int[length + 30], 0,
5622 			length);
5623 		// increase the size of the variablesCounter as well. It has to be consistent with the size of the nestedMethod collection
5624 		System.arraycopy(
5625 			this.variablesCounter, 0,
5626 			this.variablesCounter = new int[length + 30], 0,
5627 			length);
5628 	}
5629 	this.nestedMethod[this.nestedType] = 0;
5630 	this.variablesCounter[this.nestedType] = 0;
5631 }
consumeNormalAnnotation(boolean isTypeAnnotation)5632 protected void consumeNormalAnnotation(boolean isTypeAnnotation) {
5633 	// NormalTypeAnnotation ::= TypeAnnotationName '(' MemberValuePairsopt ')'
5634 	// NormalAnnotation ::= AnnotationName '(' MemberValuePairsopt ')'
5635 	NormalAnnotation normalAnnotation = null;
5636 
5637 	int oldIndex = this.identifierPtr;
5638 
5639 	TypeReference typeReference = getAnnotationType();
5640 	normalAnnotation = new NormalAnnotation(typeReference, this.intStack[this.intPtr--]);
5641 	int length;
5642 	if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
5643 		System.arraycopy(
5644 			this.astStack,
5645 			(this.astPtr -= length) + 1,
5646 			normalAnnotation.memberValuePairs = new MemberValuePair[length],
5647 			0,
5648 			length);
5649 	}
5650 	normalAnnotation.declarationSourceEnd = this.rParenPos;
5651 
5652 	if (isTypeAnnotation) {
5653 		pushOnTypeAnnotationStack(normalAnnotation);
5654 	} else {
5655 		pushOnExpressionStack(normalAnnotation);
5656 	}
5657 
5658 	if(this.currentElement != null) {
5659 		annotationRecoveryCheckPoint(normalAnnotation.sourceStart, normalAnnotation.declarationSourceEnd);
5660 
5661 		if (this.currentElement instanceof RecoveredAnnotation) {
5662 			this.currentElement = ((RecoveredAnnotation)this.currentElement).addAnnotation(normalAnnotation, oldIndex);
5663 		}
5664 	}
5665 
5666 	if(!this.statementRecoveryActivated &&
5667 			this.options.sourceLevel < ClassFileConstants.JDK1_5 &&
5668 			this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
5669 		problemReporter().invalidUsageOfAnnotation(normalAnnotation);
5670 	}
5671 	this.recordStringLiterals = true;
5672 }
consumeOneDimLoop(boolean isAnnotated)5673 protected void consumeOneDimLoop(boolean isAnnotated) {
5674 	// OneDimLoop ::= '[' ']'
5675 	// OneDimLoop ::= TypeAnnotations '[' ']'
5676 	this.dimensions++;
5677 	if (!isAnnotated) {
5678 		pushOnTypeAnnotationLengthStack(0); // signal no annotations for the current dimension.
5679 	}
5680 }
consumeOnlySynchronized()5681 protected void consumeOnlySynchronized() {
5682 	// OnlySynchronized ::= 'synchronized'
5683 	pushOnIntStack(this.synchronizedBlockSourceStart);
5684 	resetModifiers();
5685 	this.expressionLengthPtr--;
5686 }
consumeOnlyTypeArguments()5687 protected void consumeOnlyTypeArguments() {
5688 	if(!this.statementRecoveryActivated &&
5689 			this.options.sourceLevel < ClassFileConstants.JDK1_5 &&
5690 			this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
5691 		int length = this.genericsLengthStack[this.genericsLengthPtr];
5692 		problemReporter().invalidUsageOfTypeArguments(
5693 			(TypeReference)this.genericsStack[this.genericsPtr - length + 1],
5694 			(TypeReference)this.genericsStack[this.genericsPtr]);
5695 	}
5696 }
consumeOnlyTypeArgumentsForCastExpression()5697 protected void consumeOnlyTypeArgumentsForCastExpression() {
5698 	// OnlyTypeArgumentsForCastExpression ::= OnlyTypeArguments
5699 }
consumeOpenBlock()5700 protected void consumeOpenBlock() {
5701 	// OpenBlock ::= $empty
5702 
5703 	pushOnIntStack(this.scanner.startPosition);
5704 	int stackLength = this.realBlockStack.length;
5705 	if (++this.realBlockPtr >= stackLength) {
5706 		System.arraycopy(
5707 			this.realBlockStack, 0,
5708 			this.realBlockStack = new int[stackLength + StackIncrement], 0,
5709 			stackLength);
5710 	}
5711 	this.realBlockStack[this.realBlockPtr] = 0;
5712 }
consumePackageComment()5713 protected void consumePackageComment() {
5714 	// get possible comment for syntax since 1.5
5715 	if(this.options.sourceLevel >= ClassFileConstants.JDK1_5) {
5716 		checkComment();
5717 		resetModifiers();
5718 	}
5719 }
consumeInternalCompilationUnitWithModuleDeclaration()5720 protected void consumeInternalCompilationUnitWithModuleDeclaration() {
5721 	this.compilationUnit.moduleDeclaration = (ModuleDeclaration)this.astStack[this.astPtr--];
5722 	this.astLengthStack[this.astLengthPtr--] = 0;
5723 }
consumeRequiresStatement()5724 protected void consumeRequiresStatement() {
5725 	RequiresStatement req = (RequiresStatement) this.astStack[this.astPtr];
5726 	req.declarationEnd = req.declarationSourceEnd = this.endStatementPosition;
5727 	// recovery
5728 	if (this.currentElement instanceof RecoveredModule) {
5729 		this.lastCheckPoint = req.declarationSourceEnd + 1;
5730 		this.currentElement = this.currentElement.add(req, 0);
5731 		this.lastIgnoredToken = -1;
5732 		this.restartRecovery = true; // used to avoid branching back into the regular automaton
5733 	}
5734 }
consumeSingleRequiresModuleName()5735 protected void consumeSingleRequiresModuleName() {
5736 	ModuleReference impt;
5737 	int length;
5738 	char[][] tokens = new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
5739 	this.identifierPtr -= length;
5740 	long[] positions = new long[length];
5741 	System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
5742 	System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
5743 	RequiresStatement req = new RequiresStatement(impt = new ModuleReference(tokens, positions));
5744 	if (this.currentToken == TokenNameSEMICOLON){
5745 		req.declarationSourceEnd = impt.sourceEnd + 1;
5746 	} else {
5747 		req.declarationSourceEnd = impt.sourceEnd;
5748 	}
5749 	req.declarationEnd = req.declarationSourceEnd;
5750 	req.modifiersSourceStart = this.intStack[this.intPtr--];
5751 	req.modifiers |= this.intStack[this.intPtr--];
5752 	req.sourceStart = req.declarationSourceStart = this.intStack[this.intPtr--];
5753 	req.sourceEnd = impt.sourceEnd;
5754 	pushOnAstStack(req);
5755 	// recovery
5756 	if (this.currentElement instanceof RecoveredModule){
5757 		this.lastCheckPoint = req.declarationSourceEnd;
5758 	}
5759 }
consumeExportsStatement()5760 protected void consumeExportsStatement() {
5761 	ExportsStatement expt = (ExportsStatement) this.astStack[this.astPtr];
5762 	expt.declarationSourceEnd = this.endStatementPosition;
5763 	expt.declarationEnd = expt.declarationSourceEnd;
5764 	// recovery
5765 	if (this.currentElement instanceof RecoveredPackageVisibilityStatement) {
5766 		this.lastCheckPoint = expt.declarationSourceEnd + 1;
5767 		this.currentElement = this.currentElement.parent;
5768 		this.lastIgnoredToken = -1;
5769 		this.restartRecovery = true;
5770 		// used to avoid branching back into the regular automaton
5771 	}
5772 }
consumeExportsHeader()5773 protected void consumeExportsHeader() {
5774 	ImportReference impt = (ImportReference) this.astStack[this.astPtr];
5775 	impt.bits |= ASTNode.inModule;
5776 	ExportsStatement expt = new ExportsStatement(impt);
5777 	expt.declarationSourceStart = this.intStack[this.intPtr--];
5778 	expt.sourceStart = expt.declarationSourceStart;
5779 	expt.sourceEnd = impt.sourceEnd;
5780 	if (this.currentToken == TokenNameSEMICOLON){
5781 		expt.declarationSourceEnd = this.scanner.currentPosition - 1;
5782 	} else {
5783 		expt.declarationSourceEnd = expt.sourceEnd;
5784 	}
5785 	expt.declarationEnd = expt.declarationSourceEnd;
5786 	this.astStack[this.astPtr] = expt; // replace with ExportsStatement
5787 	// recovery
5788 	if (this.currentElement instanceof RecoveredModule) {
5789 		this.lastCheckPoint = expt.declarationSourceEnd + 1;
5790 		this.currentElement = this.currentElement.add(expt, 0);
5791 	}
5792 }
consumeOpensHeader()5793 protected void consumeOpensHeader() {
5794 	ImportReference impt = (ImportReference) this.astStack[this.astPtr];
5795 	impt.bits |= ASTNode.inModule;
5796 	OpensStatement stmt = new OpensStatement(impt);
5797 	stmt.declarationSourceStart = this.intStack[this.intPtr--];
5798 	stmt.sourceStart = stmt.declarationSourceStart;
5799 	stmt.sourceEnd = impt.sourceEnd;
5800 	if (this.currentToken == TokenNameSEMICOLON){
5801 		stmt.declarationSourceEnd = this.scanner.currentPosition - 1;
5802 	} else {
5803 		stmt.declarationSourceEnd = stmt.sourceEnd;
5804 	}
5805 	stmt.declarationEnd = stmt.declarationSourceEnd;
5806 	this.astStack[this.astPtr] = stmt; // replace with OpensStatement
5807 	// recovery
5808 	if (this.currentElement instanceof RecoveredModule) {
5809 		this.lastCheckPoint = stmt.declarationSourceEnd + 1;
5810 		this.lastCheckPoint = stmt.declarationSourceEnd + 1;
5811 		this.currentElement = this.currentElement.add(stmt, 0);
5812 	}
5813 }
consumeOpensStatement()5814 protected void consumeOpensStatement() {
5815 	OpensStatement expt = (OpensStatement) this.astStack[this.astPtr];
5816 	expt.declarationSourceEnd = this.endStatementPosition;
5817 	expt.declarationEnd = expt.declarationSourceEnd;
5818 	// recovery
5819 	if (this.currentElement instanceof RecoveredPackageVisibilityStatement) {
5820 		this.lastCheckPoint = expt.declarationSourceEnd + 1;
5821 		this.currentElement = this.currentElement.parent;
5822 		this.lastIgnoredToken = -1;
5823 		this.restartRecovery = true;
5824 		// used to avoid branching back into the regular automaton
5825 	}
5826 }
consumeSingleTargetModuleName()5827 protected void consumeSingleTargetModuleName() {
5828 	ModuleReference reference;
5829 	int length;
5830 	char[][] tokens = new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
5831 	this.identifierPtr -= length;
5832 	long[] positions = new long[length];
5833 	System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
5834 	System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
5835 	pushOnAstStack(reference = new ModuleReference(tokens, positions));
5836 
5837 	// recovery
5838 	if (this.currentElement != null) {
5839 		this.lastCheckPoint = reference.sourceEnd + 1;
5840 	}
5841 
5842 }
consumeTargetModuleList()5843 protected void consumeTargetModuleList() {
5844 	int length = this.astLengthStack[this.astLengthPtr--];
5845 	this.astPtr -= length;
5846 	PackageVisibilityStatement node = (PackageVisibilityStatement) this.astStack[this.astPtr];
5847 	if (length > 0) {
5848 	System.arraycopy(
5849 		this.astStack,
5850 		this.astPtr + 1,
5851 		node.targets = new ModuleReference[length],
5852 		0,
5853 		length);
5854 		node.sourceEnd = node.targets[length - 1].sourceEnd;
5855 		if (this.currentToken == TokenNameSEMICOLON){
5856 			node.declarationSourceEnd = node.sourceEnd + 1;
5857 		} else {
5858 			node.declarationSourceEnd = node.sourceEnd;
5859 		}
5860 	}
5861 
5862 	this.listLength = 0; // reset after having read target modules list
5863 	// recovery TBD
5864 	if (this.currentElement != null) { // is recovering
5865 		this.lastCheckPoint = node.sourceEnd;
5866 	}
5867 }
consumeTargetModuleNameList()5868 protected void consumeTargetModuleNameList() {
5869 	this.listLength++;
5870 	optimizedConcatNodeLists();
5871 }
consumeSinglePkgName()5872 protected void consumeSinglePkgName() {
5873 	ImportReference impt;
5874 	int length;
5875 	char[][] tokens = new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
5876 	this.identifierPtr -= length;
5877 	long[] positions = new long[length];
5878 	System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
5879 	System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
5880 	pushOnAstStack(impt = new ImportReference(tokens, positions, false, ClassFileConstants.AccDefault));
5881 
5882 	// recovery
5883 	if (this.currentElement instanceof RecoveredModule){
5884 		this.lastCheckPoint = impt.sourceEnd + 1;
5885 	}
5886 }
consumeUsesStatement()5887 protected void consumeUsesStatement() {
5888 	UsesStatement stmt = (UsesStatement) this.astStack[this.astPtr];
5889 	stmt.declarationEnd = stmt.declarationSourceEnd = this.endStatementPosition;
5890 	// recovery
5891 	if (this.currentElement instanceof RecoveredModule){
5892 		this.lastCheckPoint = stmt.declarationSourceEnd;
5893 		this.lastIgnoredToken = -1;
5894 		this.restartRecovery = true;
5895 	}
5896 }
consumeUsesHeader()5897 protected void consumeUsesHeader() {
5898 	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
5899 	pushOnGenericsLengthStack(0);
5900 	TypeReference siName = getTypeReference(0);
5901 	if (siName.annotations != null) {
5902 		for (int j = 0; j < siName.annotations.length; j++) {
5903 			Annotation[] qualifierAnnot = siName.annotations[j];
5904 			if (qualifierAnnot != null && qualifierAnnot.length > 0) {
5905 				problemReporter().misplacedTypeAnnotations(qualifierAnnot[0], qualifierAnnot[qualifierAnnot.length - 1]);
5906 				siName.annotations[j] = null;
5907 			}
5908 		}
5909 	}
5910 	UsesStatement stmt = new UsesStatement(siName);
5911 	if (this.currentToken == TokenNameSEMICOLON){
5912 		stmt.declarationSourceEnd = siName.sourceEnd + 1;
5913 	} else {
5914 		stmt.declarationSourceEnd = siName.sourceEnd;
5915 	}
5916 	stmt.declarationEnd = stmt.declarationSourceEnd;
5917 	stmt.sourceStart = stmt.declarationSourceStart = this.intStack[this.intPtr--];
5918 	stmt.sourceEnd = siName.sourceEnd;
5919 	pushOnAstStack(stmt);
5920 	// recovery
5921 	if (this.currentElement instanceof RecoveredModule){
5922 		this.lastCheckPoint = stmt.sourceEnd + 1;
5923 		this.currentElement = this.currentElement.add(stmt, 0);
5924 	}
5925 }
consumeProvidesInterface()5926 protected void consumeProvidesInterface() {
5927 	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
5928 	pushOnGenericsLengthStack(0);
5929 	TypeReference siName = getTypeReference(0);
5930 	if (siName.annotations != null) {
5931 		for (int j = 0; j < siName.annotations.length; j++) {
5932 			Annotation[] qualifierAnnot = siName.annotations[j];
5933 			if (qualifierAnnot != null && qualifierAnnot.length > 0) {
5934 				problemReporter().misplacedTypeAnnotations(qualifierAnnot[0], qualifierAnnot[qualifierAnnot.length - 1]);
5935 				siName.annotations[j] = null;
5936 			}
5937 		}
5938 	}
5939 	ProvidesStatement ref = new ProvidesStatement();
5940 	ref.serviceInterface = siName;
5941 	pushOnAstStack(ref);
5942 	ref.declarationSourceStart = this.intStack[this.intPtr--];
5943 	ref.sourceStart = ref.declarationSourceStart;
5944 	ref.sourceEnd = siName.sourceEnd;
5945 	ref.declarationSourceEnd = ref.sourceEnd;
5946 	// recovery
5947 	if (this.currentElement instanceof RecoveredModule) {
5948 		this.lastCheckPoint = siName.sourceEnd + 1;
5949 		this.currentElement = this.currentElement.add(ref, 0);
5950 		this.lastIgnoredToken = -1;
5951 	}
5952 }
consumeSingleServiceImplName()5953 protected void consumeSingleServiceImplName() {
5954 	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
5955 	pushOnGenericsLengthStack(0);
5956 	TypeReference siName = getTypeReference(0);
5957 	if (siName.annotations != null) {
5958 		for (int j = 0; j < siName.annotations.length; j++) {
5959 			Annotation[] qualifierAnnot = siName.annotations[j];
5960 			if (qualifierAnnot != null && qualifierAnnot.length > 0) {
5961 				problemReporter().misplacedTypeAnnotations(qualifierAnnot[0], qualifierAnnot[qualifierAnnot.length - 1]);
5962 				siName.annotations[j] = null;
5963 			}
5964 		}
5965 	}
5966 	pushOnAstStack(siName);
5967 	// recovery
5968 	if (this.currentElement instanceof RecoveredModule) {
5969 		this.lastCheckPoint = siName.sourceEnd + 1;
5970 	}
5971 
5972 }
consumeServiceImplNameList()5973 protected void consumeServiceImplNameList() {
5974 	this.listLength++;
5975 	optimizedConcatNodeLists();
5976 }
consumeProvidesStatement()5977 protected void consumeProvidesStatement() {
5978 	ProvidesStatement ref = (ProvidesStatement) this.astStack[this.astPtr];
5979 	ref.declarationEnd = ref.declarationSourceEnd = this.endStatementPosition;
5980 	//recovery
5981 	if (this.currentElement instanceof RecoveredProvidesStatement) {
5982 		this.lastIgnoredToken = -1;
5983 		this.currentElement = this.currentElement.parent;
5984 		this.restartRecovery = true; // used to avoid branching back into the regular automaton
5985 	}
5986 }
consumeWithClause()5987 protected void consumeWithClause() {
5988 	int length = this.astLengthStack[this.astLengthPtr--];
5989 	this.astPtr -= length;
5990 
5991 	ProvidesStatement service = (ProvidesStatement) this.astStack[this.astPtr];
5992 	System.arraycopy(
5993 		this.astStack,
5994 		this.astPtr + 1,
5995 		service.implementations = new TypeReference[length],
5996 		0,
5997 		length);
5998 
5999 	service.sourceEnd = service.implementations[length - 1].sourceEnd;
6000 
6001 	if (this.currentToken == TokenNameSEMICOLON){
6002 		service.declarationSourceEnd = service.sourceEnd + 1;
6003 	} else {
6004 		service.declarationSourceEnd = service.sourceEnd;
6005 	}
6006 	this.listLength = 0; // reset after having read super-interfaces
6007 	// recovery
6008 	if (this.currentElement instanceof RecoveredProvidesStatement) { // is recovering
6009 		this.lastCheckPoint = service.declarationSourceEnd;
6010 	}
6011 }
consumeEmptyModuleStatementsOpt()6012 protected void consumeEmptyModuleStatementsOpt() {
6013 	pushOnAstLengthStack(0);
6014 }
consumeModuleStatements()6015 protected void consumeModuleStatements() {
6016 	concatNodeLists();
6017 }
consumeModuleModifiers()6018 protected void consumeModuleModifiers() {
6019 	checkComment(); // might update modifiers with AccDeprecated
6020 	// Merge with other modifiers
6021 	this.intStack[this.intPtr -1] |= this.modifiers;
6022 	resetModifiers();
6023 	// Account for the possible presence of annotations as well
6024 	this.expressionLengthStack[this.expressionLengthPtr - 1] += this.expressionLengthStack[this.expressionLengthPtr--];
6025 }
consumeModuleHeader()6026 protected void consumeModuleHeader() {
6027 	// ModuleHeader ::= 'module' Name
6028 
6029 	int length;
6030 	char[][] tokens =
6031 		new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
6032 	this.identifierPtr -= length;
6033 	long[] positions = new long[length];
6034 	System.arraycopy(this.identifierStack, ++this.identifierPtr, tokens, 0, length);
6035 	System.arraycopy(
6036 		this.identifierPositionStack,
6037 		this.identifierPtr--,
6038 		positions,
6039 		0,
6040 		length);
6041 
6042 	ModuleDeclaration typeDecl = new ModuleDeclaration(this.compilationUnit.compilationResult, tokens, positions);
6043 	//compute the declaration source too
6044 	typeDecl.declarationSourceStart = this.intStack[this.intPtr--];
6045 	typeDecl.bodyStart = typeDecl.sourceEnd + 1;
6046 	typeDecl.modifiersSourceStart = this.intStack[this.intPtr--];
6047 	typeDecl.modifiers = this.intStack[this.intPtr--];
6048 	if (typeDecl.modifiersSourceStart >= 0) {
6049 		typeDecl.declarationSourceStart = typeDecl.modifiersSourceStart;
6050 	}
6051 //	int otherModifiersStart = this.intStack[this.intPtr--];
6052 //	int otherModifiers = this.intStack[this.intPtr--];
6053 //	if (otherModifiersStart >= 0) {
6054 //		typeDecl.declarationSourceStart = typeDecl.modifiersSourceStart = otherModifiersStart;
6055 //	}
6056 	// Merge with other modifiers
6057 //	typeDecl.modifiers |= otherModifiers;
6058 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
6059 		System.arraycopy(
6060 			this.expressionStack,
6061 			(this.expressionPtr -= length) + 1,
6062 			typeDecl.annotations = new Annotation[length],
6063 			0,
6064 			length);
6065 	}
6066 	pushOnAstStack(typeDecl);
6067 
6068 	this.listLength = 0;
6069 	// recovery
6070 	if (this.currentElement != null){
6071 		this.lastCheckPoint = typeDecl.bodyStart;
6072 		this.currentElement = this.currentElement.add(typeDecl, 0);
6073 		this.lastIgnoredToken = -1;
6074 	}
6075 		// javadoc
6076 //		typeDecl.javadoc = this.javadoc;
6077 //		this.javadoc = null;
6078 }
consumeModuleDeclaration()6079 protected void consumeModuleDeclaration() {
6080 	// ModuleDeclaration ::= ModuleHeader ModuleBody
6081 	this.compilationUnit.javadoc = this.javadoc;
6082 	this.javadoc = null;
6083 
6084 	int length = this.astLengthStack[this.astLengthPtr--];
6085 	int[] flag = new int[length + 1]; //plus one -- see <HERE>
6086 	int size1 = 0, size2 = 0, size3 = 0, size4 = 0, size5 = 0;
6087 	if (length != 0) {
6088 		//there are length declarations
6089 		//dispatch according to the type of the declarations
6090 		for (int i = length - 1; i >= 0; i--) {
6091 			ASTNode astNode = this.astStack[this.astPtr--];
6092 			if (astNode instanceof RequiresStatement) {
6093 				flag[i] = 1;
6094 				size1++;
6095 			} else if (astNode instanceof ExportsStatement) {
6096 				flag[i] = 2;
6097 				size2++;
6098 			} else if (astNode instanceof UsesStatement) {
6099 				//field
6100 				flag[i] = 3;
6101 				size3++;
6102 			} else if (astNode instanceof ProvidesStatement){
6103 				flag[i] = 4;
6104 				size4++;
6105 			} else if (astNode instanceof OpensStatement) {
6106 				flag[i] = 5;
6107 				size5++;
6108 			}
6109 		}
6110 	}
6111 	ModuleDeclaration modul = (ModuleDeclaration) this.astStack[this.astPtr];
6112 	modul.requiresCount = size1;
6113 	modul.exportsCount = size2;
6114 	modul.usesCount = size3;
6115 	modul.servicesCount = size4;
6116 	modul.opensCount = size5;
6117 	modul.requires = new RequiresStatement[size1];
6118 	modul.exports = new ExportsStatement[size2];
6119 	modul.uses = new UsesStatement[size3];
6120 	modul.services = new ProvidesStatement[size4];
6121 	modul.opens = new OpensStatement[size5];
6122 	//arrays fill up
6123 	size1 = size2 = size3 = size4 = size5 = 0;
6124 	int flagI = flag[0], start = 0;
6125 	int length2;
6126 	for (int end = 0; end <= length; end++) //<HERE> the plus one allows to
6127 		{
6128 		if (flagI != flag[end]) //treat the last element as a ended flag.....
6129 			{ //array copy
6130 			switch (flagI) {
6131 				case 1 :
6132 					size1 += (length2 = end - start);
6133 					System.arraycopy(
6134 						this.astStack,
6135 						this.astPtr + start + 1,
6136 						modul.requires,
6137 						size1 - length2,
6138 						length2);
6139 					break;
6140 				case 2 :
6141 					size2 += (length2 = end - start);
6142 					System.arraycopy(
6143 						this.astStack,
6144 						this.astPtr + start + 1,
6145 						modul.exports,
6146 						size2 - length2,
6147 						length2);
6148 					break;
6149 				case 3 :
6150 					size3 += (length2 = end - start);
6151 					System.arraycopy(
6152 						this.astStack,
6153 						this.astPtr + start + 1,
6154 						modul.uses,
6155 						size3 - length2,
6156 						length2);
6157 					break;
6158 				case 4 :
6159 					size4 += (length2 = end - start);
6160 					System.arraycopy(
6161 						this.astStack,
6162 						this.astPtr + start + 1,
6163 						modul.services,
6164 						size4 - length2,
6165 						length2);
6166 					break;
6167 				case 5 :
6168 					size5 += (length2 = end - start);
6169 					System.arraycopy(
6170 						this.astStack,
6171 						this.astPtr + start + 1,
6172 						modul.opens,
6173 						size5 - length2,
6174 						length2);
6175 					break;
6176 			}
6177 			flagI = flag[start = end];
6178 		}
6179 	}
6180 	modul.bodyEnd = this.endStatementPosition;
6181 	modul.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
6182 }
consumePackageDeclaration()6183 protected void consumePackageDeclaration() {
6184 	// PackageDeclaration ::= 'package' Name ';'
6185 	/* build an ImportRef build from the last name
6186 	stored in the identifier stack. */
6187 
6188 	ImportReference impt = this.compilationUnit.currentPackage;
6189 	this.compilationUnit.javadoc = this.javadoc;
6190 	this.javadoc = null;
6191 	// flush comments defined prior to import statements
6192 	impt.declarationEnd = this.endStatementPosition;
6193 	impt.declarationSourceEnd = flushCommentsDefinedPriorTo(impt.declarationSourceEnd);
6194 	if (this.firstToken == TokenNameQUESTION)
6195 		this.unstackedAct = ACCEPT_ACTION; // force termination at goal
6196 }
consumePackageDeclarationName()6197 protected void consumePackageDeclarationName() {
6198 	// PackageDeclarationName ::= PackageComment 'package' Name RejectTypeAnnotations
6199 	/* build an ImportRef build from the last name
6200 	stored in the identifier stack. */
6201 
6202 	ImportReference impt;
6203 	int length;
6204 	char[][] tokens =
6205 		new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
6206 	this.identifierPtr -= length;
6207 	long[] positions = new long[length];
6208 	System.arraycopy(this.identifierStack, ++this.identifierPtr, tokens, 0, length);
6209 	System.arraycopy(
6210 		this.identifierPositionStack,
6211 		this.identifierPtr--,
6212 		positions,
6213 		0,
6214 		length);
6215 
6216 	impt = new ImportReference(tokens, positions, false, ClassFileConstants.AccDefault);
6217 	this.compilationUnit.currentPackage = impt;
6218 
6219 	if (this.currentToken == TokenNameSEMICOLON){
6220 		impt.declarationSourceEnd = this.scanner.currentPosition - 1;
6221 	} else {
6222 		impt.declarationSourceEnd = impt.sourceEnd;
6223 	}
6224 	impt.declarationEnd = impt.declarationSourceEnd;
6225 	//this.endPosition is just before the ;
6226 	impt.declarationSourceStart = this.intStack[this.intPtr--];
6227 
6228 	// get possible comment source start
6229 	if(this.javadoc != null) {
6230 		impt.declarationSourceStart = this.javadoc.sourceStart;
6231 	}
6232 
6233 	// recovery
6234 	if (this.currentElement != null){
6235 		this.lastCheckPoint = impt.declarationSourceEnd+1;
6236 		this.restartRecovery = true; // used to avoid branching back into the regular automaton
6237 	}
6238 }
consumePackageDeclarationNameWithModifiers()6239 protected void consumePackageDeclarationNameWithModifiers() {
6240 	// PackageDeclarationName ::= Modifiers 'package' PushRealModifiers Name RejectTypeAnnotations
6241 	/* build an ImportRef build from the last name
6242 	stored in the identifier stack. */
6243 
6244 	ImportReference impt;
6245 	int length;
6246 	char[][] tokens =
6247 		new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
6248 	this.identifierPtr -= length;
6249 	long[] positions = new long[length];
6250 	System.arraycopy(this.identifierStack, ++this.identifierPtr, tokens, 0, length);
6251 	System.arraycopy(
6252 		this.identifierPositionStack,
6253 		this.identifierPtr--,
6254 		positions,
6255 		0,
6256 		length);
6257 
6258 	int packageModifiersSourceStart = this.intStack[this.intPtr--];
6259 	int packageModifiersSourceEnd = packageModifiersSourceStart; // Unless there were any
6260 	int packageModifiers = this.intStack[this.intPtr--];
6261 
6262 	impt = new ImportReference(tokens, positions, false, packageModifiers);
6263 	this.compilationUnit.currentPackage = impt;
6264 	// consume annotations
6265 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
6266 		System.arraycopy(
6267 			this.expressionStack,
6268 			(this.expressionPtr -= length) + 1,
6269 			impt.annotations = new Annotation[length],
6270 			0,
6271 			length);
6272 		impt.declarationSourceStart = packageModifiersSourceStart;
6273 		packageModifiersSourceEnd = this.intStack[this.intPtr--] - 2; // we don't need the position of the 'package keyword
6274 	} else {
6275 		impt.declarationSourceStart = this.intStack[this.intPtr--];
6276 		packageModifiersSourceEnd = impt.declarationSourceStart - 2;
6277 		// get possible comment source start
6278 		if (this.javadoc != null) {
6279 			impt.declarationSourceStart = this.javadoc.sourceStart;
6280 		}
6281 	}
6282 
6283 	if (packageModifiers != 0) {
6284 		problemReporter().illegalModifiers(packageModifiersSourceStart, packageModifiersSourceEnd);
6285 	}
6286 
6287 
6288 	if (this.currentToken == TokenNameSEMICOLON){
6289 		impt.declarationSourceEnd = this.scanner.currentPosition - 1;
6290 	} else {
6291 		impt.declarationSourceEnd = impt.sourceEnd;
6292 	}
6293 	impt.declarationEnd = impt.declarationSourceEnd;
6294 
6295 	// recovery
6296 	if (this.currentElement != null){
6297 		this.lastCheckPoint = impt.declarationSourceEnd+1;
6298 		this.restartRecovery = true; // used to avoid branching back into the regular automaton
6299 	}
6300 }
consumePostfixExpression()6301 protected void consumePostfixExpression() {
6302 	// PostfixExpression ::= Name
6303 	pushOnExpressionStack(getUnspecifiedReferenceOptimized());
6304 }
consumePrimaryNoNewArray()6305 protected void consumePrimaryNoNewArray() {
6306 	// PrimaryNoNewArray ::=  PushLPAREN Expression PushRPAREN
6307 	final Expression parenthesizedExpression = this.expressionStack[this.expressionPtr];
6308 	updateSourcePosition(parenthesizedExpression);
6309 	int numberOfParenthesis = (parenthesizedExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
6310 	parenthesizedExpression.bits &= ~ASTNode.ParenthesizedMASK;
6311 	parenthesizedExpression.bits |= (numberOfParenthesis + 1) << ASTNode.ParenthesizedSHIFT;
6312 }
consumePrimaryNoNewArrayArrayType()6313 protected void consumePrimaryNoNewArrayArrayType() {
6314 	// PrimaryNoNewArray ::= Name Dims '.' 'class'
6315 	this.intPtr--; // remove the class start position
6316 
6317 	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
6318 	pushOnGenericsLengthStack(0);
6319 	ClassLiteralAccess cla;
6320 	pushOnExpressionStack(
6321 		cla = new ClassLiteralAccess(this.intStack[this.intPtr--], getTypeReference(this.intStack[this.intPtr--])));
6322 	rejectIllegalTypeAnnotations(cla.type); // javac correctly rejects annotations on dimensions here.
6323 }
consumePrimaryNoNewArrayName()6324 protected void consumePrimaryNoNewArrayName() {
6325 	// PrimaryNoNewArray ::= Name '.' 'class'
6326 	this.intPtr--; // remove the class start position
6327 
6328 	// handle type arguments
6329 	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
6330 	pushOnGenericsLengthStack(0);
6331 	TypeReference typeReference = getTypeReference(0);
6332 
6333 	rejectIllegalTypeAnnotations(typeReference);
6334 
6335 	pushOnExpressionStack(
6336 		new ClassLiteralAccess(this.intStack[this.intPtr--], typeReference));
6337 }
rejectIllegalLeadingTypeAnnotations(TypeReference typeReference)6338 protected void rejectIllegalLeadingTypeAnnotations(TypeReference typeReference) {
6339 	// Reject misplaced annotations prefixed to a type reference; Used when the grammar is permissive enough to allow them in the first place.
6340 	Annotation [][]  annotations = typeReference.annotations;
6341 	if (annotations != null && annotations[0] != null) {
6342 		problemReporter().misplacedTypeAnnotations(annotations[0][0], annotations[0][annotations[0].length - 1]);
6343 		annotations[0] = null;  // don't complain further.
6344 	}
6345 }
rejectIllegalTypeAnnotations(TypeReference typeReference)6346 private void rejectIllegalTypeAnnotations(TypeReference typeReference) {
6347 	// Reject misplaced annotations on type reference; Used when grammar is permissive enough to allow them in the first place.
6348 	Annotation [][]  annotations = typeReference.annotations;
6349 	Annotation[] misplacedAnnotations;
6350 	for (int i = 0, length = annotations == null ? 0 : annotations.length; i < length; i++) {
6351 		misplacedAnnotations =  annotations[i];
6352 		if (misplacedAnnotations != null) {
6353 			problemReporter().misplacedTypeAnnotations(misplacedAnnotations[0], misplacedAnnotations[misplacedAnnotations.length - 1]);
6354 		}
6355 	}
6356 	annotations = typeReference.getAnnotationsOnDimensions(true);
6357 	for (int i = 0, length = annotations == null ? 0 : annotations.length; i < length; i++) {
6358 		misplacedAnnotations = annotations[i];
6359 		if (misplacedAnnotations != null) {
6360 				problemReporter().misplacedTypeAnnotations(misplacedAnnotations[0], misplacedAnnotations[misplacedAnnotations.length - 1]);
6361 		}
6362 	}
6363 typeReference.annotations = null;
6364 typeReference.setAnnotationsOnDimensions(null);
6365 typeReference.bits &= ~ASTNode.HasTypeAnnotations;
6366 }
consumeQualifiedSuperReceiver()6367 protected void consumeQualifiedSuperReceiver() {
6368 	// QualifiedSuperReceiver ::= Name '.' 'super'
6369 	// handle type arguments
6370 	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
6371 	pushOnGenericsLengthStack(0);
6372 	// javac does not accept annotations here anywhere ...
6373 	TypeReference typeReference = getTypeReference(0);
6374 	rejectIllegalTypeAnnotations(typeReference);
6375 	pushOnExpressionStack(
6376 		new QualifiedSuperReference(
6377 			typeReference,
6378 			this.intStack[this.intPtr--],
6379 			this.endPosition));
6380 }
consumePrimaryNoNewArrayNameThis()6381 protected void consumePrimaryNoNewArrayNameThis() {
6382 	// PrimaryNoNewArray ::= Name '.' 'this'
6383 	// handle type arguments
6384 	pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
6385 	pushOnGenericsLengthStack(0); // handle type arguments
6386 	// javac does not accept annotations here anywhere ...
6387 	TypeReference typeReference = getTypeReference(0);
6388 	rejectIllegalTypeAnnotations(typeReference);
6389 	pushOnExpressionStack(
6390 		new QualifiedThisReference(
6391 			typeReference,
6392 			this.intStack[this.intPtr--],
6393 			this.endPosition));
6394 }
consumePrimaryNoNewArrayPrimitiveArrayType()6395 protected void consumePrimaryNoNewArrayPrimitiveArrayType() {
6396 	// PrimaryNoNewArray ::= PrimitiveType Dims '.' 'class'
6397 	this.intPtr--; // remove the class start position
6398 	ClassLiteralAccess cla;
6399 	pushOnExpressionStack(
6400 		cla = new ClassLiteralAccess(this.intStack[this.intPtr--], getTypeReference(this.intStack[this.intPtr--])));
6401 	rejectIllegalTypeAnnotations(cla.type);
6402 }
consumePrimaryNoNewArrayPrimitiveType()6403 protected void consumePrimaryNoNewArrayPrimitiveType() {
6404 	// PrimaryNoNewArray ::= PrimitiveType '.' 'class'
6405 	this.intPtr--; // remove the class start position
6406 	ClassLiteralAccess cla;
6407 	pushOnExpressionStack(
6408 		cla = new ClassLiteralAccess(this.intStack[this.intPtr--], getTypeReference(0)));
6409 	rejectIllegalTypeAnnotations(cla.type);
6410 }
consumePrimaryNoNewArrayThis()6411 protected void consumePrimaryNoNewArrayThis() {
6412 	// PrimaryNoNewArray ::= 'this'
6413 	pushOnExpressionStack(new ThisReference(this.intStack[this.intPtr--], this.endPosition));
6414 }
consumePrimaryNoNewArrayWithName()6415 protected void consumePrimaryNoNewArrayWithName() {
6416 	// PrimaryNoNewArray ::=  PushLPAREN Name PushRPAREN
6417 	pushOnExpressionStack(getUnspecifiedReferenceOptimized());
6418 	final Expression parenthesizedExpression = this.expressionStack[this.expressionPtr];
6419 	updateSourcePosition(parenthesizedExpression);
6420 	int numberOfParenthesis = (parenthesizedExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
6421 	parenthesizedExpression.bits &= ~ASTNode.ParenthesizedMASK;
6422 	parenthesizedExpression.bits |= (numberOfParenthesis + 1) << ASTNode.ParenthesizedSHIFT;
6423 }
consumePrimitiveArrayType()6424 protected void consumePrimitiveArrayType() {
6425 	// nothing to do
6426 	// Will be consume by a getTypeRefence call
6427 }
consumePrimitiveType()6428 protected void consumePrimitiveType() {
6429 	// Type ::= PrimitiveType
6430 	pushOnIntStack(0);
6431 }
consumePushLeftBrace()6432 protected void consumePushLeftBrace() {
6433 	pushOnIntStack(this.endPosition); // modifiers
6434 }
consumePushModifiers()6435 protected void consumePushModifiers() {
6436 	pushOnIntStack(this.modifiers); // modifiers
6437 	pushOnIntStack(this.modifiersSourceStart);
6438 	resetModifiers();
6439 	pushOnExpressionStackLengthStack(0);
6440 }
consumePushCombineModifiers()6441 protected void consumePushCombineModifiers() {
6442 	// ModifiersWithDefault ::= Modifiersopt 'default' Modifiersopt'
6443 	// int stack on entry : ... Modifiers, ModifiersSourceStart, defaultSourceStart, defaultSourceEnd, Modifiers', Modifiers'SourceStart <<--- intPtr
6444 	// int stack on exit : ... combinedModifiers, combinedModifiersSourceStart <<--- intPtr
6445 
6446 	this.intPtr--; // pop modifiers'SourceStart, real location is with earlier block
6447 	int newModifiers = this.intStack[this.intPtr--] | ExtraCompilerModifiers.AccDefaultMethod; // pop modifiers
6448 	this.intPtr -= 2; // pop location of 'default' keyword
6449 
6450 	if ((this.intStack[this.intPtr - 1] & newModifiers) != 0) { // duplicate modifier(s) ?
6451 		newModifiers |= ExtraCompilerModifiers.AccAlternateModifierProblem;
6452 	}
6453 	this.intStack[this.intPtr - 1] |= newModifiers; // merge them in place
6454 	// Also fix number of annotations-modifiers:
6455 	this.expressionLengthStack[this.expressionLengthPtr - 1] += this.expressionLengthStack[this.expressionLengthPtr--];
6456 	if (this.currentElement != null) {
6457 		this.currentElement.addModifier(newModifiers, this.intStack[this.intPtr]);
6458 	}
6459 }
consumePushModifiersForHeader()6460 protected void consumePushModifiersForHeader() {
6461 	checkComment(); // might update modifiers with AccDeprecated
6462 	pushOnIntStack(this.modifiers); // modifiers
6463 	pushOnIntStack(this.modifiersSourceStart);
6464 	resetModifiers();
6465 	pushOnExpressionStackLengthStack(0);
6466 }
consumePushPosition()6467 protected void consumePushPosition() {
6468 	// for source managment purpose
6469 	// PushPosition ::= $empty
6470 	pushOnIntStack(this.endPosition);
6471 }
consumePushRealModifiers()6472 protected void consumePushRealModifiers() {
6473 	checkComment(); // might update modifiers with AccDeprecated
6474 	pushOnIntStack(this.modifiers); // modifiers
6475 	pushOnIntStack(this.modifiersSourceStart);
6476 	resetModifiers();
6477 }
consumeQualifiedName(boolean qualifiedNameIsAnnotated)6478 protected void consumeQualifiedName(boolean qualifiedNameIsAnnotated) {
6479 	// QualifiedName ::= Name '.' SimpleName
6480 	// QualifiedName ::= Name '.' TypeAnnotations SimpleName
6481 	/*back from the recursive loop of QualifiedName.
6482 	Updates identifier length into the length stack*/
6483 
6484 	this.identifierLengthStack[--this.identifierLengthPtr]++;
6485 	if (!qualifiedNameIsAnnotated) {
6486 		pushOnTypeAnnotationLengthStack(0);
6487 	}
6488 }
consumeUnannotatableQualifiedName()6489 protected void consumeUnannotatableQualifiedName() {
6490 	// UnannotatableName ::= UnannotatableName '.' SimpleName
6491 	this.identifierLengthStack[--this.identifierLengthPtr]++;
6492 }
consumeRecoveryMethodHeaderName()6493 protected void consumeRecoveryMethodHeaderName() {
6494 	// this method is call only inside recovery
6495 	boolean isAnnotationMethod = false;
6496 	if(this.currentElement instanceof RecoveredType) {
6497 		isAnnotationMethod = (((RecoveredType)this.currentElement).typeDeclaration.modifiers & ClassFileConstants.AccAnnotation) != 0;
6498 	} else {
6499 		RecoveredType recoveredType = this.currentElement.enclosingType();
6500 		if(recoveredType != null) {
6501 			isAnnotationMethod = (recoveredType.typeDeclaration.modifiers & ClassFileConstants.AccAnnotation) != 0;
6502 		}
6503 	}
6504 	consumeMethodHeaderName(isAnnotationMethod);
6505 }
consumeRecoveryMethodHeaderNameWithTypeParameters()6506 protected void consumeRecoveryMethodHeaderNameWithTypeParameters() {
6507 	// this method is call only inside recovery
6508 	boolean isAnnotationMethod = false;
6509 	if(this.currentElement instanceof RecoveredType) {
6510 		isAnnotationMethod = (((RecoveredType)this.currentElement).typeDeclaration.modifiers & ClassFileConstants.AccAnnotation) != 0;
6511 	} else {
6512 		RecoveredType recoveredType = this.currentElement.enclosingType();
6513 		if(recoveredType != null) {
6514 			isAnnotationMethod = (recoveredType.typeDeclaration.modifiers & ClassFileConstants.AccAnnotation) != 0;
6515 		}
6516 	}
6517 	consumeMethodHeaderNameWithTypeParameters(isAnnotationMethod);
6518 }
consumeReduceImports()6519 protected void consumeReduceImports() {
6520 	// Consume imports
6521 	int length;
6522 	if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
6523 		this.astPtr -= length;
6524 		System.arraycopy(
6525 			this.astStack,
6526 			this.astPtr + 1,
6527 			this.compilationUnit.imports = new ImportReference[length],
6528 			0,
6529 			length);
6530 	}
6531 }
consumeReferenceType()6532 protected void consumeReferenceType() {
6533 	pushOnIntStack(0); // handle array type
6534 }
consumeReferenceType1()6535 protected void consumeReferenceType1() {
6536 	pushOnGenericsStack(getTypeReference(this.intStack[this.intPtr--]));
6537 }
consumeReferenceType2()6538 protected void consumeReferenceType2() {
6539 	pushOnGenericsStack(getTypeReference(this.intStack[this.intPtr--]));
6540 }
consumeReferenceType3()6541 protected void consumeReferenceType3() {
6542 	pushOnGenericsStack(getTypeReference(this.intStack[this.intPtr--]));
6543 }
consumeResourceAsLocalVariable()6544 protected void consumeResourceAsLocalVariable() {
6545 	// Resource ::= Name
6546 	NameReference ref = getUnspecifiedReference(true);
6547 	//ref.bits |= ASTNode.IsCapturedOuterLocal;
6548 	pushOnAstStack(ref);
6549  }
consumeResourceAsFieldAccess()6550 protected void consumeResourceAsFieldAccess() {
6551 	// Resource ::= FieldAccess
6552 	FieldReference ref = (FieldReference) this.expressionStack[this.expressionPtr--];
6553 	//NameReference ref = getUnspecifiedReference(true);
6554 	//ref.bits |= ASTNode.IsCapturedOuterLocal;
6555 	pushOnAstStack(ref);
6556  }
consumeResourceAsLocalVariableDeclaration()6557 protected void consumeResourceAsLocalVariableDeclaration() {
6558 	// Resource ::= Type PushModifiers VariableDeclaratorId EnterVariable '=' ForceNoDiet VariableInitializer RestoreDiet ExitVariableWithInitialization
6559 	// Resource ::= Modifiers Type PushRealModifiers VariableDeclaratorId EnterVariable '=' ForceNoDiet VariableInitializer RestoreDiet ExitVariableWithInitialization
6560 	consumeLocalVariableDeclaration();
6561 }
consumeResourceSpecification()6562 protected void consumeResourceSpecification() {
6563 	// ResourceSpecification ::= '(' Resources ')'
6564 }
consumeResourceOptionalTrailingSemiColon(boolean punctuated)6565 protected void consumeResourceOptionalTrailingSemiColon(boolean punctuated) {
6566 	// TrailingSemiColon ::= ';'
6567 	Statement statement = (Statement) this.astStack[this.astPtr];
6568 
6569 	if (punctuated) {
6570 		if (statement instanceof LocalDeclaration) {
6571 			((LocalDeclaration) statement).declarationSourceEnd = this.endStatementPosition;
6572 		}
6573 	}
6574 }
consumeRestoreDiet()6575 protected void consumeRestoreDiet() {
6576 	// RestoreDiet ::= $empty
6577 	this.dietInt--;
6578 }
consumeRightParen()6579 protected void consumeRightParen() {
6580 	// PushRPAREN ::= ')'
6581 	pushOnIntStack(this.rParenPos);
6582 }
consumeNonTypeUseName()6583 protected void consumeNonTypeUseName() { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=383596
6584 	// RejectTypeAnnotations ::= $empty
6585 	// We can get here with type annotation stack empty, because completion parser manipulates the identifier stacks even without rule reduction. See completionIdentifierCheck
6586 	for (int i = this.identifierLengthStack[this.identifierLengthPtr]; i > 0 && this.typeAnnotationLengthPtr >= 0; --i) {
6587 		int length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--];
6588 		Annotation [] typeAnnotations;
6589 		if (length != 0) {
6590 			System.arraycopy(
6591 					this.typeAnnotationStack,
6592 					(this.typeAnnotationPtr -= length) + 1,
6593 					typeAnnotations = new Annotation[length],
6594 					0,
6595 					length);
6596 			problemReporter().misplacedTypeAnnotations(typeAnnotations[0], typeAnnotations[typeAnnotations.length - 1]);
6597 		}
6598 	}
6599 }
consumeZeroTypeAnnotations()6600 protected void consumeZeroTypeAnnotations() {
6601 	// PushZeroTypeAnnotations ::= $empty
6602 	// Name ::= SimpleName
6603 	// TypeAnnotationsopt ::= $empty
6604 	pushOnTypeAnnotationLengthStack(0); // signal absence of @308 annotations.
6605 }
6606 // BEGIN_AUTOGENERATED_REGION_CONSUME_RULE
6607 // This method is part of an automatic generation : do NOT edit-modify
consumeRule(int act)6608 protected void consumeRule(int act) {
6609   switch ( act ) {
6610     case 37 : if (DEBUG) { System.out.println("Type ::= PrimitiveType"); }  //$NON-NLS-1$
6611 		    consumePrimitiveType();
6612 			break;
6613 
6614     case 51 : if (DEBUG) { System.out.println("ReferenceType ::= ClassOrInterfaceType"); }  //$NON-NLS-1$
6615 		    consumeReferenceType();
6616 			break;
6617 
6618     case 55 : if (DEBUG) { System.out.println("ClassOrInterface ::= Name"); }  //$NON-NLS-1$
6619 		    consumeClassOrInterfaceName();
6620 			break;
6621 
6622     case 56 : if (DEBUG) { System.out.println("ClassOrInterface ::= GenericType DOT Name"); }  //$NON-NLS-1$
6623 		    consumeClassOrInterface();
6624 			break;
6625 
6626     case 57 : if (DEBUG) { System.out.println("GenericType ::= ClassOrInterface TypeArguments"); }  //$NON-NLS-1$
6627 		    consumeGenericType();
6628 			break;
6629 
6630     case 58 : if (DEBUG) { System.out.println("GenericType ::= ClassOrInterface LESS GREATER"); }  //$NON-NLS-1$
6631 		    consumeGenericTypeWithDiamond();
6632 			break;
6633 
6634     case 59 : if (DEBUG) { System.out.println("ArrayTypeWithTypeArgumentsName ::= GenericType DOT Name"); }  //$NON-NLS-1$
6635 		    consumeArrayTypeWithTypeArgumentsName();
6636 			break;
6637 
6638     case 60 : if (DEBUG) { System.out.println("ArrayType ::= PrimitiveType Dims"); }  //$NON-NLS-1$
6639 		    consumePrimitiveArrayType();
6640 			break;
6641 
6642     case 61 : if (DEBUG) { System.out.println("ArrayType ::= Name Dims"); }  //$NON-NLS-1$
6643 		    consumeNameArrayType();
6644 			break;
6645 
6646     case 62 : if (DEBUG) { System.out.println("ArrayType ::= ArrayTypeWithTypeArgumentsName Dims"); }  //$NON-NLS-1$
6647 		    consumeGenericTypeNameArrayType();
6648 			break;
6649 
6650     case 63 : if (DEBUG) { System.out.println("ArrayType ::= GenericType Dims"); }  //$NON-NLS-1$
6651 		    consumeGenericTypeArrayType();
6652 			break;
6653 
6654     case 65 : if (DEBUG) { System.out.println("Name ::= SimpleName"); }  //$NON-NLS-1$
6655 		    consumeZeroTypeAnnotations();
6656 			break;
6657 
6658     case 70 : if (DEBUG) { System.out.println("UnannotatableName ::= UnannotatableName DOT SimpleName"); }  //$NON-NLS-1$
6659 		    consumeUnannotatableQualifiedName();
6660 			break;
6661 
6662     case 71 : if (DEBUG) { System.out.println("QualifiedName ::= Name DOT SimpleName"); }  //$NON-NLS-1$
6663 		    consumeQualifiedName(false);
6664 			break;
6665 
6666     case 72 : if (DEBUG) { System.out.println("QualifiedName ::= Name DOT TypeAnnotations SimpleName"); }  //$NON-NLS-1$
6667 		    consumeQualifiedName(true);
6668 			break;
6669 
6670     case 73 : if (DEBUG) { System.out.println("TypeAnnotationsopt ::="); }  //$NON-NLS-1$
6671 		    consumeZeroTypeAnnotations();
6672 			break;
6673 
6674      case 77 : if (DEBUG) { System.out.println("TypeAnnotations0 ::= TypeAnnotations0 TypeAnnotation"); }  //$NON-NLS-1$
6675 		    consumeOneMoreTypeAnnotation();
6676 			break;
6677 
6678      case 78 : if (DEBUG) { System.out.println("TypeAnnotation ::= NormalTypeAnnotation"); }  //$NON-NLS-1$
6679 		    consumeTypeAnnotation();
6680 			break;
6681 
6682      case 79 : if (DEBUG) { System.out.println("TypeAnnotation ::= MarkerTypeAnnotation"); }  //$NON-NLS-1$
6683 		    consumeTypeAnnotation();
6684 			break;
6685 
6686      case 80 : if (DEBUG) { System.out.println("TypeAnnotation ::= SingleMemberTypeAnnotation"); }  //$NON-NLS-1$
6687 		    consumeTypeAnnotation();
6688 			break;
6689 
6690     case 81 : if (DEBUG) { System.out.println("TypeAnnotationName ::= AT308 UnannotatableName"); }  //$NON-NLS-1$
6691 		    consumeAnnotationName() ;
6692 			break;
6693 
6694     case 82 : if (DEBUG) { System.out.println("NormalTypeAnnotation ::= TypeAnnotationName LPAREN..."); }  //$NON-NLS-1$
6695 		    consumeNormalAnnotation(true) ;
6696 			break;
6697 
6698     case 83 : if (DEBUG) { System.out.println("MarkerTypeAnnotation ::= TypeAnnotationName"); }  //$NON-NLS-1$
6699 		    consumeMarkerAnnotation(true) ;
6700 			break;
6701 
6702     case 84 : if (DEBUG) { System.out.println("SingleMemberTypeAnnotation ::= TypeAnnotationName LPAREN"); }  //$NON-NLS-1$
6703 		    consumeSingleMemberAnnotation(true) ;
6704 			break;
6705 
6706     case 85 : if (DEBUG) { System.out.println("RejectTypeAnnotations ::="); }  //$NON-NLS-1$
6707 		    consumeNonTypeUseName();
6708 			break;
6709 
6710     case 86 : if (DEBUG) { System.out.println("PushZeroTypeAnnotations ::="); }  //$NON-NLS-1$
6711 		    consumeZeroTypeAnnotations();
6712 			break;
6713 
6714     case 87 : if (DEBUG) { System.out.println("VariableDeclaratorIdOrThis ::= this"); }  //$NON-NLS-1$
6715 		    consumeExplicitThisParameter(false);
6716 			break;
6717 
6718     case 88 : if (DEBUG) { System.out.println("VariableDeclaratorIdOrThis ::= UnannotatableName DOT this"); }  //$NON-NLS-1$
6719 		    consumeExplicitThisParameter(true);
6720 			break;
6721 
6722     case 89 : if (DEBUG) { System.out.println("VariableDeclaratorIdOrThis ::= VariableDeclaratorId"); }  //$NON-NLS-1$
6723 		    consumeVariableDeclaratorIdParameter();
6724 			break;
6725 
6726     case 90 : if (DEBUG) { System.out.println("CompilationUnit ::= EnterCompilationUnit..."); }  //$NON-NLS-1$
6727 		    consumeCompilationUnit();
6728 			break;
6729 
6730     case 91 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration"); }  //$NON-NLS-1$
6731 		    consumeInternalCompilationUnit();
6732 			break;
6733 
6734     case 92 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration..."); }  //$NON-NLS-1$
6735 		    consumeInternalCompilationUnit();
6736 			break;
6737 
6738     case 93 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration..."); }  //$NON-NLS-1$
6739 		    consumeInternalCompilationUnitWithTypes();
6740 			break;
6741 
6742     case 94 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration..."); }  //$NON-NLS-1$
6743 		    consumeInternalCompilationUnitWithTypes();
6744 			break;
6745 
6746     case 95 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= ImportDeclarations..."); }  //$NON-NLS-1$
6747 		    consumeInternalCompilationUnit();
6748 			break;
6749 
6750     case 96 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= TypeDeclarations"); }  //$NON-NLS-1$
6751 		    consumeInternalCompilationUnitWithTypes();
6752 			break;
6753 
6754     case 97 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= ImportDeclarations..."); }  //$NON-NLS-1$
6755 		    consumeInternalCompilationUnitWithTypes();
6756 			break;
6757 
6758     case 98 : if (DEBUG) { System.out.println("InternalCompilationUnit ::="); }  //$NON-NLS-1$
6759 		    consumeEmptyInternalCompilationUnit();
6760 			break;
6761 
6762     case 99 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= ImportDeclarations..."); }  //$NON-NLS-1$
6763 		    consumeInternalCompilationUnitWithModuleDeclaration();
6764 			break;
6765 
6766     case 100 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= ModuleDeclaration"); }  //$NON-NLS-1$
6767 		    consumeInternalCompilationUnitWithModuleDeclaration();
6768 			break;
6769 
6770     case 101 : if (DEBUG) { System.out.println("ModuleDeclaration ::= ModuleHeader ModuleBody"); }  //$NON-NLS-1$
6771 		    consumeModuleDeclaration();
6772 			break;
6773 
6774     case 102 : if (DEBUG) { System.out.println("ModuleHeader ::= Modifiersopt ModuleModifieropt module"); }  //$NON-NLS-1$
6775 		    consumeModuleHeader();
6776 			break;
6777 
6778     case 104 : if (DEBUG) { System.out.println("ModuleModifieropt ::= ModuleModifier"); }  //$NON-NLS-1$
6779 		    consumeModuleModifiers();
6780 			break;
6781 
6782     case 107 : if (DEBUG) { System.out.println("ModuleStatementsOpt ::="); }  //$NON-NLS-1$
6783 		    consumeEmptyModuleStatementsOpt();
6784 			break;
6785 
6786     case 110 : if (DEBUG) { System.out.println("ModuleStatements ::= ModuleStatements ModuleStatement"); }  //$NON-NLS-1$
6787 		    consumeModuleStatements();
6788 			break;
6789 
6790     case 116 : if (DEBUG) { System.out.println("RequiresStatement ::= SingleRequiresModuleName SEMICOLON"); }  //$NON-NLS-1$
6791 		    consumeRequiresStatement();
6792 			break;
6793 
6794     case 117 : if (DEBUG) { System.out.println("SingleRequiresModuleName ::= requires..."); }  //$NON-NLS-1$
6795 		    consumeSingleRequiresModuleName();
6796 			break;
6797 
6798     case 118 : if (DEBUG) { System.out.println("RequiresModifiersopt ::= RequiresModifiers"); }  //$NON-NLS-1$
6799 		    consumeModifiers();
6800 			break;
6801 
6802     case 119 : if (DEBUG) { System.out.println("RequiresModifiersopt ::="); }  //$NON-NLS-1$
6803 		    consumeDefaultModifiers();
6804 			break;
6805 
6806     case 121 : if (DEBUG) { System.out.println("RequiresModifiers ::= RequiresModifiers RequiresModifier"); }  //$NON-NLS-1$
6807 		    consumeModifiers2();
6808 			break;
6809 
6810     case 124 : if (DEBUG) { System.out.println("ExportsStatement ::= ExportsHeader TargetModuleListopt"); }  //$NON-NLS-1$
6811 		    consumeExportsStatement();
6812 			break;
6813 
6814     case 125 : if (DEBUG) { System.out.println("ExportsHeader ::= exports SinglePkgName"); }  //$NON-NLS-1$
6815 		    consumeExportsHeader();
6816 			break;
6817 
6818     case 127 : if (DEBUG) { System.out.println("TargetModuleListopt ::= to TargetModuleNameList"); }  //$NON-NLS-1$
6819 		    consumeTargetModuleList();
6820 			break;
6821 
6822     case 128 : if (DEBUG) { System.out.println("TargetModuleName ::= UnannotatableName"); }  //$NON-NLS-1$
6823 		    consumeSingleTargetModuleName();
6824 			break;
6825 
6826     case 130 : if (DEBUG) { System.out.println("TargetModuleNameList ::= TargetModuleNameList COMMA..."); }  //$NON-NLS-1$
6827 		    consumeTargetModuleNameList();
6828 			break;
6829 
6830     case 131 : if (DEBUG) { System.out.println("SinglePkgName ::= UnannotatableName"); }  //$NON-NLS-1$
6831 		    consumeSinglePkgName();
6832 			break;
6833 
6834     case 132 : if (DEBUG) { System.out.println("OpensStatement ::= OpensHeader TargetModuleListopt..."); }  //$NON-NLS-1$
6835 		    consumeOpensStatement();
6836 			break;
6837 
6838     case 133 : if (DEBUG) { System.out.println("OpensHeader ::= opens SinglePkgName"); }  //$NON-NLS-1$
6839 		    consumeOpensHeader();
6840 			break;
6841 
6842     case 134 : if (DEBUG) { System.out.println("UsesStatement ::= UsesHeader SEMICOLON"); }  //$NON-NLS-1$
6843 		    consumeUsesStatement();
6844 			break;
6845 
6846     case 135 : if (DEBUG) { System.out.println("UsesHeader ::= uses Name"); }  //$NON-NLS-1$
6847 		    consumeUsesHeader();
6848 			break;
6849 
6850     case 136 : if (DEBUG) { System.out.println("ProvidesStatement ::= ProvidesInterface WithClause..."); }  //$NON-NLS-1$
6851 		    consumeProvidesStatement();
6852 			break;
6853 
6854     case 137 : if (DEBUG) { System.out.println("ProvidesInterface ::= provides Name"); }  //$NON-NLS-1$
6855 		    consumeProvidesInterface();
6856 			break;
6857 
6858     case 138 : if (DEBUG) { System.out.println("ServiceImplName ::= Name"); }  //$NON-NLS-1$
6859 		    consumeSingleServiceImplName();
6860 			break;
6861 
6862     case 140 : if (DEBUG) { System.out.println("ServiceImplNameList ::= ServiceImplNameList COMMA..."); }  //$NON-NLS-1$
6863 		    consumeServiceImplNameList();
6864 			break;
6865 
6866     case 141 : if (DEBUG) { System.out.println("WithClause ::= with ServiceImplNameList"); }  //$NON-NLS-1$
6867 		    consumeWithClause();
6868 			break;
6869 
6870     case 142 : if (DEBUG) { System.out.println("ReduceImports ::="); }  //$NON-NLS-1$
6871 		    consumeReduceImports();
6872 			break;
6873 
6874     case 143 : if (DEBUG) { System.out.println("EnterCompilationUnit ::="); }  //$NON-NLS-1$
6875 		    consumeEnterCompilationUnit();
6876 			break;
6877 
6878     case 166 : if (DEBUG) { System.out.println("CatchHeader ::= catch LPAREN CatchFormalParameter RPAREN"); }  //$NON-NLS-1$
6879 		    consumeCatchHeader();
6880 			break;
6881 
6882     case 168 : if (DEBUG) { System.out.println("ImportDeclarations ::= ImportDeclarations..."); }  //$NON-NLS-1$
6883 		    consumeImportDeclarations();
6884 			break;
6885 
6886     case 170 : if (DEBUG) { System.out.println("TypeDeclarations ::= TypeDeclarations TypeDeclaration"); }  //$NON-NLS-1$
6887 		    consumeTypeDeclarations();
6888 			break;
6889 
6890     case 171 : if (DEBUG) { System.out.println("PackageDeclaration ::= PackageDeclarationName SEMICOLON"); }  //$NON-NLS-1$
6891 		    consumePackageDeclaration();
6892 			break;
6893 
6894     case 172 : if (DEBUG) { System.out.println("PackageDeclarationName ::= Modifiers package..."); }  //$NON-NLS-1$
6895 		    consumePackageDeclarationNameWithModifiers();
6896 			break;
6897 
6898     case 173 : if (DEBUG) { System.out.println("PackageDeclarationName ::= PackageComment package Name"); }  //$NON-NLS-1$
6899 		    consumePackageDeclarationName();
6900 			break;
6901 
6902     case 174 : if (DEBUG) { System.out.println("PackageComment ::="); }  //$NON-NLS-1$
6903 		    consumePackageComment();
6904 			break;
6905 
6906     case 179 : if (DEBUG) { System.out.println("SingleTypeImportDeclaration ::=..."); }  //$NON-NLS-1$
6907 		    consumeImportDeclaration();
6908 			break;
6909 
6910     case 180 : if (DEBUG) { System.out.println("SingleTypeImportDeclarationName ::= import Name..."); }  //$NON-NLS-1$
6911 		    consumeSingleTypeImportDeclarationName();
6912 			break;
6913 
6914     case 181 : if (DEBUG) { System.out.println("TypeImportOnDemandDeclaration ::=..."); }  //$NON-NLS-1$
6915 		    consumeImportDeclaration();
6916 			break;
6917 
6918     case 182 : if (DEBUG) { System.out.println("TypeImportOnDemandDeclarationName ::= import Name DOT..."); }  //$NON-NLS-1$
6919 		    consumeTypeImportOnDemandDeclarationName();
6920 			break;
6921 
6922      case 185 : if (DEBUG) { System.out.println("TypeDeclaration ::= SEMICOLON"); }  //$NON-NLS-1$
6923 		    consumeEmptyTypeDeclaration();
6924 			break;
6925 
6926     case 190 : if (DEBUG) { System.out.println("Modifiers ::= Modifiers Modifier"); }  //$NON-NLS-1$
6927 		    consumeModifiers2();
6928 			break;
6929 
6930     case 202 : if (DEBUG) { System.out.println("Modifier ::= Annotation"); }  //$NON-NLS-1$
6931 		    consumeAnnotationAsModifier();
6932 			break;
6933 
6934     case 203 : if (DEBUG) { System.out.println("ClassDeclaration ::= ClassHeader ClassBody"); }  //$NON-NLS-1$
6935 		    consumeClassDeclaration();
6936 			break;
6937 
6938     case 204 : if (DEBUG) { System.out.println("ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt..."); }  //$NON-NLS-1$
6939 		    consumeClassHeader();
6940 			break;
6941 
6942     case 205 : if (DEBUG) { System.out.println("ClassHeaderName ::= ClassHeaderName1 TypeParameters"); }  //$NON-NLS-1$
6943 		    consumeTypeHeaderNameWithTypeParameters();
6944 			break;
6945 
6946     case 207 : if (DEBUG) { System.out.println("ClassHeaderName1 ::= Modifiersopt class Identifier"); }  //$NON-NLS-1$
6947 		    consumeClassHeaderName1();
6948 			break;
6949 
6950     case 208 : if (DEBUG) { System.out.println("ClassHeaderExtends ::= extends ClassType"); }  //$NON-NLS-1$
6951 		    consumeClassHeaderExtends();
6952 			break;
6953 
6954     case 209 : if (DEBUG) { System.out.println("ClassHeaderImplements ::= implements InterfaceTypeList"); }  //$NON-NLS-1$
6955 		    consumeClassHeaderImplements();
6956 			break;
6957 
6958     case 211 : if (DEBUG) { System.out.println("InterfaceTypeList ::= InterfaceTypeList COMMA..."); }  //$NON-NLS-1$
6959 		    consumeInterfaceTypeList();
6960 			break;
6961 
6962     case 212 : if (DEBUG) { System.out.println("InterfaceType ::= ClassOrInterfaceType"); }  //$NON-NLS-1$
6963 		    consumeInterfaceType();
6964 			break;
6965 
6966     case 215 : if (DEBUG) { System.out.println("ClassBodyDeclarations ::= ClassBodyDeclarations..."); }  //$NON-NLS-1$
6967 		    consumeClassBodyDeclarations();
6968 			break;
6969 
6970     case 219 : if (DEBUG) { System.out.println("ClassBodyDeclaration ::= Diet NestedMethod..."); }  //$NON-NLS-1$
6971 		    consumeClassBodyDeclaration();
6972 			break;
6973 
6974     case 220 : if (DEBUG) { System.out.println("Diet ::="); }  //$NON-NLS-1$
6975 		    consumeDiet();
6976 			break;
6977 
6978     case 221 : if (DEBUG) { System.out.println("Initializer ::= Diet NestedMethod CreateInitializer..."); }  //$NON-NLS-1$
6979 		    consumeClassBodyDeclaration();
6980 			break;
6981 
6982     case 222 : if (DEBUG) { System.out.println("CreateInitializer ::="); }  //$NON-NLS-1$
6983 		    consumeCreateInitializer();
6984 			break;
6985 
6986     case 230 : if (DEBUG) { System.out.println("ClassMemberDeclaration ::= SEMICOLON"); }  //$NON-NLS-1$
6987 		    consumeEmptyTypeDeclaration();
6988 			break;
6989 
6990     case 233 : if (DEBUG) { System.out.println("FieldDeclaration ::= Modifiersopt Type..."); }  //$NON-NLS-1$
6991 		    consumeFieldDeclaration();
6992 			break;
6993 
6994     case 235 : if (DEBUG) { System.out.println("VariableDeclarators ::= VariableDeclarators COMMA..."); }  //$NON-NLS-1$
6995 		    consumeVariableDeclarators();
6996 			break;
6997 
6998     case 238 : if (DEBUG) { System.out.println("EnterVariable ::="); }  //$NON-NLS-1$
6999 		    consumeEnterVariable();
7000 			break;
7001 
7002     case 239 : if (DEBUG) { System.out.println("ExitVariableWithInitialization ::="); }  //$NON-NLS-1$
7003 		    consumeExitVariableWithInitialization();
7004 			break;
7005 
7006     case 240 : if (DEBUG) { System.out.println("ExitVariableWithoutInitialization ::="); }  //$NON-NLS-1$
7007 		    consumeExitVariableWithoutInitialization();
7008 			break;
7009 
7010     case 241 : if (DEBUG) { System.out.println("ForceNoDiet ::="); }  //$NON-NLS-1$
7011 		    consumeForceNoDiet();
7012 			break;
7013 
7014     case 242 : if (DEBUG) { System.out.println("RestoreDiet ::="); }  //$NON-NLS-1$
7015 		    consumeRestoreDiet();
7016 			break;
7017 
7018     case 247 : if (DEBUG) { System.out.println("MethodDeclaration ::= MethodHeader MethodBody"); }  //$NON-NLS-1$
7019 		    // set to true to consume a method with a body
7020  consumeMethodDeclaration(true, false);
7021 			break;
7022 
7023     case 248 : if (DEBUG) { System.out.println("MethodDeclaration ::= DefaultMethodHeader MethodBody"); }  //$NON-NLS-1$
7024 		    // set to true to consume a method with a body
7025  consumeMethodDeclaration(true, true);
7026 			break;
7027 
7028     case 249 : if (DEBUG) { System.out.println("AbstractMethodDeclaration ::= MethodHeader SEMICOLON"); }  //$NON-NLS-1$
7029 		    // set to false to consume a method without body
7030  consumeMethodDeclaration(false, false);
7031 			break;
7032 
7033     case 250 : if (DEBUG) { System.out.println("MethodHeader ::= MethodHeaderName FormalParameterListopt"); }  //$NON-NLS-1$
7034 		    consumeMethodHeader();
7035 			break;
7036 
7037     case 251 : if (DEBUG) { System.out.println("DefaultMethodHeader ::= DefaultMethodHeaderName..."); }  //$NON-NLS-1$
7038 		    consumeMethodHeader();
7039 			break;
7040 
7041     case 252 : if (DEBUG) { System.out.println("MethodHeaderName ::= Modifiersopt TypeParameters Type..."); }  //$NON-NLS-1$
7042 		    consumeMethodHeaderNameWithTypeParameters(false);
7043 			break;
7044 
7045     case 253 : if (DEBUG) { System.out.println("MethodHeaderName ::= Modifiersopt Type Identifier LPAREN"); }  //$NON-NLS-1$
7046 		    consumeMethodHeaderName(false);
7047 			break;
7048 
7049     case 254 : if (DEBUG) { System.out.println("DefaultMethodHeaderName ::= ModifiersWithDefault..."); }  //$NON-NLS-1$
7050 		    consumeMethodHeaderNameWithTypeParameters(false);
7051 			break;
7052 
7053     case 255 : if (DEBUG) { System.out.println("DefaultMethodHeaderName ::= ModifiersWithDefault Type..."); }  //$NON-NLS-1$
7054 		    consumeMethodHeaderName(false);
7055 			break;
7056 
7057     case 256 : if (DEBUG) { System.out.println("ModifiersWithDefault ::= Modifiersopt default..."); }  //$NON-NLS-1$
7058 		    consumePushCombineModifiers();
7059 			break;
7060 
7061     case 257 : if (DEBUG) { System.out.println("MethodHeaderRightParen ::= RPAREN"); }  //$NON-NLS-1$
7062 		    consumeMethodHeaderRightParen();
7063 			break;
7064 
7065     case 258 : if (DEBUG) { System.out.println("MethodHeaderExtendedDims ::= Dimsopt"); }  //$NON-NLS-1$
7066 		    consumeMethodHeaderExtendedDims();
7067 			break;
7068 
7069     case 259 : if (DEBUG) { System.out.println("MethodHeaderThrowsClause ::= throws ClassTypeList"); }  //$NON-NLS-1$
7070 		    consumeMethodHeaderThrowsClause();
7071 			break;
7072 
7073     case 260 : if (DEBUG) { System.out.println("ConstructorHeader ::= ConstructorHeaderName..."); }  //$NON-NLS-1$
7074 		    consumeConstructorHeader();
7075 			break;
7076 
7077     case 261 : if (DEBUG) { System.out.println("ConstructorHeaderName ::= Modifiersopt TypeParameters..."); }  //$NON-NLS-1$
7078 		    consumeConstructorHeaderNameWithTypeParameters();
7079 			break;
7080 
7081     case 262 : if (DEBUG) { System.out.println("ConstructorHeaderName ::= Modifiersopt Identifier LPAREN"); }  //$NON-NLS-1$
7082 		    consumeConstructorHeaderName();
7083 			break;
7084 
7085     case 264 : if (DEBUG) { System.out.println("FormalParameterList ::= FormalParameterList COMMA..."); }  //$NON-NLS-1$
7086 		    consumeFormalParameterList();
7087 			break;
7088 
7089     case 265 : if (DEBUG) { System.out.println("FormalParameter ::= Modifiersopt Type..."); }  //$NON-NLS-1$
7090 		    consumeFormalParameter(false);
7091 			break;
7092 
7093     case 266 : if (DEBUG) { System.out.println("FormalParameter ::= Modifiersopt Type..."); }  //$NON-NLS-1$
7094 		    consumeFormalParameter(true);
7095 			break;
7096 
7097     case 267 : if (DEBUG) { System.out.println("FormalParameter ::= Modifiersopt Type AT308DOTDOTDOT..."); }  //$NON-NLS-1$
7098 		    consumeFormalParameter(true);
7099 			break;
7100 
7101     case 268 : if (DEBUG) { System.out.println("CatchFormalParameter ::= Modifiersopt CatchType..."); }  //$NON-NLS-1$
7102 		    consumeCatchFormalParameter();
7103 			break;
7104 
7105     case 269 : if (DEBUG) { System.out.println("CatchType ::= UnionType"); }  //$NON-NLS-1$
7106 		    consumeCatchType();
7107 			break;
7108 
7109     case 270 : if (DEBUG) { System.out.println("UnionType ::= Type"); }  //$NON-NLS-1$
7110 		    consumeUnionTypeAsClassType();
7111 			break;
7112 
7113     case 271 : if (DEBUG) { System.out.println("UnionType ::= UnionType OR Type"); }  //$NON-NLS-1$
7114 		    consumeUnionType();
7115 			break;
7116 
7117     case 273 : if (DEBUG) { System.out.println("ClassTypeList ::= ClassTypeList COMMA ClassTypeElt"); }  //$NON-NLS-1$
7118 		    consumeClassTypeList();
7119 			break;
7120 
7121     case 274 : if (DEBUG) { System.out.println("ClassTypeElt ::= ClassType"); }  //$NON-NLS-1$
7122 		    consumeClassTypeElt();
7123 			break;
7124 
7125     case 275 : if (DEBUG) { System.out.println("MethodBody ::= NestedMethod LBRACE BlockStatementsopt..."); }  //$NON-NLS-1$
7126 		    consumeMethodBody();
7127 			break;
7128 
7129     case 276 : if (DEBUG) { System.out.println("NestedMethod ::="); }  //$NON-NLS-1$
7130 		    consumeNestedMethod();
7131 			break;
7132 
7133     case 277 : if (DEBUG) { System.out.println("StaticInitializer ::= StaticOnly Block"); }  //$NON-NLS-1$
7134 		    consumeStaticInitializer();
7135 			break;
7136 
7137     case 278 : if (DEBUG) { System.out.println("StaticOnly ::= static"); }  //$NON-NLS-1$
7138 		    consumeStaticOnly();
7139 			break;
7140 
7141     case 279 : if (DEBUG) { System.out.println("ConstructorDeclaration ::= ConstructorHeader MethodBody"); }  //$NON-NLS-1$
7142 		    consumeConstructorDeclaration() ;
7143 			break;
7144 
7145     case 280 : if (DEBUG) { System.out.println("ConstructorDeclaration ::= ConstructorHeader SEMICOLON"); }  //$NON-NLS-1$
7146 		    consumeInvalidConstructorDeclaration() ;
7147 			break;
7148 
7149     case 281 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= this LPAREN..."); }  //$NON-NLS-1$
7150 		    consumeExplicitConstructorInvocation(0, THIS_CALL);
7151 			break;
7152 
7153     case 282 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= OnlyTypeArguments this"); }  //$NON-NLS-1$
7154 		    consumeExplicitConstructorInvocationWithTypeArguments(0,THIS_CALL);
7155 			break;
7156 
7157     case 283 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= super LPAREN..."); }  //$NON-NLS-1$
7158 		    consumeExplicitConstructorInvocation(0,SUPER_CALL);
7159 			break;
7160 
7161     case 284 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= OnlyTypeArguments..."); }  //$NON-NLS-1$
7162 		    consumeExplicitConstructorInvocationWithTypeArguments(0,SUPER_CALL);
7163 			break;
7164 
7165     case 285 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT super..."); }  //$NON-NLS-1$
7166 		    consumeExplicitConstructorInvocation(1, SUPER_CALL);
7167 			break;
7168 
7169     case 286 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT..."); }  //$NON-NLS-1$
7170 		    consumeExplicitConstructorInvocationWithTypeArguments(1, SUPER_CALL);
7171 			break;
7172 
7173     case 287 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT super LPAREN"); }  //$NON-NLS-1$
7174 		    consumeExplicitConstructorInvocation(2, SUPER_CALL);
7175 			break;
7176 
7177     case 288 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT..."); }  //$NON-NLS-1$
7178 		    consumeExplicitConstructorInvocationWithTypeArguments(2, SUPER_CALL);
7179 			break;
7180 
7181     case 289 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT this..."); }  //$NON-NLS-1$
7182 		    consumeExplicitConstructorInvocation(1, THIS_CALL);
7183 			break;
7184 
7185     case 290 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT..."); }  //$NON-NLS-1$
7186 		    consumeExplicitConstructorInvocationWithTypeArguments(1, THIS_CALL);
7187 			break;
7188 
7189     case 291 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT this LPAREN"); }  //$NON-NLS-1$
7190 		    consumeExplicitConstructorInvocation(2, THIS_CALL);
7191 			break;
7192 
7193     case 292 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT..."); }  //$NON-NLS-1$
7194 		    consumeExplicitConstructorInvocationWithTypeArguments(2, THIS_CALL);
7195 			break;
7196 
7197     case 293 : if (DEBUG) { System.out.println("InterfaceDeclaration ::= InterfaceHeader InterfaceBody"); }  //$NON-NLS-1$
7198 		    consumeInterfaceDeclaration();
7199 			break;
7200 
7201     case 294 : if (DEBUG) { System.out.println("InterfaceHeader ::= InterfaceHeaderName..."); }  //$NON-NLS-1$
7202 		    consumeInterfaceHeader();
7203 			break;
7204 
7205     case 295 : if (DEBUG) { System.out.println("InterfaceHeaderName ::= InterfaceHeaderName1..."); }  //$NON-NLS-1$
7206 		    consumeTypeHeaderNameWithTypeParameters();
7207 			break;
7208 
7209     case 297 : if (DEBUG) { System.out.println("InterfaceHeaderName1 ::= Modifiersopt interface..."); }  //$NON-NLS-1$
7210 		    consumeInterfaceHeaderName1();
7211 			break;
7212 
7213     case 298 : if (DEBUG) { System.out.println("InterfaceHeaderExtends ::= extends InterfaceTypeList"); }  //$NON-NLS-1$
7214 		    consumeInterfaceHeaderExtends();
7215 			break;
7216 
7217     case 301 : if (DEBUG) { System.out.println("InterfaceMemberDeclarations ::=..."); }  //$NON-NLS-1$
7218 		    consumeInterfaceMemberDeclarations();
7219 			break;
7220 
7221     case 302 : if (DEBUG) { System.out.println("InterfaceMemberDeclaration ::= SEMICOLON"); }  //$NON-NLS-1$
7222 		    consumeEmptyTypeDeclaration();
7223 			break;
7224 
7225     case 304 : if (DEBUG) { System.out.println("InterfaceMemberDeclaration ::= DefaultMethodHeader..."); }  //$NON-NLS-1$
7226 		    consumeInterfaceMethodDeclaration(false);
7227 			break;
7228 
7229     case 305 : if (DEBUG) { System.out.println("InterfaceMemberDeclaration ::= MethodHeader MethodBody"); }  //$NON-NLS-1$
7230 		    consumeInterfaceMethodDeclaration(false);
7231 			break;
7232 
7233     case 306 : if (DEBUG) { System.out.println("InterfaceMemberDeclaration ::= DefaultMethodHeader..."); }  //$NON-NLS-1$
7234 		    consumeInterfaceMethodDeclaration(true);
7235 			break;
7236 
7237     case 307 : if (DEBUG) { System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader..."); }  //$NON-NLS-1$
7238 		    consumeInvalidConstructorDeclaration(true);
7239 			break;
7240 
7241     case 308 : if (DEBUG) { System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader..."); }  //$NON-NLS-1$
7242 		    consumeInvalidConstructorDeclaration(false);
7243 			break;
7244 
7245     case 319 : if (DEBUG) { System.out.println("RecordDeclaration ::= RecordHeaderPart RecordBody"); }  //$NON-NLS-1$
7246 		    consumeRecordDeclaration();
7247 			break;
7248 
7249     case 320 : if (DEBUG) { System.out.println("RecordHeaderPart ::= RecordHeaderName RecordHeader..."); }  //$NON-NLS-1$
7250 		    consumeRecordHeaderPart();
7251 			break;
7252 
7253     case 321 : if (DEBUG) { System.out.println("RecordHeaderName ::= RecordHeaderName1 TypeParameters"); }  //$NON-NLS-1$
7254 		    consumeRecordHeaderNameWithTypeParameters();
7255 			break;
7256 
7257     case 323 : if (DEBUG) { System.out.println("RecordHeaderName1 ::= Modifiersopt..."); }  //$NON-NLS-1$
7258 		    consumeRecordHeaderName1();
7259 			break;
7260 
7261     case 324 : if (DEBUG) { System.out.println("RecordComponentHeaderRightParen ::= RPAREN"); }  //$NON-NLS-1$
7262 		    consumeRecordComponentHeaderRightParen();
7263 			break;
7264 
7265     case 325 : if (DEBUG) { System.out.println("RecordHeader ::= LPAREN RecordComponentsopt..."); }  //$NON-NLS-1$
7266 		    consumeRecordHeader();
7267 			break;
7268 
7269     case 326 : if (DEBUG) { System.out.println("RecordComponentsopt ::="); }  //$NON-NLS-1$
7270 		    consumeRecordComponentsopt();
7271 			break;
7272 
7273     case 329 : if (DEBUG) { System.out.println("RecordComponents ::= RecordComponents COMMA..."); }  //$NON-NLS-1$
7274 		    consumeRecordComponents();
7275 			break;
7276 
7277     case 331 : if (DEBUG) { System.out.println("RecordComponent ::= Modifiersopt Type..."); }  //$NON-NLS-1$
7278 		    consumeRecordComponent(false);
7279 			break;
7280 
7281     case 332 : if (DEBUG) { System.out.println("VariableArityRecordComponent ::= Modifiersopt Type..."); }  //$NON-NLS-1$
7282 		    consumeRecordComponent(true);
7283 			break;
7284 
7285     case 333 : if (DEBUG) { System.out.println("VariableArityRecordComponent ::= Modifiersopt Type..."); }  //$NON-NLS-1$
7286 		    consumeRecordComponent(true);
7287 			break;
7288 
7289     case 334 : if (DEBUG) { System.out.println("RecordBody ::= LBRACE RecordBodyDeclarationopt RBRACE"); }  //$NON-NLS-1$
7290 		    consumeRecordBody();
7291 			break;
7292 
7293     case 335 : if (DEBUG) { System.out.println("RecordBodyDeclarationopt ::="); }  //$NON-NLS-1$
7294 		    consumeEmptyRecordBodyDeclaration();
7295 			break;
7296 
7297     case 338 : if (DEBUG) { System.out.println("RecordBodyDeclarations ::= RecordBodyDeclarations..."); }  //$NON-NLS-1$
7298 		    consumeRecordBodyDeclarations();
7299 			break;
7300 
7301     case 339 : if (DEBUG) { System.out.println("RecordBodyDeclaration ::= ClassBodyDeclaration"); }  //$NON-NLS-1$
7302 		    consumeRecordBodyDeclaration();
7303 			break;
7304 
7305     case 340 : if (DEBUG) { System.out.println("RecordBodyDeclaration ::= CompactConstructorDeclaration"); }  //$NON-NLS-1$
7306 		    consumeRecordBodyDeclaration();
7307 			break;
7308 
7309     case 341 : if (DEBUG) { System.out.println("CompactConstructorDeclaration ::=..."); }  //$NON-NLS-1$
7310 		    consumeCompactConstructorDeclaration();
7311 			break;
7312 
7313     case 342 : if (DEBUG) { System.out.println("CompactConstructorHeader ::=..."); }  //$NON-NLS-1$
7314 		    consumeCompactConstructorHeader();
7315 			break;
7316 
7317     case 343 : if (DEBUG) { System.out.println("CompactConstructorHeaderName ::= Modifiersopt Identifier"); }  //$NON-NLS-1$
7318 		    consumeCompactConstructorHeaderName();
7319 			break;
7320 
7321     case 344 : if (DEBUG) { System.out.println("CompactConstructorHeaderName ::= Modifiersopt..."); }  //$NON-NLS-1$
7322 		    consumeCompactConstructorHeaderNameWithTypeParameters();
7323 			break;
7324 
7325     case 346 : if (DEBUG) { System.out.println("InstanceofExpression ::= InstanceofExpression instanceof"); }  //$NON-NLS-1$
7326 		    consumeInstanceOfExpression();
7327 			break;
7328 
7329     case 350 : if (DEBUG) { System.out.println("TypeTestPattern ::= Type Identifier"); }  //$NON-NLS-1$
7330 		    consumeTypeTestPattern();
7331 			break;
7332 
7333     case 352 : if (DEBUG) { System.out.println("PushLeftBrace ::="); }  //$NON-NLS-1$
7334 		    consumePushLeftBrace();
7335 			break;
7336 
7337     case 353 : if (DEBUG) { System.out.println("ArrayInitializer ::= LBRACE PushLeftBrace ,opt RBRACE"); }  //$NON-NLS-1$
7338 		    consumeEmptyArrayInitializer();
7339 			break;
7340 
7341     case 354 : if (DEBUG) { System.out.println("ArrayInitializer ::= LBRACE PushLeftBrace..."); }  //$NON-NLS-1$
7342 		    consumeArrayInitializer();
7343 			break;
7344 
7345     case 355 : if (DEBUG) { System.out.println("ArrayInitializer ::= LBRACE PushLeftBrace..."); }  //$NON-NLS-1$
7346 		    consumeArrayInitializer();
7347 			break;
7348 
7349     case 357 : if (DEBUG) { System.out.println("VariableInitializers ::= VariableInitializers COMMA..."); }  //$NON-NLS-1$
7350 		    consumeVariableInitializers();
7351 			break;
7352 
7353     case 358 : if (DEBUG) { System.out.println("Block ::= OpenBlock LBRACE BlockStatementsopt RBRACE"); }  //$NON-NLS-1$
7354 		    consumeBlock();
7355 			break;
7356 
7357     case 359 : if (DEBUG) { System.out.println("OpenBlock ::="); }  //$NON-NLS-1$
7358 		    consumeOpenBlock() ;
7359 			break;
7360 
7361     case 360 : if (DEBUG) { System.out.println("BlockStatements ::= BlockStatement"); }  //$NON-NLS-1$
7362 		    consumeBlockStatement() ;
7363 			break;
7364 
7365     case 361 : if (DEBUG) { System.out.println("BlockStatements ::= BlockStatements BlockStatement"); }  //$NON-NLS-1$
7366 		    consumeBlockStatements() ;
7367 			break;
7368 
7369     case 369 : if (DEBUG) { System.out.println("BlockStatement ::= InterfaceDeclaration"); }  //$NON-NLS-1$
7370 		    consumeInvalidInterfaceDeclaration();
7371 			break;
7372 
7373     case 370 : if (DEBUG) { System.out.println("BlockStatement ::= AnnotationTypeDeclaration"); }  //$NON-NLS-1$
7374 		    consumeInvalidAnnotationTypeDeclaration();
7375 			break;
7376 
7377     case 371 : if (DEBUG) { System.out.println("BlockStatement ::= EnumDeclaration"); }  //$NON-NLS-1$
7378 		    consumeInvalidEnumDeclaration();
7379 			break;
7380 
7381     case 372 : if (DEBUG) { System.out.println("LocalVariableDeclarationStatement ::=..."); }  //$NON-NLS-1$
7382 		    consumeLocalVariableDeclarationStatement();
7383 			break;
7384 
7385     case 373 : if (DEBUG) { System.out.println("LocalVariableDeclaration ::= Type PushModifiers..."); }  //$NON-NLS-1$
7386 		    consumeLocalVariableDeclaration();
7387 			break;
7388 
7389     case 374 : if (DEBUG) { System.out.println("LocalVariableDeclaration ::= Modifiers Type..."); }  //$NON-NLS-1$
7390 		    consumeLocalVariableDeclaration();
7391 			break;
7392 
7393     case 375 : if (DEBUG) { System.out.println("PushModifiers ::="); }  //$NON-NLS-1$
7394 		    consumePushModifiers();
7395 			break;
7396 
7397     case 376 : if (DEBUG) { System.out.println("PushModifiersForHeader ::="); }  //$NON-NLS-1$
7398 		    consumePushModifiersForHeader();
7399 			break;
7400 
7401     case 377 : if (DEBUG) { System.out.println("PushRealModifiers ::="); }  //$NON-NLS-1$
7402 		    consumePushRealModifiers();
7403 			break;
7404 
7405     case 405 : if (DEBUG) { System.out.println("EmptyStatement ::= SEMICOLON"); }  //$NON-NLS-1$
7406 		    consumeEmptyStatement();
7407 			break;
7408 
7409     case 406 : if (DEBUG) { System.out.println("LabeledStatement ::= Label COLON Statement"); }  //$NON-NLS-1$
7410 		    consumeStatementLabel() ;
7411 			break;
7412 
7413     case 407 : if (DEBUG) { System.out.println("LabeledStatementNoShortIf ::= Label COLON..."); }  //$NON-NLS-1$
7414 		    consumeStatementLabel() ;
7415 			break;
7416 
7417     case 408 : if (DEBUG) { System.out.println("Label ::= Identifier"); }  //$NON-NLS-1$
7418 		    consumeLabel() ;
7419 			break;
7420 
7421      case 409 : if (DEBUG) { System.out.println("ExpressionStatement ::= StatementExpression SEMICOLON"); }  //$NON-NLS-1$
7422 		    consumeExpressionStatement();
7423 			break;
7424 
7425     case 418 : if (DEBUG) { System.out.println("IfThenStatement ::= if LPAREN Expression RPAREN..."); }  //$NON-NLS-1$
7426 		    consumeStatementIfNoElse();
7427 			break;
7428 
7429     case 419 : if (DEBUG) { System.out.println("IfThenElseStatement ::= if LPAREN Expression RPAREN..."); }  //$NON-NLS-1$
7430 		    consumeStatementIfWithElse();
7431 			break;
7432 
7433     case 420 : if (DEBUG) { System.out.println("IfThenElseStatementNoShortIf ::= if LPAREN Expression..."); }  //$NON-NLS-1$
7434 		    consumeStatementIfWithElse();
7435 			break;
7436 
7437     case 421 : if (DEBUG) { System.out.println("SwitchStatement ::= switch LPAREN Expression RPAREN..."); }  //$NON-NLS-1$
7438 		    consumeStatementSwitch() ;
7439 			break;
7440 
7441     case 422 : if (DEBUG) { System.out.println("SwitchBlock ::= LBRACE RBRACE"); }  //$NON-NLS-1$
7442 		    consumeEmptySwitchBlock() ;
7443 			break;
7444 
7445     case 425 : if (DEBUG) { System.out.println("SwitchBlock ::= LBRACE SwitchBlockStatements..."); }  //$NON-NLS-1$
7446 		    consumeSwitchBlock() ;
7447 			break;
7448 
7449     case 427 : if (DEBUG) { System.out.println("SwitchBlockStatements ::= SwitchBlockStatements..."); }  //$NON-NLS-1$
7450 		    consumeSwitchBlockStatements() ;
7451 			break;
7452 
7453     case 429 : if (DEBUG) { System.out.println("SwitchBlockStatement ::= SwitchLabels BlockStatements"); }  //$NON-NLS-1$
7454 		    consumeSwitchBlockStatement() ;
7455 			break;
7456 
7457     case 431 : if (DEBUG) { System.out.println("SwitchLabels ::= SwitchLabels SwitchLabel"); }  //$NON-NLS-1$
7458 		    consumeSwitchLabels() ;
7459 			break;
7460 
7461      case 432 : if (DEBUG) { System.out.println("SwitchLabel ::= SwitchLabelCaseLhs COLON"); }  //$NON-NLS-1$
7462 		    consumeCaseLabel();
7463 			break;
7464 
7465      case 433 : if (DEBUG) { System.out.println("SwitchLabel ::= default COLON"); }  //$NON-NLS-1$
7466 		    consumeDefaultLabel();
7467 			break;
7468 
7469     case 436 : if (DEBUG) { System.out.println("SwitchExpression ::= switch LPAREN Expression RPAREN..."); }  //$NON-NLS-1$
7470 		    consumeSwitchExpression() ;
7471 			break;
7472 
7473      case 439 : if (DEBUG) { System.out.println("SwitchLabeledRule ::= SwitchLabeledThrowStatement"); }  //$NON-NLS-1$
7474 		    consumeSwitchLabeledRule();
7475 			break;
7476 
7477      case 440 : if (DEBUG) { System.out.println("SwitchLabeledExpression ::= SwitchLabelExpr Expression"); }  //$NON-NLS-1$
7478 		    consumeSwitchLabeledExpression();
7479 			break;
7480 
7481      case 441 : if (DEBUG) { System.out.println("SwitchLabeledBlock ::= SwitchLabelExpr Block"); }  //$NON-NLS-1$
7482 		    consumeSwitchLabeledBlock();
7483 			break;
7484 
7485      case 442 : if (DEBUG) { System.out.println("SwitchLabeledThrowStatement ::= SwitchLabelExpr..."); }  //$NON-NLS-1$
7486 		    consumeSwitchLabeledThrowStatement();
7487 			break;
7488 
7489      case 443 : if (DEBUG) { System.out.println("SwitchLabelExpr ::= default ARROW"); }  //$NON-NLS-1$
7490 		    consumeDefaultLabelExpr();
7491 			break;
7492 
7493      case 444 : if (DEBUG) { System.out.println("SwitchLabelExpr ::= SwitchLabelCaseLhs BeginCaseExpr..."); }  //$NON-NLS-1$
7494 		    consumeCaseLabelExpr();
7495 			break;
7496 
7497      case 445 : if (DEBUG) { System.out.println("SwitchLabelCaseLhs ::= case ConstantExpressions"); }  //$NON-NLS-1$
7498 		    consumeSwitchLabelCaseLhs();
7499 			break;
7500 
7501     case 446 : if (DEBUG) { System.out.println("YieldStatement ::= RestrictedIdentifierYield Expression"); }  //$NON-NLS-1$
7502 		    consumeStatementYield() ;
7503 			break;
7504 
7505     case 447 : if (DEBUG) { System.out.println("WhileStatement ::= while LPAREN Expression RPAREN..."); }  //$NON-NLS-1$
7506 		    consumeStatementWhile() ;
7507 			break;
7508 
7509     case 448 : if (DEBUG) { System.out.println("WhileStatementNoShortIf ::= while LPAREN Expression..."); }  //$NON-NLS-1$
7510 		    consumeStatementWhile() ;
7511 			break;
7512 
7513     case 449 : if (DEBUG) { System.out.println("DoStatement ::= do Statement while LPAREN Expression..."); }  //$NON-NLS-1$
7514 		    consumeStatementDo() ;
7515 			break;
7516 
7517     case 450 : if (DEBUG) { System.out.println("ForStatement ::= for LPAREN ForInitopt SEMICOLON..."); }  //$NON-NLS-1$
7518 		    consumeStatementFor() ;
7519 			break;
7520 
7521     case 451 : if (DEBUG) { System.out.println("ForStatementNoShortIf ::= for LPAREN ForInitopt..."); }  //$NON-NLS-1$
7522 		    consumeStatementFor() ;
7523 			break;
7524 
7525     case 452 : if (DEBUG) { System.out.println("ForInit ::= StatementExpressionList"); }  //$NON-NLS-1$
7526 		    consumeForInit() ;
7527 			break;
7528 
7529     case 456 : if (DEBUG) { System.out.println("StatementExpressionList ::= StatementExpressionList..."); }  //$NON-NLS-1$
7530 		    consumeStatementExpressionList() ;
7531 			break;
7532 
7533     case 457 : if (DEBUG) { System.out.println("AssertStatement ::= assert Expression SEMICOLON"); }  //$NON-NLS-1$
7534 		    consumeSimpleAssertStatement() ;
7535 			break;
7536 
7537     case 458 : if (DEBUG) { System.out.println("AssertStatement ::= assert Expression COLON Expression"); }  //$NON-NLS-1$
7538 		    consumeAssertStatement() ;
7539 			break;
7540 
7541     case 459 : if (DEBUG) { System.out.println("BreakStatement ::= break SEMICOLON"); }  //$NON-NLS-1$
7542 		    consumeStatementBreak() ;
7543 			break;
7544 
7545     case 460 : if (DEBUG) { System.out.println("BreakStatement ::= break Identifier SEMICOLON"); }  //$NON-NLS-1$
7546 		    consumeStatementBreakWithLabel() ;
7547 			break;
7548 
7549     case 461 : if (DEBUG) { System.out.println("ContinueStatement ::= continue SEMICOLON"); }  //$NON-NLS-1$
7550 		    consumeStatementContinue() ;
7551 			break;
7552 
7553     case 462 : if (DEBUG) { System.out.println("ContinueStatement ::= continue Identifier SEMICOLON"); }  //$NON-NLS-1$
7554 		    consumeStatementContinueWithLabel() ;
7555 			break;
7556 
7557     case 463 : if (DEBUG) { System.out.println("ReturnStatement ::= return Expressionopt SEMICOLON"); }  //$NON-NLS-1$
7558 		    consumeStatementReturn() ;
7559 			break;
7560 
7561     case 464 : if (DEBUG) { System.out.println("ThrowStatement ::= throw Expression SEMICOLON"); }  //$NON-NLS-1$
7562 		    consumeStatementThrow();
7563 			break;
7564 
7565     case 465 : if (DEBUG) { System.out.println("ThrowExpression ::= throw Expression"); }  //$NON-NLS-1$
7566 		    consumeThrowExpression() ;
7567 			break;
7568 
7569     case 466 : if (DEBUG) { System.out.println("SynchronizedStatement ::= OnlySynchronized LPAREN..."); }  //$NON-NLS-1$
7570 		    consumeStatementSynchronized();
7571 			break;
7572 
7573     case 467 : if (DEBUG) { System.out.println("OnlySynchronized ::= synchronized"); }  //$NON-NLS-1$
7574 		    consumeOnlySynchronized();
7575 			break;
7576 
7577     case 468 : if (DEBUG) { System.out.println("TryStatement ::= try TryBlock Catches"); }  //$NON-NLS-1$
7578 		    consumeStatementTry(false, false);
7579 			break;
7580 
7581     case 469 : if (DEBUG) { System.out.println("TryStatement ::= try TryBlock Catchesopt Finally"); }  //$NON-NLS-1$
7582 		    consumeStatementTry(true, false);
7583 			break;
7584 
7585     case 470 : if (DEBUG) { System.out.println("TryStatementWithResources ::= try ResourceSpecification"); }  //$NON-NLS-1$
7586 		    consumeStatementTry(false, true);
7587 			break;
7588 
7589     case 471 : if (DEBUG) { System.out.println("TryStatementWithResources ::= try ResourceSpecification"); }  //$NON-NLS-1$
7590 		    consumeStatementTry(true, true);
7591 			break;
7592 
7593     case 472 : if (DEBUG) { System.out.println("ResourceSpecification ::= LPAREN Resources ;opt RPAREN"); }  //$NON-NLS-1$
7594 		    consumeResourceSpecification();
7595 			break;
7596 
7597     case 473 : if (DEBUG) { System.out.println(";opt ::="); }  //$NON-NLS-1$
7598 		    consumeResourceOptionalTrailingSemiColon(false);
7599 			break;
7600 
7601     case 474 : if (DEBUG) { System.out.println(";opt ::= SEMICOLON"); }  //$NON-NLS-1$
7602 		    consumeResourceOptionalTrailingSemiColon(true);
7603 			break;
7604 
7605     case 475 : if (DEBUG) { System.out.println("Resources ::= Resource"); }  //$NON-NLS-1$
7606 		    consumeSingleResource();
7607 			break;
7608 
7609     case 476 : if (DEBUG) { System.out.println("Resources ::= Resources TrailingSemiColon Resource"); }  //$NON-NLS-1$
7610 		    consumeMultipleResources();
7611 			break;
7612 
7613     case 477 : if (DEBUG) { System.out.println("TrailingSemiColon ::= SEMICOLON"); }  //$NON-NLS-1$
7614 		    consumeResourceOptionalTrailingSemiColon(true);
7615 			break;
7616 
7617     case 478 : if (DEBUG) { System.out.println("Resource ::= Type PushModifiers VariableDeclaratorId..."); }  //$NON-NLS-1$
7618 		    consumeResourceAsLocalVariableDeclaration();
7619 			break;
7620 
7621     case 479 : if (DEBUG) { System.out.println("Resource ::= Modifiers Type PushRealModifiers..."); }  //$NON-NLS-1$
7622 		    consumeResourceAsLocalVariableDeclaration();
7623 			break;
7624 
7625     case 480 : if (DEBUG) { System.out.println("Resource ::= Name"); }  //$NON-NLS-1$
7626 		    consumeResourceAsLocalVariable();
7627 			break;
7628 
7629     case 481 : if (DEBUG) { System.out.println("Resource ::= FieldAccess"); }  //$NON-NLS-1$
7630 		    consumeResourceAsFieldAccess();
7631 			break;
7632 
7633     case 483 : if (DEBUG) { System.out.println("ExitTryBlock ::="); }  //$NON-NLS-1$
7634 		    consumeExitTryBlock();
7635 			break;
7636 
7637     case 485 : if (DEBUG) { System.out.println("Catches ::= Catches CatchClause"); }  //$NON-NLS-1$
7638 		    consumeCatches();
7639 			break;
7640 
7641     case 486 : if (DEBUG) { System.out.println("CatchClause ::= catch LPAREN CatchFormalParameter RPAREN"); }  //$NON-NLS-1$
7642 		    consumeStatementCatch() ;
7643 			break;
7644 
7645     case 488 : if (DEBUG) { System.out.println("PushLPAREN ::= LPAREN"); }  //$NON-NLS-1$
7646 		    consumeLeftParen();
7647 			break;
7648 
7649     case 489 : if (DEBUG) { System.out.println("PushRPAREN ::= RPAREN"); }  //$NON-NLS-1$
7650 		    consumeRightParen();
7651 			break;
7652 
7653     case 494 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= this"); }  //$NON-NLS-1$
7654 		    consumePrimaryNoNewArrayThis();
7655 			break;
7656 
7657     case 495 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PushLPAREN Expression_NotName..."); }  //$NON-NLS-1$
7658 		    consumePrimaryNoNewArray();
7659 			break;
7660 
7661     case 496 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PushLPAREN Name PushRPAREN"); }  //$NON-NLS-1$
7662 		    consumePrimaryNoNewArrayWithName();
7663 			break;
7664 
7665     case 499 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name DOT this"); }  //$NON-NLS-1$
7666 		    consumePrimaryNoNewArrayNameThis();
7667 			break;
7668 
7669     case 500 : if (DEBUG) { System.out.println("QualifiedSuperReceiver ::= Name DOT super"); }  //$NON-NLS-1$
7670 		    consumeQualifiedSuperReceiver();
7671 			break;
7672 
7673     case 501 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name DOT class"); }  //$NON-NLS-1$
7674 		    consumePrimaryNoNewArrayName();
7675 			break;
7676 
7677     case 502 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name Dims DOT class"); }  //$NON-NLS-1$
7678 		    consumePrimaryNoNewArrayArrayType();
7679 			break;
7680 
7681     case 503 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PrimitiveType Dims DOT class"); }  //$NON-NLS-1$
7682 		    consumePrimaryNoNewArrayPrimitiveArrayType();
7683 			break;
7684 
7685     case 504 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PrimitiveType DOT class"); }  //$NON-NLS-1$
7686 		    consumePrimaryNoNewArrayPrimitiveType();
7687 			break;
7688 
7689     case 510 : if (DEBUG) { System.out.println("ReferenceExpressionTypeArgumentsAndTrunk0 ::=..."); }  //$NON-NLS-1$
7690 		    consumeReferenceExpressionTypeArgumentsAndTrunk(false);
7691 			break;
7692 
7693     case 511 : if (DEBUG) { System.out.println("ReferenceExpressionTypeArgumentsAndTrunk0 ::=..."); }  //$NON-NLS-1$
7694 		    consumeReferenceExpressionTypeArgumentsAndTrunk(true);
7695 			break;
7696 
7697     case 512 : if (DEBUG) { System.out.println("ReferenceExpression ::= PrimitiveType Dims COLON_COLON"); }  //$NON-NLS-1$
7698 		    consumeReferenceExpressionTypeForm(true);
7699 			break;
7700 
7701     case 513 : if (DEBUG) { System.out.println("ReferenceExpression ::= Name Dimsopt COLON_COLON..."); }  //$NON-NLS-1$
7702 		    consumeReferenceExpressionTypeForm(false);
7703 			break;
7704 
7705     case 514 : if (DEBUG) { System.out.println("ReferenceExpression ::= Name BeginTypeArguments..."); }  //$NON-NLS-1$
7706 		    consumeReferenceExpressionGenericTypeForm();
7707 			break;
7708 
7709     case 515 : if (DEBUG) { System.out.println("ReferenceExpression ::= Primary COLON_COLON..."); }  //$NON-NLS-1$
7710 		    consumeReferenceExpressionPrimaryForm();
7711 			break;
7712 
7713     case 516 : if (DEBUG) { System.out.println("ReferenceExpression ::= QualifiedSuperReceiver..."); }  //$NON-NLS-1$
7714 		    consumeReferenceExpressionPrimaryForm();
7715 			break;
7716 
7717     case 517 : if (DEBUG) { System.out.println("ReferenceExpression ::= super COLON_COLON..."); }  //$NON-NLS-1$
7718 		    consumeReferenceExpressionSuperForm();
7719 			break;
7720 
7721     case 518 : if (DEBUG) { System.out.println("NonWildTypeArgumentsopt ::="); }  //$NON-NLS-1$
7722 		    consumeEmptyTypeArguments();
7723 			break;
7724 
7725     case 520 : if (DEBUG) { System.out.println("IdentifierOrNew ::= Identifier"); }  //$NON-NLS-1$
7726 		    consumeIdentifierOrNew(false);
7727 			break;
7728 
7729     case 521 : if (DEBUG) { System.out.println("IdentifierOrNew ::= new"); }  //$NON-NLS-1$
7730 		    consumeIdentifierOrNew(true);
7731 			break;
7732 
7733     case 522 : if (DEBUG) { System.out.println("LambdaExpression ::= LambdaParameters ARROW LambdaBody"); }  //$NON-NLS-1$
7734 		    consumeLambdaExpression();
7735 			break;
7736 
7737     case 523 : if (DEBUG) { System.out.println("NestedLambda ::="); }  //$NON-NLS-1$
7738 		    consumeNestedLambda();
7739 			break;
7740 
7741     case 524 : if (DEBUG) { System.out.println("LambdaParameters ::= Identifier NestedLambda"); }  //$NON-NLS-1$
7742 		    consumeTypeElidedLambdaParameter(false);
7743 			break;
7744 
7745     case 530 : if (DEBUG) { System.out.println("TypeElidedFormalParameterList ::=..."); }  //$NON-NLS-1$
7746 		    consumeFormalParameterList();
7747 			break;
7748 
7749     case 531 : if (DEBUG) { System.out.println("TypeElidedFormalParameter ::= Modifiersopt Identifier"); }  //$NON-NLS-1$
7750 		    consumeTypeElidedLambdaParameter(true);
7751 			break;
7752 
7753     case 534 : if (DEBUG) { System.out.println("ElidedLeftBraceAndReturn ::="); }  //$NON-NLS-1$
7754 		    consumeElidedLeftBraceAndReturn();
7755 			break;
7756 
7757     case 535 : if (DEBUG) { System.out.println("AllocationHeader ::= new ClassType LPAREN..."); }  //$NON-NLS-1$
7758 		    consumeAllocationHeader();
7759 			break;
7760 
7761     case 536 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= new..."); }  //$NON-NLS-1$
7762 		    consumeClassInstanceCreationExpressionWithTypeArguments();
7763 			break;
7764 
7765     case 537 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= new ClassType..."); }  //$NON-NLS-1$
7766 		    consumeClassInstanceCreationExpression();
7767 			break;
7768 
7769     case 538 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= Primary DOT new..."); }  //$NON-NLS-1$
7770 		    consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() ;
7771 			break;
7772 
7773     case 539 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= Primary DOT new..."); }  //$NON-NLS-1$
7774 		    consumeClassInstanceCreationExpressionQualified() ;
7775 			break;
7776 
7777     case 540 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::=..."); }  //$NON-NLS-1$
7778 		    consumeClassInstanceCreationExpressionQualified() ;
7779 			break;
7780 
7781     case 541 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::=..."); }  //$NON-NLS-1$
7782 		    consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() ;
7783 			break;
7784 
7785     case 542 : if (DEBUG) { System.out.println("EnterInstanceCreationArgumentList ::="); }  //$NON-NLS-1$
7786 		    consumeEnterInstanceCreationArgumentList();
7787 			break;
7788 
7789     case 543 : if (DEBUG) { System.out.println("ClassInstanceCreationExpressionName ::= Name DOT new"); }  //$NON-NLS-1$
7790 		    consumeClassInstanceCreationExpressionName() ;
7791 			break;
7792 
7793     case 544 : if (DEBUG) { System.out.println("UnqualifiedClassBodyopt ::="); }  //$NON-NLS-1$
7794 		    consumeClassBodyopt();
7795 			break;
7796 
7797     case 546 : if (DEBUG) { System.out.println("UnqualifiedEnterAnonymousClassBody ::="); }  //$NON-NLS-1$
7798 		    consumeEnterAnonymousClassBody(false);
7799 			break;
7800 
7801     case 547 : if (DEBUG) { System.out.println("QualifiedClassBodyopt ::="); }  //$NON-NLS-1$
7802 		    consumeClassBodyopt();
7803 			break;
7804 
7805     case 549 : if (DEBUG) { System.out.println("QualifiedEnterAnonymousClassBody ::="); }  //$NON-NLS-1$
7806 		    consumeEnterAnonymousClassBody(true);
7807 			break;
7808 
7809     case 551 : if (DEBUG) { System.out.println("ArgumentList ::= ArgumentList COMMA Expression"); }  //$NON-NLS-1$
7810 		    consumeArgumentList();
7811 			break;
7812 
7813     case 552 : if (DEBUG) { System.out.println("ArrayCreationHeader ::= new PrimitiveType..."); }  //$NON-NLS-1$
7814 		    consumeArrayCreationHeader();
7815 			break;
7816 
7817     case 553 : if (DEBUG) { System.out.println("ArrayCreationHeader ::= new ClassOrInterfaceType..."); }  //$NON-NLS-1$
7818 		    consumeArrayCreationHeader();
7819 			break;
7820 
7821     case 554 : if (DEBUG) { System.out.println("ArrayCreationWithoutArrayInitializer ::= new..."); }  //$NON-NLS-1$
7822 		    consumeArrayCreationExpressionWithoutInitializer();
7823 			break;
7824 
7825     case 555 : if (DEBUG) { System.out.println("ArrayCreationWithArrayInitializer ::= new PrimitiveType"); }  //$NON-NLS-1$
7826 		    consumeArrayCreationExpressionWithInitializer();
7827 			break;
7828 
7829     case 556 : if (DEBUG) { System.out.println("ArrayCreationWithoutArrayInitializer ::= new..."); }  //$NON-NLS-1$
7830 		    consumeArrayCreationExpressionWithoutInitializer();
7831 			break;
7832 
7833     case 557 : if (DEBUG) { System.out.println("ArrayCreationWithArrayInitializer ::= new..."); }  //$NON-NLS-1$
7834 		    consumeArrayCreationExpressionWithInitializer();
7835 			break;
7836 
7837     case 559 : if (DEBUG) { System.out.println("DimWithOrWithOutExprs ::= DimWithOrWithOutExprs..."); }  //$NON-NLS-1$
7838 		    consumeDimWithOrWithOutExprs();
7839 			break;
7840 
7841      case 561 : if (DEBUG) { System.out.println("DimWithOrWithOutExpr ::= TypeAnnotationsopt LBRACKET..."); }  //$NON-NLS-1$
7842 		    consumeDimWithOrWithOutExpr();
7843 			break;
7844 
7845      case 562 : if (DEBUG) { System.out.println("Dims ::= DimsLoop"); }  //$NON-NLS-1$
7846 		    consumeDims();
7847 			break;
7848 
7849      case 565 : if (DEBUG) { System.out.println("OneDimLoop ::= LBRACKET RBRACKET"); }  //$NON-NLS-1$
7850 		    consumeOneDimLoop(false);
7851 			break;
7852 
7853      case 566 : if (DEBUG) { System.out.println("OneDimLoop ::= TypeAnnotations LBRACKET RBRACKET"); }  //$NON-NLS-1$
7854 		    consumeOneDimLoop(true);
7855 			break;
7856 
7857     case 567 : if (DEBUG) { System.out.println("FieldAccess ::= Primary DOT Identifier"); }  //$NON-NLS-1$
7858 		    consumeFieldAccess(false);
7859 			break;
7860 
7861     case 568 : if (DEBUG) { System.out.println("FieldAccess ::= super DOT Identifier"); }  //$NON-NLS-1$
7862 		    consumeFieldAccess(true);
7863 			break;
7864 
7865     case 569 : if (DEBUG) { System.out.println("FieldAccess ::= QualifiedSuperReceiver DOT Identifier"); }  //$NON-NLS-1$
7866 		    consumeFieldAccess(false);
7867 			break;
7868 
7869     case 570 : if (DEBUG) { System.out.println("MethodInvocation ::= Name LPAREN ArgumentListopt RPAREN"); }  //$NON-NLS-1$
7870 		    consumeMethodInvocationName();
7871 			break;
7872 
7873     case 571 : if (DEBUG) { System.out.println("MethodInvocation ::= Name DOT OnlyTypeArguments..."); }  //$NON-NLS-1$
7874 		    consumeMethodInvocationNameWithTypeArguments();
7875 			break;
7876 
7877     case 572 : if (DEBUG) { System.out.println("MethodInvocation ::= Primary DOT OnlyTypeArguments..."); }  //$NON-NLS-1$
7878 		    consumeMethodInvocationPrimaryWithTypeArguments();
7879 			break;
7880 
7881     case 573 : if (DEBUG) { System.out.println("MethodInvocation ::= Primary DOT Identifier LPAREN..."); }  //$NON-NLS-1$
7882 		    consumeMethodInvocationPrimary();
7883 			break;
7884 
7885     case 574 : if (DEBUG) { System.out.println("MethodInvocation ::= QualifiedSuperReceiver DOT..."); }  //$NON-NLS-1$
7886 		    consumeMethodInvocationPrimary();
7887 			break;
7888 
7889     case 575 : if (DEBUG) { System.out.println("MethodInvocation ::= QualifiedSuperReceiver DOT..."); }  //$NON-NLS-1$
7890 		    consumeMethodInvocationPrimaryWithTypeArguments();
7891 			break;
7892 
7893     case 576 : if (DEBUG) { System.out.println("MethodInvocation ::= super DOT OnlyTypeArguments..."); }  //$NON-NLS-1$
7894 		    consumeMethodInvocationSuperWithTypeArguments();
7895 			break;
7896 
7897     case 577 : if (DEBUG) { System.out.println("MethodInvocation ::= super DOT Identifier LPAREN..."); }  //$NON-NLS-1$
7898 		    consumeMethodInvocationSuper();
7899 			break;
7900 
7901     case 578 : if (DEBUG) { System.out.println("ArrayAccess ::= Name LBRACKET Expression RBRACKET"); }  //$NON-NLS-1$
7902 		    consumeArrayAccess(true);
7903 			break;
7904 
7905     case 579 : if (DEBUG) { System.out.println("ArrayAccess ::= PrimaryNoNewArray LBRACKET Expression..."); }  //$NON-NLS-1$
7906 		    consumeArrayAccess(false);
7907 			break;
7908 
7909     case 580 : if (DEBUG) { System.out.println("ArrayAccess ::= ArrayCreationWithArrayInitializer..."); }  //$NON-NLS-1$
7910 		    consumeArrayAccess(false);
7911 			break;
7912 
7913     case 582 : if (DEBUG) { System.out.println("PostfixExpression ::= Name"); }  //$NON-NLS-1$
7914 		    consumePostfixExpression();
7915 			break;
7916 
7917     case 585 : if (DEBUG) { System.out.println("PostIncrementExpression ::= PostfixExpression PLUS_PLUS"); }  //$NON-NLS-1$
7918 		    consumeUnaryExpression(OperatorIds.PLUS,true);
7919 			break;
7920 
7921     case 586 : if (DEBUG) { System.out.println("PostDecrementExpression ::= PostfixExpression..."); }  //$NON-NLS-1$
7922 		    consumeUnaryExpression(OperatorIds.MINUS,true);
7923 			break;
7924 
7925     case 587 : if (DEBUG) { System.out.println("PushPosition ::="); }  //$NON-NLS-1$
7926 		    consumePushPosition();
7927 			break;
7928 
7929     case 590 : if (DEBUG) { System.out.println("UnaryExpression ::= PLUS PushPosition UnaryExpression"); }  //$NON-NLS-1$
7930 		    consumeUnaryExpression(OperatorIds.PLUS);
7931 			break;
7932 
7933     case 591 : if (DEBUG) { System.out.println("UnaryExpression ::= MINUS PushPosition UnaryExpression"); }  //$NON-NLS-1$
7934 		    consumeUnaryExpression(OperatorIds.MINUS);
7935 			break;
7936 
7937     case 593 : if (DEBUG) { System.out.println("PreIncrementExpression ::= PLUS_PLUS PushPosition..."); }  //$NON-NLS-1$
7938 		    consumeUnaryExpression(OperatorIds.PLUS,false);
7939 			break;
7940 
7941     case 594 : if (DEBUG) { System.out.println("PreDecrementExpression ::= MINUS_MINUS PushPosition..."); }  //$NON-NLS-1$
7942 		    consumeUnaryExpression(OperatorIds.MINUS,false);
7943 			break;
7944 
7945     case 596 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus ::= TWIDDLE PushPosition..."); }  //$NON-NLS-1$
7946 		    consumeUnaryExpression(OperatorIds.TWIDDLE);
7947 			break;
7948 
7949     case 597 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus ::= NOT PushPosition..."); }  //$NON-NLS-1$
7950 		    consumeUnaryExpression(OperatorIds.NOT);
7951 			break;
7952 
7953     case 599 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN PrimitiveType Dimsopt..."); }  //$NON-NLS-1$
7954 		    consumeCastExpressionWithPrimitiveType();
7955 			break;
7956 
7957     case 600 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name..."); }  //$NON-NLS-1$
7958 		    consumeCastExpressionWithGenericsArray();
7959 			break;
7960 
7961     case 601 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name..."); }  //$NON-NLS-1$
7962 		    consumeCastExpressionWithQualifiedGenericsArray();
7963 			break;
7964 
7965     case 602 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name PushRPAREN..."); }  //$NON-NLS-1$
7966 		    consumeCastExpressionLL1();
7967 			break;
7968 
7969     case 603 : if (DEBUG) { System.out.println("CastExpression ::= BeginIntersectionCast PushLPAREN..."); }  //$NON-NLS-1$
7970 		    consumeCastExpressionLL1WithBounds();
7971 			break;
7972 
7973     case 604 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name Dims..."); }  //$NON-NLS-1$
7974 		    consumeCastExpressionWithNameArray();
7975 			break;
7976 
7977     case 605 : if (DEBUG) { System.out.println("AdditionalBoundsListOpt ::="); }  //$NON-NLS-1$
7978 		    consumeZeroAdditionalBounds();
7979 			break;
7980 
7981     case 609 : if (DEBUG) { System.out.println("OnlyTypeArgumentsForCastExpression ::= OnlyTypeArguments"); }  //$NON-NLS-1$
7982 		    consumeOnlyTypeArgumentsForCastExpression();
7983 			break;
7984 
7985     case 610 : if (DEBUG) { System.out.println("InsideCastExpression ::="); }  //$NON-NLS-1$
7986 		    consumeInsideCastExpression();
7987 			break;
7988 
7989     case 611 : if (DEBUG) { System.out.println("InsideCastExpressionLL1 ::="); }  //$NON-NLS-1$
7990 		    consumeInsideCastExpressionLL1();
7991 			break;
7992 
7993     case 612 : if (DEBUG) { System.out.println("InsideCastExpressionLL1WithBounds ::="); }  //$NON-NLS-1$
7994 		    consumeInsideCastExpressionLL1WithBounds ();
7995 			break;
7996 
7997     case 613 : if (DEBUG) { System.out.println("InsideCastExpressionWithQualifiedGenerics ::="); }  //$NON-NLS-1$
7998 		    consumeInsideCastExpressionWithQualifiedGenerics();
7999 			break;
8000 
8001     case 615 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); }  //$NON-NLS-1$
8002 		    consumeBinaryExpression(OperatorIds.MULTIPLY);
8003 			break;
8004 
8005     case 616 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); }  //$NON-NLS-1$
8006 		    consumeBinaryExpression(OperatorIds.DIVIDE);
8007 			break;
8008 
8009     case 617 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); }  //$NON-NLS-1$
8010 		    consumeBinaryExpression(OperatorIds.REMAINDER);
8011 			break;
8012 
8013     case 619 : if (DEBUG) { System.out.println("AdditiveExpression ::= AdditiveExpression PLUS..."); }  //$NON-NLS-1$
8014 		    consumeBinaryExpression(OperatorIds.PLUS);
8015 			break;
8016 
8017     case 620 : if (DEBUG) { System.out.println("AdditiveExpression ::= AdditiveExpression MINUS..."); }  //$NON-NLS-1$
8018 		    consumeBinaryExpression(OperatorIds.MINUS);
8019 			break;
8020 
8021     case 622 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression LEFT_SHIFT..."); }  //$NON-NLS-1$
8022 		    consumeBinaryExpression(OperatorIds.LEFT_SHIFT);
8023 			break;
8024 
8025     case 623 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression RIGHT_SHIFT..."); }  //$NON-NLS-1$
8026 		    consumeBinaryExpression(OperatorIds.RIGHT_SHIFT);
8027 			break;
8028 
8029     case 624 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression UNSIGNED_RIGHT_SHIFT"); }  //$NON-NLS-1$
8030 		    consumeBinaryExpression(OperatorIds.UNSIGNED_RIGHT_SHIFT);
8031 			break;
8032 
8033     case 626 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression LESS..."); }  //$NON-NLS-1$
8034 		    consumeBinaryExpression(OperatorIds.LESS);
8035 			break;
8036 
8037     case 627 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression GREATER..."); }  //$NON-NLS-1$
8038 		    consumeBinaryExpression(OperatorIds.GREATER);
8039 			break;
8040 
8041     case 628 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression LESS_EQUAL"); }  //$NON-NLS-1$
8042 		    consumeBinaryExpression(OperatorIds.LESS_EQUAL);
8043 			break;
8044 
8045     case 629 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression..."); }  //$NON-NLS-1$
8046 		    consumeBinaryExpression(OperatorIds.GREATER_EQUAL);
8047 			break;
8048 
8049     case 631 : if (DEBUG) { System.out.println("EqualityExpression ::= EqualityExpression EQUAL_EQUAL..."); }  //$NON-NLS-1$
8050 		    consumeEqualityExpression(OperatorIds.EQUAL_EQUAL);
8051 			break;
8052 
8053     case 632 : if (DEBUG) { System.out.println("EqualityExpression ::= EqualityExpression NOT_EQUAL..."); }  //$NON-NLS-1$
8054 		    consumeEqualityExpression(OperatorIds.NOT_EQUAL);
8055 			break;
8056 
8057     case 634 : if (DEBUG) { System.out.println("AndExpression ::= AndExpression AND EqualityExpression"); }  //$NON-NLS-1$
8058 		    consumeBinaryExpression(OperatorIds.AND);
8059 			break;
8060 
8061     case 636 : if (DEBUG) { System.out.println("ExclusiveOrExpression ::= ExclusiveOrExpression XOR..."); }  //$NON-NLS-1$
8062 		    consumeBinaryExpression(OperatorIds.XOR);
8063 			break;
8064 
8065     case 638 : if (DEBUG) { System.out.println("InclusiveOrExpression ::= InclusiveOrExpression OR..."); }  //$NON-NLS-1$
8066 		    consumeBinaryExpression(OperatorIds.OR);
8067 			break;
8068 
8069     case 640 : if (DEBUG) { System.out.println("ConditionalAndExpression ::= ConditionalAndExpression..."); }  //$NON-NLS-1$
8070 		    consumeBinaryExpression(OperatorIds.AND_AND);
8071 			break;
8072 
8073     case 642 : if (DEBUG) { System.out.println("ConditionalOrExpression ::= ConditionalOrExpression..."); }  //$NON-NLS-1$
8074 		    consumeBinaryExpression(OperatorIds.OR_OR);
8075 			break;
8076 
8077     case 644 : if (DEBUG) { System.out.println("ConditionalExpression ::= ConditionalOrExpression..."); }  //$NON-NLS-1$
8078 		    consumeConditionalExpression(OperatorIds.QUESTIONCOLON) ;
8079 			break;
8080 
8081     case 647 : if (DEBUG) { System.out.println("Assignment ::= PostfixExpression AssignmentOperator..."); }  //$NON-NLS-1$
8082 		    consumeAssignment();
8083 			break;
8084 
8085     case 649 : if (DEBUG) { System.out.println("Assignment ::= InvalidArrayInitializerAssignement"); }  //$NON-NLS-1$
8086 		    ignoreExpressionAssignment();
8087 			break;
8088 
8089     case 650 : if (DEBUG) { System.out.println("AssignmentOperator ::= EQUAL"); }  //$NON-NLS-1$
8090 		    consumeAssignmentOperator(EQUAL);
8091 			break;
8092 
8093     case 651 : if (DEBUG) { System.out.println("AssignmentOperator ::= MULTIPLY_EQUAL"); }  //$NON-NLS-1$
8094 		    consumeAssignmentOperator(MULTIPLY);
8095 			break;
8096 
8097     case 652 : if (DEBUG) { System.out.println("AssignmentOperator ::= DIVIDE_EQUAL"); }  //$NON-NLS-1$
8098 		    consumeAssignmentOperator(DIVIDE);
8099 			break;
8100 
8101     case 653 : if (DEBUG) { System.out.println("AssignmentOperator ::= REMAINDER_EQUAL"); }  //$NON-NLS-1$
8102 		    consumeAssignmentOperator(REMAINDER);
8103 			break;
8104 
8105     case 654 : if (DEBUG) { System.out.println("AssignmentOperator ::= PLUS_EQUAL"); }  //$NON-NLS-1$
8106 		    consumeAssignmentOperator(PLUS);
8107 			break;
8108 
8109     case 655 : if (DEBUG) { System.out.println("AssignmentOperator ::= MINUS_EQUAL"); }  //$NON-NLS-1$
8110 		    consumeAssignmentOperator(MINUS);
8111 			break;
8112 
8113     case 656 : if (DEBUG) { System.out.println("AssignmentOperator ::= LEFT_SHIFT_EQUAL"); }  //$NON-NLS-1$
8114 		    consumeAssignmentOperator(LEFT_SHIFT);
8115 			break;
8116 
8117     case 657 : if (DEBUG) { System.out.println("AssignmentOperator ::= RIGHT_SHIFT_EQUAL"); }  //$NON-NLS-1$
8118 		    consumeAssignmentOperator(RIGHT_SHIFT);
8119 			break;
8120 
8121     case 658 : if (DEBUG) { System.out.println("AssignmentOperator ::= UNSIGNED_RIGHT_SHIFT_EQUAL"); }  //$NON-NLS-1$
8122 		    consumeAssignmentOperator(UNSIGNED_RIGHT_SHIFT);
8123 			break;
8124 
8125     case 659 : if (DEBUG) { System.out.println("AssignmentOperator ::= AND_EQUAL"); }  //$NON-NLS-1$
8126 		    consumeAssignmentOperator(AND);
8127 			break;
8128 
8129     case 660 : if (DEBUG) { System.out.println("AssignmentOperator ::= XOR_EQUAL"); }  //$NON-NLS-1$
8130 		    consumeAssignmentOperator(XOR);
8131 			break;
8132 
8133     case 661 : if (DEBUG) { System.out.println("AssignmentOperator ::= OR_EQUAL"); }  //$NON-NLS-1$
8134 		    consumeAssignmentOperator(OR);
8135 			break;
8136 
8137     case 662 : if (DEBUG) { System.out.println("Expression ::= AssignmentExpression"); }  //$NON-NLS-1$
8138 		    consumeExpression();
8139 			break;
8140 
8141     case 665 : if (DEBUG) { System.out.println("Expressionopt ::="); }  //$NON-NLS-1$
8142 		    consumeEmptyExpression();
8143 			break;
8144 
8145     case 668 : if (DEBUG) { System.out.println("ConstantExpressions ::= ConstantExpressions COMMA..."); }  //$NON-NLS-1$
8146 		    consumeConstantExpressions();
8147 			break;
8148 
8149     case 672 : if (DEBUG) { System.out.println("ClassBodyDeclarationsopt ::="); }  //$NON-NLS-1$
8150 		    consumeEmptyClassBodyDeclarationsopt();
8151 			break;
8152 
8153     case 673 : if (DEBUG) { System.out.println("ClassBodyDeclarationsopt ::= NestedType..."); }  //$NON-NLS-1$
8154 		    consumeClassBodyDeclarationsopt();
8155 			break;
8156 
8157      case 674 : if (DEBUG) { System.out.println("Modifiersopt ::="); }  //$NON-NLS-1$
8158 		    consumeDefaultModifiers();
8159 			break;
8160 
8161     case 675 : if (DEBUG) { System.out.println("Modifiersopt ::= Modifiers"); }  //$NON-NLS-1$
8162 		    consumeModifiers();
8163 			break;
8164 
8165     case 676 : if (DEBUG) { System.out.println("BlockStatementsopt ::="); }  //$NON-NLS-1$
8166 		    consumeEmptyBlockStatementsopt();
8167 			break;
8168 
8169      case 678 : if (DEBUG) { System.out.println("Dimsopt ::="); }  //$NON-NLS-1$
8170 		    consumeEmptyDimsopt();
8171 			break;
8172 
8173      case 680 : if (DEBUG) { System.out.println("ArgumentListopt ::="); }  //$NON-NLS-1$
8174 		    consumeEmptyArgumentListopt();
8175 			break;
8176 
8177     case 684 : if (DEBUG) { System.out.println("FormalParameterListopt ::="); }  //$NON-NLS-1$
8178 		    consumeFormalParameterListopt();
8179 			break;
8180 
8181      case 688 : if (DEBUG) { System.out.println("InterfaceMemberDeclarationsopt ::="); }  //$NON-NLS-1$
8182 		    consumeEmptyInterfaceMemberDeclarationsopt();
8183 			break;
8184 
8185      case 689 : if (DEBUG) { System.out.println("InterfaceMemberDeclarationsopt ::= NestedType..."); }  //$NON-NLS-1$
8186 		    consumeInterfaceMemberDeclarationsopt();
8187 			break;
8188 
8189     case 690 : if (DEBUG) { System.out.println("NestedType ::="); }  //$NON-NLS-1$
8190 		    consumeNestedType();
8191 			break;
8192 
8193      case 691 : if (DEBUG) { System.out.println("ForInitopt ::="); }  //$NON-NLS-1$
8194 		    consumeEmptyForInitopt();
8195 			break;
8196 
8197      case 693 : if (DEBUG) { System.out.println("ForUpdateopt ::="); }  //$NON-NLS-1$
8198 		    consumeEmptyForUpdateopt();
8199 			break;
8200 
8201      case 697 : if (DEBUG) { System.out.println("Catchesopt ::="); }  //$NON-NLS-1$
8202 		    consumeEmptyCatchesopt();
8203 			break;
8204 
8205      case 699 : if (DEBUG) { System.out.println("EnumDeclaration ::= EnumHeader EnumBody"); }  //$NON-NLS-1$
8206 		    consumeEnumDeclaration();
8207 			break;
8208 
8209      case 700 : if (DEBUG) { System.out.println("EnumHeader ::= EnumHeaderName ClassHeaderImplementsopt"); }  //$NON-NLS-1$
8210 		    consumeEnumHeader();
8211 			break;
8212 
8213      case 701 : if (DEBUG) { System.out.println("EnumHeaderName ::= Modifiersopt enum Identifier"); }  //$NON-NLS-1$
8214 		    consumeEnumHeaderName();
8215 			break;
8216 
8217      case 702 : if (DEBUG) { System.out.println("EnumHeaderName ::= Modifiersopt enum Identifier..."); }  //$NON-NLS-1$
8218 		    consumeEnumHeaderNameWithTypeParameters();
8219 			break;
8220 
8221      case 703 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumBodyDeclarationsopt RBRACE"); }  //$NON-NLS-1$
8222 		    consumeEnumBodyNoConstants();
8223 			break;
8224 
8225      case 704 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE COMMA EnumBodyDeclarationsopt..."); }  //$NON-NLS-1$
8226 		    consumeEnumBodyNoConstants();
8227 			break;
8228 
8229      case 705 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumConstants COMMA..."); }  //$NON-NLS-1$
8230 		    consumeEnumBodyWithConstants();
8231 			break;
8232 
8233      case 706 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumConstants..."); }  //$NON-NLS-1$
8234 		    consumeEnumBodyWithConstants();
8235 			break;
8236 
8237     case 708 : if (DEBUG) { System.out.println("EnumConstants ::= EnumConstants COMMA EnumConstant"); }  //$NON-NLS-1$
8238 		    consumeEnumConstants();
8239 			break;
8240 
8241     case 709 : if (DEBUG) { System.out.println("EnumConstantHeaderName ::= Modifiersopt Identifier"); }  //$NON-NLS-1$
8242 		    consumeEnumConstantHeaderName();
8243 			break;
8244 
8245     case 710 : if (DEBUG) { System.out.println("EnumConstantHeader ::= EnumConstantHeaderName..."); }  //$NON-NLS-1$
8246 		    consumeEnumConstantHeader();
8247 			break;
8248 
8249     case 711 : if (DEBUG) { System.out.println("EnumConstant ::= EnumConstantHeader ForceNoDiet..."); }  //$NON-NLS-1$
8250 		    consumeEnumConstantWithClassBody();
8251 			break;
8252 
8253     case 712 : if (DEBUG) { System.out.println("EnumConstant ::= EnumConstantHeader"); }  //$NON-NLS-1$
8254 		    consumeEnumConstantNoClassBody();
8255 			break;
8256 
8257     case 713 : if (DEBUG) { System.out.println("Arguments ::= LPAREN ArgumentListopt RPAREN"); }  //$NON-NLS-1$
8258 		    consumeArguments();
8259 			break;
8260 
8261     case 714 : if (DEBUG) { System.out.println("Argumentsopt ::="); }  //$NON-NLS-1$
8262 		    consumeEmptyArguments();
8263 			break;
8264 
8265     case 716 : if (DEBUG) { System.out.println("EnumDeclarations ::= SEMICOLON ClassBodyDeclarationsopt"); }  //$NON-NLS-1$
8266 		    consumeEnumDeclarations();
8267 			break;
8268 
8269     case 717 : if (DEBUG) { System.out.println("EnumBodyDeclarationsopt ::="); }  //$NON-NLS-1$
8270 		    consumeEmptyEnumDeclarations();
8271 			break;
8272 
8273     case 719 : if (DEBUG) { System.out.println("EnhancedForStatement ::= EnhancedForStatementHeader..."); }  //$NON-NLS-1$
8274 		    consumeEnhancedForStatement();
8275 			break;
8276 
8277     case 720 : if (DEBUG) { System.out.println("EnhancedForStatementNoShortIf ::=..."); }  //$NON-NLS-1$
8278 		    consumeEnhancedForStatement();
8279 			break;
8280 
8281     case 721 : if (DEBUG) { System.out.println("EnhancedForStatementHeaderInit ::= for LPAREN Type..."); }  //$NON-NLS-1$
8282 		    consumeEnhancedForStatementHeaderInit(false);
8283 			break;
8284 
8285     case 722 : if (DEBUG) { System.out.println("EnhancedForStatementHeaderInit ::= for LPAREN Modifiers"); }  //$NON-NLS-1$
8286 		    consumeEnhancedForStatementHeaderInit(true);
8287 			break;
8288 
8289     case 723 : if (DEBUG) { System.out.println("EnhancedForStatementHeader ::=..."); }  //$NON-NLS-1$
8290 		    consumeEnhancedForStatementHeader();
8291 			break;
8292 
8293     case 724 : if (DEBUG) { System.out.println("SingleStaticImportDeclaration ::=..."); }  //$NON-NLS-1$
8294 		    consumeImportDeclaration();
8295 			break;
8296 
8297     case 725 : if (DEBUG) { System.out.println("SingleStaticImportDeclarationName ::= import static Name"); }  //$NON-NLS-1$
8298 		    consumeSingleStaticImportDeclarationName();
8299 			break;
8300 
8301     case 726 : if (DEBUG) { System.out.println("StaticImportOnDemandDeclaration ::=..."); }  //$NON-NLS-1$
8302 		    consumeImportDeclaration();
8303 			break;
8304 
8305     case 727 : if (DEBUG) { System.out.println("StaticImportOnDemandDeclarationName ::= import static..."); }  //$NON-NLS-1$
8306 		    consumeStaticImportOnDemandDeclarationName();
8307 			break;
8308 
8309     case 728 : if (DEBUG) { System.out.println("TypeArguments ::= LESS TypeArgumentList1"); }  //$NON-NLS-1$
8310 		    consumeTypeArguments();
8311 			break;
8312 
8313     case 729 : if (DEBUG) { System.out.println("OnlyTypeArguments ::= LESS TypeArgumentList1"); }  //$NON-NLS-1$
8314 		    consumeOnlyTypeArguments();
8315 			break;
8316 
8317     case 731 : if (DEBUG) { System.out.println("TypeArgumentList1 ::= TypeArgumentList COMMA..."); }  //$NON-NLS-1$
8318 		    consumeTypeArgumentList1();
8319 			break;
8320 
8321     case 733 : if (DEBUG) { System.out.println("TypeArgumentList ::= TypeArgumentList COMMA TypeArgument"); }  //$NON-NLS-1$
8322 		    consumeTypeArgumentList();
8323 			break;
8324 
8325     case 734 : if (DEBUG) { System.out.println("TypeArgument ::= ReferenceType"); }  //$NON-NLS-1$
8326 		    consumeTypeArgument();
8327 			break;
8328 
8329     case 738 : if (DEBUG) { System.out.println("ReferenceType1 ::= ReferenceType GREATER"); }  //$NON-NLS-1$
8330 		    consumeReferenceType1();
8331 			break;
8332 
8333     case 739 : if (DEBUG) { System.out.println("ReferenceType1 ::= ClassOrInterface LESS..."); }  //$NON-NLS-1$
8334 		    consumeTypeArgumentReferenceType1();
8335 			break;
8336 
8337     case 741 : if (DEBUG) { System.out.println("TypeArgumentList2 ::= TypeArgumentList COMMA..."); }  //$NON-NLS-1$
8338 		    consumeTypeArgumentList2();
8339 			break;
8340 
8341     case 744 : if (DEBUG) { System.out.println("ReferenceType2 ::= ReferenceType RIGHT_SHIFT"); }  //$NON-NLS-1$
8342 		    consumeReferenceType2();
8343 			break;
8344 
8345     case 745 : if (DEBUG) { System.out.println("ReferenceType2 ::= ClassOrInterface LESS..."); }  //$NON-NLS-1$
8346 		    consumeTypeArgumentReferenceType2();
8347 			break;
8348 
8349     case 747 : if (DEBUG) { System.out.println("TypeArgumentList3 ::= TypeArgumentList COMMA..."); }  //$NON-NLS-1$
8350 		    consumeTypeArgumentList3();
8351 			break;
8352 
8353     case 750 : if (DEBUG) { System.out.println("ReferenceType3 ::= ReferenceType UNSIGNED_RIGHT_SHIFT"); }  //$NON-NLS-1$
8354 		    consumeReferenceType3();
8355 			break;
8356 
8357     case 751 : if (DEBUG) { System.out.println("Wildcard ::= TypeAnnotationsopt QUESTION"); }  //$NON-NLS-1$
8358 		    consumeWildcard();
8359 			break;
8360 
8361     case 752 : if (DEBUG) { System.out.println("Wildcard ::= TypeAnnotationsopt QUESTION WildcardBounds"); }  //$NON-NLS-1$
8362 		    consumeWildcardWithBounds();
8363 			break;
8364 
8365     case 753 : if (DEBUG) { System.out.println("WildcardBounds ::= extends ReferenceType"); }  //$NON-NLS-1$
8366 		    consumeWildcardBoundsExtends();
8367 			break;
8368 
8369     case 754 : if (DEBUG) { System.out.println("WildcardBounds ::= super ReferenceType"); }  //$NON-NLS-1$
8370 		    consumeWildcardBoundsSuper();
8371 			break;
8372 
8373     case 755 : if (DEBUG) { System.out.println("Wildcard1 ::= TypeAnnotationsopt QUESTION GREATER"); }  //$NON-NLS-1$
8374 		    consumeWildcard1();
8375 			break;
8376 
8377     case 756 : if (DEBUG) { System.out.println("Wildcard1 ::= TypeAnnotationsopt QUESTION..."); }  //$NON-NLS-1$
8378 		    consumeWildcard1WithBounds();
8379 			break;
8380 
8381     case 757 : if (DEBUG) { System.out.println("WildcardBounds1 ::= extends ReferenceType1"); }  //$NON-NLS-1$
8382 		    consumeWildcardBounds1Extends();
8383 			break;
8384 
8385     case 758 : if (DEBUG) { System.out.println("WildcardBounds1 ::= super ReferenceType1"); }  //$NON-NLS-1$
8386 		    consumeWildcardBounds1Super();
8387 			break;
8388 
8389     case 759 : if (DEBUG) { System.out.println("Wildcard2 ::= TypeAnnotationsopt QUESTION RIGHT_SHIFT"); }  //$NON-NLS-1$
8390 		    consumeWildcard2();
8391 			break;
8392 
8393     case 760 : if (DEBUG) { System.out.println("Wildcard2 ::= TypeAnnotationsopt QUESTION..."); }  //$NON-NLS-1$
8394 		    consumeWildcard2WithBounds();
8395 			break;
8396 
8397     case 761 : if (DEBUG) { System.out.println("WildcardBounds2 ::= extends ReferenceType2"); }  //$NON-NLS-1$
8398 		    consumeWildcardBounds2Extends();
8399 			break;
8400 
8401     case 762 : if (DEBUG) { System.out.println("WildcardBounds2 ::= super ReferenceType2"); }  //$NON-NLS-1$
8402 		    consumeWildcardBounds2Super();
8403 			break;
8404 
8405     case 763 : if (DEBUG) { System.out.println("Wildcard3 ::= TypeAnnotationsopt QUESTION..."); }  //$NON-NLS-1$
8406 		    consumeWildcard3();
8407 			break;
8408 
8409     case 764 : if (DEBUG) { System.out.println("Wildcard3 ::= TypeAnnotationsopt QUESTION..."); }  //$NON-NLS-1$
8410 		    consumeWildcard3WithBounds();
8411 			break;
8412 
8413     case 765 : if (DEBUG) { System.out.println("WildcardBounds3 ::= extends ReferenceType3"); }  //$NON-NLS-1$
8414 		    consumeWildcardBounds3Extends();
8415 			break;
8416 
8417     case 766 : if (DEBUG) { System.out.println("WildcardBounds3 ::= super ReferenceType3"); }  //$NON-NLS-1$
8418 		    consumeWildcardBounds3Super();
8419 			break;
8420 
8421     case 767 : if (DEBUG) { System.out.println("TypeParameterHeader ::= TypeAnnotationsopt Identifier"); }  //$NON-NLS-1$
8422 		    consumeTypeParameterHeader();
8423 			break;
8424 
8425     case 768 : if (DEBUG) { System.out.println("TypeParameters ::= LESS TypeParameterList1"); }  //$NON-NLS-1$
8426 		    consumeTypeParameters();
8427 			break;
8428 
8429     case 770 : if (DEBUG) { System.out.println("TypeParameterList ::= TypeParameterList COMMA..."); }  //$NON-NLS-1$
8430 		    consumeTypeParameterList();
8431 			break;
8432 
8433     case 772 : if (DEBUG) { System.out.println("TypeParameter ::= TypeParameterHeader extends..."); }  //$NON-NLS-1$
8434 		    consumeTypeParameterWithExtends();
8435 			break;
8436 
8437     case 773 : if (DEBUG) { System.out.println("TypeParameter ::= TypeParameterHeader extends..."); }  //$NON-NLS-1$
8438 		    consumeTypeParameterWithExtendsAndBounds();
8439 			break;
8440 
8441     case 775 : if (DEBUG) { System.out.println("AdditionalBoundList ::= AdditionalBoundList..."); }  //$NON-NLS-1$
8442 		    consumeAdditionalBoundList();
8443 			break;
8444 
8445     case 776 : if (DEBUG) { System.out.println("AdditionalBound ::= AND ReferenceType"); }  //$NON-NLS-1$
8446 		    consumeAdditionalBound();
8447 			break;
8448 
8449     case 778 : if (DEBUG) { System.out.println("TypeParameterList1 ::= TypeParameterList COMMA..."); }  //$NON-NLS-1$
8450 		    consumeTypeParameterList1();
8451 			break;
8452 
8453     case 779 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader GREATER"); }  //$NON-NLS-1$
8454 		    consumeTypeParameter1();
8455 			break;
8456 
8457     case 780 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader extends..."); }  //$NON-NLS-1$
8458 		    consumeTypeParameter1WithExtends();
8459 			break;
8460 
8461     case 781 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader extends..."); }  //$NON-NLS-1$
8462 		    consumeTypeParameter1WithExtendsAndBounds();
8463 			break;
8464 
8465     case 783 : if (DEBUG) { System.out.println("AdditionalBoundList1 ::= AdditionalBoundList..."); }  //$NON-NLS-1$
8466 		    consumeAdditionalBoundList1();
8467 			break;
8468 
8469     case 784 : if (DEBUG) { System.out.println("AdditionalBound1 ::= AND ReferenceType1"); }  //$NON-NLS-1$
8470 		    consumeAdditionalBound1();
8471 			break;
8472 
8473     case 790 : if (DEBUG) { System.out.println("UnaryExpression_NotName ::= PLUS PushPosition..."); }  //$NON-NLS-1$
8474 		    consumeUnaryExpression(OperatorIds.PLUS);
8475 			break;
8476 
8477     case 791 : if (DEBUG) { System.out.println("UnaryExpression_NotName ::= MINUS PushPosition..."); }  //$NON-NLS-1$
8478 		    consumeUnaryExpression(OperatorIds.MINUS);
8479 			break;
8480 
8481     case 794 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus_NotName ::= TWIDDLE..."); }  //$NON-NLS-1$
8482 		    consumeUnaryExpression(OperatorIds.TWIDDLE);
8483 			break;
8484 
8485     case 795 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus_NotName ::= NOT PushPosition"); }  //$NON-NLS-1$
8486 		    consumeUnaryExpression(OperatorIds.NOT);
8487 			break;
8488 
8489     case 798 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); }  //$NON-NLS-1$
8490 		    consumeBinaryExpression(OperatorIds.MULTIPLY);
8491 			break;
8492 
8493     case 799 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name MULTIPLY..."); }  //$NON-NLS-1$
8494 		    consumeBinaryExpressionWithName(OperatorIds.MULTIPLY);
8495 			break;
8496 
8497     case 800 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); }  //$NON-NLS-1$
8498 		    consumeBinaryExpression(OperatorIds.DIVIDE);
8499 			break;
8500 
8501     case 801 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name DIVIDE..."); }  //$NON-NLS-1$
8502 		    consumeBinaryExpressionWithName(OperatorIds.DIVIDE);
8503 			break;
8504 
8505     case 802 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); }  //$NON-NLS-1$
8506 		    consumeBinaryExpression(OperatorIds.REMAINDER);
8507 			break;
8508 
8509     case 803 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name REMAINDER..."); }  //$NON-NLS-1$
8510 		    consumeBinaryExpressionWithName(OperatorIds.REMAINDER);
8511 			break;
8512 
8513     case 805 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::=..."); }  //$NON-NLS-1$
8514 		    consumeBinaryExpression(OperatorIds.PLUS);
8515 			break;
8516 
8517     case 806 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::= Name PLUS..."); }  //$NON-NLS-1$
8518 		    consumeBinaryExpressionWithName(OperatorIds.PLUS);
8519 			break;
8520 
8521     case 807 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::=..."); }  //$NON-NLS-1$
8522 		    consumeBinaryExpression(OperatorIds.MINUS);
8523 			break;
8524 
8525     case 808 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::= Name MINUS..."); }  //$NON-NLS-1$
8526 		    consumeBinaryExpressionWithName(OperatorIds.MINUS);
8527 			break;
8528 
8529     case 810 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); }  //$NON-NLS-1$
8530 		    consumeBinaryExpression(OperatorIds.LEFT_SHIFT);
8531 			break;
8532 
8533     case 811 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name LEFT_SHIFT..."); }  //$NON-NLS-1$
8534 		    consumeBinaryExpressionWithName(OperatorIds.LEFT_SHIFT);
8535 			break;
8536 
8537     case 812 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); }  //$NON-NLS-1$
8538 		    consumeBinaryExpression(OperatorIds.RIGHT_SHIFT);
8539 			break;
8540 
8541     case 813 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name RIGHT_SHIFT..."); }  //$NON-NLS-1$
8542 		    consumeBinaryExpressionWithName(OperatorIds.RIGHT_SHIFT);
8543 			break;
8544 
8545     case 814 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); }  //$NON-NLS-1$
8546 		    consumeBinaryExpression(OperatorIds.UNSIGNED_RIGHT_SHIFT);
8547 			break;
8548 
8549     case 815 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name UNSIGNED_RIGHT_SHIFT..."); }  //$NON-NLS-1$
8550 		    consumeBinaryExpressionWithName(OperatorIds.UNSIGNED_RIGHT_SHIFT);
8551 			break;
8552 
8553     case 817 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= ShiftExpression_NotName"); }  //$NON-NLS-1$
8554 		    consumeBinaryExpression(OperatorIds.LESS);
8555 			break;
8556 
8557     case 818 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name LESS..."); }  //$NON-NLS-1$
8558 		    consumeBinaryExpressionWithName(OperatorIds.LESS);
8559 			break;
8560 
8561     case 819 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= ShiftExpression_NotName"); }  //$NON-NLS-1$
8562 		    consumeBinaryExpression(OperatorIds.GREATER);
8563 			break;
8564 
8565     case 820 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name GREATER..."); }  //$NON-NLS-1$
8566 		    consumeBinaryExpressionWithName(OperatorIds.GREATER);
8567 			break;
8568 
8569     case 821 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::=..."); }  //$NON-NLS-1$
8570 		    consumeBinaryExpression(OperatorIds.LESS_EQUAL);
8571 			break;
8572 
8573     case 822 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name LESS_EQUAL..."); }  //$NON-NLS-1$
8574 		    consumeBinaryExpressionWithName(OperatorIds.LESS_EQUAL);
8575 			break;
8576 
8577     case 823 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::=..."); }  //$NON-NLS-1$
8578 		    consumeBinaryExpression(OperatorIds.GREATER_EQUAL);
8579 			break;
8580 
8581     case 824 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name GREATER_EQUAL..."); }  //$NON-NLS-1$
8582 		    consumeBinaryExpressionWithName(OperatorIds.GREATER_EQUAL);
8583 			break;
8584 
8585     case 826 : if (DEBUG) { System.out.println("InstanceofExpression_NotName ::= Name instanceof..."); }  //$NON-NLS-1$
8586 		    consumeInstanceOfExpressionWithName();
8587 			break;
8588 
8589     case 827 : if (DEBUG) { System.out.println("InstanceofExpression_NotName ::=..."); }  //$NON-NLS-1$
8590 		    consumeInstanceOfExpression();
8591 			break;
8592 
8593     case 829 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::=..."); }  //$NON-NLS-1$
8594 		    consumeEqualityExpression(OperatorIds.EQUAL_EQUAL);
8595 			break;
8596 
8597     case 830 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::= Name EQUAL_EQUAL..."); }  //$NON-NLS-1$
8598 		    consumeEqualityExpressionWithName(OperatorIds.EQUAL_EQUAL);
8599 			break;
8600 
8601     case 831 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::=..."); }  //$NON-NLS-1$
8602 		    consumeEqualityExpression(OperatorIds.NOT_EQUAL);
8603 			break;
8604 
8605     case 832 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::= Name NOT_EQUAL..."); }  //$NON-NLS-1$
8606 		    consumeEqualityExpressionWithName(OperatorIds.NOT_EQUAL);
8607 			break;
8608 
8609     case 834 : if (DEBUG) { System.out.println("AndExpression_NotName ::= AndExpression_NotName AND..."); }  //$NON-NLS-1$
8610 		    consumeBinaryExpression(OperatorIds.AND);
8611 			break;
8612 
8613     case 835 : if (DEBUG) { System.out.println("AndExpression_NotName ::= Name AND EqualityExpression"); }  //$NON-NLS-1$
8614 		    consumeBinaryExpressionWithName(OperatorIds.AND);
8615 			break;
8616 
8617     case 837 : if (DEBUG) { System.out.println("ExclusiveOrExpression_NotName ::=..."); }  //$NON-NLS-1$
8618 		    consumeBinaryExpression(OperatorIds.XOR);
8619 			break;
8620 
8621     case 838 : if (DEBUG) { System.out.println("ExclusiveOrExpression_NotName ::= Name XOR AndExpression"); }  //$NON-NLS-1$
8622 		    consumeBinaryExpressionWithName(OperatorIds.XOR);
8623 			break;
8624 
8625     case 840 : if (DEBUG) { System.out.println("InclusiveOrExpression_NotName ::=..."); }  //$NON-NLS-1$
8626 		    consumeBinaryExpression(OperatorIds.OR);
8627 			break;
8628 
8629     case 841 : if (DEBUG) { System.out.println("InclusiveOrExpression_NotName ::= Name OR..."); }  //$NON-NLS-1$
8630 		    consumeBinaryExpressionWithName(OperatorIds.OR);
8631 			break;
8632 
8633     case 843 : if (DEBUG) { System.out.println("ConditionalAndExpression_NotName ::=..."); }  //$NON-NLS-1$
8634 		    consumeBinaryExpression(OperatorIds.AND_AND);
8635 			break;
8636 
8637     case 844 : if (DEBUG) { System.out.println("ConditionalAndExpression_NotName ::= Name AND_AND..."); }  //$NON-NLS-1$
8638 		    consumeBinaryExpressionWithName(OperatorIds.AND_AND);
8639 			break;
8640 
8641     case 846 : if (DEBUG) { System.out.println("ConditionalOrExpression_NotName ::=..."); }  //$NON-NLS-1$
8642 		    consumeBinaryExpression(OperatorIds.OR_OR);
8643 			break;
8644 
8645     case 847 : if (DEBUG) { System.out.println("ConditionalOrExpression_NotName ::= Name OR_OR..."); }  //$NON-NLS-1$
8646 		    consumeBinaryExpressionWithName(OperatorIds.OR_OR);
8647 			break;
8648 
8649     case 849 : if (DEBUG) { System.out.println("ConditionalExpression_NotName ::=..."); }  //$NON-NLS-1$
8650 		    consumeConditionalExpression(OperatorIds.QUESTIONCOLON) ;
8651 			break;
8652 
8653     case 850 : if (DEBUG) { System.out.println("ConditionalExpression_NotName ::= Name QUESTION..."); }  //$NON-NLS-1$
8654 		    consumeConditionalExpressionWithName(OperatorIds.QUESTIONCOLON) ;
8655 			break;
8656 
8657     case 854 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= Modifiers AT..."); }  //$NON-NLS-1$
8658 		    consumeAnnotationTypeDeclarationHeaderName() ;
8659 			break;
8660 
8661     case 855 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= Modifiers AT..."); }  //$NON-NLS-1$
8662 		    consumeAnnotationTypeDeclarationHeaderNameWithTypeParameters() ;
8663 			break;
8664 
8665     case 856 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= AT..."); }  //$NON-NLS-1$
8666 		    consumeAnnotationTypeDeclarationHeaderNameWithTypeParameters() ;
8667 			break;
8668 
8669     case 857 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= AT..."); }  //$NON-NLS-1$
8670 		    consumeAnnotationTypeDeclarationHeaderName() ;
8671 			break;
8672 
8673     case 858 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeader ::=..."); }  //$NON-NLS-1$
8674 		    consumeAnnotationTypeDeclarationHeader() ;
8675 			break;
8676 
8677     case 859 : if (DEBUG) { System.out.println("AnnotationTypeDeclaration ::=..."); }  //$NON-NLS-1$
8678 		    consumeAnnotationTypeDeclaration() ;
8679 			break;
8680 
8681     case 861 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarationsopt ::="); }  //$NON-NLS-1$
8682 		    consumeEmptyAnnotationTypeMemberDeclarationsopt() ;
8683 			break;
8684 
8685     case 862 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarationsopt ::= NestedType..."); }  //$NON-NLS-1$
8686 		    consumeAnnotationTypeMemberDeclarationsopt() ;
8687 			break;
8688 
8689     case 864 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarations ::=..."); }  //$NON-NLS-1$
8690 		    consumeAnnotationTypeMemberDeclarations() ;
8691 			break;
8692 
8693     case 865 : if (DEBUG) { System.out.println("AnnotationMethodHeaderName ::= Modifiersopt..."); }  //$NON-NLS-1$
8694 		    consumeMethodHeaderNameWithTypeParameters(true);
8695 			break;
8696 
8697     case 866 : if (DEBUG) { System.out.println("AnnotationMethodHeaderName ::= Modifiersopt Type..."); }  //$NON-NLS-1$
8698 		    consumeMethodHeaderName(true);
8699 			break;
8700 
8701     case 867 : if (DEBUG) { System.out.println("AnnotationMethodHeaderDefaultValueopt ::="); }  //$NON-NLS-1$
8702 		    consumeEmptyMethodHeaderDefaultValue() ;
8703 			break;
8704 
8705     case 868 : if (DEBUG) { System.out.println("AnnotationMethodHeaderDefaultValueopt ::= DefaultValue"); }  //$NON-NLS-1$
8706 		    consumeMethodHeaderDefaultValue();
8707 			break;
8708 
8709     case 869 : if (DEBUG) { System.out.println("AnnotationMethodHeader ::= AnnotationMethodHeaderName..."); }  //$NON-NLS-1$
8710 		    consumeMethodHeader();
8711 			break;
8712 
8713     case 870 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclaration ::=..."); }  //$NON-NLS-1$
8714 		    consumeAnnotationTypeMemberDeclaration() ;
8715 			break;
8716 
8717     case 878 : if (DEBUG) { System.out.println("AnnotationName ::= AT UnannotatableName"); }  //$NON-NLS-1$
8718 		    consumeAnnotationName() ;
8719 			break;
8720 
8721     case 879 : if (DEBUG) { System.out.println("NormalAnnotation ::= AnnotationName LPAREN..."); }  //$NON-NLS-1$
8722 		    consumeNormalAnnotation(false) ;
8723 			break;
8724 
8725     case 880 : if (DEBUG) { System.out.println("MemberValuePairsopt ::="); }  //$NON-NLS-1$
8726 		    consumeEmptyMemberValuePairsopt() ;
8727 			break;
8728 
8729     case 883 : if (DEBUG) { System.out.println("MemberValuePairs ::= MemberValuePairs COMMA..."); }  //$NON-NLS-1$
8730 		    consumeMemberValuePairs() ;
8731 			break;
8732 
8733     case 884 : if (DEBUG) { System.out.println("MemberValuePair ::= SimpleName EQUAL EnterMemberValue..."); }  //$NON-NLS-1$
8734 		    consumeMemberValuePair() ;
8735 			break;
8736 
8737     case 885 : if (DEBUG) { System.out.println("EnterMemberValue ::="); }  //$NON-NLS-1$
8738 		    consumeEnterMemberValue() ;
8739 			break;
8740 
8741     case 886 : if (DEBUG) { System.out.println("ExitMemberValue ::="); }  //$NON-NLS-1$
8742 		    consumeExitMemberValue() ;
8743 			break;
8744 
8745     case 888 : if (DEBUG) { System.out.println("MemberValue ::= Name"); }  //$NON-NLS-1$
8746 		    consumeMemberValueAsName() ;
8747 			break;
8748 
8749     case 891 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); }  //$NON-NLS-1$
8750 		    consumeMemberValueArrayInitializer() ;
8751 			break;
8752 
8753     case 892 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); }  //$NON-NLS-1$
8754 		    consumeMemberValueArrayInitializer() ;
8755 			break;
8756 
8757     case 893 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); }  //$NON-NLS-1$
8758 		    consumeEmptyMemberValueArrayInitializer() ;
8759 			break;
8760 
8761     case 894 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); }  //$NON-NLS-1$
8762 		    consumeEmptyMemberValueArrayInitializer() ;
8763 			break;
8764 
8765     case 895 : if (DEBUG) { System.out.println("EnterMemberValueArrayInitializer ::="); }  //$NON-NLS-1$
8766 		    consumeEnterMemberValueArrayInitializer() ;
8767 			break;
8768 
8769     case 897 : if (DEBUG) { System.out.println("MemberValues ::= MemberValues COMMA MemberValue"); }  //$NON-NLS-1$
8770 		    consumeMemberValues() ;
8771 			break;
8772 
8773     case 898 : if (DEBUG) { System.out.println("MarkerAnnotation ::= AnnotationName"); }  //$NON-NLS-1$
8774 		    consumeMarkerAnnotation(false) ;
8775 			break;
8776 
8777     case 899 : if (DEBUG) { System.out.println("SingleMemberAnnotationMemberValue ::= MemberValue"); }  //$NON-NLS-1$
8778 		    consumeSingleMemberAnnotationMemberValue() ;
8779 			break;
8780 
8781     case 900 : if (DEBUG) { System.out.println("SingleMemberAnnotation ::= AnnotationName LPAREN..."); }  //$NON-NLS-1$
8782 		    consumeSingleMemberAnnotation(false) ;
8783 			break;
8784 
8785     case 901 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= Modifiersopt TypeParameters"); }  //$NON-NLS-1$
8786 		    consumeRecoveryMethodHeaderNameWithTypeParameters();
8787 			break;
8788 
8789     case 902 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= Modifiersopt Type..."); }  //$NON-NLS-1$
8790 		    consumeRecoveryMethodHeaderName();
8791 			break;
8792 
8793     case 903 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= ModifiersWithDefault..."); }  //$NON-NLS-1$
8794 		    consumeRecoveryMethodHeaderNameWithTypeParameters();
8795 			break;
8796 
8797     case 904 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= ModifiersWithDefault Type"); }  //$NON-NLS-1$
8798 		    consumeRecoveryMethodHeaderName();
8799 			break;
8800 
8801     case 905 : if (DEBUG) { System.out.println("RecoveryMethodHeader ::= RecoveryMethodHeaderName..."); }  //$NON-NLS-1$
8802 		    consumeMethodHeader();
8803 			break;
8804 
8805     case 906 : if (DEBUG) { System.out.println("RecoveryMethodHeader ::= RecoveryMethodHeaderName..."); }  //$NON-NLS-1$
8806 		    consumeMethodHeader();
8807 			break;
8808 
8809 	}
8810 }
8811 // END_AUTOGENERATED_REGION_CONSUME_RULE
consumeVariableDeclaratorIdParameter()8812 protected void consumeVariableDeclaratorIdParameter () {
8813 	pushOnIntStack(1);  // signal "normal" variable declarator id parameter.
8814 }
consumeExplicitThisParameter(boolean isQualified)8815 protected void consumeExplicitThisParameter(boolean isQualified) {
8816 	// VariableDeclaratorIdOrThis ::= 'this'
8817 	// VariableDeclaratorIdOrThis ::= UnannotatableName '.' 'this'
8818 	// VariableDeclaratorIdOrThis ::= VariableDeclaratorId
8819 
8820 	NameReference qualifyingNameReference = null;
8821 	if (isQualified) {
8822 		qualifyingNameReference = getUnspecifiedReference(false); // By construction the qualified name is unannotated here, so we should not meddle with the type annotation stack
8823 	}
8824 	pushOnExpressionStack(qualifyingNameReference);
8825 	int thisStart = this.intStack[this.intPtr--];
8826 	pushIdentifier(ConstantPool.This, (((long) thisStart << 32)) + (thisStart + 3));
8827 	pushOnIntStack(0);  // extended dimensions ...
8828 	pushOnIntStack(0);  // signal explicit this
8829 }
8830 
isAssistParser()8831 protected boolean isAssistParser() {
8832 	return false;
8833 }
consumeNestedLambda()8834 protected void consumeNestedLambda() {
8835 	// NestedLambda ::= $empty - we get here just after the type+parenthesis elided singleton parameter or just before the '(' of the parameter list.
8836 	consumeNestedType();
8837 	this.nestedMethod[this.nestedType] ++;
8838 	LambdaExpression lambda = new LambdaExpression(this.compilationUnit.compilationResult, isAssistParser());
8839 	pushOnAstStack(lambda);
8840 	this.processingLambdaParameterList = true;
8841 }
8842 
consumeLambdaHeader()8843 protected void consumeLambdaHeader() {
8844 	// LambdaHeader ::= LambdaParameters '->'  Synthetic/fake production with a synthetic non-terminal. Body not seen yet.
8845 
8846 	int arrowPosition = this.scanner.currentPosition - 1;
8847 
8848 	Argument [] arguments = null;
8849 	int length = this.astLengthStack[this.astLengthPtr--];
8850 	this.astPtr -= length;
8851 	//arguments
8852 	if (length != 0) {
8853 		System.arraycopy(
8854 			this.astStack,
8855 			this.astPtr + 1,
8856 			arguments = new Argument[length],
8857 			0,
8858 			length);
8859 	}
8860 	for (int i = 0; i < length; i++) {
8861 		final Argument argument = arguments[i];
8862 		if (argument.isReceiver()) {
8863 			problemReporter().illegalThis(argument);
8864 		}
8865 		if (argument.name.length == 1 && argument.name[0] == '_')
8866 			problemReporter().illegalUseOfUnderscoreAsAnIdentifier(argument.sourceStart, argument.sourceEnd, true); // true == lambdaParameter
8867 	}
8868 	LambdaExpression lexp = (LambdaExpression) this.astStack[this.astPtr];
8869 	lexp.setArguments(arguments);
8870 	lexp.setArrowPosition(arrowPosition);
8871 	lexp.sourceEnd = this.intStack[this.intPtr--];   // ')' position or identifier position.
8872 	lexp.sourceStart = this.intStack[this.intPtr--]; // '(' position or identifier position.
8873 	lexp.hasParentheses = (this.scanner.getSource()[lexp.sourceStart] == '(');
8874 	this.listLength -= arguments == null ? 0 : arguments.length;  // not necessary really.
8875 	this.processingLambdaParameterList = false;
8876 	if (this.currentElement != null) {
8877 		this.lastCheckPoint = arrowPosition + 1; // we don't want the typed formal parameters to be processed by recovery.
8878 		this.currentElement.lambdaNestLevel++;
8879 	}
8880 }
setArgumentsTypeVar(LambdaExpression lexp)8881 private void setArgumentsTypeVar(LambdaExpression lexp) {
8882 	Argument[] args =  lexp.arguments;
8883 	if (!this.parsingJava11Plus || args == null || args.length == 0) {
8884 		lexp.argumentsTypeVar = false;
8885 		return;
8886 	}
8887 
8888 	boolean isVar = false, mixReported = false;
8889 	for (int i = 0, l = args.length; i < l; ++i) {
8890 		Argument arg = args[i];
8891 		TypeReference type = arg.type;
8892 		char[][] typeName = type != null ? type.getTypeName() : null;
8893 		boolean prev = isVar;
8894 		isVar = typeName != null && typeName.length == 1 &&
8895 				CharOperation.equals(typeName[0], TypeConstants.VAR);
8896 		lexp.argumentsTypeVar |= isVar;
8897 		if (i > 0 && prev != isVar && !mixReported) { // report only once per list
8898 			this.problemReporter().varCannotBeMixedWithNonVarParams(isVar ? arg : args[i - 1]);
8899 			mixReported = true;
8900 		}
8901 		if (isVar && (type.dimensions() > 0 || type.extraDimensions() > 0)) {
8902 			this.problemReporter().varLocalCannotBeArray(arg);
8903 		}
8904 	}
8905 }
consumeLambdaExpression()8906 protected void consumeLambdaExpression() {
8907 
8908 	// LambdaExpression ::= LambdaHeader LambdaBody
8909 
8910 	this.nestedType--;
8911 
8912 	this.astLengthPtr--; 	// pop length for LambdaBody (always 1)
8913 	Statement body = (Statement) this.astStack[this.astPtr--];
8914 	if (body instanceof Block) {
8915 		if (this.options.ignoreMethodBodies) {
8916 			Statement oldBody = body;
8917 			body = new Block(0);
8918 			body.sourceStart = oldBody.sourceStart;
8919 			body.sourceEnd = oldBody.sourceEnd;
8920 		}
8921 	}
8922 
8923 	LambdaExpression lexp = (LambdaExpression) this.astStack[this.astPtr--];
8924 	this.astLengthPtr--;
8925 	lexp.setBody(body);
8926 	lexp.sourceEnd = body.sourceEnd;
8927 
8928 	if (body instanceof Expression &&  ((Expression) body).isTrulyExpression()) {
8929 		Expression expression = (Expression) body;
8930 		expression.statementEnd = body.sourceEnd;
8931 	}
8932 	if (!this.parsingJava8Plus) {
8933 		problemReporter().lambdaExpressionsNotBelow18(lexp);
8934 	}
8935 	setArgumentsTypeVar(lexp);
8936 	pushOnExpressionStack(lexp);
8937 	if (this.currentElement != null) {
8938 		this.lastCheckPoint = body.sourceEnd + 1;
8939 		this.currentElement.lambdaNestLevel --;
8940 	}
8941 	this.referenceContext.compilationResult().hasFunctionalTypes = true;
8942 	markEnclosingMemberWithLocalOrFunctionalType(LocalTypeKind.LAMBDA);
8943 	if (lexp.compilationResult.getCompilationUnit() == null) {
8944 		// unit built out of model. Stash a textual representation of lambda to enable LE.copy().
8945 		int length = lexp.sourceEnd - lexp.sourceStart + 1;
8946 		System.arraycopy(this.scanner.getSource(), lexp.sourceStart, lexp.text = new char [length], 0, length);
8947 	}
8948 }
8949 
typeElidedArgument()8950 protected Argument typeElidedArgument() {
8951 	this.identifierLengthPtr--;
8952 	char[] identifierName = this.identifierStack[this.identifierPtr];
8953 	long namePositions = this.identifierPositionStack[this.identifierPtr--];
8954 
8955 	Argument arg =
8956 		new Argument(
8957 			identifierName,
8958 			namePositions,
8959 			null, // elided type
8960 			ClassFileConstants.AccDefault,
8961 			true);
8962 	arg.declarationSourceStart = (int) (namePositions >>> 32);
8963 	return arg;
8964 }
8965 
consumeTypeElidedLambdaParameter(boolean parenthesized)8966 protected void consumeTypeElidedLambdaParameter(boolean parenthesized) {
8967 
8968 	// LambdaParameters ::= Identifier
8969 	// TypeElidedFormalParameter ::= Modifiersopt Identifier
8970 
8971 	int modifier = ClassFileConstants.AccDefault;
8972 	int annotationLength = 0;
8973 	int modifiersStart = 0;
8974 	if (parenthesized) { // The grammar is permissive enough to allow optional modifiers for the parenthesized version, they should be rejected if present.
8975 		modifiersStart = this.intStack[this.intPtr--];
8976 		modifier = this.intStack[this.intPtr--];
8977 		// pop annotations
8978 		annotationLength = this.expressionLengthStack[this.expressionLengthPtr--];
8979 		this.expressionPtr -= annotationLength;
8980 	}
8981 
8982 	Argument arg = typeElidedArgument();
8983 	if (modifier != ClassFileConstants.AccDefault || annotationLength != 0) {
8984 		problemReporter().illegalModifiersForElidedType(arg);
8985 		arg.declarationSourceStart = modifiersStart;
8986 	}
8987 	if (!parenthesized) { // in the absence of '(' and ')', record positions.
8988 		pushOnIntStack(arg.declarationSourceStart);
8989 		pushOnIntStack(arg.declarationSourceEnd);
8990 	}
8991 	pushOnAstStack(arg);
8992 	this.listLength++;  // not relevant really.
8993 }
consumeElidedLeftBraceAndReturn()8994 protected void consumeElidedLeftBraceAndReturn() {
8995 	/* ElidedLeftBraceAndReturn ::= $empty
8996 	   Alert ! Sleight of hand - Part I : Record stack depth now that we are at the state with the kernel item
8997 	   ElidedLeftBraceAndReturn .Expression ElidedSemicolonAndRightBrace
8998 	*/
8999 	int stackLength = this.stateStackLengthStack.length;
9000 	if (++this.valueLambdaNestDepth >= stackLength) {
9001 		System.arraycopy(
9002 			this.stateStackLengthStack, 0,
9003 			this.stateStackLengthStack = new int[stackLength + 4], 0,
9004 			stackLength);
9005 	}
9006 	this.stateStackLengthStack[this.valueLambdaNestDepth] = this.stateStackTop;
9007 }
consumeExpression()9008 protected void consumeExpression() {
9009 	/* Expression ::= AssignmentExpression
9010 	   Alert ! Sleight of hand - Part II: See if we are at the state with the item: "ElidedLeftBraceAndReturn Expression .ElidedSemicolonAndRightBrace"
9011        If so, push back the current token into the lexer stream, materialize the synthetic terminal marker symbol, switch and continue.
9012     */
9013 	if (this.valueLambdaNestDepth >= 0 && this.stateStackLengthStack[this.valueLambdaNestDepth] == this.stateStackTop - 1) {
9014 		this.valueLambdaNestDepth--;
9015 		this.scanner.ungetToken(this.currentToken);
9016 		this.currentToken = TokenNameElidedSemicolonAndRightBrace; // conjure a rabbit out of the hat ...
9017 		Expression exp = this.expressionStack[this.expressionPtr--];
9018 		this.expressionLengthPtr--;
9019 		pushOnAstStack(exp);
9020 	}
9021 }
consumeIdentifierOrNew(boolean newForm)9022 protected void consumeIdentifierOrNew(boolean newForm) {
9023 	// IdentifierOrNew ::= 'Identifier'
9024 	// IdentifierOrNew ::= 'new'
9025 	if (newForm) {
9026 		int newStart = this.intStack[this.intPtr--];
9027 		pushIdentifier(ConstantPool.Init, (((long) newStart << 32)) + (newStart + 2));
9028 	}
9029 }
consumeEmptyTypeArguments()9030 protected void consumeEmptyTypeArguments() {
9031 	// NonWildTypeArgumentsopt ::= $empty
9032 	pushOnGenericsLengthStack(0); // signal absence of type arguments.
9033 }
9034 
newReferenceExpression()9035 public ReferenceExpression newReferenceExpression() {
9036 	return new ReferenceExpression(this.scanner);
9037 }
9038 
consumeReferenceExpressionTypeForm(boolean isPrimitive)9039 protected void consumeReferenceExpressionTypeForm(boolean isPrimitive) { // actually Name or Type form.
9040 
9041 	// ReferenceExpression ::= PrimitiveType Dims '::' NonWildTypeArgumentsopt IdentifierOrNew
9042 	// ReferenceExpression ::= Name Dimsopt '::' NonWildTypeArgumentsopt IdentifierOrNew
9043 
9044 	ReferenceExpression referenceExpression = newReferenceExpression();
9045 	TypeReference [] typeArguments = null;
9046 	char [] selector;
9047 	int sourceEnd;
9048 
9049 	sourceEnd = (int) this.identifierPositionStack[this.identifierPtr];
9050 	referenceExpression.nameSourceStart = (int) (this.identifierPositionStack[this.identifierPtr] >>> 32);
9051 	selector = this.identifierStack[this.identifierPtr--];
9052 	this.identifierLengthPtr--;
9053 
9054 	int length = this.genericsLengthStack[this.genericsLengthPtr--];
9055 	if (length > 0) {
9056 		this.genericsPtr -= length;
9057 		System.arraycopy(this.genericsStack, this.genericsPtr + 1, typeArguments = new TypeReference[length], 0, length);
9058 		this.intPtr--;  // pop type arguments source start.
9059 	}
9060 
9061 	int dimension = this.intStack[this.intPtr--];
9062 	boolean typeAnnotatedName = false;
9063 	for (int i = this.identifierLengthStack[this.identifierLengthPtr], j = 0; i > 0 && this.typeAnnotationLengthPtr >= 0; --i, j++) {
9064 		length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr - j];
9065 		if (length != 0) {
9066 			typeAnnotatedName = true;
9067 			break;
9068 		}
9069 	}
9070 
9071 	if (dimension > 0 || typeAnnotatedName) {
9072 		if (!isPrimitive) {
9073 			pushOnGenericsLengthStack(0);
9074 			pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
9075 		}
9076 		referenceExpression.initialize(this.compilationUnit.compilationResult, getTypeReference(dimension), typeArguments, selector, sourceEnd);
9077 	} else {
9078 		referenceExpression.initialize(this.compilationUnit.compilationResult, getUnspecifiedReference(), typeArguments, selector, sourceEnd);
9079 	}
9080 	if (CharOperation.equals(selector, TypeConstants.INIT) && referenceExpression.lhs instanceof NameReference) {
9081 		referenceExpression.lhs.bits &= ~Binding.VARIABLE;
9082 	}
9083 	consumeReferenceExpression(referenceExpression);
9084 }
consumeReferenceExpressionPrimaryForm()9085 protected void consumeReferenceExpressionPrimaryForm() {
9086 	// ReferenceExpression ::= Primary '::' NonWildTypeArgumentsopt Identifier
9087 
9088 	ReferenceExpression referenceExpression = newReferenceExpression();
9089 	TypeReference [] typeArguments = null;
9090 	char [] selector;
9091 	int sourceEnd;
9092 
9093 	sourceEnd = (int) this.identifierPositionStack[this.identifierPtr];
9094 	referenceExpression.nameSourceStart = (int) (this.identifierPositionStack[this.identifierPtr] >>> 32);
9095 	selector = this.identifierStack[this.identifierPtr--];
9096 	this.identifierLengthPtr--;
9097 
9098 	int length = this.genericsLengthStack[this.genericsLengthPtr--];
9099 	if (length > 0) {
9100 		this.genericsPtr -= length;
9101 		System.arraycopy(this.genericsStack, this.genericsPtr + 1, typeArguments = new TypeReference[length], 0, length);
9102 		this.intPtr--;  // pop type arguments source start.
9103 	}
9104 
9105 	Expression primary = this.expressionStack[this.expressionPtr--];
9106 	this.expressionLengthPtr--;
9107 	referenceExpression.initialize(this.compilationUnit.compilationResult, primary, typeArguments, selector, sourceEnd);
9108 	consumeReferenceExpression(referenceExpression);
9109 }
consumeReferenceExpressionSuperForm()9110 protected void consumeReferenceExpressionSuperForm() {
9111 	// ReferenceExpression ::= 'super' '::' NonWildTypeArgumentsopt Identifier
9112 
9113 	ReferenceExpression referenceExpression = newReferenceExpression();
9114 	TypeReference [] typeArguments = null;
9115 	char [] selector;
9116 	int sourceEnd;
9117 
9118 	sourceEnd = (int) this.identifierPositionStack[this.identifierPtr];
9119 	referenceExpression.nameSourceStart = (int) (this.identifierPositionStack[this.identifierPtr] >>> 32);
9120 	selector = this.identifierStack[this.identifierPtr--];
9121 	this.identifierLengthPtr--;
9122 
9123 	int length = this.genericsLengthStack[this.genericsLengthPtr--];
9124 	if (length > 0) {
9125 		this.genericsPtr -= length;
9126 		System.arraycopy(this.genericsStack, this.genericsPtr + 1, typeArguments = new TypeReference[length], 0, length);
9127 		this.intPtr--;  // pop type arguments source start.
9128 	}
9129 
9130 	SuperReference superReference = new SuperReference(this.intStack[this.intPtr--], this.endPosition);
9131 	referenceExpression.initialize(this.compilationUnit.compilationResult, superReference, typeArguments, selector, sourceEnd);
9132 	consumeReferenceExpression(referenceExpression);
9133 }
consumeReferenceExpression(ReferenceExpression referenceExpression)9134 protected void consumeReferenceExpression(ReferenceExpression referenceExpression) {
9135 	pushOnExpressionStack(referenceExpression);
9136 	if (!this.parsingJava8Plus) {
9137 		problemReporter().referenceExpressionsNotBelow18(referenceExpression);
9138 	}
9139 	if (referenceExpression.compilationResult.getCompilationUnit() == null) {
9140 		// unit built out of model. Stash a textual representation to enable RE.copy().
9141 		int length = referenceExpression.sourceEnd - referenceExpression.sourceStart + 1;
9142 		System.arraycopy(this.scanner.getSource(), referenceExpression.sourceStart, referenceExpression.text = new char [length], 0, length);
9143 	}
9144 	this.referenceContext.compilationResult().hasFunctionalTypes = true;
9145 	markEnclosingMemberWithLocalOrFunctionalType(LocalTypeKind.METHOD_REFERENCE);
9146 }
consumeReferenceExpressionTypeArgumentsAndTrunk(boolean qualified)9147 protected void consumeReferenceExpressionTypeArgumentsAndTrunk(boolean qualified) {
9148 	// ReferenceExpressionTypeArgumentsAndTrunk ::= OnlyTypeArguments Dimsopt ==> qualified == false
9149 	// ReferenceExpressionTypeArgumentsAndTrunk ::= OnlyTypeArguments '.' ClassOrInterfaceType Dimsopt ==> qualified == true
9150 	pushOnIntStack(qualified ? 1 : 0);
9151 	pushOnIntStack(this.scanner.startPosition - 1); // mark position of :: as the end of type
9152 }
consumeReferenceExpressionGenericTypeForm()9153 protected void consumeReferenceExpressionGenericTypeForm() {
9154 
9155 	// ReferenceExpression ::= Name BeginTypeArguments ReferenceExpressionTypeArgumentsAndTrunk '::' NonWildTypeArgumentsopt IdentifierOrNew
9156 
9157 	ReferenceExpression referenceExpression = newReferenceExpression();
9158 	TypeReference type;
9159 	TypeReference [] typeArguments = null;
9160 	char [] selector;
9161 	int sourceEnd;
9162 
9163 	sourceEnd = (int) this.identifierPositionStack[this.identifierPtr];
9164 	referenceExpression.nameSourceStart = (int) (this.identifierPositionStack[this.identifierPtr] >>> 32);
9165 	selector = this.identifierStack[this.identifierPtr--];
9166 	this.identifierLengthPtr--;
9167 
9168 	int length = this.genericsLengthStack[this.genericsLengthPtr--];
9169 	if (length > 0) {
9170 		this.genericsPtr -= length;
9171 		System.arraycopy(this.genericsStack, this.genericsPtr + 1, typeArguments = new TypeReference[length], 0, length);
9172 		this.intPtr--;  // pop type arguments source start.
9173 	}
9174 
9175 	int typeSourceEnd = this.intStack[this.intPtr--];
9176 	boolean qualified = this.intStack[this.intPtr--] != 0;
9177 	int dims = this.intStack[this.intPtr--];
9178 	if (qualified) {
9179 		Annotation [][] annotationsOnDimensions = dims == 0 ? null : getAnnotationsOnDimensions(dims);
9180 		TypeReference rightSide = getTypeReference(0);
9181 		type = computeQualifiedGenericsFromRightSide(rightSide, dims, annotationsOnDimensions);
9182 	} else {
9183 		pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
9184 		type = getTypeReference(dims);
9185 	}
9186 	this.intPtr--; // pop '<' position
9187 	type.sourceEnd = typeSourceEnd;
9188 
9189 	referenceExpression.initialize(this.compilationUnit.compilationResult, type, typeArguments, selector, sourceEnd);
9190 
9191 	consumeReferenceExpression(referenceExpression);
9192 }
consumeEnterInstanceCreationArgumentList()9193 protected void consumeEnterInstanceCreationArgumentList() {
9194 	return;
9195 }
consumeSimpleAssertStatement()9196 protected void consumeSimpleAssertStatement() {
9197 	// AssertStatement ::= 'assert' Expression ';'
9198 	this.expressionLengthPtr--;
9199 	pushOnAstStack(new AssertStatement(this.expressionStack[this.expressionPtr--], this.intStack[this.intPtr--]));
9200 }
consumeSingleMemberAnnotation(boolean isTypeAnnotation)9201 protected void consumeSingleMemberAnnotation(boolean isTypeAnnotation) {
9202 	// SingleMemberTypeAnnotation ::= TypeAnnotationName '(' SingleMemberAnnotationMemberValue ')'
9203 	// SingleMemberAnnotation ::= AnnotationName '(' SingleMemberAnnotationMemberValue ')'
9204 	SingleMemberAnnotation singleMemberAnnotation = null;
9205 
9206 	int oldIndex = this.identifierPtr;
9207 
9208 	TypeReference typeReference = getAnnotationType();
9209 	singleMemberAnnotation = new SingleMemberAnnotation(typeReference, this.intStack[this.intPtr--]);
9210 	singleMemberAnnotation.memberValue = this.expressionStack[this.expressionPtr--];
9211 	this.expressionLengthPtr--;
9212 	singleMemberAnnotation.declarationSourceEnd = this.rParenPos;
9213 
9214 	if (isTypeAnnotation) {
9215 		pushOnTypeAnnotationStack(singleMemberAnnotation);
9216 	} else {
9217 		pushOnExpressionStack(singleMemberAnnotation);
9218 	}
9219 
9220 	if(this.currentElement != null) {
9221 		annotationRecoveryCheckPoint(singleMemberAnnotation.sourceStart, singleMemberAnnotation.declarationSourceEnd);
9222 
9223 		if (this.currentElement instanceof RecoveredAnnotation) {
9224 			this.currentElement = ((RecoveredAnnotation)this.currentElement).addAnnotation(singleMemberAnnotation, oldIndex);
9225 		}
9226 	}
9227 
9228 	if(!this.statementRecoveryActivated &&
9229 			this.options.sourceLevel < ClassFileConstants.JDK1_5 &&
9230 			this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
9231 		problemReporter().invalidUsageOfAnnotation(singleMemberAnnotation);
9232 	}
9233 	this.recordStringLiterals = true;
9234 }
consumeSingleMemberAnnotationMemberValue()9235 protected void consumeSingleMemberAnnotationMemberValue() {
9236 	// this rule is used for syntax recovery only
9237 	if (this.currentElement != null && this.currentElement instanceof RecoveredAnnotation) {
9238 		RecoveredAnnotation recoveredAnnotation = (RecoveredAnnotation) this.currentElement;
9239 
9240 		recoveredAnnotation.setKind(RecoveredAnnotation.SINGLE_MEMBER);
9241 	}
9242 
9243 }
consumeSingleResource()9244 protected void consumeSingleResource() {
9245 	// Resources ::= Resource
9246 }
consumeSingleStaticImportDeclarationName()9247 protected void consumeSingleStaticImportDeclarationName() {
9248 	// SingleTypeImportDeclarationName ::= 'import' Name RejectTypeAnnotations
9249 	/* push an ImportRef build from the last name
9250 	stored in the identifier stack. */
9251 
9252 	ImportReference impt;
9253 	int length;
9254 	char[][] tokens = new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
9255 	this.identifierPtr -= length;
9256 	long[] positions = new long[length];
9257 	System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
9258 	System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
9259 	pushOnAstStack(impt = new ImportReference(tokens, positions, false, ClassFileConstants.AccStatic));
9260 
9261 	this.modifiers = ClassFileConstants.AccDefault;
9262 	this.modifiersSourceStart = -1; // <-- see comment into modifiersFlag(int)
9263 
9264 	if (this.currentToken == TokenNameSEMICOLON){
9265 		impt.declarationSourceEnd = this.scanner.currentPosition - 1;
9266 	} else {
9267 		impt.declarationSourceEnd = impt.sourceEnd;
9268 	}
9269 	impt.declarationEnd = impt.declarationSourceEnd;
9270 	//this.endPosition is just before the ;
9271 	impt.declarationSourceStart = this.intStack[this.intPtr--];
9272 
9273 	if(!this.statementRecoveryActivated &&
9274 			this.options.sourceLevel < ClassFileConstants.JDK1_5 &&
9275 			this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
9276 		impt.modifiers = ClassFileConstants.AccDefault; // convert the static import reference to a non-static importe reference
9277 		problemReporter().invalidUsageOfStaticImports(impt);
9278 	}
9279 
9280 	// recovery
9281 	if (this.currentElement != null){
9282 		this.lastCheckPoint = impt.declarationSourceEnd+1;
9283 		this.currentElement = this.currentElement.add(impt, 0);
9284 		this.lastIgnoredToken = -1;
9285 		this.restartRecovery = true; // used to avoid branching back into the regular automaton
9286 	}
9287 }
consumeSingleTypeImportDeclarationName()9288 protected void consumeSingleTypeImportDeclarationName() {
9289 	// SingleTypeImportDeclarationName ::= 'import' Name
9290 	/* push an ImportRef build from the last name
9291 	stored in the identifier stack. */
9292 
9293 	ImportReference impt;
9294 	int length;
9295 	char[][] tokens = new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
9296 	this.identifierPtr -= length;
9297 	long[] positions = new long[length];
9298 	System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
9299 	System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
9300 	pushOnAstStack(impt = new ImportReference(tokens, positions, false, ClassFileConstants.AccDefault));
9301 
9302 	if (this.currentToken == TokenNameSEMICOLON){
9303 		impt.declarationSourceEnd = this.scanner.currentPosition - 1;
9304 	} else {
9305 		impt.declarationSourceEnd = impt.sourceEnd;
9306 	}
9307 	impt.declarationEnd = impt.declarationSourceEnd;
9308 	//this.endPosition is just before the ;
9309 	impt.declarationSourceStart = this.intStack[this.intPtr--];
9310 
9311 	// recovery
9312 	if (this.currentElement != null){
9313 		this.lastCheckPoint = impt.declarationSourceEnd+1;
9314 		this.currentElement = this.currentElement.add(impt, 0);
9315 		this.lastIgnoredToken = -1;
9316 		this.restartRecovery = true; // used to avoid branching back into the regular automaton
9317 	}
9318 }
consumeStatementBreak()9319 protected void consumeStatementBreak() {
9320 	// BreakStatement ::= 'break' ';'
9321 	// break pushes a position on this.intStack in case there is no label
9322 
9323 	pushOnAstStack(new BreakStatement(null, this.intStack[this.intPtr--], this.endStatementPosition));
9324 
9325 	if (this.pendingRecoveredType != null) {
9326 		// Used only in statements recovery.
9327 		// This is not a real break statement but a placeholder for an existing local type.
9328 		// The break statement must be replace by the local type.
9329 		if (this.pendingRecoveredType.allocation == null &&
9330 				this.endPosition <= this.pendingRecoveredType.declarationSourceEnd) {
9331 			this.astStack[this.astPtr] = this.pendingRecoveredType;
9332 			this.pendingRecoveredType = null;
9333 			return;
9334 		}
9335 		this.pendingRecoveredType = null;
9336 	}
9337 }
consumeStatementBreakWithLabel()9338 protected void consumeStatementBreakWithLabel() {
9339 	// BreakStatement ::= 'break' Identifier ';'
9340 	// break pushs a position on this.intStack in case there is no label
9341 
9342 	pushOnAstStack(
9343 		new BreakStatement(
9344 			this.identifierStack[this.identifierPtr--],
9345 			this.intStack[this.intPtr--],
9346 			this.endStatementPosition));
9347 	this.identifierLengthPtr--;
9348 }
consumeStatementYield()9349 protected void consumeStatementYield() {
9350 	// YieldStatement ::= RestrictedIdentifierYield Expression ';'
9351 
9352 	// add the compliance check
9353 		if (this.expressionLengthStack[this.expressionLengthPtr--] != 0) {
9354 			Expression expr = this.expressionStack[this.expressionPtr--];
9355 			YieldStatement yieldStatement = new YieldStatement(
9356 					expr,
9357 					this.intStack[this.intPtr--],
9358 					this.endStatementPosition);
9359 			pushOnAstStack(yieldStatement);
9360 		}
9361 }
consumeStatementCatch()9362 protected void consumeStatementCatch() {
9363 	// CatchClause ::= 'catch' '(' FormalParameter ')'    Block
9364 
9365 	//catch are stored directly into the Try
9366 	//has they always comes two by two....
9367 	//we remove one entry from the astlengthPtr.
9368 	//The construction of the try statement must
9369 	//then fetch the catches using  2*i and 2*i + 1
9370 
9371 	this.astLengthPtr--;
9372 	this.listLength = 0; // reset formalParameter counter (incremented for catch variable)
9373 }
consumeStatementContinue()9374 protected void consumeStatementContinue() {
9375 	// ContinueStatement ::= 'continue' ';'
9376 	// continue pushs a position on this.intStack in case there is no label
9377 
9378 	pushOnAstStack(
9379 		new ContinueStatement(
9380 			null,
9381 			this.intStack[this.intPtr--],
9382 			this.endStatementPosition));
9383 }
consumeStatementContinueWithLabel()9384 protected void consumeStatementContinueWithLabel() {
9385 	// ContinueStatement ::= 'continue' Identifier ';'
9386 	// continue pushs a position on this.intStack in case there is no label
9387 
9388 	pushOnAstStack(
9389 		new ContinueStatement(
9390 			this.identifierStack[this.identifierPtr--],
9391 			this.intStack[this.intPtr--],
9392 			this.endStatementPosition));
9393 	this.identifierLengthPtr--;
9394 }
consumeStatementDo()9395 protected void consumeStatementDo() {
9396 	// DoStatement ::= 'do' Statement 'while' '(' Expression ')' ';'
9397 
9398 	//the 'while' pushes a value on this.intStack that we need to remove
9399 	this.intPtr--;
9400 
9401 	Statement statement = (Statement) this.astStack[this.astPtr];
9402 	this.expressionLengthPtr--;
9403 	this.astStack[this.astPtr] =
9404 		new DoStatement(
9405 			this.expressionStack[this.expressionPtr--],
9406 			statement,
9407 			this.intStack[this.intPtr--],
9408 			this.endStatementPosition);
9409 }
consumeStatementExpressionList()9410 protected void consumeStatementExpressionList() {
9411 	// StatementExpressionList ::= StatementExpressionList ',' StatementExpression
9412 	concatExpressionLists();
9413 }
consumeStatementFor()9414 protected void consumeStatementFor() {
9415 	// ForStatement ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' Statement
9416 	// ForStatementNoShortIf ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' StatementNoShortIf
9417 
9418 	int length;
9419 	Expression cond = null;
9420 	Statement[] inits, updates;
9421 	boolean scope = true;
9422 
9423 	//statements
9424 	this.astLengthPtr--;
9425 	Statement statement = (Statement) this.astStack[this.astPtr--];
9426 
9427 	//updates are on the expresion stack
9428 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) == 0) {
9429 		updates = null;
9430 	} else {
9431 		this.expressionPtr -= length;
9432 		System.arraycopy(
9433 			this.expressionStack,
9434 			this.expressionPtr + 1,
9435 			updates = new Statement[length],
9436 			0,
9437 			length);
9438 	}
9439 
9440 	if (this.expressionLengthStack[this.expressionLengthPtr--] != 0)
9441 		cond = this.expressionStack[this.expressionPtr--];
9442 
9443 	//inits may be on two different stacks
9444 	if ((length = this.astLengthStack[this.astLengthPtr--]) == 0) {
9445 		inits = null;
9446 		scope = false;
9447 	} else {
9448 		if (length == -1) { //on this.expressionStack
9449 			scope = false;
9450 			length = this.expressionLengthStack[this.expressionLengthPtr--];
9451 			this.expressionPtr -= length;
9452 			System.arraycopy(
9453 				this.expressionStack,
9454 				this.expressionPtr + 1,
9455 				inits = new Statement[length],
9456 				0,
9457 				length);
9458 		} else { //on this.astStack
9459 			this.astPtr -= length;
9460 			System.arraycopy(
9461 				this.astStack,
9462 				this.astPtr + 1,
9463 				inits = new Statement[length],
9464 				0,
9465 				length);
9466 		}
9467 	}
9468 	pushOnAstStack(
9469 		new ForStatement(
9470 			inits,
9471 			cond,
9472 			updates,
9473 			statement,
9474 			scope,
9475 			this.intStack[this.intPtr--],
9476 			this.endStatementPosition));
9477 }
consumeStatementIfNoElse()9478 protected void consumeStatementIfNoElse() {
9479 	// IfThenStatement ::=  'if' '(' Expression ')' Statement
9480 
9481 	//optimize the push/pop
9482 	this.expressionLengthPtr--;
9483 	Statement thenStatement = (Statement) this.astStack[this.astPtr];
9484 	this.astStack[this.astPtr] =
9485 		new IfStatement(
9486 			this.expressionStack[this.expressionPtr--],
9487 			thenStatement,
9488 			this.intStack[this.intPtr--],
9489 			this.endStatementPosition);
9490 }
consumeStatementIfWithElse()9491 protected void consumeStatementIfWithElse() {
9492 	// IfThenElseStatement ::=  'if' '(' Expression ')' StatementNoShortIf 'else' Statement
9493 	// IfThenElseStatementNoShortIf ::=  'if' '(' Expression ')' StatementNoShortIf 'else' StatementNoShortIf
9494 
9495 	this.expressionLengthPtr--;
9496 
9497 	// optimized {..., Then, Else } ==> {..., If }
9498 	this.astLengthPtr--;
9499 
9500 	//optimize the push/pop
9501 	this.astStack[--this.astPtr] =
9502 		new IfStatement(
9503 			this.expressionStack[this.expressionPtr--],
9504 			(Statement) this.astStack[this.astPtr],
9505 			(Statement) this.astStack[this.astPtr + 1],
9506 			this.intStack[this.intPtr--],
9507 			this.endStatementPosition);
9508 }
consumeStatementLabel()9509 protected void consumeStatementLabel() {
9510 	// LabeledStatement ::= 'Identifier' ':' Statement
9511 	// LabeledStatementNoShortIf ::= 'Identifier' ':' StatementNoShortIf
9512 
9513 	//optimize push/pop
9514 	Statement statement = (Statement) this.astStack[this.astPtr];
9515 	this.astStack[this.astPtr] =
9516 		new LabeledStatement(
9517 			this.identifierStack[this.identifierPtr],
9518 			statement,
9519 			this.identifierPositionStack[this.identifierPtr--],
9520 			this.endStatementPosition);
9521 	this.identifierLengthPtr--;
9522 }
consumeStatementReturn()9523 protected void consumeStatementReturn() {
9524 	// ReturnStatement ::= 'return' Expressionopt ';'
9525 	// return pushs a position on this.intStack in case there is no expression
9526 
9527 	if (this.expressionLengthStack[this.expressionLengthPtr--] != 0) {
9528 		pushOnAstStack(
9529 			new ReturnStatement(
9530 				this.expressionStack[this.expressionPtr--],
9531 				this.intStack[this.intPtr--],
9532 				this.endStatementPosition)
9533 		);
9534 	} else {
9535 		pushOnAstStack(new ReturnStatement(null, this.intStack[this.intPtr--], this.endStatementPosition));
9536 	}
9537 }
createSwitchStatementOrExpression(boolean isStmt)9538 private SwitchStatement createSwitchStatementOrExpression(boolean isStmt) {
9539 
9540 	//OpenBlock just makes the semantic action blockStart()
9541 	//the block is inlined but a scope need to be created
9542 	//if some declaration occurs.
9543 	this.nestedType--;
9544 	this.switchNestingLevel--;
9545 	this.scanner.breakPreviewAllowed = this.switchNestingLevel > 0;
9546 	int length;
9547 	SwitchStatement switchStatement = isStmt ? new SwitchStatement() : new SwitchExpression();
9548 	this.expressionLengthPtr--;
9549 	switchStatement.expression = this.expressionStack[this.expressionPtr--];
9550 	if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
9551 		this.astPtr -= length;
9552 		System.arraycopy(
9553 				this.astStack,
9554 				this.astPtr + 1,
9555 				switchStatement.statements = new Statement[length],
9556 				0,
9557 				length);
9558 	}
9559 	switchStatement.explicitDeclarations = this.realBlockStack[this.realBlockPtr--];
9560 	pushOnAstStack(switchStatement);
9561 	switchStatement.blockStart = this.intStack[this.intPtr--];
9562 	switchStatement.sourceStart = this.intStack[this.intPtr--];
9563 	switchStatement.sourceEnd = this.endStatementPosition;
9564 	if (length == 0 && !containsComment(switchStatement.blockStart, switchStatement.sourceEnd)) {
9565 		switchStatement.bits |= ASTNode.UndocumentedEmptyBlock;
9566 	}
9567 	return switchStatement;
9568 }
consumeStatementSwitch()9569 protected void consumeStatementSwitch() {
9570 	// SwitchStatement ::= 'switch' OpenBlock '(' Expression ')' SwitchBlock
9571 	createSwitchStatementOrExpression(true);
9572 }
consumeStatementSynchronized()9573 protected void consumeStatementSynchronized() {
9574 	// SynchronizedStatement ::= OnlySynchronized '(' Expression ')' Block
9575 	//optimize the push/pop
9576 
9577 	if (this.astLengthStack[this.astLengthPtr] == 0) {
9578 		this.astLengthStack[this.astLengthPtr] = 1;
9579 		this.expressionLengthPtr--;
9580 		this.astStack[++this.astPtr] =
9581 			new SynchronizedStatement(
9582 				this.expressionStack[this.expressionPtr--],
9583 				null,
9584 				this.intStack[this.intPtr--],
9585 				this.endStatementPosition);
9586 	} else {
9587 		this.expressionLengthPtr--;
9588 		this.astStack[this.astPtr] =
9589 			new SynchronizedStatement(
9590 				this.expressionStack[this.expressionPtr--],
9591 				(Block) this.astStack[this.astPtr],
9592 				this.intStack[this.intPtr--],
9593 				this.endStatementPosition);
9594 	}
9595 	this.modifiers = ClassFileConstants.AccDefault;
9596 	this.modifiersSourceStart = -1; // <-- see comment into modifiersFlag(int)
9597 }
consumeStatementThrow()9598 protected void consumeStatementThrow() {
9599 	// ThrowStatement ::= 'throw' Expression ';'
9600 	this.expressionLengthPtr--;
9601 	pushOnAstStack(new ThrowStatement(this.expressionStack[this.expressionPtr--], this.intStack[this.intPtr--], this.endStatementPosition));
9602 }
consumeStatementTry(boolean withFinally, boolean hasResources)9603 protected void consumeStatementTry(boolean withFinally, boolean hasResources) {
9604 	// TryStatement ::= 'try'  Block Catches
9605 	// TryStatement ::= 'try'  Block Catchesopt Finally
9606 	// TryStatementWithResources ::= 'try' ResourceSpecification TryBlock Catchesopt
9607 	// TryStatementWithResources ::= 'try' ResourceSpecification TryBlock Catchesopt Finally
9608 
9609 	int length;
9610 	TryStatement tryStmt = new TryStatement();
9611 	//finally
9612 	if (withFinally) {
9613 		this.astLengthPtr--;
9614 		tryStmt.finallyBlock = (Block) this.astStack[this.astPtr--];
9615 	}
9616 	//catches are handle by two <argument-block> [see statementCatch]
9617 	if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
9618 		if (length == 1) {
9619 			tryStmt.catchBlocks = new Block[] {(Block) this.astStack[this.astPtr--]};
9620 			tryStmt.catchArguments = new Argument[] {(Argument) this.astStack[this.astPtr--]};
9621 		} else {
9622 			Block[] bks = (tryStmt.catchBlocks = new Block[length]);
9623 			Argument[] args = (tryStmt.catchArguments = new Argument[length]);
9624 			while (length-- > 0) {
9625 				bks[length] = (Block) this.astStack[this.astPtr--];
9626 				args[length] = (Argument) this.astStack[this.astPtr--];
9627 			}
9628 		}
9629 	}
9630 	//try
9631 	this.astLengthPtr--;
9632 	tryStmt.tryBlock = (Block) this.astStack[this.astPtr--];
9633 
9634 	if (hasResources) {
9635 		// get the resources
9636 		length = this.astLengthStack[this.astLengthPtr--];
9637 		Statement[] stmts  = new Statement[length];
9638 		System.arraycopy(
9639 		this.astStack,
9640 		(this.astPtr -= length) + 1,
9641 		stmts,
9642 		0,
9643 		length);
9644 
9645 		tryStmt.resources = stmts;
9646 
9647 		if (this.options.sourceLevel < ClassFileConstants.JDK1_7) {
9648 			problemReporter().autoManagedResourcesNotBelow17(stmts);
9649 		}
9650 		if (this.options.sourceLevel < ClassFileConstants.JDK9) {
9651 			for (int i = 0, l = stmts.length; i < l; ++i) {
9652 				Statement stmt = stmts[i];
9653 				if (stmt instanceof FieldReference || stmt instanceof NameReference) {
9654 					problemReporter().autoManagedVariableResourcesNotBelow9((Expression) stmt);
9655 				}
9656 			}
9657 		}
9658 	}
9659 	//positions
9660 	tryStmt.sourceEnd = this.endStatementPosition;
9661 	tryStmt.sourceStart = this.intStack[this.intPtr--];
9662 	pushOnAstStack(tryStmt);
9663 }
consumeStatementWhile()9664 protected void consumeStatementWhile() {
9665 	// WhileStatement ::= 'while' '(' Expression ')' Statement
9666 	// WhileStatementNoShortIf ::= 'while' '(' Expression ')' StatementNoShortIf
9667 
9668 	this.expressionLengthPtr--;
9669 	Statement statement = (Statement) this.astStack[this.astPtr];
9670 	this.astStack[this.astPtr] =
9671 		new WhileStatement(
9672 			this.expressionStack[this.expressionPtr--],
9673 			statement,
9674 			this.intStack[this.intPtr--],
9675 			this.endStatementPosition);
9676 }
consumeStaticImportOnDemandDeclarationName()9677 protected void consumeStaticImportOnDemandDeclarationName() {
9678 	// StaticImportOnDemandDeclarationName ::= 'import' 'static' Name '.' RejectTypeAnnotations '*'
9679 	/* push an ImportRef build from the last name
9680 	stored in the identifier stack. */
9681 
9682 	ImportReference impt;
9683 	int length;
9684 	char[][] tokens = new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
9685 	this.identifierPtr -= length;
9686 	long[] positions = new long[length];
9687 	System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
9688 	System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
9689 	pushOnAstStack(impt = new ImportReference(tokens, positions, true, ClassFileConstants.AccStatic));
9690 
9691 	// star end position
9692 	impt.trailingStarPosition = this.intStack[this.intPtr--];
9693 	this.modifiers = ClassFileConstants.AccDefault;
9694 	this.modifiersSourceStart = -1; // <-- see comment into modifiersFlag(int)
9695 
9696 	if (this.currentToken == TokenNameSEMICOLON){
9697 		impt.declarationSourceEnd = this.scanner.currentPosition - 1;
9698 	} else {
9699 		impt.declarationSourceEnd = impt.sourceEnd;
9700 	}
9701 	impt.declarationEnd = impt.declarationSourceEnd;
9702 	//this.endPosition is just before the ;
9703 	impt.declarationSourceStart = this.intStack[this.intPtr--];
9704 
9705 	if(!this.statementRecoveryActivated &&
9706 			this.options.sourceLevel < ClassFileConstants.JDK1_5 &&
9707 			this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
9708 		impt.modifiers = ClassFileConstants.AccDefault; // convert the static import reference to a non-static importe reference
9709 		problemReporter().invalidUsageOfStaticImports(impt);
9710 	}
9711 
9712 	// recovery
9713 	if (this.currentElement != null){
9714 		this.lastCheckPoint = impt.declarationSourceEnd+1;
9715 		this.currentElement = this.currentElement.add(impt, 0);
9716 		this.lastIgnoredToken = -1;
9717 		this.restartRecovery = true; // used to avoid branching back into the regular automaton
9718 	}
9719 }
consumeStaticInitializer()9720 protected void consumeStaticInitializer() {
9721 	// StaticInitializer ::=  StaticOnly Block
9722 	//push an Initializer
9723 	//optimize the push/pop
9724 	Block block = (Block) this.astStack[this.astPtr];
9725 	if (this.diet) block.bits &= ~ASTNode.UndocumentedEmptyBlock; // clear bit set since was diet
9726 	Initializer initializer = new Initializer(block, ClassFileConstants.AccStatic);
9727 	this.astStack[this.astPtr] = initializer;
9728 	initializer.sourceEnd = this.endStatementPosition;
9729 	initializer.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
9730 	this.nestedMethod[this.nestedType] --;
9731 	initializer.declarationSourceStart = this.intStack[this.intPtr--];
9732 	initializer.bodyStart = this.intStack[this.intPtr--];
9733 	initializer.bodyEnd = this.endPosition;
9734 	// doc comment
9735 	initializer.javadoc = this.javadoc;
9736 	this.javadoc = null;
9737 
9738 	// recovery
9739 	if (this.currentElement != null){
9740 		this.lastCheckPoint = initializer.declarationSourceEnd;
9741 		this.currentElement = this.currentElement.add(initializer, 0);
9742 		this.lastIgnoredToken = -1;
9743 	}
9744 }
consumeStaticOnly()9745 protected void consumeStaticOnly() {
9746 	// StaticOnly ::= 'static'
9747 	int savedModifiersSourceStart = this.modifiersSourceStart;
9748 	checkComment(); // might update declaration source start
9749 	if (this.modifiersSourceStart >= savedModifiersSourceStart) {
9750 		this.modifiersSourceStart = savedModifiersSourceStart;
9751 	}
9752 	pushOnIntStack(this.scanner.currentPosition);
9753 	pushOnIntStack(
9754 		this.modifiersSourceStart >= 0 ? this.modifiersSourceStart : this.scanner.startPosition);
9755 	jumpOverMethodBody();
9756 	this.nestedMethod[this.nestedType]++;
9757 	resetModifiers();
9758 	this.expressionLengthPtr--; // remove the 0 pushed in consumeToken() for the static modifier
9759 
9760 	// recovery
9761 	if (this.currentElement != null){
9762 		this.recoveredStaticInitializerStart = this.intStack[this.intPtr]; // remember start position only for static initializers
9763 	}
9764 }
consumeTextBlock()9765 protected void consumeTextBlock() {
9766 	if (!this.parsingJava14Plus) {
9767 		problemReporter().previewFeatureNotSupported(this.scanner.startPosition, this.scanner.currentPosition - 1, "Text Blocks", CompilerOptions.VERSION_14); //$NON-NLS-1$
9768 	} else if (!this.options.enablePreviewFeatures){
9769 		problemReporter().previewFeatureNotEnabled(this.scanner.startPosition, this.scanner.currentPosition - 1, "Text Blocks"); //$NON-NLS-1$
9770 	} else {
9771 		if (this.options.isAnyEnabled(IrritantSet.PREVIEW)) {
9772 			problemReporter().previewFeatureUsed(this.scanner.startPosition, this.scanner.currentPosition - 1);
9773 		}
9774 	}
9775 	char[] textBlock2 = this.scanner.getCurrentTextBlock();
9776 	TextBlock textBlock;
9777 	if (this.recordStringLiterals &&
9778 			!this.reparsingLambdaExpression &&
9779 			this.checkExternalizeStrings &&
9780 			this.lastPosistion < this.scanner.currentPosition &&
9781 			!this.statementRecoveryActivated) {
9782 		textBlock =
9783 				new TextBlock(
9784 						textBlock2,
9785 						this.scanner.startPosition,
9786 						this.scanner.currentPosition - 1,
9787 						Util.getLineNumber(this.scanner.startPosition, this.scanner.lineEnds, 0, this.scanner.linePtr));
9788 		// TODO
9789 		//this.compilationUnit.recordStringLiteral(stringLiteral, this.currentElement != null);
9790 	} else {
9791 		textBlock = new TextBlock(
9792 				textBlock2,
9793 			this.scanner.startPosition,
9794 			this.scanner.currentPosition - 1,
9795 			0);
9796 	}
9797 	pushOnExpressionStack(textBlock);
9798 	// Regardless of the error reported above, we have to push the ast node accordingly
9799 }
consumeSwitchBlock()9800 protected void consumeSwitchBlock() {
9801 	// SwitchBlock ::= '{' SwitchBlockStatements SwitchLabels '}'
9802 	concatNodeLists();
9803 
9804 }
consumeSwitchBlockStatement()9805 protected void consumeSwitchBlockStatement() {
9806 	// SwitchBlockStatement ::= SwitchLabels BlockStatements
9807 	concatNodeLists();
9808 }
consumeSwitchBlockStatements()9809 protected void consumeSwitchBlockStatements() {
9810 	// SwitchBlockStatements ::= SwitchBlockStatements SwitchBlockStatement
9811 	concatNodeLists();
9812 }
consumeSwitchLabels()9813 protected void consumeSwitchLabels() {
9814 	// SwitchLabels ::= SwitchLabels SwitchLabel
9815 	optimizedConcatNodeLists();
9816 }
consumeSwitchLabelCaseLhs()9817 protected void consumeSwitchLabelCaseLhs() {
9818 	if (this.scanner.lookBack[1] == TerminalTokens.TokenNameCOLON) // kludge for yield :(
9819 		this.scanner.yieldColons = 1;
9820 }
consumeCaseLabelExpr()9821 protected void consumeCaseLabelExpr() {
9822 //	SwitchLabelExpr ::= SwitchLabelCaseLhs BeginCaseExpr '->'
9823 	consumeCaseLabel();
9824 	CaseStatement caseStatement = (CaseStatement) this.astStack[this.astPtr];
9825 	if (!this.parsingJava14Plus) {
9826 		problemReporter().arrowInCaseStatementsNotSupported(caseStatement);
9827 	}
9828 	caseStatement.isExpr = true;
9829 }
consumeDefaultLabelExpr()9830 protected void consumeDefaultLabelExpr() {
9831 //	SwitchLabelDefaultExpr ::= 'default' '->'
9832 	consumeDefaultLabel();
9833 	CaseStatement defaultStatement = (CaseStatement) this.astStack[this.astPtr];
9834 	if (!this.parsingJava14Plus) {
9835 		problemReporter().arrowInCaseStatementsNotSupported(defaultStatement);
9836 	}
9837 	defaultStatement.isExpr = true;
9838 }
collectResultExpressionsYield(SwitchExpression s)9839 /* package */ void collectResultExpressionsYield(SwitchExpression s) {
9840 	if (s.resultExpressions != null)
9841 		return; // already calculated.
9842 
9843 	class ResultExpressionsCollector extends ASTVisitor {
9844 		Stack<SwitchExpression> targetSwitchExpressions;
9845 		Stack<TryStatement> tryStatements;
9846 		public ResultExpressionsCollector(SwitchExpression se) {
9847 			if (this.targetSwitchExpressions == null)
9848 				this.targetSwitchExpressions = new Stack<>();
9849 			this.targetSwitchExpressions.push(se);
9850 		}
9851 		@Override
9852 		public boolean visit(SwitchExpression switchExpression, BlockScope blockScope) {
9853 			if (switchExpression.resultExpressions == null)
9854 				switchExpression.resultExpressions = new ArrayList<>(0);
9855 			this.targetSwitchExpressions.push(switchExpression);
9856 			return false;
9857 		}
9858 		@Override
9859 		public void endVisit(SwitchExpression switchExpression,	BlockScope blockScope) {
9860 			this.targetSwitchExpressions.pop();
9861 		}
9862 		@Override
9863 		public boolean visit(YieldStatement yieldStatement, BlockScope blockScope) {
9864 			SwitchExpression targetSwitchExpression = this.targetSwitchExpressions.peek();
9865 			if (yieldStatement.expression != null) {
9866 				targetSwitchExpression.resultExpressions.add(yieldStatement.expression);
9867 				yieldStatement.switchExpression = this.targetSwitchExpressions.peek();
9868 			} else {
9869 				// flag an error while resolving
9870 				yieldStatement.switchExpression = targetSwitchExpression;
9871 			}
9872 			if (this.tryStatements != null && !this.tryStatements.empty())
9873 				yieldStatement.tryStatement = this.tryStatements.peek();
9874 			return true;
9875 		}
9876 		@Override
9877 		public boolean visit(SwitchStatement stmt, BlockScope blockScope) {
9878 			return true;
9879 		}
9880 		@Override
9881 		public boolean visit(TypeDeclaration stmt, BlockScope blockScope) {
9882 			return false;
9883 		}
9884 		@Override
9885 		public boolean visit(LambdaExpression stmt, BlockScope blockScope) {
9886 			return false;
9887 		}
9888 		@Override
9889 		public boolean visit(TryStatement stmt, BlockScope blockScope) {
9890 			if (this.tryStatements == null)
9891 				this.tryStatements = new Stack<>();
9892 			this.tryStatements.push(stmt);
9893 			SwitchExpression targetSwitchExpression = this.targetSwitchExpressions.peek();
9894 			targetSwitchExpression.containsTry = true;
9895 			stmt.enclosingSwitchExpression = targetSwitchExpression;
9896 			return true;
9897 		}
9898 		@Override
9899 		public void endVisit(TryStatement stmt, BlockScope blockScope) {
9900 			this.tryStatements.pop();
9901 		}
9902 	}
9903 	s.resultExpressions = new ArrayList<>(0); // indicates processed
9904 	int l = s.statements == null ? 0 : s.statements.length;
9905 	for (int i = 0; i < l; ++i) {
9906 		Statement stmt = s.statements[i];
9907 		if (stmt instanceof CaseStatement) {
9908 			CaseStatement caseStatement = (CaseStatement) stmt;
9909 			if (!caseStatement.isExpr) continue;
9910 			stmt = s.statements[++i];
9911 			if (stmt instanceof Expression && ((Expression) stmt).isTrulyExpression()) {
9912 				s.resultExpressions.add((Expression) stmt);
9913 				continue;
9914 			} else if (stmt instanceof ThrowStatement) {
9915 				// TODO: Throw Expression Processing. Anything to be done here for resolve?
9916 				continue;
9917 			}
9918 		}
9919 		// break statement and block statement of SwitchLabelRule or block statement of ':'
9920 		ResultExpressionsCollector reCollector = new ResultExpressionsCollector(s);
9921 		stmt.traverse(reCollector, null);
9922 	}
9923 }
consumeSwitchExpression()9924 protected void consumeSwitchExpression() {
9925 // SwitchExpression ::= 'switch' '(' Expression ')' OpenBlock SwitchExpressionBlock
9926 	createSwitchStatementOrExpression(false);
9927 	if (this.astLengthStack[this.astLengthPtr--] != 0) {
9928 		SwitchExpression s = (SwitchExpression) this.astStack[this.astPtr--];
9929 
9930 		if (!this.parsingJava14Plus) {
9931 			problemReporter().switchExpressionsNotSupported(s);
9932 		}
9933 		collectResultExpressionsYield(s);
9934 		this.switchWithTry |= s.containsTry;
9935 		pushOnExpressionStack(s);
9936 	}
9937 }
consumeSwitchExprThrowDefaultArm()9938 protected void consumeSwitchExprThrowDefaultArm() {
9939 //	SwitchExprThrowDefaultArm ::= SwitchLabelDefaultExpr Expression ';'
9940 	consumeStatementThrow();
9941 //	pushSwitchLabeledRule(SwitchLabeledRule.RULE_KIND.DEFAULT_THROW);
9942 }
consumeConstantExpression()9943 protected void consumeConstantExpression() {
9944 	// do nothing for now.
9945 }
consumeConstantExpressions()9946 protected void consumeConstantExpressions() {
9947 	concatExpressionLists();
9948 }
consumeSwitchLabeledRules()9949 protected void consumeSwitchLabeledRules() {
9950 	concatNodeLists();
9951 }
consumeSwitchLabeledRule()9952 protected void consumeSwitchLabeledRule() {
9953 //	SwitchLabeledRule ::= SwitchLabeledExpression
9954 //	SwitchLabeledRule ::= SwitchLabeledBlock
9955 //	SwitchLabeledRule ::= SwitchLabeledThrowStatement
9956 //	concatNodeLists();
9957 
9958 	// do nothing explicit here
9959 }
consumeSwitchLabeledRuleToBlockStatement()9960 protected void consumeSwitchLabeledRuleToBlockStatement() {
9961 	// do nothing
9962 }
consumeSwitchLabeledExpression()9963 protected void consumeSwitchLabeledExpression() {
9964 	consumeExpressionStatement();
9965 	Expression expr = (Expression) this.astStack[this.astPtr];
9966 	YieldStatement yieldStatement = new YieldStatement(
9967 			expr,
9968 			expr.sourceStart,
9969 			this.endStatementPosition);
9970 	yieldStatement.isImplicit = true;
9971 	this.astStack[this.astPtr] = yieldStatement;
9972 	concatNodeLists();
9973 }
consumeSwitchLabeledBlock()9974 protected void consumeSwitchLabeledBlock() {
9975 	concatNodeLists();
9976 }
consumeSwitchLabeledThrowStatement()9977 protected void consumeSwitchLabeledThrowStatement() {
9978 	// TODO: Semicolon not there - so we call this early
9979 	consumeStatementThrow();
9980 	concatNodeLists();
9981 }
consumeThrowExpression()9982 protected void consumeThrowExpression() {
9983 	// do nothing
9984 }
9985 protected boolean caseFlagSet = false;
consumeToken(int type)9986 protected void consumeToken(int type) {
9987 	/* remember the last consumed value */
9988 	/* try to minimize the number of build values */
9989 //	// clear the commentPtr of the scanner in case we read something different from a modifier
9990 //	switch(type) {
9991 //		case TokenNameabstract :
9992 //		case TokenNamestrictfp :
9993 //		case TokenNamefinal :
9994 //		case TokenNamenative :
9995 //		case TokenNameprivate :
9996 //		case TokenNameprotected :
9997 //		case TokenNamepublic :
9998 //		case TokenNametransient :
9999 //		case TokenNamevolatile :
10000 //		case TokenNamestatic :
10001 //		case TokenNamesynchronized :
10002 //			break;
10003 //		default:
10004 //			this.scanner.commentPtr = -1;
10005 //	}
10006 	//System.out.println(this.scanner.toStringAction(type));
10007 	switch (type) {
10008 		case TokenNameARROW:
10009 			if (!this.caseFlagSet && this.scanner.lookBack[0] != TokenNamedefault)
10010 				consumeLambdaHeader();
10011 			this.caseFlagSet = false;
10012 			break;
10013 		case TokenNameCOLON_COLON:
10014 			this.colonColonStart = this.scanner.currentPosition - 2;
10015 			break;
10016 		case TokenNameBeginCaseExpr:
10017 			this.caseFlagSet = true;
10018 			break;
10019 		case TokenNameBeginLambda:
10020 			flushCommentsDefinedPriorTo(this.scanner.currentPosition);
10021 			break;
10022 		case TokenNameIdentifier :
10023 			pushIdentifier();
10024 			if (this.scanner.useAssertAsAnIndentifier  &&
10025 					this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
10026 				long positions = this.identifierPositionStack[this.identifierPtr];
10027 				if(!this.statementRecoveryActivated) problemReporter().useAssertAsAnIdentifier((int) (positions >>> 32), (int) positions);
10028 			}
10029 			if (this.scanner.useEnumAsAnIndentifier  &&
10030 					this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
10031 				long positions = this.identifierPositionStack[this.identifierPtr];
10032 				if(!this.statementRecoveryActivated) problemReporter().useEnumAsAnIdentifier((int) (positions >>> 32), (int) positions);
10033 			}
10034 			break;
10035 		case TokenNameinterface :
10036 			//'class' is pushing two int (positions) on the stack ==> 'interface' needs to do it too....
10037 			pushOnIntStack(this.scanner.currentPosition - 1);
10038 			pushOnIntStack(this.scanner.startPosition);
10039 			break;
10040 		case TokenNameabstract :
10041 			checkAndSetModifiers(ClassFileConstants.AccAbstract);
10042 			pushOnExpressionStackLengthStack(0);
10043 			break;
10044 		case TokenNamestrictfp :
10045 			checkAndSetModifiers(ClassFileConstants.AccStrictfp);
10046 			pushOnExpressionStackLengthStack(0);
10047 			break;
10048 		case TokenNamefinal :
10049 			checkAndSetModifiers(ClassFileConstants.AccFinal);
10050 			pushOnExpressionStackLengthStack(0);
10051 			break;
10052 		case TokenNamenative :
10053 			checkAndSetModifiers(ClassFileConstants.AccNative);
10054 			pushOnExpressionStackLengthStack(0);
10055 			break;
10056 		case TokenNameopen :
10057 			checkAndSetModifiers(ClassFileConstants.ACC_OPEN);
10058 			pushOnExpressionStackLengthStack(0);
10059 			break;
10060 		case TokenNameprivate :
10061 			checkAndSetModifiers(ClassFileConstants.AccPrivate);
10062 			pushOnExpressionStackLengthStack(0);
10063 			break;
10064 		case TokenNameprotected :
10065 			checkAndSetModifiers(ClassFileConstants.AccProtected);
10066 			pushOnExpressionStackLengthStack(0);
10067 			break;
10068 		case TokenNamepublic :
10069 			checkAndSetModifiers(ClassFileConstants.AccPublic);
10070 			pushOnExpressionStackLengthStack(0);
10071 			break;
10072 		case TokenNametransient :
10073 			checkAndSetModifiers(ClassFileConstants.AccTransient);
10074 			pushOnExpressionStackLengthStack(0);
10075 			break;
10076 		case TokenNametransitive :
10077 			checkAndSetModifiers(ClassFileConstants.ACC_TRANSITIVE);
10078 			pushOnExpressionStackLengthStack(0);
10079 			break;
10080 		case TokenNamevolatile :
10081 			checkAndSetModifiers(ClassFileConstants.AccVolatile);
10082 			pushOnExpressionStackLengthStack(0);
10083 			break;
10084 		case TokenNamestatic :
10085 			if (isParsingModuleDeclaration())
10086 				checkAndSetModifiers(ClassFileConstants.ACC_STATIC_PHASE);
10087 			else
10088 				checkAndSetModifiers(ClassFileConstants.AccStatic);
10089 			pushOnExpressionStackLengthStack(0);
10090 			break;
10091 		case TokenNamesynchronized :
10092 			this.synchronizedBlockSourceStart = this.scanner.startPosition;
10093 			checkAndSetModifiers(ClassFileConstants.AccSynchronized);
10094 			pushOnExpressionStackLengthStack(0);
10095 			break;
10096 			//==============================
10097 		case TokenNamevoid :
10098 			pushIdentifier(-T_void);
10099 			pushOnIntStack(this.scanner.currentPosition - 1);
10100 			pushOnIntStack(this.scanner.startPosition);
10101 			break;
10102 			//push a default dimension while void is not part of the primitive
10103 			//declaration baseType and so takes the place of a type without getting into
10104 			//regular type parsing that generates a dimension on this.intStack
10105 		case TokenNameboolean :
10106 			pushIdentifier(-T_boolean);
10107 			pushOnIntStack(this.scanner.currentPosition - 1);
10108 			pushOnIntStack(this.scanner.startPosition);
10109 			break;
10110 		case TokenNamebyte :
10111 			pushIdentifier(-T_byte);
10112 			pushOnIntStack(this.scanner.currentPosition - 1);
10113 			pushOnIntStack(this.scanner.startPosition);
10114 			break;
10115 		case TokenNamechar :
10116 			pushIdentifier(-T_char);
10117 			pushOnIntStack(this.scanner.currentPosition - 1);
10118 			pushOnIntStack(this.scanner.startPosition);
10119 			break;
10120 		case TokenNamedouble :
10121 			pushIdentifier(-T_double);
10122 			pushOnIntStack(this.scanner.currentPosition - 1);
10123 			pushOnIntStack(this.scanner.startPosition);
10124 			break;
10125 		case TokenNamefloat :
10126 			pushIdentifier(-T_float);
10127 			pushOnIntStack(this.scanner.currentPosition - 1);
10128 			pushOnIntStack(this.scanner.startPosition);
10129 			break;
10130 		case TokenNameint :
10131 			pushIdentifier(-T_int);
10132 			pushOnIntStack(this.scanner.currentPosition - 1);
10133 			pushOnIntStack(this.scanner.startPosition);
10134 			break;
10135 		case TokenNamelong :
10136 			pushIdentifier(-T_long);
10137 			pushOnIntStack(this.scanner.currentPosition - 1);
10138 			pushOnIntStack(this.scanner.startPosition);
10139 			break;
10140 		case TokenNameshort :
10141 			pushIdentifier(-T_short);
10142 			pushOnIntStack(this.scanner.currentPosition - 1);
10143 			pushOnIntStack(this.scanner.startPosition);
10144 			break;
10145 			//==============================
10146 		case TokenNameIntegerLiteral :
10147 			pushOnExpressionStack(
10148 				IntLiteral.buildIntLiteral(
10149 					this.scanner.getCurrentTokenSource(),
10150 					this.scanner.startPosition,
10151 					this.scanner.currentPosition - 1));
10152 			break;
10153 		case TokenNameLongLiteral :
10154 			pushOnExpressionStack(
10155 				LongLiteral.buildLongLiteral(
10156 					this.scanner.getCurrentTokenSource(),
10157 					this.scanner.startPosition,
10158 					this.scanner.currentPosition - 1));
10159 			break;
10160 		case TokenNameFloatingPointLiteral :
10161 			pushOnExpressionStack(
10162 				new FloatLiteral(
10163 					this.scanner.getCurrentTokenSource(),
10164 					this.scanner.startPosition,
10165 					this.scanner.currentPosition - 1));
10166 			break;
10167 		case TokenNameDoubleLiteral :
10168 			pushOnExpressionStack(
10169 				new DoubleLiteral(
10170 					this.scanner.getCurrentTokenSource(),
10171 					this.scanner.startPosition,
10172 					this.scanner.currentPosition - 1));
10173 			break;
10174 		case TokenNameCharacterLiteral :
10175 			pushOnExpressionStack(
10176 				new CharLiteral(
10177 					this.scanner.getCurrentTokenSource(),
10178 					this.scanner.startPosition,
10179 					this.scanner.currentPosition - 1));
10180 			break;
10181 		case TokenNameStringLiteral :
10182 			StringLiteral stringLiteral;
10183 			if (this.recordStringLiterals &&
10184 					!this.reparsingLambdaExpression &&
10185 					this.checkExternalizeStrings &&
10186 					this.lastPosistion < this.scanner.currentPosition &&
10187 					!this.statementRecoveryActivated) {
10188 				stringLiteral = createStringLiteral(
10189 					this.scanner.getCurrentTokenSourceString(),
10190 					this.scanner.startPosition,
10191 					this.scanner.currentPosition - 1,
10192 					Util.getLineNumber(this.scanner.startPosition, this.scanner.lineEnds, 0, this.scanner.linePtr));
10193 				this.compilationUnit.recordStringLiteral(stringLiteral, this.currentElement != null);
10194 			} else {
10195 				stringLiteral = createStringLiteral(
10196 					this.scanner.getCurrentTokenSourceString(),
10197 					this.scanner.startPosition,
10198 					this.scanner.currentPosition - 1,
10199 					0);
10200 			}
10201 			pushOnExpressionStack(stringLiteral);
10202 			break;
10203 		case TokenNameTextBlock :
10204 			consumeTextBlock();
10205 			break;
10206 		case TokenNamefalse :
10207 			pushOnExpressionStack(
10208 				new FalseLiteral(this.scanner.startPosition, this.scanner.currentPosition - 1));
10209 			break;
10210 		case TokenNametrue :
10211 			pushOnExpressionStack(
10212 				new TrueLiteral(this.scanner.startPosition, this.scanner.currentPosition - 1));
10213 			break;
10214 		case TokenNamenull :
10215 			pushOnExpressionStack(
10216 				new NullLiteral(this.scanner.startPosition, this.scanner.currentPosition - 1));
10217 			break;
10218 			//============================
10219 		case TokenNamesuper :
10220 		case TokenNamethis :
10221 			this.endPosition = this.scanner.currentPosition - 1;
10222 			pushOnIntStack(this.scanner.startPosition);
10223 			break;
10224 		case TokenNamefor :
10225 			this.forStartPosition = this.scanner.startPosition;
10226 			//$FALL-THROUGH$
10227 		case TokenNameassert :
10228 		case TokenNameimport :
10229 		case TokenNamepackage :
10230 		case TokenNamethrow :
10231 		case TokenNamedo :
10232 		case TokenNameif :
10233 		case TokenNametry :
10234 		case TokenNamewhile :
10235 		case TokenNamebreak :
10236 		case TokenNamecontinue :
10237 		case TokenNamereturn :
10238 		case TokenNamecase :
10239 		case TokenNamemodule:
10240 		case TokenNamerequires:
10241 		case TokenNameexports:
10242 		case TokenNameopens:
10243 		case TokenNameuses:
10244 		case TokenNameprovides:
10245 		case TokenNameRestrictedIdentifierYield:
10246 			pushOnIntStack(this.scanner.startPosition);
10247 			break;
10248 		case TokenNameswitch :
10249 			consumeNestedType();
10250 			++this.switchNestingLevel;
10251 			this.nestedMethod[this.nestedType] ++;
10252 			pushOnIntStack(this.scanner.startPosition);
10253 			break;
10254 		case TokenNamenew :
10255 			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=40954
10256 			resetModifiers();
10257 			pushOnIntStack(this.scanner.startPosition);
10258 			break;
10259 		case TokenNameRestrictedIdentifierrecord:
10260 		case TokenNameclass :
10261 			pushOnIntStack(this.scanner.currentPosition - 1);
10262 			pushOnIntStack(this.scanner.startPosition);
10263 			break;
10264 		case TokenNameenum :
10265 			pushOnIntStack(this.scanner.currentPosition - 1);
10266 			pushOnIntStack(this.scanner.startPosition);
10267 			break;
10268 		case TokenNamedefault :
10269 			pushOnIntStack(this.scanner.startPosition);
10270 			pushOnIntStack(this.scanner.currentPosition - 1);
10271 			break;
10272 			//let extra semantic action decide when to push
10273 		case TokenNameRBRACKET :
10274 			this.rBracketPosition = this.scanner.startPosition;
10275 			this.endPosition = this.scanner.startPosition;
10276 			this.endStatementPosition = this.scanner.currentPosition - 1;
10277 			break;
10278 		case TokenNameLBRACE :
10279 			this.endStatementPosition = this.scanner.currentPosition - 1;
10280 			//$FALL-THROUGH$
10281 		case TokenNamePLUS :
10282 		case TokenNameMINUS :
10283 		case TokenNameNOT :
10284 		case TokenNameTWIDDLE :
10285 			this.endPosition = this.scanner.startPosition;
10286 			break;
10287 		case TokenNamePLUS_PLUS :
10288 		case TokenNameMINUS_MINUS :
10289 			this.endPosition = this.scanner.startPosition;
10290 			this.endStatementPosition = this.scanner.currentPosition - 1;
10291 			break;
10292 		case TokenNameRBRACE:
10293 		case TokenNameSEMICOLON :
10294 			this.endStatementPosition = this.scanner.currentPosition - 1;
10295 			this.endPosition = this.scanner.startPosition - 1;
10296 			//the item is not part of the potential futur expression/statement
10297 			break;
10298 		case TokenNameRPAREN :
10299 			// in order to handle ( expression) ////// (cast)expression///// foo(x)
10300 			this.rParenPos = this.scanner.currentPosition - 1; // position of the end of right parenthesis (in case of unicode \u0029) lex00101
10301 			break;
10302 		case TokenNameLPAREN :
10303 			this.lParenPos = this.scanner.startPosition;
10304 			break;
10305 		case TokenNameAT308:
10306 			this.expectTypeAnnotation = true;
10307 			pushOnIntStack(this.dimensions); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=417660: Stack the dimensions, they get unstacked in consumeTypeAnnotation.
10308 			this.dimensions = 0;
10309 			//$FALL-THROUGH$
10310 		case TokenNameAT :
10311 			pushOnIntStack(this.scanner.startPosition);
10312 			break;
10313 		case TokenNameQUESTION  :
10314 			pushOnIntStack(this.scanner.startPosition);
10315 			pushOnIntStack(this.scanner.currentPosition - 1);
10316 			break;
10317 		case TokenNameLESS :
10318 			pushOnIntStack(this.scanner.startPosition);
10319 			break;
10320 		case TokenNameELLIPSIS :
10321 			pushOnIntStack(this.scanner.currentPosition - 1);
10322 			break;
10323 		case TokenNameEQUAL  :
10324 			if (this.currentElement != null && this.currentElement instanceof RecoveredAnnotation) {
10325 				RecoveredAnnotation recoveredAnnotation = (RecoveredAnnotation) this.currentElement;
10326 				if (recoveredAnnotation.memberValuPairEqualEnd == -1) {
10327 					recoveredAnnotation.memberValuPairEqualEnd = this.scanner.currentPosition - 1;
10328 				}
10329 			}
10330 			break;
10331 		case TokenNameMULTIPLY :
10332 			// star end position
10333 			pushOnIntStack(this.scanner.currentPosition - 1);
10334 			break;
10335 			//  case TokenNameCOMMA :
10336 			//  case TokenNameCOLON  :
10337 			//  case TokenNameLBRACKET  :
10338 			//  case TokenNameDOT :
10339 			//  case TokenNameERROR :
10340 			//  case TokenNameEOF  :
10341 			//  case TokenNamecase  :
10342 			//  case TokenNamecatch  :
10343 			//  case TokenNameelse  :
10344 			//  case TokenNameextends  :
10345 			//  case TokenNamefinally  :
10346 			//  case TokenNameimplements  :
10347 			//  case TokenNamethrows  :
10348 			//  case TokenNameinstanceof  :
10349 			//  case TokenNameEQUAL_EQUAL  :
10350 			//  case TokenNameLESS_EQUAL  :
10351 			//  case TokenNameGREATER_EQUAL  :
10352 			//  case TokenNameNOT_EQUAL  :
10353 			//  case TokenNameLEFT_SHIFT  :
10354 			//  case TokenNameRIGHT_SHIFT  :
10355 			//  case TokenNameUNSIGNED_RIGHT_SHIFT :
10356 			//  case TokenNamePLUS_EQUAL  :
10357 			//  case TokenNameMINUS_EQUAL  :
10358 			//  case TokenNameMULTIPLY_EQUAL  :
10359 			//  case TokenNameDIVIDE_EQUAL  :
10360 			//  case TokenNameAND_EQUAL  :
10361 			//  case TokenNameOR_EQUAL  :
10362 			//  case TokenNameXOR_EQUAL  :
10363 			//  case TokenNameREMAINDER_EQUAL  :
10364 			//  case TokenNameLEFT_SHIFT_EQUAL  :
10365 			//  case TokenNameRIGHT_SHIFT_EQUAL  :
10366 			//  case TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL  :
10367 			//  case TokenNameOR_OR  :
10368 			//  case TokenNameAND_AND  :
10369 			//  case TokenNameREMAINDER :
10370 			//  case TokenNameXOR  :
10371 			//  case TokenNameAND  :
10372 			//  case TokenNameMULTIPLY :
10373 			//  case TokenNameOR  :
10374 			//  case TokenNameDIVIDE :
10375 			//  case TokenNameGREATER  :
10376 	}
10377 }
consumeTypeArgument()10378 protected void consumeTypeArgument() {
10379 	pushOnGenericsStack(getTypeReference(this.intStack[this.intPtr--]));
10380 }
consumeTypeArgumentList()10381 protected void consumeTypeArgumentList() {
10382 	concatGenericsLists();
10383 }
consumeTypeArgumentList1()10384 protected void consumeTypeArgumentList1() {
10385 	concatGenericsLists();
10386 }
consumeTypeArgumentList2()10387 protected void consumeTypeArgumentList2() {
10388 	concatGenericsLists();
10389 }
consumeTypeArgumentList3()10390 protected void consumeTypeArgumentList3() {
10391 	concatGenericsLists();
10392 }
consumeTypeArgumentReferenceType1()10393 protected void consumeTypeArgumentReferenceType1() {
10394 	concatGenericsLists();
10395 	pushOnGenericsStack(getTypeReference(0));
10396 	this.intPtr--; // pop '<' position.
10397 }
consumeTypeArgumentReferenceType2()10398 protected void consumeTypeArgumentReferenceType2() {
10399 	concatGenericsLists();
10400 	pushOnGenericsStack(getTypeReference(0));
10401 	this.intPtr--;
10402 }
consumeTypeArguments()10403 protected void consumeTypeArguments() {
10404 	concatGenericsLists();
10405 	this.intPtr--;
10406 
10407 	if(!this.statementRecoveryActivated &&
10408 			this.options.sourceLevel < ClassFileConstants.JDK1_5 &&
10409 			this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
10410 		int length = this.genericsLengthStack[this.genericsLengthPtr];
10411 		problemReporter().invalidUsageOfTypeArguments(
10412 			(TypeReference)this.genericsStack[this.genericsPtr - length + 1],
10413 			(TypeReference)this.genericsStack[this.genericsPtr]);
10414 	}
10415 }
consumeTypeDeclarations()10416 protected void consumeTypeDeclarations() {
10417 	// TypeDeclarations ::= TypeDeclarations TypeDeclaration
10418 	concatNodeLists();
10419 }
consumeTypeHeaderNameWithTypeParameters()10420 protected void consumeTypeHeaderNameWithTypeParameters() {
10421 	// ClassHeaderName ::= ClassHeaderName1 TypeParameters
10422 	// InterfaceHeaderName ::= InterfaceHeaderName1 TypeParameters
10423 	TypeDeclaration typeDecl = (TypeDeclaration)this.astStack[this.astPtr];
10424 
10425 	// consume type parameters
10426 	int length = this.genericsLengthStack[this.genericsLengthPtr--];
10427 	this.genericsPtr -= length;
10428 	System.arraycopy(this.genericsStack, this.genericsPtr + 1, typeDecl.typeParameters = new TypeParameter[length], 0, length);
10429 
10430 	typeDecl.bodyStart = typeDecl.typeParameters[length-1].declarationSourceEnd + 1;
10431 
10432 	this.listTypeParameterLength = 0;
10433 
10434 	if (this.currentElement != null) {
10435 		// is recovering
10436 		if (this.currentElement instanceof RecoveredType) {
10437 			RecoveredType recoveredType = (RecoveredType) this.currentElement;
10438 			recoveredType.pendingTypeParameters = null;
10439 			this.lastCheckPoint = typeDecl.bodyStart;
10440 		} else {
10441 			this.lastCheckPoint = typeDecl.bodyStart;
10442 			this.currentElement = this.currentElement.add(typeDecl, 0);
10443 			this.lastIgnoredToken = -1;
10444 		}
10445 	}
10446 }
consumeTypeImportOnDemandDeclarationName()10447 protected void consumeTypeImportOnDemandDeclarationName() {
10448 	// TypeImportOnDemandDeclarationName ::= 'import' Name '.' RejectTypeAnnotations '*'
10449 	/* push an ImportRef build from the last name
10450 	stored in the identifier stack. */
10451 
10452 	ImportReference impt;
10453 	int length;
10454 	char[][] tokens = new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
10455 	this.identifierPtr -= length;
10456 	long[] positions = new long[length];
10457 	System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
10458 	System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
10459 	pushOnAstStack(impt = new ImportReference(tokens, positions, true, ClassFileConstants.AccDefault));
10460 
10461 	// star end position
10462 	impt.trailingStarPosition = this.intStack[this.intPtr--];
10463 	if (this.currentToken == TokenNameSEMICOLON){
10464 		impt.declarationSourceEnd = this.scanner.currentPosition - 1;
10465 	} else {
10466 		impt.declarationSourceEnd = impt.sourceEnd;
10467 	}
10468 	impt.declarationEnd = impt.declarationSourceEnd;
10469 	//this.endPosition is just before the ;
10470 	impt.declarationSourceStart = this.intStack[this.intPtr--];
10471 
10472 	// recovery
10473 	if (this.currentElement != null){
10474 		this.lastCheckPoint = impt.declarationSourceEnd+1;
10475 		this.currentElement = this.currentElement.add(impt, 0);
10476 		this.lastIgnoredToken = -1;
10477 		this.restartRecovery = true; // used to avoid branching back into the regular automaton
10478 	}
10479 }
consumeTypeParameter1()10480 protected void consumeTypeParameter1() {
10481 	// nothing to do
10482 }
consumeTypeParameter1WithExtends()10483 protected void consumeTypeParameter1WithExtends() {
10484 	//TypeParameter1 ::= TypeParameterHeader 'extends' ReferenceType1
10485 	TypeReference superType = (TypeReference) this.genericsStack[this.genericsPtr--];
10486 	this.genericsLengthPtr--;
10487 	TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
10488 	typeParameter.declarationSourceEnd = superType.sourceEnd;
10489 	typeParameter.type = superType;
10490 	superType.bits |= ASTNode.IsSuperType;
10491 	typeParameter.bits |= (superType.bits & ASTNode.HasTypeAnnotations);
10492 	this.genericsStack[this.genericsPtr] = typeParameter;
10493 }
consumeTypeParameter1WithExtendsAndBounds()10494 protected void consumeTypeParameter1WithExtendsAndBounds() {
10495 	//TypeParameter1 ::= TypeParameterHeader 'extends' ReferenceType AdditionalBoundList1
10496 	int additionalBoundsLength = this.genericsLengthStack[this.genericsLengthPtr--];
10497 	TypeReference[] bounds = new TypeReference[additionalBoundsLength];
10498 	this.genericsPtr -= additionalBoundsLength;
10499 	System.arraycopy(this.genericsStack, this.genericsPtr + 1, bounds, 0, additionalBoundsLength);
10500 	TypeReference superType = getTypeReference(this.intStack[this.intPtr--]);
10501 	TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
10502 	typeParameter.declarationSourceEnd = bounds[additionalBoundsLength - 1].sourceEnd;
10503 	typeParameter.type = superType;
10504 	typeParameter.bits |= (superType.bits & ASTNode.HasTypeAnnotations);
10505 	superType.bits |= ASTNode.IsSuperType;
10506 	typeParameter.bounds = bounds;
10507 	for (int i = 0, max = bounds.length; i < max; i++) {
10508 		TypeReference bound = bounds[i];
10509 		bound.bits |= ASTNode.IsSuperType;
10510 		typeParameter.bits |= (bound.bits & ASTNode.HasTypeAnnotations);
10511 	}
10512 }
consumeTypeParameterHeader()10513 protected void consumeTypeParameterHeader() {
10514 	//TypeParameterHeader ::= TypeAnnotationsopt Identifier
10515 	TypeParameter typeParameter = new TypeParameter();
10516 	int length;
10517 	if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
10518 		System.arraycopy(
10519 				this.typeAnnotationStack,
10520 				(this.typeAnnotationPtr -= length) + 1,
10521 				typeParameter.annotations = new Annotation[length],
10522 				0,
10523 				length);
10524 		typeParameter.bits |= ASTNode.HasTypeAnnotations;
10525 	}
10526 	long pos = this.identifierPositionStack[this.identifierPtr];
10527 	final int end = (int) pos;
10528 	typeParameter.declarationSourceEnd = end;
10529 	typeParameter.sourceEnd = end;
10530 	final int start = (int) (pos >>> 32);
10531 	typeParameter.declarationSourceStart = start;
10532 	typeParameter.sourceStart = start;
10533 	typeParameter.name = this.identifierStack[this.identifierPtr--];
10534 	this.identifierLengthPtr--;
10535 	pushOnGenericsStack(typeParameter);
10536 
10537 	this.listTypeParameterLength++;
10538 }
consumeTypeParameterList()10539 protected void consumeTypeParameterList() {
10540 	//TypeParameterList ::= TypeParameterList ',' TypeParameter
10541 	concatGenericsLists();
10542 }
consumeTypeParameterList1()10543 protected void consumeTypeParameterList1() {
10544 	//TypeParameterList1 ::= TypeParameterList ',' TypeParameter1
10545 	concatGenericsLists();
10546 }
consumeTypeParameters()10547 protected void consumeTypeParameters() {
10548 	int startPos = this.intStack[this.intPtr--];
10549 
10550 	if(this.currentElement != null) {
10551 		if(this.currentElement instanceof RecoveredType) {
10552 			RecoveredType recoveredType =(RecoveredType) this.currentElement;
10553 			int length = this.genericsLengthStack[this.genericsLengthPtr];
10554 			TypeParameter[] typeParameters = new TypeParameter[length];
10555 			System.arraycopy(this.genericsStack, this.genericsPtr - length + 1, typeParameters, 0, length);
10556 
10557 			recoveredType.add(typeParameters, startPos);
10558 		}
10559 	}
10560 
10561 
10562 	if(!this.statementRecoveryActivated &&
10563 			this.options.sourceLevel < ClassFileConstants.JDK1_5&&
10564 			this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
10565 		int length = this.genericsLengthStack[this.genericsLengthPtr];
10566 		problemReporter().invalidUsageOfTypeParameters(
10567 			(TypeParameter) this.genericsStack[this.genericsPtr - length + 1],
10568 			(TypeParameter) this.genericsStack[this.genericsPtr]);
10569 	}
10570 }
consumeTypeParameterWithExtends()10571 protected void consumeTypeParameterWithExtends() {
10572 	//TypeParameter ::= TypeParameterHeader 'extends' ReferenceType
10573 	TypeReference superType = getTypeReference(this.intStack[this.intPtr--]);
10574 	TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
10575 	typeParameter.declarationSourceEnd = superType.sourceEnd;
10576 	typeParameter.type = superType;
10577 	typeParameter.bits |= (superType.bits & ASTNode.HasTypeAnnotations);
10578 	superType.bits |= ASTNode.IsSuperType;
10579 }
consumeTypeParameterWithExtendsAndBounds()10580 protected void consumeTypeParameterWithExtendsAndBounds() {
10581 	//TypeParameter ::= TypeParameterHeader 'extends' ReferenceType AdditionalBoundList
10582 	int additionalBoundsLength = this.genericsLengthStack[this.genericsLengthPtr--];
10583 	TypeReference[] bounds = new TypeReference[additionalBoundsLength];
10584 	this.genericsPtr -= additionalBoundsLength;
10585 	System.arraycopy(this.genericsStack, this.genericsPtr + 1, bounds, 0, additionalBoundsLength);
10586 	TypeReference superType = getTypeReference(this.intStack[this.intPtr--]);
10587 	TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
10588 	typeParameter.type = superType;
10589 	typeParameter.bits |= (superType.bits & ASTNode.HasTypeAnnotations);
10590 	superType.bits |= ASTNode.IsSuperType;
10591 	typeParameter.bounds = bounds;
10592 	typeParameter.declarationSourceEnd = bounds[additionalBoundsLength - 1].sourceEnd;
10593 	for (int i = 0, max = bounds.length; i < max; i++) {
10594 		TypeReference bound = bounds[i];
10595 		bound.bits |= ASTNode.IsSuperType;
10596 		typeParameter.bits |= (bound.bits & ASTNode.HasTypeAnnotations);
10597 	}
10598 }
consumeZeroAdditionalBounds()10599 protected void consumeZeroAdditionalBounds() {
10600 	if (this.currentToken == TokenNameRPAREN)  // Signal zero additional bounds - do this only when the cast type is fully seen (i.e not in error path)
10601 		pushOnGenericsLengthStack(0);          // Not all stacks are adjusted - this is not meant to be popped by getTypeReference
10602 }
consumeUnaryExpression(int op)10603 protected void consumeUnaryExpression(int op) {
10604 	// UnaryExpression ::= '+' PushPosition UnaryExpression
10605 	// UnaryExpression ::= '-' PushPosition UnaryExpression
10606 	// UnaryExpressionNotPlusMinus ::= '~' PushPosition UnaryExpression
10607 	// UnaryExpressionNotPlusMinus ::= '!' PushPosition UnaryExpression
10608 
10609 	//optimize the push/pop
10610 
10611 	//handle manually the -2147483648 while it is not a real
10612 	//computation of an - and 2147483648 (notice that 2147483648
10613 	//is Integer.MAX_VALUE+1.....)
10614 	//Same for -9223372036854775808L ............
10615 
10616 	//this.intStack have the position of the operator
10617 
10618 	Expression r, exp = this.expressionStack[this.expressionPtr];
10619 	if (op == MINUS) {
10620 		if (exp instanceof IntLiteral) {
10621 			IntLiteral intLiteral = (IntLiteral) exp;
10622 			IntLiteral convertToMinValue = intLiteral.convertToMinValue();
10623 			if (convertToMinValue ==  intLiteral) {
10624 				// not a min value literal so we convert it to an unary expression
10625 				r = new UnaryExpression(exp, op);
10626 			} else {
10627 				r = convertToMinValue;
10628 			}
10629 		} else if (exp instanceof LongLiteral) {
10630 			LongLiteral longLiteral = (LongLiteral) exp;
10631 			LongLiteral convertToMinValue = longLiteral.convertToMinValue();
10632 			if (convertToMinValue ==  longLiteral) {
10633 				// not a min value literal so we convert it to an unary expression
10634 				r = new UnaryExpression(exp, op);
10635 			} else {
10636 				r = convertToMinValue;
10637 			}
10638 		} else {
10639 			r = new UnaryExpression(exp, op);
10640 		}
10641 	} else {
10642 		r = new UnaryExpression(exp, op);
10643 	}
10644 	r.sourceStart = this.intStack[this.intPtr--];
10645 	r.sourceEnd = exp.sourceEnd;
10646 	this.expressionStack[this.expressionPtr] = r;
10647 }
consumeUnaryExpression(int op, boolean post)10648 protected void consumeUnaryExpression(int op, boolean post) {
10649 	// PreIncrementExpression ::= '++' PushPosition UnaryExpression
10650 	// PreDecrementExpression ::= '--' PushPosition UnaryExpression
10651 
10652 	// ++ and -- operators
10653 	//optimize the push/pop
10654 
10655 	//this.intStack has the position of the operator when prefix
10656 
10657 	Expression leftHandSide = this.expressionStack[this.expressionPtr];
10658 	if (leftHandSide instanceof Reference) {
10659 		// ++foo()++ is unvalid
10660 		if (post) {
10661 			this.expressionStack[this.expressionPtr] =
10662 				new PostfixExpression(
10663 					leftHandSide,
10664 					IntLiteral.One,
10665 					op,
10666 					this.endStatementPosition);
10667 		} else {
10668 			this.expressionStack[this.expressionPtr] =
10669 				new PrefixExpression(
10670 					leftHandSide,
10671 					IntLiteral.One,
10672 					op,
10673 					this.intStack[this.intPtr--]);
10674 		}
10675 	} else {
10676 		//the ++ or the -- is NOT taken into account if code gen proceeds
10677 		if (!post) {
10678 			this.intPtr--;
10679 		}
10680 		if(!this.statementRecoveryActivated) problemReporter().invalidUnaryExpression(leftHandSide);
10681 	}
10682 }
consumeVariableDeclarators()10683 protected void consumeVariableDeclarators() {
10684 	// VariableDeclarators ::= VariableDeclarators ',' VariableDeclarator
10685 	optimizedConcatNodeLists();
10686 }
consumeVariableInitializers()10687 protected void consumeVariableInitializers() {
10688 	// VariableInitializers ::= VariableInitializers ',' VariableInitializer
10689 	concatExpressionLists();
10690 }
consumeWildcard()10691 protected void consumeWildcard() {
10692 	final Wildcard wildcard = new Wildcard(Wildcard.UNBOUND);
10693 	wildcard.sourceEnd = this.intStack[this.intPtr--];
10694 	wildcard.sourceStart = this.intStack[this.intPtr--];
10695 	annotateTypeReference(wildcard);
10696 	pushOnGenericsStack(wildcard);
10697 }
consumeWildcard1()10698 protected void consumeWildcard1() {
10699 	final Wildcard wildcard = new Wildcard(Wildcard.UNBOUND);
10700 	wildcard.sourceEnd = this.intStack[this.intPtr--];
10701 	wildcard.sourceStart = this.intStack[this.intPtr--];
10702 	annotateTypeReference(wildcard);
10703 	pushOnGenericsStack(wildcard);
10704 }
consumeWildcard1WithBounds()10705 protected void consumeWildcard1WithBounds() {
10706 	// Nothing to do
10707 	// The wildcard is created by the consumeWildcardBounds1Extends or by consumeWildcardBounds1Super
10708 }
consumeWildcard2()10709 protected void consumeWildcard2() {
10710 	final Wildcard wildcard = new Wildcard(Wildcard.UNBOUND);
10711 	wildcard.sourceEnd = this.intStack[this.intPtr--];
10712 	wildcard.sourceStart = this.intStack[this.intPtr--];
10713 	annotateTypeReference(wildcard);
10714 	pushOnGenericsStack(wildcard);
10715 }
consumeWildcard2WithBounds()10716 protected void consumeWildcard2WithBounds() {
10717 	// Nothing to do
10718 	// The wildcard is created by the consumeWildcardBounds2Extends or by consumeWildcardBounds2Super
10719 }
consumeWildcard3()10720 protected void consumeWildcard3() {
10721 	final Wildcard wildcard = new Wildcard(Wildcard.UNBOUND);
10722 	wildcard.sourceEnd = this.intStack[this.intPtr--];
10723 	wildcard.sourceStart = this.intStack[this.intPtr--];
10724 	annotateTypeReference(wildcard);
10725 	pushOnGenericsStack(wildcard);
10726 }
consumeWildcard3WithBounds()10727 protected void consumeWildcard3WithBounds() {
10728 	// Nothing to do
10729 	// The wildcard is created by the consumeWildcardBounds3Extends or by consumeWildcardBounds3Super
10730 }
consumeWildcardBounds1Extends()10731 protected void consumeWildcardBounds1Extends() {
10732 	Wildcard wildcard = new Wildcard(Wildcard.EXTENDS);
10733 	wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
10734 	wildcard.sourceEnd = wildcard.bound.sourceEnd;
10735 	this.intPtr--; // remove end position of the '?'
10736 	wildcard.sourceStart = this.intStack[this.intPtr--];
10737 	annotateTypeReference(wildcard);
10738 	this.genericsStack[this.genericsPtr] = wildcard;
10739 }
consumeWildcardBounds1Super()10740 protected void consumeWildcardBounds1Super() {
10741 	Wildcard wildcard = new Wildcard(Wildcard.SUPER);
10742 	wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
10743 	this.intPtr--; // remove the starting position of the super keyword
10744 	wildcard.sourceEnd = wildcard.bound.sourceEnd;
10745 	this.intPtr--; // remove end position of the '?'
10746 	wildcard.sourceStart = this.intStack[this.intPtr--];
10747 	annotateTypeReference(wildcard);
10748 	this.genericsStack[this.genericsPtr] = wildcard;
10749 }
consumeWildcardBounds2Extends()10750 protected void consumeWildcardBounds2Extends() {
10751 	Wildcard wildcard = new Wildcard(Wildcard.EXTENDS);
10752 	wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
10753 	wildcard.sourceEnd = wildcard.bound.sourceEnd;
10754 	this.intPtr--; // remove end position of the '?'
10755 	wildcard.sourceStart = this.intStack[this.intPtr--];
10756 	annotateTypeReference(wildcard);
10757 	this.genericsStack[this.genericsPtr] = wildcard;
10758 }
consumeWildcardBounds2Super()10759 protected void consumeWildcardBounds2Super() {
10760 	Wildcard wildcard = new Wildcard(Wildcard.SUPER);
10761 	wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
10762 	this.intPtr--; // remove the starting position of the super keyword
10763 	wildcard.sourceEnd = wildcard.bound.sourceEnd;
10764 	this.intPtr--; // remove end position of the '?'
10765 	wildcard.sourceStart = this.intStack[this.intPtr--];
10766 	annotateTypeReference(wildcard);
10767 	this.genericsStack[this.genericsPtr] = wildcard;
10768 }
consumeWildcardBounds3Extends()10769 protected void consumeWildcardBounds3Extends() {
10770 	Wildcard wildcard = new Wildcard(Wildcard.EXTENDS);
10771 	wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
10772 	wildcard.sourceEnd = wildcard.bound.sourceEnd;
10773 	this.intPtr--; // remove end position of the '?'
10774 	wildcard.sourceStart = this.intStack[this.intPtr--];
10775 	annotateTypeReference(wildcard);
10776 	this.genericsStack[this.genericsPtr] = wildcard;
10777 }
consumeWildcardBounds3Super()10778 protected void consumeWildcardBounds3Super() {
10779 	Wildcard wildcard = new Wildcard(Wildcard.SUPER);
10780 	wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
10781 	this.intPtr--; // remove the starting position of the super keyword
10782 	wildcard.sourceEnd = wildcard.bound.sourceEnd;
10783 	this.intPtr--; // remove end position of the '?'
10784 	wildcard.sourceStart = this.intStack[this.intPtr--];
10785 	annotateTypeReference(wildcard);
10786 	this.genericsStack[this.genericsPtr] = wildcard;
10787 }
consumeWildcardBoundsExtends()10788 protected void consumeWildcardBoundsExtends() {
10789 	Wildcard wildcard = new Wildcard(Wildcard.EXTENDS);
10790 	wildcard.bound = getTypeReference(this.intStack[this.intPtr--]);
10791 	wildcard.sourceEnd = wildcard.bound.sourceEnd;
10792 	this.intPtr--; // remove end position of the '?'
10793 	wildcard.sourceStart = this.intStack[this.intPtr--];
10794 	annotateTypeReference(wildcard);
10795 	pushOnGenericsStack(wildcard);
10796 }
consumeWildcardBoundsSuper()10797 protected void consumeWildcardBoundsSuper() {
10798 	Wildcard wildcard = new Wildcard(Wildcard.SUPER);
10799 	wildcard.bound = getTypeReference(this.intStack[this.intPtr--]);
10800 	this.intPtr--; // remove the starting position of the super keyword
10801 	wildcard.sourceEnd = wildcard.bound.sourceEnd;
10802 	this.intPtr--; // remove end position of the '?'
10803 	wildcard.sourceStart = this.intStack[this.intPtr--];
10804 	annotateTypeReference(wildcard);
10805 	pushOnGenericsStack(wildcard);
10806 }
consumeWildcardWithBounds()10807 protected void consumeWildcardWithBounds() {
10808 	// Nothing to do
10809 	// The wildcard is created by the consumeWildcardBoundsExtends or by consumeWildcardBoundsSuper
10810 }
10811 /* Java 14 preview - records */
consumeRecordDeclaration()10812 protected void consumeRecordDeclaration() {
10813 	// RecordDeclaration ::= RecordHeaderPart RecordBody
10814 
10815 	int length;
10816 	if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
10817 		//there are length declarations
10818 		//dispatch according to the type of the declarations
10819 		dispatchDeclarationIntoRecordDeclaration(length);
10820 	}
10821 
10822 	TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
10823 	this.recordNestedMethodLevels.remove(typeDecl);
10824 	if (!this.options.enablePreviewFeatures){
10825 		problemReporter().previewFeatureNotEnabled(typeDecl.sourceStart, typeDecl.sourceEnd, "Records"); //$NON-NLS-1$
10826 	} else {
10827 		if (this.options.isAnyEnabled(IrritantSet.PREVIEW)) {
10828 			problemReporter().previewFeatureUsed(typeDecl.sourceStart, typeDecl.sourceEnd);
10829 		}
10830 	}
10831 	//convert constructor that do not have the type's name into methods
10832 	ConstructorDeclaration cd = typeDecl.getConstructor(this);
10833 	if (cd == null) {
10834 		/* create canonical constructor - check for the clash later at binding time */
10835 		cd = typeDecl.createDefaultConstructor(!(this.diet && this.dietInt == 0), true);
10836 	} else {
10837 		cd.bits |= ASTNode.IsCanonicalConstructor;
10838 	}
10839 
10840 	if (this.scanner.containsAssertKeyword) {
10841 		typeDecl.bits |= ASTNode.ContainsAssertion;
10842 	}
10843 	typeDecl.addClinit();
10844 	typeDecl.bodyEnd = this.endStatementPosition;
10845 	if (length == 0 && !containsComment(typeDecl.bodyStart, typeDecl.bodyEnd)) {
10846 		typeDecl.bits |= ASTNode.UndocumentedEmptyBlock;
10847 	}
10848 	TypeReference superClass = new QualifiedTypeReference(TypeConstants.JAVA_LANG_RECORD, new long[] {0});
10849 	superClass.bits |= ASTNode.IsSuperType;
10850 	typeDecl.superclass = superClass;
10851 	typeDecl.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
10852 }
consumeRecordHeaderPart()10853 protected void consumeRecordHeaderPart() {
10854 	// RecordHeaderPart ::= RecordHeaderName RecordHeader ClassHeaderImplementsopt
10855 	TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
10856 	assert typeDecl.isRecord();
10857 	// do nothing
10858 }
consumeRecordHeaderNameWithTypeParameters()10859 protected void consumeRecordHeaderNameWithTypeParameters() {
10860 	// RecordHeaderName ::= RecordHeaderName1 TypeParameters
10861 	consumeTypeHeaderNameWithTypeParameters();
10862 }
consumeRecordHeaderName1()10863 protected void consumeRecordHeaderName1() {
10864 	// Modifiersopt RestrictedIdentifierrecord 'Identifier'
10865 	consumeClassOrRecordHeaderName1(true);
10866 }
consumeRecordComponentHeaderRightParen()10867 protected void consumeRecordComponentHeaderRightParen() {
10868 	// RecordComponentHeaderRightParen ::= ')'
10869 	int length = this.astLengthStack[this.astLengthPtr--];
10870 	this.astPtr -= length;
10871 	TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
10872 	int nestedMethodLevel = this.nestedMethod[this.nestedType];
10873 	typeDecl.isLocalRecord = nestedMethodLevel > 0;
10874 	if (typeDecl.isLocalRecord)
10875 		typeDecl.modifiers |= ClassFileConstants.AccStatic; // JLS 14 Sec 14.3
10876 	this.recordNestedMethodLevels.put(typeDecl, new Integer[] {this.nestedType, nestedMethodLevel});
10877 	this.astStack[this.astPtr] = typeDecl;
10878 //	rd.sourceEnd = 	this.rParenPos;
10879 	if (length != 0) {
10880 		RecordComponent[] recComps = new RecordComponent[length];
10881 		System.arraycopy(
10882 				this.astStack,
10883 				this.astPtr + 1,
10884 				recComps,
10885 				0,
10886 				length);
10887 		typeDecl.recordComponents = recComps;
10888 		convertToFields(typeDecl, recComps);
10889 	} else {
10890 		typeDecl.recordComponents = ASTNode.NO_RECORD_COMPONENTS;
10891 	}
10892 	typeDecl.bodyStart = this.rParenPos+1;
10893 	this.listLength = 0; // reset this.listLength after having read all parameters
10894 	// recovery
10895 	if (this.currentElement != null){
10896 		this.lastCheckPoint = typeDecl.bodyStart;
10897 		if (this.currentElement.parseTree() == typeDecl) return;
10898 	}
10899 }
convertToFields(TypeDeclaration typeDecl, RecordComponent[] recComps)10900 private void convertToFields(TypeDeclaration typeDecl, RecordComponent[] recComps) {
10901 	int length = recComps.length;
10902 	FieldDeclaration[] fields = new FieldDeclaration[length];
10903 	int nFields = 0;
10904 	Set<String> argsSet = new HashSet<>();
10905 	for (int i = 0, max = recComps.length; i < max; i++) {
10906 		RecordComponent recComp = recComps[i];
10907 		String argName = new String(recComp.name);
10908 		if (TypeDeclaration.disallowedComponentNames.contains(argName)) {
10909 			problemReporter().recordIllegalComponentNameInRecord(recComp, typeDecl);
10910 			continue;
10911 		}
10912 		if (argsSet.contains(argName)) {
10913 			// flag the error at the place where duplicate params of methods would have been flagged.
10914 			continue;
10915 		}
10916 		if (recComp.type.getLastToken() == TypeConstants.VOID) {
10917 			problemReporter().recordComponentCannotBeVoid(recComp);
10918 			continue;
10919 		}
10920 		if (recComp.isVarArgs() && i < max - 1)
10921 			problemReporter().recordIllegalVararg(recComp, typeDecl);
10922 
10923 		argsSet.add(argName);
10924 		FieldDeclaration f = fields[nFields++] = createFieldDeclaration(recComp.name, recComp.sourceStart, recComp.sourceEnd);
10925 		f.bits = recComp.bits;
10926 		f.declarationSourceStart = recComp.declarationSourceStart;
10927 		f.declarationEnd = recComp.declarationEnd;
10928 		f.declarationSourceEnd = recComp.declarationSourceEnd;
10929 		f.endPart1Position = recComp.sourceEnd; //TODO BETA_JAVA14 - recheck
10930 		f.endPart2Position = recComp.declarationSourceEnd;
10931 		f.modifiers = ClassFileConstants.AccPrivate | ClassFileConstants.AccFinal;
10932 		// Note: JVMS 14 S 4.7.8 The Synthetic Attribute mandates do not mark Synthetic for Record compoents.
10933 		// hence marking this "explicitly" as implicit.
10934 		f.isARecordComponent = true;
10935 		/*
10936 		 * JLS 14 Sec 8.10.1 Record Header
10937 		 * The record header declares a number of record components. The record components
10938 		 * declare the fields of the record class. Each record component in the RecordHeader
10939 		 * declares one private final field in the record class whose name is same as the
10940 		 * Identifier in the record component.
10941 		 *
10942 		 * JLS 14 Sec 8.10.3 Record Components
10943 		 * For each record component appearing in the record component list:
10944 		 * An implicitly declared private final field with the same name as the record
10945 		 * component and the type as the declared type of the record component.
10946 		 */
10947 		f.modifiers |= ClassFileConstants.AccPrivate | ClassFileConstants.AccFinal;
10948 		f.modifiers |= ExtraCompilerModifiers.AccRecord;
10949 		f.modifiersSourceStart = recComp.modifiersSourceStart;
10950 		f.sourceStart = recComp.sourceStart;
10951 		f.sourceEnd = recComp.sourceEnd;
10952 		f.type = recComp.type;
10953 		/*
10954 		 * JLS 14 SEC 8.10.3 Item 1 says the following:
10955 		 *  "This field is annotated with the annotation that appears on the corresponding
10956 		 *  record component, if this annotation type is applicable to a field declaration
10957 		 *  or type context."
10958 		 *
10959 		 *  However, at this point there is no sufficient information to conclude the ElementType
10960 		 *  targeted by the annotation. Hence, do a blanket assignment for now and later (read binding
10961 		 *  time) weed out the irrelevant ones.
10962 		 */
10963 //		f.annotations = recComp.annotations;
10964 //		comp.annotations = null;
10965 		if ((recComp.bits & ASTNode.HasTypeAnnotations) != 0) {
10966 			f.bits |= ASTNode.HasTypeAnnotations;
10967 		}
10968 	}
10969 	if (nFields < fields.length) {
10970 		// Note: This happens only if there are errors in the code.
10971 		FieldDeclaration[] tmp = new FieldDeclaration[nFields];
10972 		System.arraycopy(fields	, 0, tmp, 0, nFields);
10973 		fields = tmp;
10974 	}
10975 	typeDecl.fields = fields;
10976 	typeDecl.nRecordComponents = fields.length;
10977 }
consumeRecordHeader()10978 protected void consumeRecordHeader() {
10979 	//RecordHeader ::= '(' RecordComponentsopt RecordComponentHeaderRightParen
10980 	//TODO: BETA_JAVA14_RECORD flag TypeDeclaration.RECORD_DECL ?
10981 }
consumeRecordComponentsopt()10982 protected void consumeRecordComponentsopt() {
10983 	// RecordComponentsopt ::= $empty
10984 	pushOnAstLengthStack(0);
10985 }
consumeRecordComponents()10986 protected void consumeRecordComponents() {
10987 	// RecordComponents ::= RecordComponents ',' RecordComponent
10988 	optimizedConcatNodeLists();
10989 }
10990 // TODO: merge consumeFormalParameter and this method once record becomes a standard feature
consumeRecordComponent(boolean isVarArgs)10991 protected void consumeRecordComponent(boolean isVarArgs) {
10992 // RecordComponent ::= Modifiersopt Type VariableDeclaratorId
10993 //	VariableArityRecordComponent ::= Modifiersopt Type PushZeroTypeAnnotations '...' VariableDeclaratorId
10994 //	VariableArityRecordComponent ::= Modifiersopt Type @308... TypeAnnotations '...' VariableDeclaratorId
10995 // Note that there is a difference wrt VariableDeclaratorId wrt to the JLS 8.10.1 specification which specifies
10996 // 'identifier' - however this is identical to consumeFormalParameter where this error is caught and reported.
10997 	this.identifierLengthPtr--;
10998 	char[] identifierName = this.identifierStack[this.identifierPtr];
10999 	long namePositions = this.identifierPositionStack[this.identifierPtr--];
11000 	int extendedDimensions = this.intStack[this.intPtr--];
11001 	Annotation [][] annotationsOnExtendedDimensions = extendedDimensions == 0 ? null : getAnnotationsOnDimensions(extendedDimensions);
11002 	Annotation [] varArgsAnnotations = null;
11003 	int endOfEllipsis = 0;
11004 	int length;
11005 	int firstDimensions = 0;
11006 	if (isVarArgs) {
11007 		endOfEllipsis = this.intStack[this.intPtr--];
11008 		if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
11009 			System.arraycopy(
11010 				this.typeAnnotationStack,
11011 				(this.typeAnnotationPtr -= length) + 1,
11012 				varArgsAnnotations = new Annotation[length],
11013 				0,
11014 				length);
11015 		}
11016 	}
11017 	firstDimensions = this.intStack[this.intPtr--];
11018 	TypeReference type = getTypeReference(firstDimensions);
11019 	if (isVarArgs || extendedDimensions != 0) {
11020 		if (isVarArgs) {
11021 			type = augmentTypeWithAdditionalDimensions(type, 1, varArgsAnnotations != null ? new Annotation[][] { varArgsAnnotations } : null, true);
11022 		}
11023 		if (extendedDimensions != 0) {
11024 			type = augmentTypeWithAdditionalDimensions(type, extendedDimensions, annotationsOnExtendedDimensions, false);
11025 		}
11026 		type.sourceEnd = type.isParameterizedTypeReference() ? this.endStatementPosition : this.endPosition;
11027 	}
11028 	if (isVarArgs) {
11029 		if (extendedDimensions == 0) {
11030 			type.sourceEnd = endOfEllipsis;
11031 		}
11032 		type.bits |= ASTNode.IsVarArgs; // set isVarArgs
11033 	}
11034 	int modifierPositions = this.intStack[this.intPtr--];
11035 	RecordComponent recordComponent;
11036 	recordComponent = new RecordComponent(
11037 			identifierName,
11038 			namePositions,
11039 			type,
11040 			this.intStack[this.intPtr--] & ~ClassFileConstants.AccDeprecated); // modifiers
11041 	recordComponent.declarationSourceStart = modifierPositions;
11042 	recordComponent.bits |= (type.bits & ASTNode.HasTypeAnnotations);
11043 	// consume annotations
11044 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
11045 		System.arraycopy(
11046 			this.expressionStack,
11047 			(this.expressionPtr -= length) + 1,
11048 			recordComponent.annotations = new Annotation[length],
11049 			0,
11050 			length);
11051 		recordComponent.bits |= ASTNode.HasTypeAnnotations;
11052 		RecoveredType currentRecoveryType = this.currentRecoveryType();
11053 		if (currentRecoveryType != null)
11054 			currentRecoveryType.annotationsConsumed(recordComponent.annotations);
11055 	}
11056 	pushOnAstStack(recordComponent);
11057 
11058 	/* if incomplete record header, this.listLength counter will not have been reset,
11059 		indicating that some arguments are available on the stack */
11060 	this.listLength++;
11061 	if(isVarArgs) {
11062 		if (!this.statementRecoveryActivated &&
11063 				this.options.sourceLevel < ClassFileConstants.JDK1_5 &&
11064 				this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
11065 				problemReporter().invalidUsageOfVarargs(recordComponent);
11066 		} else if (!this.statementRecoveryActivated &&
11067 				extendedDimensions > 0) {
11068 			problemReporter().illegalExtendedDimensions(recordComponent);
11069 		}
11070 	}
11071 }
consumeRecordBody()11072 protected void consumeRecordBody() {
11073 	// RecordBody ::= '{' RecordBodyDeclarationopt '}'
11074 	// do nothing
11075 }
consumeEmptyRecordBodyDeclaration()11076 protected void consumeEmptyRecordBodyDeclaration() {
11077 	// RecordBodyDeclarationopt ::= $empty
11078 	//TODO: Throw an error for empty record?
11079 	pushOnAstLengthStack(0);
11080 }
consumeRecordBodyDeclarations()11081 protected void consumeRecordBodyDeclarations() {
11082 	//	RecordBodyDeclarations ::= RecordBodyDeclaration
11083 	//	RecordBodyDeclarations ::= RecordBodyDeclarations RecordBodyDeclaration
11084 	concatNodeLists();
11085 }
consumeRecordBodyDeclaration()11086 protected void consumeRecordBodyDeclaration() {
11087 	// RecordBodyDeclaration ::=  ClassBodyDeclaration
11088 //	consumeClassBodyDeclaration();
11089 }
consumeCompactConstructorDeclaration()11090 protected void consumeCompactConstructorDeclaration() {
11091 	// CompactConstructorDeclaration ::= CompactConstructorHeaderName MethodHeaderThrowsClauseopt MethodBody
11092 
11093 	//must provide a default constructor call when needed
11094 
11095 	int length;
11096 
11097 	// pop the position of the {  (body of the method) pushed in block decl
11098 	this.intPtr--;
11099 	this.intPtr--;
11100 
11101 	//statements
11102 	this.realBlockPtr--;
11103 	Statement[] statements = null;
11104 	if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
11105 		this.astPtr -= length;
11106 		if (!this.options.ignoreMethodBodies) {
11107 			System.arraycopy(
11108 					this.astStack,
11109 					this.astPtr + 1,
11110 					statements = new Statement[length],
11111 					0,
11112 					length);
11113 		}
11114 	}
11115 
11116 	CompactConstructorDeclaration ccd = (CompactConstructorDeclaration) this.astStack[this.astPtr];
11117 	ccd.statements = statements;
11118 
11119 	if (!(this.diet && this.dietInt == 0)
11120 			&& statements == null
11121 			&& !containsComment(ccd.bodyStart, this.endPosition)) {
11122 		ccd.bits |= ASTNode.UndocumentedEmptyBlock;
11123 	}
11124 
11125 	//watch for } that could be given as a unicode ! ( u007D is '}' )
11126 	// store the this.endPosition (position just before the '}') in case there is
11127 	// a trailing comment behind the end of the method
11128 	ccd.bodyEnd = this.endPosition;
11129 	ccd.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
11130 }
consumeCompactConstructorHeader()11131 protected void consumeCompactConstructorHeader() {
11132 //	CompactConstructorHeader ::= CompactConstructorHeaderName MethodHeaderThrowsClauseopt
11133 
11134 	// TODO: Ideally a consumeConstructorHeader should be ok; but if this is overridden and
11135 	// rParentPos is used (ref model), that is incorrect since rParentPos does not exist for CCH
11136 	AbstractMethodDeclaration method = (AbstractMethodDeclaration)this.astStack[this.astPtr];
11137 
11138 	if (this.currentToken == TokenNameLBRACE){
11139 		method.bodyStart = this.scanner.currentPosition;
11140 	}
11141 	// recovery
11142 	if (this.currentElement != null){
11143 		if (this.currentToken == TokenNameSEMICOLON){ // for invalid constructors
11144 			method.modifiers |= ExtraCompilerModifiers.AccSemicolonBody;
11145 			method.declarationSourceEnd = this.scanner.currentPosition-1;
11146 			method.bodyEnd = this.scanner.currentPosition-1;
11147 			if (this.currentElement.parseTree() == method && this.currentElement.parent != null) {
11148 				this.currentElement = this.currentElement.parent;
11149 			}
11150 		}
11151 		this.restartRecovery = true; // used to avoid branching back into the regular automaton
11152 	}
11153 }
consumeCompactConstructorHeaderName()11154 protected void consumeCompactConstructorHeaderName() {
11155 	// CompactConstructorHeaderName ::= Modifiersopt 'Identifier'
11156 
11157 	/* recovering - might be an empty message send */
11158 	if (this.currentElement != null){
11159 		if (this.lastIgnoredToken == TokenNamenew){ // was an allocation expression
11160 			this.lastCheckPoint = this.scanner.startPosition; // force to restart at this exact position
11161 			this.restartRecovery = true;
11162 			return;
11163 		}
11164 	}
11165 	CompactConstructorDeclaration ccd = new CompactConstructorDeclaration(this.compilationUnit.compilationResult);
11166 	populateCompactConstructor(ccd);
11167 }
consumeCompactConstructorHeaderNameWithTypeParameters()11168 protected void consumeCompactConstructorHeaderNameWithTypeParameters() {
11169 	//  CompactConstructorHeaderName ::= Modifiersopt TypeParameters 'Identifier'
11170 	/* recovering - might be an empty message send */
11171 	if (this.currentElement != null){
11172 		if (this.lastIgnoredToken == TokenNamenew){ // was an allocation expression
11173 			this.lastCheckPoint = this.scanner.startPosition; // force to restart at this exact position
11174 			this.restartRecovery = true;
11175 			return;
11176 		}
11177 	}
11178 	CompactConstructorDeclaration ccd = new CompactConstructorDeclaration(this.compilationUnit.compilationResult);
11179 	helperConstructorHeaderNameWithTypeParameters(ccd);
11180 }
dispatchDeclarationIntoRecordDeclaration(int length)11181 protected void dispatchDeclarationIntoRecordDeclaration(int length) {
11182 	/* they are length on this.astStack that should go into
11183 	   methods fields constructors lists of the typeDecl
11184 
11185 	   Return if there is a constructor declaration in the methods declaration */
11186 
11187 
11188 	// Looks for the size of each array .
11189 
11190 	if (length == 0)
11191 		return;
11192 	int[] flag = new int[length + 1]; //plus one -- see <HERE>
11193 	int nFields = 0, size2 = 0, size3 = 0;
11194 	boolean hasAbstractMethods = false;
11195 	for (int i = length - 1; i >= 0; i--) {
11196 		ASTNode astNode = this.astStack[this.astPtr--];
11197 		if (astNode instanceof AbstractMethodDeclaration) {
11198 			//methods and constructors have been regrouped into one single list
11199 			flag[i] = 2;
11200 			size2++;
11201 			if (((AbstractMethodDeclaration) astNode).isAbstract()) {
11202 				hasAbstractMethods = true;
11203 			}
11204 		} else if (astNode instanceof TypeDeclaration) {
11205 			flag[i] = 3;
11206 			size3++;
11207 		} else {
11208 			//field
11209 			flag[i] = 1;
11210 			nFields++;
11211 		}
11212 	}
11213 
11214 	//arrays creation
11215 	TypeDeclaration recordDecl = (TypeDeclaration) this.astStack[this.astPtr];
11216 	int nCreatedFields = recordDecl.fields != null ? recordDecl.fields.length : 0;
11217 	if (nFields != 0) {
11218 		FieldDeclaration[] tmp = new FieldDeclaration[(recordDecl.fields != null ? recordDecl.fields.length  : 0) + nFields];
11219 		if (recordDecl.fields != null)
11220 			System.arraycopy(
11221 					recordDecl.fields,
11222 					0,
11223 					tmp,
11224 					0,
11225 					recordDecl.fields.length);
11226 		recordDecl.fields = tmp;
11227 	}
11228 	if (size2 != 0) {
11229 		recordDecl.methods = new AbstractMethodDeclaration[size2];
11230 		if (hasAbstractMethods) recordDecl.bits |= ASTNode.HasAbstractMethods;
11231 	}
11232 	if (size3 != 0) {
11233 		recordDecl.memberTypes = new TypeDeclaration[size3];
11234 	}
11235 
11236 	//arrays fill up
11237 	nFields = nCreatedFields;
11238 	size2 = size3 = 0;
11239 	int flagI = flag[0], start = 0;
11240 	int length2;
11241 	for (int end = 0; end <= length; end++) //<HERE> the plus one allows to
11242 		{
11243 		if (flagI != flag[end]) //treat the last element as a ended flag.....
11244 			{ //array copy
11245 			switch (flagI) {
11246 				case 1 :
11247 					nFields += (length2 = end - start);
11248 					System.arraycopy(
11249 						this.astStack,
11250 						this.astPtr + start + 1,
11251 						recordDecl.fields,
11252 						nFields - length2,
11253 						length2);
11254 					break;
11255 				case 2 :
11256 					size2 += (length2 = end - start);
11257 					System.arraycopy(
11258 						this.astStack,
11259 						this.astPtr + start + 1,
11260 						recordDecl.methods,
11261 						size2 - length2,
11262 						length2);
11263 					break;
11264 				case 3 :
11265 					size3 += (length2 = end - start);
11266 					System.arraycopy(
11267 						this.astStack,
11268 						this.astPtr + start + 1,
11269 						recordDecl.memberTypes,
11270 						size3 - length2,
11271 						length2);
11272 					break;
11273 			}
11274 			flagI = flag[start = end];
11275 		}
11276 	}
11277 	checkForRecordMemberErrors(recordDecl, nCreatedFields);
11278 
11279 	if (recordDecl.memberTypes != null) {
11280 		for (int i = recordDecl.memberTypes.length - 1; i >= 0; i--) {
11281 			recordDecl.memberTypes[i].enclosingType = recordDecl;
11282 		}
11283 	}
11284 }
checkForRecordMemberErrors(TypeDeclaration typeDecl, int nCreatedFields)11285 private void checkForRecordMemberErrors(TypeDeclaration typeDecl, int nCreatedFields) {
11286 	if (typeDecl.fields == null)
11287 		return;
11288 	for (int i = nCreatedFields; i < typeDecl.fields.length; i++) {
11289 		FieldDeclaration f = typeDecl.fields[i];
11290 		if (f != null && !f.isStatic()) {
11291 			if (f instanceof Initializer)
11292 				problemReporter().recordInstanceInitializerBlockInRecord((Initializer) f);
11293 			else
11294 				problemReporter().recordNonStaticFieldDeclarationInRecord(f);
11295 		}
11296 	}
11297 	if (typeDecl.methods != null) {
11298 		for (int i = 0; i < typeDecl.methods.length; i++) {
11299 			AbstractMethodDeclaration method = typeDecl.methods[i];
11300 			if ((method.modifiers & ClassFileConstants.AccNative) != 0) {
11301 				problemReporter().recordIllegalNativeModifierInRecord(method);
11302 			}
11303 		}
11304 	}
11305 }
11306 /* Java 14 preview - records - end*/
11307 /**
11308  * Given the current comment stack, answer whether some comment is available in a certain exclusive range
11309  *
11310  * @param sourceStart int
11311  * @param sourceEnd int
11312  * @return boolean
11313  */
containsComment(int sourceStart, int sourceEnd)11314 public boolean containsComment(int sourceStart, int sourceEnd) {
11315 	int iComment = this.scanner.commentPtr;
11316 	for (; iComment >= 0; iComment--) {
11317 		int commentStart = this.scanner.commentStarts[iComment];
11318 		if (commentStart < 0) commentStart = -commentStart;
11319 		// ignore comments before start
11320 		if (commentStart < sourceStart) continue;
11321 		// ignore comments after end
11322 		if (commentStart > sourceEnd) continue;
11323 		return true;
11324 	}
11325 	return false;
11326 }
11327 
convertToMethodDeclaration(ConstructorDeclaration c, CompilationResult compilationResult)11328 public MethodDeclaration convertToMethodDeclaration(ConstructorDeclaration c, CompilationResult compilationResult) {
11329 	MethodDeclaration m = new MethodDeclaration(compilationResult);
11330 	m.typeParameters = c.typeParameters;
11331 	m.sourceStart = c.sourceStart;
11332 	m.sourceEnd = c.sourceEnd;
11333 	m.bodyStart = c.bodyStart;
11334 	m.bodyEnd = c.bodyEnd;
11335 	m.declarationSourceEnd = c.declarationSourceEnd;
11336 	m.declarationSourceStart = c.declarationSourceStart;
11337 	m.selector = c.selector;
11338 	m.statements = c.statements;
11339 	m.modifiers = c.modifiers;
11340 	m.annotations = c.annotations;
11341 	m.arguments = c.arguments;
11342 	m.thrownExceptions = c.thrownExceptions;
11343 	m.explicitDeclarations = c.explicitDeclarations;
11344 	m.returnType = null;
11345 	m.javadoc = c.javadoc;
11346 	m.bits = c.bits;
11347 	return m;
11348 }
11349 
augmentTypeWithAdditionalDimensions(TypeReference typeReference, int additionalDimensions, Annotation[][] additionalAnnotations, boolean isVarargs)11350 protected TypeReference augmentTypeWithAdditionalDimensions(TypeReference typeReference, int additionalDimensions, Annotation[][] additionalAnnotations, boolean isVarargs) {
11351 	return typeReference.augmentTypeWithAdditionalDimensions(additionalDimensions, additionalAnnotations, isVarargs);
11352 }
11353 
createFieldDeclaration(char[] fieldDeclarationName, int sourceStart, int sourceEnd)11354 protected FieldDeclaration createFieldDeclaration(char[] fieldDeclarationName, int sourceStart, int sourceEnd) {
11355 	return new FieldDeclaration(fieldDeclarationName, sourceStart, sourceEnd);
11356 }
createJavadocParser()11357 protected JavadocParser createJavadocParser() {
11358 	return new JavadocParser(this);
11359 }
createLocalDeclaration(char[] localDeclarationName, int sourceStart, int sourceEnd)11360 protected LocalDeclaration createLocalDeclaration(char[] localDeclarationName, int sourceStart, int sourceEnd) {
11361 	return new LocalDeclaration(localDeclarationName, sourceStart, sourceEnd);
11362 }
createStringLiteral(char[] token, int start, int end, int lineNumber)11363 protected StringLiteral createStringLiteral(char[] token, int start, int end, int lineNumber) {
11364 	return new StringLiteral(token, start, end, lineNumber);
11365 }
currentRecoveryType()11366 protected RecoveredType currentRecoveryType() {
11367 	if(this.currentElement != null) {
11368 		if(this.currentElement instanceof RecoveredType) {
11369 			return (RecoveredType) this.currentElement;
11370 		} else {
11371 			return this.currentElement.enclosingType();
11372 		}
11373 	}
11374 	return null;
11375 }
dietParse(ICompilationUnit sourceUnit, CompilationResult compilationResult)11376 public CompilationUnitDeclaration dietParse(ICompilationUnit sourceUnit, CompilationResult compilationResult) {
11377 
11378 	CompilationUnitDeclaration parsedUnit;
11379 	boolean old = this.diet;
11380 	int oldInt = this.dietInt;
11381 	try {
11382 		this.dietInt = 0;
11383 		this.diet = true;
11384 		parsedUnit = parse(sourceUnit, compilationResult);
11385 	} finally {
11386 		this.diet = old;
11387 		this.dietInt = oldInt;
11388 	}
11389 	return parsedUnit;
11390 }
dispatchDeclarationInto(int length)11391 protected void dispatchDeclarationInto(int length) {
11392 	/* they are length on this.astStack that should go into
11393 	   methods fields constructors lists of the typeDecl
11394 
11395 	   Return if there is a constructor declaration in the methods declaration */
11396 
11397 
11398 	// Looks for the size of each array .
11399 
11400 	if (length == 0)
11401 		return;
11402 	int[] flag = new int[length + 1]; //plus one -- see <HERE>
11403 	int size1 = 0, size2 = 0, size3 = 0;
11404 	boolean hasAbstractMethods = false;
11405 	for (int i = length - 1; i >= 0; i--) {
11406 		ASTNode astNode = this.astStack[this.astPtr--];
11407 		if (astNode instanceof AbstractMethodDeclaration) {
11408 			//methods and constructors have been regrouped into one single list
11409 			flag[i] = 2;
11410 			size2++;
11411 			if (((AbstractMethodDeclaration) astNode).isAbstract()) {
11412 				hasAbstractMethods = true;
11413 			}
11414 		} else if (astNode instanceof TypeDeclaration) {
11415 			flag[i] = 3;
11416 			size3++;
11417 		} else {
11418 			//field
11419 			flag[i] = 1;
11420 			size1++;
11421 		}
11422 	}
11423 
11424 	//arrays creation
11425 	TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
11426 	if (size1 != 0) {
11427 		typeDecl.fields = new FieldDeclaration[size1];
11428 	}
11429 	if (size2 != 0) {
11430 		typeDecl.methods = new AbstractMethodDeclaration[size2];
11431 		if (hasAbstractMethods) typeDecl.bits |= ASTNode.HasAbstractMethods;
11432 	}
11433 	if (size3 != 0) {
11434 		typeDecl.memberTypes = new TypeDeclaration[size3];
11435 	}
11436 
11437 	//arrays fill up
11438 	size1 = size2 = size3 = 0;
11439 	int flagI = flag[0], start = 0;
11440 	int length2;
11441 	for (int end = 0; end <= length; end++) //<HERE> the plus one allows to
11442 		{
11443 		if (flagI != flag[end]) //treat the last element as a ended flag.....
11444 			{ //array copy
11445 			switch (flagI) {
11446 				case 1 :
11447 					size1 += (length2 = end - start);
11448 					System.arraycopy(
11449 						this.astStack,
11450 						this.astPtr + start + 1,
11451 						typeDecl.fields,
11452 						size1 - length2,
11453 						length2);
11454 					break;
11455 				case 2 :
11456 					size2 += (length2 = end - start);
11457 					System.arraycopy(
11458 						this.astStack,
11459 						this.astPtr + start + 1,
11460 						typeDecl.methods,
11461 						size2 - length2,
11462 						length2);
11463 					break;
11464 				case 3 :
11465 					size3 += (length2 = end - start);
11466 					System.arraycopy(
11467 						this.astStack,
11468 						this.astPtr + start + 1,
11469 						typeDecl.memberTypes,
11470 						size3 - length2,
11471 						length2);
11472 					break;
11473 			}
11474 			flagI = flag[start = end];
11475 		}
11476 	}
11477 
11478 	if (typeDecl.memberTypes != null) {
11479 		for (int i = typeDecl.memberTypes.length - 1; i >= 0; i--) {
11480 			TypeDeclaration memberType = typeDecl.memberTypes[i];
11481 			memberType.enclosingType = typeDecl;
11482 			markNestedRecordStatic(memberType);
11483 		}
11484 	}
11485 }
markNestedRecordStatic(TypeDeclaration typeDeclaration)11486 private void markNestedRecordStatic(TypeDeclaration typeDeclaration) {
11487 	/*
11488 	 * JLS 14 8.10 (Preview)
11489 	 * A nested record type is implicitly static.
11490 	 * It is permitted for the declaration of a nested record type to redundantly specify the static modifier.
11491 	 */
11492 	if (typeDeclaration.isRecord())
11493 		typeDeclaration.modifiers |= ClassFileConstants.AccStatic;
11494 }
dispatchDeclarationIntoEnumDeclaration(int length)11495 protected void dispatchDeclarationIntoEnumDeclaration(int length) {
11496 
11497 	if (length == 0)
11498 		return;
11499 	int[] flag = new int[length + 1]; //plus one -- see <HERE>
11500 	int size1 = 0, size2 = 0, size3 = 0;
11501 	TypeDeclaration enumDeclaration = (TypeDeclaration) this.astStack[this.astPtr - length];
11502 	boolean hasAbstractMethods = false;
11503 	int enumConstantsCounter = 0;
11504 	for (int i = length - 1; i >= 0; i--) {
11505 		ASTNode astNode = this.astStack[this.astPtr--];
11506 		if (astNode instanceof AbstractMethodDeclaration) {
11507 			//methods and constructors have been regrouped into one single list
11508 			flag[i] = 2;
11509 			size2++;
11510 			if (((AbstractMethodDeclaration) astNode).isAbstract()) {
11511 				hasAbstractMethods = true;
11512 			}
11513 		} else if (astNode instanceof TypeDeclaration) {
11514 			flag[i] = 3;
11515 			size3++;
11516 		} else if (astNode instanceof FieldDeclaration) {
11517 			flag[i] = 1;
11518 			size1++;
11519 			if (((FieldDeclaration) astNode).getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) {
11520 				enumConstantsCounter++;
11521 			}
11522 		}
11523 	}
11524 
11525 	//arrays creation
11526 	if (size1 != 0) {
11527 		enumDeclaration.fields = new FieldDeclaration[size1];
11528 	}
11529 	if (size2 != 0) {
11530 		enumDeclaration.methods = new AbstractMethodDeclaration[size2];
11531 		if (hasAbstractMethods) enumDeclaration.bits |= ASTNode.HasAbstractMethods;
11532 	}
11533 	if (size3 != 0) {
11534 		enumDeclaration.memberTypes = new TypeDeclaration[size3];
11535 	}
11536 
11537 	//arrays fill up
11538 	size1 = size2 = size3 = 0;
11539 	int flagI = flag[0], start = 0;
11540 	int length2;
11541 	for (int end = 0; end <= length; end++) //<HERE> the plus one allows to
11542 	{
11543 		if (flagI != flag[end]) //treat the last element as a ended flag.....
11544 		{ //array copy
11545 			switch (flagI) {
11546 				case 1 :
11547 					size1 += (length2 = end - start);
11548 					System.arraycopy(
11549 							this.astStack,
11550 							this.astPtr + start + 1,
11551 							enumDeclaration.fields,
11552 							size1 - length2,
11553 							length2);
11554 					break;
11555 				case 2 :
11556 					size2 += (length2 = end - start);
11557 					System.arraycopy(
11558 							this.astStack,
11559 							this.astPtr + start + 1,
11560 							enumDeclaration.methods,
11561 							size2 - length2,
11562 							length2);
11563 					break;
11564 				case 3 :
11565 					size3 += (length2 = end - start);
11566 					System.arraycopy(
11567 							this.astStack,
11568 							this.astPtr + start + 1,
11569 							enumDeclaration.memberTypes,
11570 							size3 - length2,
11571 							length2);
11572 					break;
11573 			}
11574 			flagI = flag[start = end];
11575 		}
11576 	}
11577 
11578 	if (enumDeclaration.memberTypes != null) {
11579 		for (int i = enumDeclaration.memberTypes.length - 1; i >= 0; i--) {
11580 			enumDeclaration.memberTypes[i].enclosingType = enumDeclaration;
11581 		}
11582 	}
11583 	enumDeclaration.enumConstantsCounter = enumConstantsCounter;
11584 }
endParse(int act)11585 protected CompilationUnitDeclaration endParse(int act) {
11586 
11587 	this.lastAct = act;
11588 
11589 	if(this.statementRecoveryActivated) {
11590 		RecoveredElement recoveredElement = buildInitialRecoveryState();
11591 
11592 		if (recoveredElement != null) {
11593 			recoveredElement.topElement().updateParseTree();
11594 		}
11595 
11596 		if(this.hasError) resetStacks();
11597 	} else if (this.currentElement != null){
11598 		if (VERBOSE_RECOVERY){
11599 			System.out.print(Messages.parser_syntaxRecovery);
11600 			System.out.println("--------------------------");		 //$NON-NLS-1$
11601 			System.out.println(this.compilationUnit);
11602 			System.out.println("----------------------------------"); //$NON-NLS-1$
11603 		}
11604 		this.currentElement.topElement().updateParseTree();
11605 	} else {
11606 		if (this.diet & VERBOSE_RECOVERY){
11607 			System.out.print(Messages.parser_regularParse);
11608 			System.out.println("--------------------------");	 //$NON-NLS-1$
11609 			System.out.println(this.compilationUnit);
11610 			System.out.println("----------------------------------"); //$NON-NLS-1$
11611 		}
11612 	}
11613 	persistLineSeparatorPositions();
11614 	for (int i = 0; i < this.scanner.foundTaskCount; i++){
11615 		if(!this.statementRecoveryActivated) problemReporter().task(
11616 			new String(this.scanner.foundTaskTags[i]),
11617 			new String(this.scanner.foundTaskMessages[i]),
11618 			this.scanner.foundTaskPriorities[i] == null ? null : new String(this.scanner.foundTaskPriorities[i]),
11619 			this.scanner.foundTaskPositions[i][0],
11620 			this.scanner.foundTaskPositions[i][1]);
11621 	}
11622 	this.javadoc = null;
11623 	return this.compilationUnit;
11624 }
11625 /*
11626  * Flush comments defined prior to a given positions.
11627  *
11628  * Note: comments are stacked in syntactical order
11629  *
11630  * Either answer given <position>, or the end position of a comment line
11631  * immediately following the <position> (same line)
11632  *
11633  * e.g.
11634  * void foo(){
11635  * } // end of method foo
11636  */
flushCommentsDefinedPriorTo(int position)11637 public int flushCommentsDefinedPriorTo(int position) {
11638 
11639 	int lastCommentIndex = this.scanner.commentPtr;
11640 	if (lastCommentIndex < 0) return position; // no comment
11641 
11642 	// compute the index of the first obsolete comment
11643 	int index = lastCommentIndex;
11644 	int validCount = 0;
11645 	while (index >= 0){
11646 		int commentEnd = this.scanner.commentStops[index];
11647 		if (commentEnd < 0) commentEnd = -commentEnd; // negative end position for non-javadoc comments
11648 		if (commentEnd <= position){
11649 			break;
11650 		}
11651 		index--;
11652 		validCount++;
11653 	}
11654 	// if the source at <position> is immediately followed by a line comment, then
11655 	// flush this comment and shift <position> to the comment end.
11656 	if (validCount > 0){
11657 		int immediateCommentEnd = -this.scanner.commentStops[index+1]; //non-javadoc comment end positions are negative
11658 		if (immediateCommentEnd > 0){ // only tolerating non-javadoc comments
11659 			// is there any line break until the end of the immediate comment ? (thus only tolerating line comment)
11660 			immediateCommentEnd--; // comment end in one char too far
11661 			if (Util.getLineNumber(position, this.scanner.lineEnds, 0, this.scanner.linePtr)
11662 					== Util.getLineNumber(immediateCommentEnd, this.scanner.lineEnds, 0, this.scanner.linePtr)){
11663 				position = immediateCommentEnd;
11664 				validCount--; // flush this comment
11665 				index++;
11666 			}
11667 		}
11668 	}
11669 
11670 	if (index < 0) return position; // no obsolete comment
11671 
11672 	switch (validCount) {
11673 		case 0:
11674 			// do nothing
11675 			break;
11676 		// move valid comment infos, overriding obsolete comment infos
11677 		case 2:
11678 			this.scanner.commentStarts[0] = this.scanner.commentStarts[index+1];
11679 			this.scanner.commentStops[0] = this.scanner.commentStops[index+1];
11680 			this.scanner.commentTagStarts[0] = this.scanner.commentTagStarts[index+1];
11681 			this.scanner.commentStarts[1] = this.scanner.commentStarts[index+2];
11682 			this.scanner.commentStops[1] = this.scanner.commentStops[index+2];
11683 			this.scanner.commentTagStarts[1] = this.scanner.commentTagStarts[index+2];
11684 			break;
11685 		case 1:
11686 			this.scanner.commentStarts[0] = this.scanner.commentStarts[index+1];
11687 			this.scanner.commentStops[0] = this.scanner.commentStops[index+1];
11688 			this.scanner.commentTagStarts[0] = this.scanner.commentTagStarts[index+1];
11689 			break;
11690 		default:
11691 			System.arraycopy(this.scanner.commentStarts, index + 1, this.scanner.commentStarts, 0, validCount);
11692 			System.arraycopy(this.scanner.commentStops, index + 1, this.scanner.commentStops, 0, validCount);
11693 			System.arraycopy(this.scanner.commentTagStarts, index + 1, this.scanner.commentTagStarts, 0, validCount);
11694 	}
11695 	this.scanner.commentPtr = validCount - 1;
11696 	return position;
11697 }
11698 
getAnnotationType()11699 protected TypeReference getAnnotationType() {
11700 	int length = this.identifierLengthStack[this.identifierLengthPtr--];
11701 	if (length == 1) {
11702 		return new SingleTypeReference(
11703 				this.identifierStack[this.identifierPtr],
11704 				this.identifierPositionStack[this.identifierPtr--]);
11705 	} else {
11706 		char[][] tokens = new char[length][];
11707 		this.identifierPtr -= length;
11708 		long[] positions = new long[length];
11709 		System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
11710 		System.arraycopy(
11711 			this.identifierPositionStack,
11712 			this.identifierPtr + 1,
11713 			positions,
11714 			0,
11715 			length);
11716 		return new QualifiedTypeReference(tokens, positions);
11717 	}
11718 }
getFirstToken()11719 public int getFirstToken() {
11720 	// the first token is a virtual token that
11721 	// allows the parser to parse several goals
11722 	// even if they aren't LALR(1)....
11723 	// Goal ::= '++' CompilationUnit
11724 	// Goal ::= '--' MethodBody
11725 	// Goal ::= '==' ConstructorBody
11726 	// -- Initializer
11727 	// Goal ::= '>>' StaticInitializer
11728 	// Goal ::= '>>' Block
11729 	// -- error recovery
11730 	// Goal ::= '>>>' Headers
11731 	// Goal ::= '*' BlockStatements
11732 	// Goal ::= '*' MethodPushModifiersHeader
11733 	// -- JDOM
11734 	// Goal ::= '&&' FieldDeclaration
11735 	// Goal ::= '||' ImportDeclaration
11736 	// Goal ::= '?' PackageDeclaration
11737 	// Goal ::= '+' TypeDeclaration
11738 	// Goal ::= '/' GenericMethodDeclaration
11739 	// Goal ::= '&' ClassBodyDeclaration
11740 	// -- code snippet
11741 	// Goal ::= '%' Expression
11742 	// -- completion parser
11743 	// Goal ::= '!' ConstructorBlockStatementsopt
11744 	// Goal ::= '~' BlockStatementsopt
11745 
11746 	return this.firstToken;
11747 }
11748 /*
11749  * Answer back an array of sourceStart/sourceEnd positions of the available JavaDoc comments.
11750  * The array is a flattened structure: 2*n entries with consecutives start and end positions.
11751  *
11752  * If no JavaDoc is available, then null is answered instead of an empty array.
11753  *
11754  * e.g. { 10, 20, 25, 45 }  --> javadoc1 from 10 to 20, javadoc2 from 25 to 45
11755  */
getJavaDocPositions()11756 public int[] getJavaDocPositions() {
11757 
11758 	int javadocCount = 0;
11759 	int max = this.scanner.commentPtr;
11760 	for (int i = 0; i <= max; i++){
11761 		// javadoc only (non javadoc comment have negative start and/or end positions.)
11762 		if (this.scanner.commentStarts[i] >= 0 && this.scanner.commentStops[i] > 0) {
11763 			javadocCount++;
11764 		}
11765 	}
11766 	if (javadocCount == 0) return null;
11767 
11768 	int[] positions = new int[2*javadocCount];
11769 	int index = 0;
11770 	for (int i = 0; i <= max; i++){
11771 		// javadoc only (non javadoc comment have negative start and/or end positions.)
11772 		int commentStart = this.scanner.commentStarts[i];
11773 		if (commentStart >= 0) {
11774 			int commentStop = this.scanner.commentStops[i];
11775 			if (commentStop > 0){
11776 				positions[index++] = commentStart;
11777 				positions[index++] = commentStop-1; //stop is one over
11778 			}
11779 		}
11780 	}
11781 	return positions;
11782 }
getMethodBodies(CompilationUnitDeclaration unit)11783 public void getMethodBodies(CompilationUnitDeclaration unit) {
11784 	//fill the methods bodies in order for the code to be generated
11785 
11786 	if (unit == null) return;
11787 
11788 	if (unit.ignoreMethodBodies) {
11789 		unit.ignoreFurtherInvestigation = true;
11790 		return;
11791 		// if initial diet parse did not work, no need to dig into method bodies.
11792 	}
11793 
11794 	if ((unit.bits & ASTNode.HasAllMethodBodies) != 0)
11795 		return; //work already done ...
11796 
11797 	// save existing values to restore them at the end of the parsing process
11798 	// see bug 47079 for more details
11799 	int[] oldLineEnds = this.scanner.lineEnds;
11800 	int oldLinePtr = this.scanner.linePtr;
11801 
11802 	//real parse of the method....
11803 	CompilationResult compilationResult = unit.compilationResult;
11804 	char[] contents = this.readManager != null
11805 		? this.readManager.getContents(compilationResult.compilationUnit)
11806 		: compilationResult.compilationUnit.getContents();
11807 	this.scanner.setSource(contents, compilationResult);
11808 
11809 	if (this.javadocParser != null && this.javadocParser.checkDocComment) {
11810 		this.javadocParser.scanner.setSource(contents);
11811 	}
11812 	if (unit.types != null) {
11813 		for (int i = 0, length = unit.types.length; i < length; i++)
11814 			unit.types[i].parseMethods(this, unit);
11815 	}
11816 
11817 	// tag unit has having read bodies
11818 	unit.bits |= ASTNode.HasAllMethodBodies;
11819 
11820 	// this is done to prevent any side effects on the compilation unit result
11821 	// line separator positions array.
11822 	this.scanner.lineEnds = oldLineEnds;
11823 	this.scanner.linePtr = oldLinePtr;
11824 }
getNextCharacter(char[] comment, int[] index)11825 	protected char getNextCharacter(char[] comment, int[] index) {
11826 		char nextCharacter = comment[index[0]++];
11827 		switch(nextCharacter) {
11828 			case '\\' :
11829 				int c1, c2, c3, c4;
11830 				index[0]++;
11831 				while (comment[index[0]] == 'u') index[0]++;
11832 				if (!(((c1 = ScannerHelper.getHexadecimalValue(comment[index[0]++])) > 15
11833 					|| c1 < 0)
11834 					|| ((c2 = ScannerHelper.getHexadecimalValue(comment[index[0]++])) > 15 || c2 < 0)
11835 					|| ((c3 = ScannerHelper.getHexadecimalValue(comment[index[0]++])) > 15 || c3 < 0)
11836 					|| ((c4 = ScannerHelper.getHexadecimalValue(comment[index[0]++])) > 15 || c4 < 0))) {
11837 						nextCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
11838 				}
11839 				break;
11840 		}
11841 		return nextCharacter;
11842 	}
getTypeReference(Expression exp)11843 protected Expression getTypeReference(Expression exp) {
11844 
11845 	exp.bits &= ~ASTNode.RestrictiveFlagMASK;
11846 	exp.bits |= Binding.TYPE;
11847 	return exp;
11848 }
annotateTypeReference(Wildcard ref)11849 protected void annotateTypeReference(Wildcard ref) {
11850 	int length;
11851 	if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
11852 		if (ref.annotations == null)
11853 			ref.annotations = new Annotation[ref.getAnnotatableLevels()][];
11854 		System.arraycopy(
11855 				this.typeAnnotationStack,
11856 				(this.typeAnnotationPtr -= length) + 1,
11857 				ref.annotations[0] = new Annotation[length],
11858 				0,
11859 				length);
11860 		if (ref.sourceStart > ref.annotations[0][0].sourceStart) {
11861 			ref.sourceStart = ref.annotations[0][0].sourceStart;
11862 		}
11863 		ref.bits |= ASTNode.HasTypeAnnotations;
11864 	}
11865 	if (ref.bound != null) {
11866 		ref.bits |= (ref.bound.bits & ASTNode.HasTypeAnnotations);
11867 	}
11868 }
getTypeReference(int dim)11869 protected TypeReference getTypeReference(int dim) {
11870 	/* build a Reference on a variable that may be qualified or not
11871 	 This variable is a type reference and dim will be its dimensions*/
11872 
11873 	TypeReference ref;
11874 	Annotation [][] annotationsOnDimensions = null;
11875 	int length = this.identifierLengthStack[this.identifierLengthPtr--];
11876 	if (length < 0) { //flag for precompiled type reference on base types
11877 		if (dim > 0) {
11878 			annotationsOnDimensions = getAnnotationsOnDimensions(dim);
11879 		}
11880 		ref = TypeReference.baseTypeReference(-length, dim, annotationsOnDimensions);
11881 		ref.sourceStart = this.intStack[this.intPtr--];
11882 		if (dim == 0) {
11883 			ref.sourceEnd = this.intStack[this.intPtr--];
11884 		} else {
11885 			this.intPtr--;
11886 			ref.sourceEnd = this.rBracketPosition;
11887 		}
11888 	} else {
11889 		int numberOfIdentifiers = this.genericsIdentifiersLengthStack[this.genericsIdentifiersLengthPtr--];
11890 		if (length != numberOfIdentifiers || this.genericsLengthStack[this.genericsLengthPtr] != 0) {
11891 			// generic type
11892 			ref = getTypeReferenceForGenericType(dim, length, numberOfIdentifiers);
11893 		} else if (length == 1) {
11894 			// single type reference
11895 			this.genericsLengthPtr--; // pop the 0
11896 			if (dim == 0) {
11897 				ref =
11898 					new SingleTypeReference(
11899 						this.identifierStack[this.identifierPtr],
11900 						this.identifierPositionStack[this.identifierPtr--]);
11901 			} else {
11902 				annotationsOnDimensions = getAnnotationsOnDimensions(dim);
11903 				ref =
11904 					new ArrayTypeReference(
11905 						this.identifierStack[this.identifierPtr],
11906 						dim,
11907 						annotationsOnDimensions,
11908 						this.identifierPositionStack[this.identifierPtr--]);
11909 				ref.sourceEnd = this.endPosition;
11910 				if (annotationsOnDimensions != null) {
11911 					ref.bits |= ASTNode.HasTypeAnnotations;
11912 				}
11913 			}
11914 		} else {
11915 			this.genericsLengthPtr--;
11916 			//Qualified type reference
11917 			char[][] tokens = new char[length][];
11918 			this.identifierPtr -= length;
11919 			long[] positions = new long[length];
11920 			System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
11921 			System.arraycopy(
11922 				this.identifierPositionStack,
11923 				this.identifierPtr + 1,
11924 				positions,
11925 				0,
11926 				length);
11927 			if (dim == 0) {
11928 				ref = new QualifiedTypeReference(tokens, positions);
11929 			} else {
11930 				annotationsOnDimensions = getAnnotationsOnDimensions(dim);
11931 				ref = new ArrayQualifiedTypeReference(tokens, dim, annotationsOnDimensions, positions);
11932 				ref.sourceEnd = this.endPosition;
11933 				if (annotationsOnDimensions != null) {
11934 					ref.bits |= ASTNode.HasTypeAnnotations;
11935 				}
11936 			}
11937 		}
11938 	}
11939 	int levels = ref.getAnnotatableLevels();
11940 	for (int i = levels - 1; i >= 0; i--) {
11941 		if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
11942 			if (ref.annotations == null)
11943 				ref.annotations = new Annotation[levels][];
11944 			System.arraycopy(
11945 					this.typeAnnotationStack,
11946 					(this.typeAnnotationPtr -= length) + 1,
11947 					ref.annotations[i] = new Annotation[length],
11948 					0,
11949 					length);
11950 			if (i == 0) {
11951 				ref.sourceStart = ref.annotations[0][0].sourceStart;
11952 			}
11953 			ref.bits |= ASTNode.HasTypeAnnotations;
11954 		}
11955 	}
11956 	return ref;
11957 }
getTypeReferenceForGenericType(int dim, int identifierLength, int numberOfIdentifiers)11958 protected TypeReference getTypeReferenceForGenericType(int dim, int identifierLength, int numberOfIdentifiers) {
11959 	Annotation[][] annotationsOnDimensions = dim == 0 ? null : getAnnotationsOnDimensions(dim);
11960 	if (identifierLength == 1 && numberOfIdentifiers == 1) {
11961 		int currentTypeArgumentsLength = this.genericsLengthStack[this.genericsLengthPtr--];
11962 		TypeReference[] typeArguments = null;
11963 		if (currentTypeArgumentsLength < 0) {
11964 			typeArguments = TypeReference.NO_TYPE_ARGUMENTS;
11965 		} else {
11966 			typeArguments = new TypeReference[currentTypeArgumentsLength];
11967 			this.genericsPtr -= currentTypeArgumentsLength;
11968 			System.arraycopy(this.genericsStack, this.genericsPtr + 1, typeArguments, 0, currentTypeArgumentsLength);
11969 		}
11970 		ParameterizedSingleTypeReference parameterizedSingleTypeReference = new ParameterizedSingleTypeReference(this.identifierStack[this.identifierPtr], typeArguments, dim, annotationsOnDimensions, this.identifierPositionStack[this.identifierPtr--]);
11971 		if (dim != 0) {
11972 			parameterizedSingleTypeReference.sourceEnd = this.endStatementPosition;
11973 		}
11974 		/* We used to eagerly mark the PSTR as constituting diamond usage if we encountered <>, but that is too eager and
11975 		   complicates error handling by making it hard to distinguish legitimate use cases from ill formed ones. We are
11976 		   more discriminating now and tag a type as being diamond only where <> can legally occur.
11977 		   See https://bugs.eclipse.org/bugs/show_bug.cgi?id=339478#c11
11978 		*/
11979 		return parameterizedSingleTypeReference;
11980 	} else {
11981 		TypeReference[][] typeArguments = new TypeReference[numberOfIdentifiers][];
11982 		char[][] tokens = new char[numberOfIdentifiers][];
11983 		long[] positions = new long[numberOfIdentifiers];
11984 		int index = numberOfIdentifiers;
11985 		int currentIdentifiersLength = identifierLength;
11986 		while (index > 0) {
11987 			int currentTypeArgumentsLength = this.genericsLengthStack[this.genericsLengthPtr--];
11988 			if (currentTypeArgumentsLength > 0) {
11989 				this.genericsPtr -= currentTypeArgumentsLength;
11990 				System.arraycopy(this.genericsStack, this.genericsPtr + 1, typeArguments[index - 1] = new TypeReference[currentTypeArgumentsLength], 0, currentTypeArgumentsLength);
11991 			} else if (currentTypeArgumentsLength < 0) {
11992 				// diamond case for qualified type reference (java.util.ArrayList<>)
11993 				typeArguments[index - 1] = TypeReference.NO_TYPE_ARGUMENTS;
11994 			}
11995 			switch(currentIdentifiersLength) {
11996 				case 1 :
11997 					// we are in a case A<B>.C<D> or A<B>.C<D>
11998 					tokens[index - 1] = this.identifierStack[this.identifierPtr];
11999 					positions[index - 1] = this.identifierPositionStack[this.identifierPtr--];
12000 					break;
12001 				default:
12002 					// we are in a case A.B.C<B>.C<D> or A.B.C<B>...
12003 					this.identifierPtr -= currentIdentifiersLength;
12004 					System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, index - currentIdentifiersLength, currentIdentifiersLength);
12005 					System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, index - currentIdentifiersLength, currentIdentifiersLength);
12006 			}
12007 			index -= currentIdentifiersLength;
12008 			if (index > 0) {
12009 				currentIdentifiersLength = this.identifierLengthStack[this.identifierLengthPtr--];
12010 			}
12011 		}
12012 		ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference = new ParameterizedQualifiedTypeReference(tokens, typeArguments, dim, annotationsOnDimensions, positions);
12013 		if (dim != 0) {
12014 			parameterizedQualifiedTypeReference.sourceEnd = this.endStatementPosition;
12015 		}
12016 		/* We used to eagerly mark the PQTR as constituting diamond usage if we encountered <>, but that is too eager and
12017 		   complicates error handling by making it hard to distinguish legitimate use cases from ill formed ones. We are
12018 		   more discriminating now and tag a type as being diamond only where <> can legally occur.
12019 		   See https://bugs.eclipse.org/bugs/show_bug.cgi?id=339478#c11
12020 		*/
12021 		return parameterizedQualifiedTypeReference;
12022 	}
12023 }
getUnspecifiedReference()12024 protected NameReference getUnspecifiedReference() {
12025 	return getUnspecifiedReference(true);
12026 }
getUnspecifiedReference(boolean rejectTypeAnnotations)12027 protected NameReference getUnspecifiedReference(boolean rejectTypeAnnotations) {
12028 	/* build a (unspecified) NameReference which may be qualified*/
12029 	if (rejectTypeAnnotations) { // Compensate for overpermissive grammar.
12030 		consumeNonTypeUseName();
12031 	}
12032 	int length;
12033 	NameReference ref;
12034 	if ((length = this.identifierLengthStack[this.identifierLengthPtr--]) == 1)
12035 		// single variable reference
12036 		ref =
12037 			new SingleNameReference(
12038 				this.identifierStack[this.identifierPtr],
12039 				this.identifierPositionStack[this.identifierPtr--]);
12040 	else
12041 		//Qualified variable reference
12042 		{
12043 		char[][] tokens = new char[length][];
12044 		this.identifierPtr -= length;
12045 		System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
12046 		long[] positions = new long[length];
12047 		System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
12048 		ref =
12049 			new QualifiedNameReference(tokens,
12050 				positions,
12051 				(int) (this.identifierPositionStack[this.identifierPtr + 1] >> 32), // sourceStart
12052 				(int) this.identifierPositionStack[this.identifierPtr + length]); // sourceEnd
12053 	}
12054 	return ref;
12055 }
getUnspecifiedReferenceOptimized()12056 protected NameReference getUnspecifiedReferenceOptimized() {
12057 	/* build a (unspecified) NameReference which may be qualified
12058 	The optimization occurs for qualified reference while we are
12059 	certain in this case the last item of the qualified name is
12060 	a field access. This optimization is IMPORTANT while it results
12061 	that when a NameReference is build, the type checker should always
12062 	look for that it is not a type reference */
12063 	consumeNonTypeUseName();
12064 	int length;
12065 	NameReference ref;
12066 	if ((length = this.identifierLengthStack[this.identifierLengthPtr--]) == 1) {
12067 		// single variable reference
12068 		ref =
12069 			new SingleNameReference(
12070 				this.identifierStack[this.identifierPtr],
12071 				this.identifierPositionStack[this.identifierPtr--]);
12072 		ref.bits &= ~ASTNode.RestrictiveFlagMASK;
12073 		ref.bits |= Binding.LOCAL | Binding.FIELD;
12074 		return ref;
12075 	}
12076 
12077 	//Qualified-variable-reference
12078 	//In fact it is variable-reference DOT field-ref , but it would result in a type
12079 	//conflict tha can be only reduce by making a superclass (or inetrface ) between
12080 	//nameReference and FiledReference or putting FieldReference under NameReference
12081 	//or else..........This optimisation is not really relevant so just leave as it is
12082 
12083 	char[][] tokens = new char[length][];
12084 	this.identifierPtr -= length;
12085 	System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
12086 	long[] positions = new long[length];
12087 	System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
12088 	ref = new QualifiedNameReference(
12089 			tokens,
12090 			positions,
12091 			(int) (this.identifierPositionStack[this.identifierPtr + 1] >> 32), // sourceStart
12092 			(int) this.identifierPositionStack[this.identifierPtr + length]); // sourceEnd
12093 	ref.bits &= ~ASTNode.RestrictiveFlagMASK;
12094 	ref.bits |= Binding.LOCAL | Binding.FIELD;
12095 	return ref;
12096 }
goForBlockStatementsopt()12097 public void goForBlockStatementsopt() {
12098 	//tells the scanner to go for block statements opt parsing
12099 
12100 	this.firstToken = TokenNameTWIDDLE;
12101 	this.scanner.recordLineSeparator = false;
12102 }
goForBlockStatementsOrCatchHeader()12103 public void goForBlockStatementsOrCatchHeader() {
12104 	//tells the scanner to go for block statements or method headers parsing
12105 
12106 	this.firstToken = TokenNameMULTIPLY;
12107 	this.scanner.recordLineSeparator = false;
12108 }
goForClassBodyDeclarations()12109 public void goForClassBodyDeclarations() {
12110 	//tells the scanner to go for any body declarations parsing
12111 
12112 	this.firstToken = TokenNameAND;
12113 	this.scanner.recordLineSeparator = true;
12114 }
goForCompilationUnit()12115 public void goForCompilationUnit(){
12116 	//tells the scanner to go for compilation unit parsing
12117 
12118 	this.firstToken = TokenNamePLUS_PLUS ;
12119 	this.scanner.foundTaskCount = 0;
12120 	this.scanner.recordLineSeparator = true;
12121 }
goForExpression(boolean recordLineSeparator)12122 public void goForExpression(boolean recordLineSeparator) {
12123 	//tells the scanner to go for an expression parsing
12124 
12125 	this.firstToken = TokenNameREMAINDER;
12126 	this.scanner.recordLineSeparator = recordLineSeparator; // recovery goals must record line separators
12127 }
goForFieldDeclaration()12128 public void goForFieldDeclaration(){
12129 	//tells the scanner to go for field declaration parsing
12130 
12131 	this.firstToken = TokenNameAND_AND ;
12132 	this.scanner.recordLineSeparator = true;
12133 }
goForGenericMethodDeclaration()12134 public void goForGenericMethodDeclaration(){
12135 	//tells the scanner to go for generic method declarations parsing
12136 
12137 	this.firstToken = TokenNameDIVIDE;
12138 	this.scanner.recordLineSeparator = true;
12139 }
goForHeaders()12140 public void goForHeaders(){
12141 	//tells the scanner to go for headers only parsing
12142 	RecoveredType currentType = currentRecoveryType();
12143 	if(currentType != null && currentType.insideEnumConstantPart) {
12144 		this.firstToken = TokenNameNOT;
12145 	} else {
12146 		this.firstToken = TokenNameUNSIGNED_RIGHT_SHIFT;
12147 	}
12148 	this.scanner.recordLineSeparator = true; // recovery goals must record line separators
12149 	this.scanner.scanContext = null;
12150 }
goForImportDeclaration()12151 public void goForImportDeclaration(){
12152 	//tells the scanner to go for import declaration parsing
12153 
12154 	this.firstToken = TokenNameOR_OR ;
12155 	this.scanner.recordLineSeparator = true;
12156 }
goForInitializer()12157 public void goForInitializer(){
12158 	//tells the scanner to go for initializer parsing
12159 
12160 	this.firstToken = TokenNameRIGHT_SHIFT ;
12161 	this.scanner.recordLineSeparator = false;
12162 }
goForMemberValue()12163 public void goForMemberValue() {
12164 	//tells the scanner to go for a member value parsing
12165 
12166 	this.firstToken = TokenNameOR_OR;
12167 	this.scanner.recordLineSeparator = true; // recovery goals must record line separators
12168 }
goForMethodBody()12169 public void goForMethodBody(){
12170 	//tells the scanner to go for method body parsing
12171 
12172 	this.firstToken = TokenNameMINUS_MINUS ;
12173 	this.scanner.recordLineSeparator = false;
12174 }
goForPackageDeclaration()12175 public void goForPackageDeclaration() {
12176 	goForPackageDeclaration(true);
12177 }
goForPackageDeclaration(boolean recordLineSeparators)12178 public void goForPackageDeclaration(boolean recordLineSeparators) {
12179 	//tells the scanner to go for package declaration parsing
12180 
12181 	this.firstToken = TokenNameQUESTION;
12182 	this.scanner.recordLineSeparator = recordLineSeparators;
12183 }
goForTypeDeclaration()12184 public void goForTypeDeclaration() {
12185 	//tells the scanner to go for type (interface or class) declaration parsing
12186 
12187 	this.firstToken = TokenNamePLUS;
12188 	this.scanner.recordLineSeparator = true;
12189 }
12190 /**
12191  * Look for a specific tag comment leading a given source range (comment located after any statement in astStack)
12192  * @param rangeEnd int
12193  * @return boolean
12194  */
hasLeadingTagComment(char[] commentPrefixTag, int rangeEnd)12195 public boolean hasLeadingTagComment(char[] commentPrefixTag, int rangeEnd) {
12196 	int iComment = this.scanner.commentPtr;
12197 	if (iComment < 0) return false; // no comment available
12198 	int iStatement = this.astLengthPtr;
12199 	if (iStatement < 0 || this.astLengthStack[iStatement] <= 1) return false; // no statement available
12200 	// Fallthrough comment must be located after the previous statement
12201 	ASTNode lastNode = this.astStack[this.astPtr];
12202 	int rangeStart = lastNode.sourceEnd;
12203 	previousComment: for (; iComment >= 0; iComment--) {
12204 		int commentStart = this.scanner.commentStarts[iComment];
12205 		if (commentStart < 0) commentStart = -commentStart; // line comments have negative start positions
12206 		// ignore comments before start
12207 		if (commentStart < rangeStart) return false; // no more comments in range
12208 		// ignore comments after end
12209 		if (commentStart > rangeEnd) continue previousComment;
12210 		// found last comment in range - only check the last comment in range
12211 		char[] source = this.scanner.source;
12212 		int charPos = commentStart+2; // skip // or /*
12213 		// tag can be leaded by optional spaces
12214 		for (; charPos < rangeEnd; charPos++) {
12215 			char c = source[charPos];
12216 			if (c >= ScannerHelper.MAX_OBVIOUS || (ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[c] & ScannerHelper.C_JLS_SPACE) == 0) {
12217 				break;
12218 			}
12219 		}
12220 		for (int iTag = 0, length = commentPrefixTag.length; iTag < length; iTag++, charPos++) {
12221 			if (charPos >= rangeEnd // comment is too small to host tag
12222 					|| source[charPos] != commentPrefixTag[iTag]) {
12223 				if (iTag == 0) {
12224 					return false; // didn't even match leading '$' -> not a tag comment
12225 				} else {
12226 					continue previousComment; // accept as tag comment -> skip it and keep searching backwards
12227 				}
12228 			}
12229 		}
12230 		return true;
12231 	}
12232 	return false;
12233 }
12234 
ignoreNextClosingBrace()12235 protected void ignoreNextClosingBrace() {
12236 	this.ignoreNextClosingBrace = true;
12237 }
12238 
ignoreExpressionAssignment()12239 protected void ignoreExpressionAssignment() {
12240 	// Assignment ::= InvalidArrayInitializerAssignement
12241 	// encoded operator would be: this.intStack[this.intPtr]
12242 	this.intPtr--;
12243 	ArrayInitializer arrayInitializer = (ArrayInitializer) this.expressionStack[this.expressionPtr--];
12244 	this.expressionLengthPtr -- ;
12245 	// report a syntax error and abort parsing
12246 	if(!this.statementRecoveryActivated) problemReporter().arrayConstantsOnlyInArrayInitializers(arrayInitializer.sourceStart, arrayInitializer.sourceEnd);
12247 }
initialize()12248 public void initialize() {
12249 	this.initialize(false);
12250 }
initialize(boolean parsingCompilationUnit)12251 public void initialize(boolean parsingCompilationUnit) {
12252 	//positioning the parser for a new compilation unit
12253 	//avoiding stack reallocation and all that....
12254 	this.javadoc = null;
12255 	this.astPtr = -1;
12256 	this.astLengthPtr = -1;
12257 	this.patternPtr = -1;
12258 	this.patternLengthPtr = -1;
12259 	this.expressionPtr = -1;
12260 	this.expressionLengthPtr = -1;
12261 	this.typeAnnotationLengthPtr = -1;
12262 	this.typeAnnotationPtr = -1;
12263 	this.identifierPtr = -1;
12264 	this.identifierLengthPtr	= -1;
12265 	this.intPtr = -1;
12266 	this.nestedMethod[this.nestedType = 0] = 0; // need to reset for further reuse
12267 	this.switchNestingLevel = 0;
12268 	this.switchWithTry = false;
12269 	this.variablesCounter[this.nestedType] = 0;
12270 	this.dimensions = 0 ;
12271 	this.realBlockPtr = -1;
12272 	this.compilationUnit = null;
12273 	this.referenceContext = null;
12274 	this.endStatementPosition = 0;
12275 	this.valueLambdaNestDepth = -1;
12276 
12277 	//remove objects from stack too, while the same parser/compiler couple is
12278 	//re-used between two compilations ....
12279 
12280 	int astLength = this.astStack.length;
12281 	if (this.noAstNodes.length < astLength){
12282 		this.noAstNodes = new ASTNode[astLength];
12283 		//System.out.println("Resized AST stacks : "+ astLength);
12284 
12285 	}
12286 	System.arraycopy(this.noAstNodes, 0, this.astStack, 0, astLength);
12287 
12288 	int expressionLength = this.expressionStack.length;
12289 	if (this.noExpressions.length < expressionLength){
12290 		this.noExpressions = new Expression[expressionLength];
12291 		//System.out.println("Resized EXPR stacks : "+ expressionLength);
12292 	}
12293 	System.arraycopy(this.noExpressions, 0, this.expressionStack, 0, expressionLength);
12294 
12295 	// reset this.scanner state
12296 	this.scanner.commentPtr = -1;
12297 	this.scanner.foundTaskCount = 0;
12298 	this.scanner.eofPosition = Integer.MAX_VALUE;
12299 	this.recordStringLiterals = true;
12300 	final boolean checkNLS = this.options.getSeverity(CompilerOptions.NonExternalizedString) != ProblemSeverities.Ignore;
12301 	this.checkExternalizeStrings = checkNLS;
12302 	this.scanner.checkNonExternalizedStringLiterals = parsingCompilationUnit && checkNLS;
12303 	this.scanner.checkUninternedIdentityComparison = parsingCompilationUnit && this.options.complainOnUninternedIdentityComparison;
12304 	this.scanner.lastPosition = -1;
12305 
12306 	resetModifiers();
12307 
12308 	// recovery
12309 	this.lastCheckPoint = -1;
12310 	this.currentElement = null;
12311 	this.restartRecovery = false;
12312 	this.hasReportedError = false;
12313 	this.recoveredStaticInitializerStart = 0;
12314 	this.lastIgnoredToken = -1;
12315 	this.lastErrorEndPosition = -1;
12316 	this.lastErrorEndPositionBeforeRecovery = -1;
12317 	this.lastJavadocEnd = -1;
12318 	this.listLength = 0;
12319 	this.listTypeParameterLength = 0;
12320 	this.lastPosistion = -1;
12321 
12322 	this.rBraceStart = 0;
12323 	this.rBraceEnd = 0;
12324 	this.rBraceSuccessorStart = 0;
12325 	this.rBracketPosition = 0;
12326 
12327 	this.genericsIdentifiersLengthPtr = -1;
12328 	this.genericsLengthPtr = -1;
12329 	this.genericsPtr = -1;
12330 }
initializeScanner()12331 public void initializeScanner(){
12332 	this.scanner = new Scanner(
12333 		false /*comment*/,
12334 		false /*whitespace*/,
12335 		false, /* will be set in initialize(boolean) */
12336 		this.options.sourceLevel /*sourceLevel*/,
12337 		this.options.complianceLevel /*complianceLevel*/,
12338 		this.options.taskTags/*taskTags*/,
12339 		this.options.taskPriorities/*taskPriorities*/,
12340 		this.options.isTaskCaseSensitive/*taskCaseSensitive*/,
12341 		this.options.enablePreviewFeatures /*isPreviewEnabled*/);
12342 }
jumpOverMethodBody()12343 public void jumpOverMethodBody() {
12344 	//on diet parsing.....do not buffer method statements
12345 
12346 	//the scanner.diet is reinitialized to false
12347 	//automatically by the scanner once it has jumped over
12348 	//the statements
12349 
12350 	if (this.diet && (this.dietInt == 0))
12351 		this.scanner.diet = true;
12352 }
jumpOverType()12353 private void jumpOverType(){
12354 	if (this.recoveredTypes != null && this.nextTypeStart > -1 && this.nextTypeStart < this.scanner.currentPosition) {
12355 
12356 		if (DEBUG_AUTOMATON) {
12357 			System.out.println("Jump         -"); //$NON-NLS-1$
12358 		}
12359 
12360 		TypeDeclaration typeDeclaration = this.recoveredTypes[this.recoveredTypePtr];
12361 		boolean isAnonymous = typeDeclaration.allocation != null;
12362 
12363 		this.scanner.startPosition = typeDeclaration.declarationSourceEnd + 1;
12364 		this.scanner.currentPosition = typeDeclaration.declarationSourceEnd + 1;
12365 		this.scanner.diet = false; // quit jumping over method bodies
12366 
12367 		if(!isAnonymous) {
12368 			((RecoveryScanner)this.scanner).setPendingTokens(new int[]{TokenNameSEMICOLON, TokenNamebreak});
12369 		} else {
12370 			((RecoveryScanner)this.scanner).setPendingTokens(new int[]{TokenNameIdentifier, TokenNameEQUAL, TokenNameIdentifier});
12371 		}
12372 
12373 		this.pendingRecoveredType = typeDeclaration;
12374 
12375 		try {
12376 			this.currentToken = this.scanner.getNextToken();
12377 		} catch(InvalidInputException e){
12378 			// it's impossible because we added pending tokens before
12379 		}
12380 
12381 		if(++this.recoveredTypePtr < this.recoveredTypes.length) {
12382 			TypeDeclaration nextTypeDeclaration = this.recoveredTypes[this.recoveredTypePtr];
12383 			this.nextTypeStart =
12384 				nextTypeDeclaration.allocation == null
12385 					? nextTypeDeclaration.declarationSourceStart
12386 							: nextTypeDeclaration.allocation.sourceStart;
12387 		} else {
12388 			this.nextTypeStart = Integer.MAX_VALUE;
12389 		}
12390 	}
12391 }
markEnclosingMemberWithLocalType()12392 protected void markEnclosingMemberWithLocalType() {
12393 	if (this.currentElement != null) return; // this is already done in the recovery code
12394 	markEnclosingMemberWithLocalOrFunctionalType(LocalTypeKind.LOCAL);
12395 }
markEnclosingMemberWithLocalOrFunctionalType(LocalTypeKind context)12396 protected void markEnclosingMemberWithLocalOrFunctionalType(LocalTypeKind context) {
12397 	for (int i = this.astPtr; i >= 0; i--) {
12398 		ASTNode node = this.astStack[i];
12399 		if (node instanceof AbstractMethodDeclaration
12400 				|| node instanceof FieldDeclaration
12401 				|| (node instanceof TypeDeclaration // mark type for now: all initializers will be marked when added to this type
12402 						// and enclosing type must not be closed (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=147485)
12403 						&& ((TypeDeclaration) node).declarationSourceEnd == 0)) {
12404 			switch (context) {
12405 				case METHOD_REFERENCE:
12406 					node.bits |= ASTNode.HasFunctionalInterfaceTypes;
12407 					break;
12408 				case LAMBDA:
12409 					node.bits |= ASTNode.HasFunctionalInterfaceTypes;
12410 					//$FALL-THROUGH$
12411 				case LOCAL:
12412 					node.bits |= ASTNode.HasLocalType;
12413 			}
12414 			return;
12415 		}
12416 	}
12417 	// default to reference context (case of parse method body)
12418 	if (this.referenceContext instanceof AbstractMethodDeclaration
12419 			|| this.referenceContext instanceof TypeDeclaration) {
12420 		ASTNode node = (ASTNode)this.referenceContext;
12421 		switch (context) {
12422 			case METHOD_REFERENCE:
12423 				node.bits |= ASTNode.HasFunctionalInterfaceTypes;
12424 				break;
12425 			case LAMBDA:
12426 				node.bits |= ASTNode.HasFunctionalInterfaceTypes;
12427 				//$FALL-THROUGH$
12428 			case LOCAL:
12429 				node.bits |= ASTNode.HasLocalType;
12430 		}
12431 	}
12432 }
12433 
12434 /*
12435  * Move checkpoint location (current implementation is moving it by one token)
12436  *
12437  * Answers true if successfully moved checkpoint (in other words, it did not attempt to move it
12438  * beyond end of file).
12439  */
moveRecoveryCheckpoint()12440 protected boolean moveRecoveryCheckpoint() {
12441 
12442 	int pos = this.lastCheckPoint;
12443 	/* reset this.scanner, and move checkpoint by one token */
12444 	this.scanner.startPosition = pos;
12445 	this.scanner.currentPosition = pos;
12446 	this.scanner.diet = false; // quit jumping over method bodies
12447 
12448 	/* if about to restart, then no need to shift token */
12449 	if (this.restartRecovery){
12450 		this.lastIgnoredToken = -1;
12451 		this.scanner.insideRecovery = true;
12452 		return true;
12453 	}
12454 
12455 	/* protect against shifting on an invalid token */
12456 	this.lastIgnoredToken = this.nextIgnoredToken;
12457 	this.nextIgnoredToken = -1;
12458 	do {
12459 		try {
12460 			this.scanner.lookBack[0] = this.scanner.lookBack[1] = TokenNameNotAToken; // stay clear of the voodoo in the present method
12461 			this.nextIgnoredToken = this.scanner.getNextNotFakedToken();
12462 		} catch(InvalidInputException e){
12463 			pos = this.scanner.currentPosition;
12464 		} finally {
12465 			this.scanner.lookBack[0] = this.scanner.lookBack[1] = TokenNameNotAToken; // steer clear of the voodoo in the present method
12466 		}
12467 	} while (this.nextIgnoredToken < 0);
12468 
12469 	if (this.nextIgnoredToken == TokenNameEOF) { // no more recovery after this point
12470 		if (this.currentToken == TokenNameEOF) { // already tried one iteration on EOF
12471 			return false;
12472 		}
12473 	}
12474 	this.lastCheckPoint = this.scanner.currentPosition;
12475 
12476 	/* reset this.scanner again to previous checkpoint location*/
12477 	this.scanner.startPosition = pos;
12478 	this.scanner.currentPosition = pos;
12479 	this.scanner.commentPtr = -1;
12480 	this.scanner.foundTaskCount = 0;
12481 	return true;
12482 
12483 /*
12484  	The following implementation moves the checkpoint location by one line:
12485 
12486 	int pos = this.lastCheckPoint;
12487 	// reset this.scanner, and move checkpoint by one token
12488 	this.scanner.startPosition = pos;
12489 	this.scanner.currentPosition = pos;
12490 	this.scanner.diet = false; // quit jumping over method bodies
12491 
12492 	// if about to restart, then no need to shift token
12493 	if (this.restartRecovery){
12494 		this.lastIgnoredToken = -1;
12495 		return true;
12496 	}
12497 
12498 	// protect against shifting on an invalid token
12499 	this.lastIgnoredToken = this.nextIgnoredToken;
12500 	this.nextIgnoredToken = -1;
12501 
12502 	boolean wasTokenizingWhiteSpace = this.scanner.tokenizeWhiteSpace;
12503 	this.scanner.tokenizeWhiteSpace = true;
12504 	checkpointMove:
12505 		do {
12506 			try {
12507 				this.nextIgnoredToken = this.scanner.getNextToken();
12508 				switch(this.nextIgnoredToken){
12509 					case Scanner.TokenNameWHITESPACE :
12510 						if(this.scanner.getLineNumber(this.scanner.startPosition)
12511 							== this.scanner.getLineNumber(this.scanner.currentPosition)){
12512 							this.nextIgnoredToken = -1;
12513 							}
12514 						break;
12515 					case TokenNameSEMICOLON :
12516 					case TokenNameLBRACE :
12517 					case TokenNameRBRACE :
12518 						break;
12519 					case TokenNameIdentifier :
12520 						if(this.scanner.currentPosition == this.scanner.startPosition){
12521 							this.scanner.currentPosition++; // on fake completion identifier
12522 						}
12523 					default:
12524 						this.nextIgnoredToken = -1;
12525 						break;
12526 					case TokenNameEOF :
12527 						break checkpointMove;
12528 				}
12529 			} catch(InvalidInputException e){
12530 				pos = this.scanner.currentPosition;
12531 			}
12532 		} while (this.nextIgnoredToken < 0);
12533 	this.scanner.tokenizeWhiteSpace = wasTokenizingWhiteSpace;
12534 
12535 	if (this.nextIgnoredToken == TokenNameEOF) { // no more recovery after this point
12536 		if (this.currentToken == TokenNameEOF) { // already tried one iteration on EOF
12537 			return false;
12538 		}
12539 	}
12540 	this.lastCheckPoint = this.scanner.currentPosition;
12541 
12542 	// reset this.scanner again to previous checkpoint location
12543 	this.scanner.startPosition = pos;
12544 	this.scanner.currentPosition = pos;
12545 	this.scanner.commentPtr = -1;
12546 
12547 	return true;
12548 */
12549 }
newMessageSend()12550 protected MessageSend newMessageSend() {
12551 	// '(' ArgumentListopt ')'
12552 	// the arguments are on the expression stack
12553 
12554 	MessageSend m = new MessageSend();
12555 	int length;
12556 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
12557 		this.expressionPtr -= length;
12558 		System.arraycopy(
12559 			this.expressionStack,
12560 			this.expressionPtr + 1,
12561 			m.arguments = new Expression[length],
12562 			0,
12563 			length);
12564 	}
12565 	return m;
12566 }
newMessageSendWithTypeArguments()12567 protected MessageSend newMessageSendWithTypeArguments() {
12568 	MessageSend m = new MessageSend();
12569 	int length;
12570 	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
12571 		this.expressionPtr -= length;
12572 		System.arraycopy(
12573 			this.expressionStack,
12574 			this.expressionPtr + 1,
12575 			m.arguments = new Expression[length],
12576 			0,
12577 			length);
12578 	}
12579 	return m;
12580 }
optimizedConcatNodeLists()12581 protected void optimizedConcatNodeLists() {
12582 	/*back from a recursive loop. Virtualy group the
12583 	astNode into an array using this.astLengthStack*/
12584 
12585 	/*
12586 	 * This is a case where you have two sublists into the this.astStack that you want
12587 	 * to merge in one list. There is no action required on the this.astStack. The only
12588 	 * thing you need to do is merge the two lengths specified on the astStackLength.
12589 	 * The top two length are for example:
12590 	 * ... p   n
12591 	 * and you want to result in a list like:
12592 	 * ... n+p
12593 	 * This means that the p could be equals to 0 in case there is no astNode pushed
12594 	 * on the this.astStack.
12595 	 * Look at the InterfaceMemberDeclarations for an example.
12596 	 * This case optimizes the fact that p == 1.
12597 	 */
12598 
12599 	this.astLengthStack[--this.astLengthPtr]++;
12600 }
12601 @Override
atConflictScenario(int token)12602 public boolean atConflictScenario(int token) {
12603 
12604 	/* Answer true if the parser is at a configuration where the scanner must look ahead and help disambiguate between (a) '<' as an operator and '<' as the
12605 	   start of <type argument> and (b) the use of '(' in '(' expression ')' and '( type ')' and '(' lambda formal parameters ')'. (c) whether the token @
12606 	   begins a Java SE5 style declaration annotation or if it begins a SE8 style type annotation. When requested thus, the scanner helps by fabricating
12607 	   synthetic tokens and injecting them into the stream ahead of the tokens that trigger conflicts in the absence of these artificial tokens. These
12608 	   manufactured token help transform the grammar into LALR(1) by splitting the states so that they have unambigious prefixes.
12609 
12610 	   We do this by claiming to the automaton that the next token seen is the (suitable) synthetic token and observing the response of the state machine.
12611 	   Error signals we are NOT at a conflict site, while shift or shift/reduce signals that we are. Accept is impossible, while there may be intermediate
12612 	   reductions that are called for -- It is axiomatic of the push down automaton that corresponds to the LALR grammar that it will never shift on invalid
12613 	   input.
12614 
12615 	   Obviously, the dry runs should not alter the parser state in any way or otherwise cause side effects. Proof by argument that this is the case:
12616 
12617 	       - The only pieces of state needed to answer the question are: this.stack, this.stateStackTop and the last action variable `act`. None of the various
12618 	         and sundry stacks used in the AST constructions process are touched here.
12619 	       - As we reduce, we DON'T call the semantic action functions i.e the consume* method calls are skipped.
12620 	       - Lexer stream is left untouched.
12621 	       - this.stateStackTop and the last action variable `act` of the automaton are readily cloned, these being primitives and changes are to the replicas.
12622 	       - We never remove elements from the state stack here (or elsewhere for that matter). Pops are implemented by mere adjustments of the stack pointer.
12623 	       - During this algorithm, either the stack pointer monotonically decreases or stays fixed. (The only way for the stack pointer to increase would call
12624 	         for a shift or a shift/reduce at which point the algorithm is ready to terminate already.) This means that we don't have to replicate the stack.
12625 	         Pushes can be mimiced by writing to a local stackTopState variable, leaving the original stack untouched.
12626 
12627 	    Though this code looks complex, we should exit early in most situations.
12628 	 */
12629 	if (this.unstackedAct == ERROR_ACTION) { // automaton is not running.
12630 		return false;
12631 	}
12632 	if (token != TokenNameAT) {
12633 		token = token == TokenNameLPAREN ? TokenNameBeginLambda : TokenNameBeginTypeArguments;
12634 	}
12635 
12636 	return automatonWillShift(token, this.unstackedAct);
12637 }
12638 /*main loop of the automat
12639 When a rule is reduced, the method consumeRule(int) is called with the number
12640 of the consumed rule. When a terminal is consumed, the method consumeToken(int) is
12641 called in order to remember (when needed) the consumed token */
12642 // (int)asr[asi(act)]
12643 // name[symbol_index[currentKind]]
parse()12644 protected void parse() {
12645 	if (DEBUG) System.out.println("-- ENTER INSIDE PARSE METHOD --");  //$NON-NLS-1$
12646 
12647 	if (DEBUG_AUTOMATON) {
12648 		System.out.println("- Start --------------------------------");  //$NON-NLS-1$
12649 	}
12650 
12651 	boolean isDietParse = this.diet;
12652 	int oldFirstToken = getFirstToken();
12653 	this.hasError = false;
12654 
12655 	this.hasReportedError = false;
12656 	int act = START_STATE;
12657 	this.unstackedAct = ERROR_ACTION;
12658 	this.stateStackTop = -1;
12659 	this.currentToken = getFirstToken();
12660 
12661 try {
12662 	this.scanner.setActiveParser(this);
12663 	ProcessTerminals : for (;;) {
12664 		int stackLength = this.stack.length;
12665 		if (++this.stateStackTop >= stackLength) {
12666 			System.arraycopy(
12667 				this.stack, 0,
12668 				this.stack = new int[stackLength + StackIncrement], 0,
12669 				stackLength);
12670 		}
12671 		this.stack[this.stateStackTop] = act;
12672 		this.unstackedAct = act = actFromTokenOrSynthetic(act);
12673 		if (act == ERROR_ACTION || this.restartRecovery) {
12674 			if (DEBUG_AUTOMATON) {
12675 				if (this.restartRecovery) {
12676 					System.out.println("Restart      - "); //$NON-NLS-1$
12677 				} else {
12678 					System.out.println("Error        - "); //$NON-NLS-1$
12679 				}
12680 			}
12681 
12682 			int errorPos = this.scanner.currentPosition - 1;
12683 			if (!this.hasReportedError) {
12684 				this.hasError = true;
12685 			}
12686 			int previousToken = this.currentToken;
12687 			switch (resumeOnSyntaxError()) {
12688 				case HALT:
12689 					act = ERROR_ACTION;
12690 					break ProcessTerminals;
12691 				case RESTART:
12692 					if (act == ERROR_ACTION && previousToken != 0) this.lastErrorEndPosition = errorPos;
12693 					act = START_STATE;
12694 					this.stateStackTop = -1;
12695 					this.currentToken = getFirstToken();
12696 					continue ProcessTerminals;
12697 				case RESUME:
12698 					if (act == ERROR_ACTION) {
12699 						act = this.stack[this.stateStackTop--];
12700 						continue ProcessTerminals;
12701 					} else {
12702 						// FALL THROUGH.
12703 					}
12704 			}
12705 		}
12706 		if (act <= NUM_RULES) {
12707 			this.stateStackTop--;
12708 
12709 			if (DEBUG_AUTOMATON) {
12710 				System.out.print("Reduce       - "); //$NON-NLS-1$
12711 			}
12712 
12713 		} else if (act > ERROR_ACTION) { /* shift-reduce */
12714 			consumeToken(this.currentToken);
12715 			if (this.currentElement != null) {
12716 				boolean oldValue = this.recordStringLiterals;
12717 				this.recordStringLiterals = false;
12718 				recoveryTokenCheck();
12719 				this.recordStringLiterals = oldValue;
12720 			}
12721 			try {
12722 				this.currentToken = this.scanner.getNextToken();
12723 			} catch(InvalidInputException e){
12724 				if (!this.hasReportedError){
12725 					problemReporter().scannerError(this, e.getMessage());
12726 					this.hasReportedError = true;
12727 				}
12728 				this.lastCheckPoint = this.scanner.currentPosition;
12729 				this.currentToken = 0;
12730 				this.restartRecovery = true;
12731 			}
12732 			if(this.statementRecoveryActivated) {
12733 				jumpOverType();
12734 			}
12735 			this.unstackedAct = act -= ERROR_ACTION;
12736 
12737 			if (DEBUG_AUTOMATON) {
12738 				System.out.print("Shift/Reduce - (" + name[terminal_index[this.currentToken]]+") ");  //$NON-NLS-1$  //$NON-NLS-2$
12739 			}
12740 
12741 		} else {
12742 		    if (act < ACCEPT_ACTION) { /* shift */
12743 				consumeToken(this.currentToken);
12744 				if (this.currentElement != null) {
12745 					boolean oldValue = this.recordStringLiterals;
12746 					this.recordStringLiterals = false;
12747 					recoveryTokenCheck();
12748 					this.recordStringLiterals = oldValue;
12749 				}
12750 				try{
12751 					this.currentToken = this.scanner.getNextToken();
12752 				} catch(InvalidInputException e){
12753 					if (!this.hasReportedError){
12754 						problemReporter().scannerError(this, e.getMessage());
12755 						this.hasReportedError = true;
12756 					}
12757 					this.lastCheckPoint = this.scanner.currentPosition;
12758 					this.currentToken = 0;
12759 					this.restartRecovery = true;
12760 				}
12761 				if(this.statementRecoveryActivated) {
12762 					jumpOverType();
12763 				}
12764 				if (DEBUG_AUTOMATON) {
12765 					System.out.println("Shift        - (" + name[terminal_index[this.currentToken]]+")");  //$NON-NLS-1$  //$NON-NLS-2$
12766 				}
12767 				continue ProcessTerminals;
12768 			}
12769 			break ProcessTerminals;
12770 		}
12771 
12772 		// ProcessNonTerminals :
12773 		do { /* reduce */
12774 
12775 			if (DEBUG_AUTOMATON) {
12776 				System.out.println(name[non_terminal_index[lhs[act]]]);
12777 			}
12778 
12779 			this.stateStackTop -= (rhs[act] - 1);
12780 			this.unstackedAct = ntAction(this.stack[this.stateStackTop], lhs[act]);
12781 			consumeRule(act);
12782 			act = this.unstackedAct;
12783 
12784 			if (act == ACCEPT_ACTION) {
12785 				break ProcessTerminals;
12786 			}
12787 
12788 			if (DEBUG_AUTOMATON) {
12789 				if (act <= NUM_RULES) {
12790 					System.out.print("             - ");  //$NON-NLS-1$
12791 				}
12792 			}
12793 
12794 		} while (act <= NUM_RULES);
12795 
12796 		if (DEBUG_AUTOMATON) {
12797 			System.out.println("----------------------------------------");  //$NON-NLS-1$
12798 		}
12799 	}
12800 } finally {
12801 	this.unstackedAct = ERROR_ACTION;
12802 	this.scanner.setActiveParser(null);
12803 }
12804 
12805 	if (DEBUG_AUTOMATON) {
12806 		System.out.println("- End ----------------------------------");  //$NON-NLS-1$
12807 	}
12808 
12809 	endParse(act);
12810 	// record all nls tags in the corresponding compilation unit
12811 	final NLSTag[] tags = this.scanner.getNLSTags();
12812 	if (tags != null) {
12813 		this.compilationUnit.nlsTags = tags;
12814 	}
12815 
12816 	this.scanner.checkNonExternalizedStringLiterals = false;
12817 
12818 	if (this.scanner.checkUninternedIdentityComparison) {
12819 		this.compilationUnit.validIdentityComparisonLines = this.scanner.getIdentityComparisonLines();
12820 		this.scanner.checkUninternedIdentityComparison = false;
12821 	}
12822 
12823 	if (this.reportSyntaxErrorIsRequired && this.hasError && !this.statementRecoveryActivated) {
12824 		if(!this.options.performStatementsRecovery) {
12825 			reportSyntaxErrors(isDietParse, oldFirstToken);
12826 		} else {
12827 			RecoveryScannerData data = this.referenceContext.compilationResult().recoveryScannerData;
12828 
12829 			if(this.recoveryScanner == null) {
12830 				this.recoveryScanner = new RecoveryScanner(this.scanner, data);
12831 			} else {
12832 				this.recoveryScanner.setData(data);
12833 			}
12834 
12835 			this.recoveryScanner.setSource(this.scanner.source);
12836 			this.recoveryScanner.lineEnds = this.scanner.lineEnds;
12837 			this.recoveryScanner.linePtr = this.scanner.linePtr;
12838 
12839 			reportSyntaxErrors(isDietParse, oldFirstToken);
12840 
12841 			if(data == null) {
12842 				this.referenceContext.compilationResult().recoveryScannerData =
12843 					this.recoveryScanner.getData();
12844 			}
12845 
12846 			if (this.methodRecoveryActivated && this.options.performStatementsRecovery) {
12847 				this.methodRecoveryActivated = false;
12848 				recoverStatements();
12849 				this.methodRecoveryActivated = true;
12850 
12851 				this.lastAct = ERROR_ACTION;
12852 			}
12853 		}
12854 	}
12855 	this.problemReporter.referenceContext = null; // Null this so we won't escalate problems needlessly (bug 393192)
12856 	if (DEBUG) System.out.println("-- EXIT FROM PARSE METHOD --");  //$NON-NLS-1$
12857 }
parse(ConstructorDeclaration cd, CompilationUnitDeclaration unit, boolean recordLineSeparator)12858 public void parse(ConstructorDeclaration cd, CompilationUnitDeclaration unit, boolean recordLineSeparator) {
12859 	//only parse the method body of cd
12860 	//fill out its statements
12861 
12862 	//convert bugs into parse error
12863 
12864 	boolean oldMethodRecoveryActivated = this.methodRecoveryActivated;
12865 	if(this.options.performMethodsFullRecovery) {
12866 		this.methodRecoveryActivated = true;
12867 		// we should not relocate bodyStart if there is a block within the statements
12868 		this.ignoreNextOpeningBrace = true;
12869 	}
12870 
12871 	initialize();
12872 	goForBlockStatementsopt();
12873 	if (recordLineSeparator) {
12874 		this.scanner.recordLineSeparator = true;
12875 	}
12876 	this.nestedMethod[this.nestedType]++;
12877 	pushOnRealBlockStack(0);
12878 
12879 	this.referenceContext = cd;
12880 	this.compilationUnit = unit;
12881 
12882 	this.scanner.resetTo(cd.bodyStart, cd.bodyEnd);
12883 	try {
12884 		parse();
12885 	} catch (AbortCompilation ex) {
12886 		this.lastAct = ERROR_ACTION;
12887 	} finally {
12888 		this.nestedMethod[this.nestedType]--;
12889 		if(this.options.performStatementsRecovery) {
12890 			this.methodRecoveryActivated = oldMethodRecoveryActivated;
12891 		}
12892 	}
12893 
12894 	checkNonNLSAfterBodyEnd(cd.declarationSourceEnd);
12895 
12896 	if (this.lastAct == ERROR_ACTION) {
12897 		cd.bits |= ASTNode.HasSyntaxErrors;
12898 		initialize();
12899 		return;
12900 	}
12901 
12902 	//statements
12903 	cd.explicitDeclarations = this.realBlockStack[this.realBlockPtr--];
12904 	int length;
12905 	if (this.astLengthPtr > -1 && (length = this.astLengthStack[this.astLengthPtr--]) != 0) {
12906 		this.astPtr -= length;
12907 		if (!this.options.ignoreMethodBodies) {
12908 			if (this.astStack[this.astPtr + 1] instanceof ExplicitConstructorCall)
12909 				//avoid a isSomeThing that would only be used here BUT what is faster between two alternatives ?
12910 				{
12911 				System.arraycopy(
12912 					this.astStack,
12913 					this.astPtr + 2,
12914 					cd.statements = new Statement[length - 1],
12915 					0,
12916 					length - 1);
12917 				cd.constructorCall = (ExplicitConstructorCall) this.astStack[this.astPtr + 1];
12918 			} else { //need to add explicitly the super();
12919 				System.arraycopy(
12920 					this.astStack,
12921 					this.astPtr + 1,
12922 					cd.statements = new Statement[length],
12923 					0,
12924 					length);
12925 				cd.constructorCall = SuperReference.implicitSuperConstructorCall();
12926 			}
12927 		}
12928 	} else {
12929 		if (!this.options.ignoreMethodBodies) {
12930 			cd.constructorCall = SuperReference.implicitSuperConstructorCall();
12931 		}
12932 		if (!containsComment(cd.bodyStart, cd.bodyEnd)) {
12933 			cd.bits |= ASTNode.UndocumentedEmptyBlock;
12934 		}
12935 	}
12936 
12937 	ExplicitConstructorCall explicitConstructorCall = cd.constructorCall;
12938 	if (explicitConstructorCall != null && explicitConstructorCall.sourceEnd == 0) {
12939 		explicitConstructorCall.sourceEnd = cd.sourceEnd;
12940 		explicitConstructorCall.sourceStart = cd.sourceStart;
12941 	}
12942 }
12943 // A P I
12944 
parse( FieldDeclaration field, TypeDeclaration type, CompilationUnitDeclaration unit, char[] initializationSource)12945 public void parse(
12946 	FieldDeclaration field,
12947 	TypeDeclaration type,
12948 	CompilationUnitDeclaration unit,
12949 	char[] initializationSource) {
12950 	//only parse the initializationSource of the given field
12951 
12952 	//convert bugs into parse error
12953 
12954 	initialize();
12955 	goForExpression(true /* record line separators */);
12956 	this.nestedMethod[this.nestedType]++;
12957 
12958 	this.referenceContext = type;
12959 	this.compilationUnit = unit;
12960 
12961 	this.scanner.setSource(initializationSource);
12962 	this.scanner.resetTo(0, initializationSource.length-1);
12963 	try {
12964 		parse();
12965 	} catch (AbortCompilation ex) {
12966 		this.lastAct = ERROR_ACTION;
12967 	} finally {
12968 		this.nestedMethod[this.nestedType]--;
12969 	}
12970 
12971 	if (this.lastAct == ERROR_ACTION) {
12972 		field.bits |= ASTNode.HasSyntaxErrors;
12973 		return;
12974 	}
12975 
12976 	field.initialization = this.expressionStack[this.expressionPtr];
12977 
12978 	// mark field with local type if one was found during parsing
12979 	if ((type.bits & ASTNode.HasLocalType) != 0) {
12980 		field.bits |= ASTNode.HasLocalType;
12981 	}
12982 }
12983 // A P I
12984 
parse( ICompilationUnit sourceUnit, CompilationResult compilationResult)12985 public CompilationUnitDeclaration parse(
12986 	ICompilationUnit sourceUnit,
12987 	CompilationResult compilationResult) {
12988 	// parses a compilation unit and manages error handling (even bugs....)
12989 
12990 	return parse(sourceUnit, compilationResult, -1, -1/*parse without reseting the scanner*/);
12991 }
12992 // A P I
12993 
parse( ICompilationUnit sourceUnit, CompilationResult compilationResult, int start, int end)12994 public CompilationUnitDeclaration parse(
12995 	ICompilationUnit sourceUnit,
12996 	CompilationResult compilationResult,
12997 	int start,
12998 	int end) {
12999 	// parses a compilation unit and manages error handling (even bugs....)
13000 
13001 	CompilationUnitDeclaration unit;
13002 	try {
13003 		/* automaton initialization */
13004 		initialize(true);
13005 		goForCompilationUnit();
13006 
13007 		/* unit creation */
13008 		this.referenceContext =
13009 			this.compilationUnit =
13010 				new CompilationUnitDeclaration(
13011 					this.problemReporter,
13012 					compilationResult,
13013 					0);
13014 
13015 		/* scanners initialization */
13016 		char[] contents;
13017 		try {
13018 			contents = this.readManager != null ? this.readManager.getContents(sourceUnit) : sourceUnit.getContents();
13019 		} catch(AbortCompilationUnit abortException) {
13020 			problemReporter().cannotReadSource(this.compilationUnit, abortException, this.options.verbose);
13021 			contents = CharOperation.NO_CHAR; // pretend empty from thereon
13022 		}
13023 		this.scanner.setSource(contents);
13024 		this.compilationUnit.sourceEnd = this.scanner.source.length - 1;
13025 		if (end != -1) this.scanner.resetTo(start, end);
13026 		if (this.javadocParser != null && this.javadocParser.checkDocComment) {
13027 			this.javadocParser.scanner.setSource(contents);
13028 			if (end != -1) {
13029 				this.javadocParser.scanner.resetTo(start, end);
13030 			}
13031 		}
13032 		/* run automaton */
13033 		parse();
13034 	} finally {
13035 		unit = this.compilationUnit;
13036  		this.compilationUnit = null; // reset parser
13037 		// tag unit has having read bodies
13038 		if (!this.diet) unit.bits |= ASTNode.HasAllMethodBodies;
13039 	}
13040 	return unit;
13041 }
13042 // A P I
13043 
parse( Initializer initializer, TypeDeclaration type, CompilationUnitDeclaration unit)13044 public void parse(
13045 	Initializer initializer,
13046 	TypeDeclaration type,
13047 	CompilationUnitDeclaration unit) {
13048 	//only parse the method body of md
13049 	//fill out method statements
13050 
13051 	//convert bugs into parse error
13052 
13053 	boolean oldMethodRecoveryActivated = this.methodRecoveryActivated;
13054 	if(this.options.performMethodsFullRecovery) {
13055 		this.methodRecoveryActivated = true;
13056 	}
13057 
13058 	initialize();
13059 	goForBlockStatementsopt();
13060 	this.nestedMethod[this.nestedType]++;
13061 	pushOnRealBlockStack(0);
13062 
13063 	this.referenceContext = type;
13064 	this.compilationUnit = unit;
13065 
13066 	this.scanner.resetTo(initializer.bodyStart, initializer.bodyEnd); // just on the beginning {
13067 	try {
13068 		parse();
13069 	} catch (AbortCompilation ex) {
13070 		this.lastAct = ERROR_ACTION;
13071 	} finally {
13072 		this.nestedMethod[this.nestedType]--;
13073 		if(this.options.performStatementsRecovery) {
13074 			this.methodRecoveryActivated = oldMethodRecoveryActivated;
13075 		}
13076 	}
13077 
13078 	checkNonNLSAfterBodyEnd(initializer.declarationSourceEnd);
13079 
13080 	if (this.lastAct == ERROR_ACTION) {
13081 		initializer.bits |= ASTNode.HasSyntaxErrors;
13082 		return;
13083 	}
13084 
13085 	//refill statements
13086 	initializer.block.explicitDeclarations = this.realBlockStack[this.realBlockPtr--];
13087 	int length;
13088 	if (this.astLengthPtr > -1 && (length = this.astLengthStack[this.astLengthPtr--]) > 0) {
13089 		System.arraycopy(this.astStack, (this.astPtr -= length) + 1, initializer.block.statements = new Statement[length], 0, length);
13090 	} else {
13091 		// check whether this block at least contains some comment in it
13092 		if (!containsComment(initializer.block.sourceStart, initializer.block.sourceEnd)) {
13093 			initializer.block.bits |= ASTNode.UndocumentedEmptyBlock;
13094 		}
13095 	}
13096 
13097 	// mark initializer with local type if one was found during parsing
13098 	if ((type.bits & ASTNode.HasLocalType) != 0) {
13099 		initializer.bits |= ASTNode.HasLocalType;
13100 	}
13101 }
13102 // A P I
parse(MethodDeclaration md, CompilationUnitDeclaration unit)13103 public void parse(MethodDeclaration md, CompilationUnitDeclaration unit) {
13104 	//only parse the method body of md
13105 	//fill out method statements
13106 
13107 	//convert bugs into parse error
13108 
13109 	if (md.isAbstract())
13110 		return;
13111 	if (md.isNative())
13112 		return;
13113 	if ((md.modifiers & ExtraCompilerModifiers.AccSemicolonBody) != 0)
13114 		return;
13115 
13116 	boolean oldMethodRecoveryActivated = this.methodRecoveryActivated;
13117 	if(this.options.performMethodsFullRecovery) {
13118 		// we should not relocate bodyStart if there is a block within the statements
13119 		this.ignoreNextOpeningBrace = true;
13120 		this.methodRecoveryActivated = true;
13121 		this.rParenPos = md.sourceEnd;
13122 	}
13123 	initialize();
13124 	goForBlockStatementsopt();
13125 	this.nestedMethod[this.nestedType]++;
13126 	pushOnRealBlockStack(0);
13127 
13128 	this.referenceContext = md;
13129 	this.compilationUnit = unit;
13130 
13131 	this.scanner.resetTo(md.bodyStart, md.bodyEnd);
13132 	// reset the scanner to parser from { down to }
13133 	try {
13134 		parse();
13135 	} catch (AbortCompilation ex) {
13136 		this.lastAct = ERROR_ACTION;
13137 	} finally {
13138 		this.nestedMethod[this.nestedType]--;
13139 		if(this.options.performStatementsRecovery) {
13140 			this.methodRecoveryActivated = oldMethodRecoveryActivated;
13141 		}
13142 	}
13143 
13144 	checkNonNLSAfterBodyEnd(md.declarationSourceEnd);
13145 
13146 	if (this.lastAct == ERROR_ACTION) {
13147 		md.bits |= ASTNode.HasSyntaxErrors;
13148 		return;
13149 	}
13150 
13151 	//refill statements
13152 	md.explicitDeclarations = this.realBlockStack[this.realBlockPtr--];
13153 	int length;
13154 	if (this.astLengthPtr > -1 && (length = this.astLengthStack[this.astLengthPtr--]) != 0) {
13155 		if (this.options.ignoreMethodBodies) {
13156 			// ignore statements
13157 			this.astPtr -= length;
13158 		} else {
13159 			System.arraycopy(
13160 				this.astStack,
13161 				(this.astPtr -= length) + 1,
13162 				md.statements = new Statement[length],
13163 				0,
13164 				length);
13165 		}
13166 	} else {
13167 		if (!containsComment(md.bodyStart, md.bodyEnd)) {
13168 			md.bits |= ASTNode.UndocumentedEmptyBlock;
13169 		}
13170 	}
13171 }
parseClassBodyDeclarations(char[] source, int offset, int length, CompilationUnitDeclaration unit)13172 public ASTNode[] parseClassBodyDeclarations(char[] source, int offset, int length, CompilationUnitDeclaration unit) {
13173 	boolean oldDiet = this.diet;
13174 	int oldInt = this.dietInt;
13175 	boolean oldTolerateDefaultClassMethods = this.tolerateDefaultClassMethods;
13176 	/* automaton initialization */
13177 	initialize();
13178 	goForClassBodyDeclarations();
13179 	/* scanner initialization */
13180 	this.scanner.setSource(source);
13181 	this.scanner.resetTo(offset, offset + length - 1);
13182 	if (this.javadocParser != null && this.javadocParser.checkDocComment) {
13183 		this.javadocParser.scanner.setSource(source);
13184 		this.javadocParser.scanner.resetTo(offset, offset + length - 1);
13185 	}
13186 
13187 	/* type declaration should be parsed as member type declaration */
13188 	this.nestedType = 1;
13189 
13190 	/* unit creation */
13191 	TypeDeclaration referenceContextTypeDeclaration = new TypeDeclaration(unit.compilationResult);
13192 	referenceContextTypeDeclaration.name = Util.EMPTY_STRING.toCharArray();
13193 	referenceContextTypeDeclaration.fields = new FieldDeclaration[0];
13194 	this.compilationUnit = unit;
13195 	unit.types = new TypeDeclaration[1];
13196 	unit.types[0] = referenceContextTypeDeclaration;
13197 	this.referenceContext = unit;
13198 
13199 	/* run automaton */
13200 	try {
13201 		this.diet = true;
13202 		this.dietInt = 0;
13203 		this.tolerateDefaultClassMethods = this.parsingJava8Plus;
13204 		parse();
13205 	} catch (AbortCompilation ex) {
13206 		this.lastAct = ERROR_ACTION;
13207 	} finally {
13208 		this.diet = oldDiet;
13209 		this.dietInt = oldInt;
13210 		this.tolerateDefaultClassMethods = oldTolerateDefaultClassMethods;
13211 	}
13212 
13213 	ASTNode[] result = null;
13214 	if (this.lastAct == ERROR_ACTION) {
13215 		if (!this.options.performMethodsFullRecovery && !this.options.performStatementsRecovery) {
13216 			return null;
13217 		}
13218 		// collect all body declaration inside the compilation unit except the default constructor
13219 		final List bodyDeclarations = new ArrayList();
13220 		ASTVisitor visitor = new ASTVisitor() {
13221 			@Override
13222 			public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
13223 				if (!methodDeclaration.isDefaultConstructor()) {
13224 					bodyDeclarations.add(methodDeclaration);
13225 				}
13226 				return false;
13227 			}
13228 			@Override
13229 			public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
13230 				bodyDeclarations.add(fieldDeclaration);
13231 				return false;
13232 			}
13233 			@Override
13234 			public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope scope) {
13235 				bodyDeclarations.add(memberTypeDeclaration);
13236 				return false;
13237 			}
13238 		};
13239 		unit.ignoreFurtherInvestigation = false;
13240 		unit.traverse(visitor, unit.scope);
13241 		unit.ignoreFurtherInvestigation = true;
13242 		result = (ASTNode[]) bodyDeclarations.toArray(new ASTNode[bodyDeclarations.size()]);
13243 	} else {
13244 		int astLength;
13245 		if (this.astLengthPtr > -1 && (astLength = this.astLengthStack[this.astLengthPtr--]) != 0) {
13246 			result = new ASTNode[astLength];
13247 			this.astPtr -= astLength;
13248 			System.arraycopy(this.astStack, this.astPtr + 1, result, 0, astLength);
13249 		} else {
13250 			// empty class body declaration (like ';' see https://bugs.eclipse.org/bugs/show_bug.cgi?id=280079).
13251 			result = new ASTNode[0];
13252 		}
13253 	}
13254 	boolean containsInitializers = false;
13255 	TypeDeclaration typeDeclaration = null;
13256 	for (int i = 0, max = result.length; i < max; i++) {
13257 		// parse each class body declaration
13258 		ASTNode node = result[i];
13259 		if (node instanceof TypeDeclaration) {
13260 			((TypeDeclaration) node).parseMethods(this, unit);
13261 		} else if (node instanceof AbstractMethodDeclaration) {
13262 			((AbstractMethodDeclaration) node).parseStatements(this, unit);
13263 		} else if (node instanceof FieldDeclaration) {
13264 			FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
13265 			switch(fieldDeclaration.getKind()) {
13266 				case AbstractVariableDeclaration.INITIALIZER:
13267 					containsInitializers = true;
13268 					if (typeDeclaration == null) {
13269 						typeDeclaration = referenceContextTypeDeclaration;
13270 					}
13271 					if (typeDeclaration.fields == null) {
13272 						typeDeclaration.fields = new FieldDeclaration[1];
13273 						typeDeclaration.fields[0] = fieldDeclaration;
13274 					} else {
13275 						int length2 = typeDeclaration.fields.length;
13276 						FieldDeclaration[] temp = new FieldDeclaration[length2 + 1];
13277 						System.arraycopy(typeDeclaration.fields, 0, temp, 0, length2);
13278 						temp[length2] = fieldDeclaration;
13279 						typeDeclaration.fields = temp;
13280 					}
13281 					break;
13282 			}
13283 		}
13284 		if (((node.bits & ASTNode.HasSyntaxErrors) != 0) && (!this.options.performMethodsFullRecovery && !this.options.performStatementsRecovery)) {
13285 			return null;
13286 		}
13287 	}
13288 	if (containsInitializers) {
13289 		FieldDeclaration[] fieldDeclarations = typeDeclaration.fields;
13290 		for (int i = 0, max = fieldDeclarations.length; i < max; i++) {
13291 			Initializer initializer = (Initializer) fieldDeclarations[i];
13292 			initializer.parseStatements(this, typeDeclaration , unit);
13293 			if (((initializer.bits & ASTNode.HasSyntaxErrors) != 0) && (!this.options.performMethodsFullRecovery && !this.options.performStatementsRecovery)) {
13294 				return null;
13295 			}
13296 		}
13297 	}
13298 	return result;
13299 }
13300 
parseLambdaExpression(char[] source, int offset, int length, CompilationUnitDeclaration unit, boolean recordLineSeparators)13301 public Expression parseLambdaExpression(char[] source, int offset, int length, CompilationUnitDeclaration unit, boolean recordLineSeparators) {
13302 	this.haltOnSyntaxError = true; // unexposed/unshared object, no threading concerns.
13303 	this.reparsingLambdaExpression = true;
13304 	return parseExpression(source, offset, length, unit, recordLineSeparators);
13305 }
13306 
parsePackageDeclaration(char[] source, CompilationResult result)13307 public char[][] parsePackageDeclaration(char[] source, CompilationResult result) {
13308 	initialize();
13309 	goForPackageDeclaration(false);
13310 	this.referenceContext =
13311 			this.compilationUnit =
13312 				new CompilationUnitDeclaration(
13313 					problemReporter(),
13314 					result,
13315 					source.length);
13316 	this.scanner.setSource(source);
13317 	try {
13318 		parse();
13319 	} catch (AbortCompilation ex) {
13320 		this.lastAct = ERROR_ACTION;
13321 	}
13322 
13323 	if (this.lastAct == ERROR_ACTION) {
13324 		return null;
13325 	}
13326 
13327 	return this.compilationUnit.currentPackage == null ? null : this.compilationUnit.currentPackage.getImportName();
13328 
13329 }
parseExpression(char[] source, int offset, int length, CompilationUnitDeclaration unit, boolean recordLineSeparators)13330 public Expression parseExpression(char[] source, int offset, int length, CompilationUnitDeclaration unit, boolean recordLineSeparators) {
13331 
13332 	initialize();
13333 	goForExpression(recordLineSeparators);
13334 	this.nestedMethod[this.nestedType]++;
13335 
13336 	this.referenceContext = unit;
13337 	this.compilationUnit = unit;
13338 
13339 	this.scanner.setSource(source);
13340 	this.scanner.resetTo(offset, offset + length - 1);
13341 	try {
13342 		parse();
13343 	} catch (AbortCompilation ex) {
13344 		this.lastAct = ERROR_ACTION;
13345 	} finally {
13346 		this.nestedMethod[this.nestedType]--;
13347 	}
13348 
13349 	if (this.lastAct == ERROR_ACTION) {
13350 		return null;
13351 	}
13352 
13353 	return this.expressionStack[this.expressionPtr];
13354 }
parseMemberValue(char[] source, int offset, int length, CompilationUnitDeclaration unit)13355 public Expression parseMemberValue(char[] source, int offset, int length, CompilationUnitDeclaration unit) {
13356 
13357 	initialize();
13358 	goForMemberValue();
13359 	this.nestedMethod[this.nestedType]++;
13360 
13361 	this.referenceContext = unit;
13362 	this.compilationUnit = unit;
13363 
13364 	this.scanner.setSource(source);
13365 	this.scanner.resetTo(offset, offset + length - 1);
13366 	try {
13367 		parse();
13368 	} catch (AbortCompilation ex) {
13369 		this.lastAct = ERROR_ACTION;
13370 	} finally {
13371 		this.nestedMethod[this.nestedType]--;
13372 	}
13373 
13374 	if (this.lastAct == ERROR_ACTION) {
13375 		return null;
13376 	}
13377 
13378 	return this.expressionStack[this.expressionPtr];
13379 }
parseStatements(ReferenceContext rc, int start, int end, TypeDeclaration[] types, CompilationUnitDeclaration unit)13380 public void parseStatements(ReferenceContext rc, int start, int end, TypeDeclaration[] types, CompilationUnitDeclaration unit) {
13381 	boolean oldStatementRecoveryEnabled = this.statementRecoveryActivated;
13382 	this.statementRecoveryActivated = true;
13383 
13384 	initialize();
13385 
13386 	goForBlockStatementsopt();
13387 	this.nestedMethod[this.nestedType]++;
13388 	pushOnRealBlockStack(0);
13389 
13390 	pushOnAstLengthStack(0);
13391 
13392 	this.referenceContext = rc;
13393 	this.compilationUnit = unit;
13394 
13395 	this.pendingRecoveredType = null;
13396 
13397 	if(types != null && types.length > 0) {
13398 		this.recoveredTypes = types;
13399 		this.recoveredTypePtr = 0;
13400 		this.nextTypeStart =
13401 			this.recoveredTypes[0].allocation == null
13402 				? this.recoveredTypes[0].declarationSourceStart
13403 						: this.recoveredTypes[0].allocation.sourceStart;
13404 	} else {
13405 		this.recoveredTypes = null;
13406 		this.recoveredTypePtr = -1;
13407 		this.nextTypeStart = -1;
13408 	}
13409 
13410 	this.scanner.resetTo(start, end);
13411 	// reset the scanner to parser from { down to }
13412 
13413 	this.lastCheckPoint = this.scanner.initialPosition;
13414 
13415 
13416 	this.stateStackTop = -1;
13417 
13418 	try {
13419 		parse();
13420 	} catch (AbortCompilation ex) {
13421 		this.lastAct = ERROR_ACTION;
13422 	} finally {
13423 		this.nestedMethod[this.nestedType]--;
13424 		this.recoveredTypes = null;
13425 		this.statementRecoveryActivated = oldStatementRecoveryEnabled;
13426 	}
13427 
13428 	checkNonNLSAfterBodyEnd(end);
13429 }
persistLineSeparatorPositions()13430 public void persistLineSeparatorPositions() {
13431 	if (this.scanner.recordLineSeparator) {
13432 		this.compilationUnit.compilationResult.lineSeparatorPositions = this.scanner.getLineEnds();
13433 	}
13434 }
13435 /*
13436  * Prepares the state of the parser to go for BlockStatements.
13437  */
prepareForBlockStatements()13438 protected void prepareForBlockStatements() {
13439 	this.nestedMethod[this.nestedType = 0] = 1;
13440 	this.variablesCounter[this.nestedType] = 0;
13441 	this.realBlockStack[this.realBlockPtr = 1] = 0;
13442 	this.switchNestingLevel = 0;
13443 	this.switchWithTry = false;
13444 }
13445 /**
13446  * Returns this parser's problem reporter initialized with its reference context.
13447  * Also it is assumed that a problem is going to be reported, so initializes
13448  * the compilation result's line positions.
13449  *
13450  * @return ProblemReporter
13451  */
problemReporter()13452 public ProblemReporter problemReporter(){
13453 	if (this.scanner.recordLineSeparator) {
13454 		this.compilationUnit.compilationResult.lineSeparatorPositions = this.scanner.getLineEnds();
13455 	}
13456 	this.problemReporter.referenceContext = this.referenceContext;
13457 	return this.problemReporter;
13458 }
pushIdentifier(char [] identifier, long position)13459 protected void pushIdentifier(char [] identifier, long position) {
13460 	int stackLength = this.identifierStack.length;
13461 	if (++this.identifierPtr >= stackLength) {
13462 		System.arraycopy(
13463 			this.identifierStack, 0,
13464 			this.identifierStack = new char[stackLength + 20][], 0,
13465 			stackLength);
13466 		System.arraycopy(
13467 			this.identifierPositionStack, 0,
13468 			this.identifierPositionStack = new long[stackLength + 20], 0,
13469 			stackLength);
13470 	}
13471 	this.identifierStack[this.identifierPtr] = identifier;
13472 	this.identifierPositionStack[this.identifierPtr] = position;
13473 
13474 	stackLength = this.identifierLengthStack.length;
13475 	if (++this.identifierLengthPtr >= stackLength) {
13476 		System.arraycopy(
13477 			this.identifierLengthStack, 0,
13478 			this.identifierLengthStack = new int[stackLength + 10], 0,
13479 			stackLength);
13480 	}
13481 	this.identifierLengthStack[this.identifierLengthPtr] = 1;
13482 	if (this.parsingJava8Plus && identifier.length == 1 && identifier[0] == '_' && !this.processingLambdaParameterList) {
13483 		problemReporter().illegalUseOfUnderscoreAsAnIdentifier((int) (position >>> 32), (int) position, this.parsingJava9Plus);
13484 	}
13485 }
pushIdentifier()13486 protected void pushIdentifier() {
13487 	/*push the consumeToken on the identifier stack.
13488 	Increase the total number of identifier in the stack.
13489 	identifierPtr points on the next top */
13490 
13491 	pushIdentifier(this.scanner.getCurrentIdentifierSource(), (((long) this.scanner.startPosition) << 32) + (this.scanner.currentPosition - 1));
13492 }
pushIdentifier(int flag)13493 protected void pushIdentifier(int flag) {
13494 	/*push a special flag on the stack :
13495 	-zero stands for optional Name
13496 	-negative number for direct ref to base types.
13497 	identifierLengthPtr points on the top */
13498 
13499 	int stackLength = this.identifierLengthStack.length;
13500 	if (++this.identifierLengthPtr >= stackLength) {
13501 		System.arraycopy(
13502 			this.identifierLengthStack, 0,
13503 			this.identifierLengthStack = new int[stackLength + 10], 0,
13504 			stackLength);
13505 	}
13506 	this.identifierLengthStack[this.identifierLengthPtr] = flag;
13507 }
pushOnAstLengthStack(int pos)13508 protected void pushOnAstLengthStack(int pos) {
13509 
13510 	int stackLength = this.astLengthStack.length;
13511 	if (++this.astLengthPtr >= stackLength) {
13512 		System.arraycopy(
13513 			this.astLengthStack, 0,
13514 			this.astLengthStack = new int[stackLength + StackIncrement], 0,
13515 			stackLength);
13516 	}
13517 	this.astLengthStack[this.astLengthPtr] = pos;
13518 }
pushOnPatternStack(ASTNode pattern)13519 protected void pushOnPatternStack(ASTNode pattern) {
13520 	/*add a new obj on top of the ast stack
13521 	astPtr points on the top*/
13522 
13523 	int stackLength = this.patternStack.length;
13524 	if (++this.patternPtr >= stackLength) {
13525 		System.arraycopy(
13526 			this.patternStack, 0,
13527 			this.patternStack = new ASTNode[stackLength + AstStackIncrement], 0,
13528 			stackLength);
13529 		this.patternPtr = stackLength;
13530 	}
13531 	this.patternStack[this.patternPtr] = pattern;
13532 
13533 	stackLength = this.patternLengthStack.length;
13534 	if (++this.patternLengthPtr >= stackLength) {
13535 		System.arraycopy(
13536 			this.patternLengthStack, 0,
13537 			this.patternLengthStack = new int[stackLength + AstStackIncrement], 0,
13538 			stackLength);
13539 	}
13540 	this.patternLengthStack[this.patternLengthPtr] = 1;
13541 }
pushOnAstStack(ASTNode node)13542 protected void pushOnAstStack(ASTNode node) {
13543 	/*add a new obj on top of the ast stack
13544 	astPtr points on the top*/
13545 
13546 	int stackLength = this.astStack.length;
13547 	if (++this.astPtr >= stackLength) {
13548 		System.arraycopy(
13549 			this.astStack, 0,
13550 			this.astStack = new ASTNode[stackLength + AstStackIncrement], 0,
13551 			stackLength);
13552 		this.astPtr = stackLength;
13553 	}
13554 	this.astStack[this.astPtr] = node;
13555 
13556 	stackLength = this.astLengthStack.length;
13557 	if (++this.astLengthPtr >= stackLength) {
13558 		System.arraycopy(
13559 			this.astLengthStack, 0,
13560 			this.astLengthStack = new int[stackLength + AstStackIncrement], 0,
13561 			stackLength);
13562 	}
13563 	this.astLengthStack[this.astLengthPtr] = 1;
13564 }
pushOnTypeAnnotationStack(Annotation annotation)13565 protected void pushOnTypeAnnotationStack(Annotation annotation) {
13566 
13567 	int stackLength = this.typeAnnotationStack.length;
13568 	if (++this.typeAnnotationPtr >= stackLength) {
13569 		System.arraycopy(
13570 			this.typeAnnotationStack, 0,
13571 			this.typeAnnotationStack = new Annotation[stackLength + TypeAnnotationStackIncrement], 0,
13572 			stackLength);
13573 	}
13574 	this.typeAnnotationStack[this.typeAnnotationPtr] = annotation;
13575 
13576 	stackLength = this.typeAnnotationLengthStack.length;
13577 	if (++this.typeAnnotationLengthPtr >= stackLength) {
13578 		System.arraycopy(
13579 			this.typeAnnotationLengthStack, 0,
13580 			this.typeAnnotationLengthStack = new int[stackLength + TypeAnnotationStackIncrement], 0,
13581 			stackLength);
13582 	}
13583 	this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr] = 1;
13584 }
pushOnTypeAnnotationLengthStack(int pos)13585 protected void pushOnTypeAnnotationLengthStack(int pos) {
13586 
13587 	int stackLength = this.typeAnnotationLengthStack.length;
13588 	if (++this.typeAnnotationLengthPtr >= stackLength) {
13589 		System.arraycopy(
13590 			this.typeAnnotationLengthStack, 0,
13591 			this.typeAnnotationLengthStack = new int[stackLength + TypeAnnotationStackIncrement], 0,
13592 			stackLength);
13593 	}
13594 	this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr] = pos;
13595 }
pushOnExpressionStack(Expression expr)13596 protected void pushOnExpressionStack(Expression expr) {
13597 
13598 	int stackLength = this.expressionStack.length;
13599 	if (++this.expressionPtr >= stackLength) {
13600 		System.arraycopy(
13601 			this.expressionStack, 0,
13602 			this.expressionStack = new Expression[stackLength + ExpressionStackIncrement], 0,
13603 			stackLength);
13604 	}
13605 	this.expressionStack[this.expressionPtr] = expr;
13606 
13607 	stackLength = this.expressionLengthStack.length;
13608 	if (++this.expressionLengthPtr >= stackLength) {
13609 		System.arraycopy(
13610 			this.expressionLengthStack, 0,
13611 			this.expressionLengthStack = new int[stackLength + ExpressionStackIncrement], 0,
13612 			stackLength);
13613 	}
13614 	this.expressionLengthStack[this.expressionLengthPtr] = 1;
13615 }
pushOnExpressionStackLengthStack(int pos)13616 protected void pushOnExpressionStackLengthStack(int pos) {
13617 
13618 	int stackLength = this.expressionLengthStack.length;
13619 	if (++this.expressionLengthPtr >= stackLength) {
13620 		System.arraycopy(
13621 			this.expressionLengthStack, 0,
13622 			this.expressionLengthStack = new int[stackLength + StackIncrement], 0,
13623 			stackLength);
13624 	}
13625 	this.expressionLengthStack[this.expressionLengthPtr] = pos;
13626 }
pushOnGenericsIdentifiersLengthStack(int pos)13627 protected void pushOnGenericsIdentifiersLengthStack(int pos) {
13628 	int stackLength = this.genericsIdentifiersLengthStack.length;
13629 	if (++this.genericsIdentifiersLengthPtr >= stackLength) {
13630 		System.arraycopy(
13631 			this.genericsIdentifiersLengthStack, 0,
13632 			this.genericsIdentifiersLengthStack = new int[stackLength + GenericsStackIncrement], 0,
13633 			stackLength);
13634 	}
13635 	this.genericsIdentifiersLengthStack[this.genericsIdentifiersLengthPtr] = pos;
13636 }
pushOnGenericsLengthStack(int pos)13637 protected void pushOnGenericsLengthStack(int pos) {
13638 	int stackLength = this.genericsLengthStack.length;
13639 	if (++this.genericsLengthPtr >= stackLength) {
13640 		System.arraycopy(
13641 			this.genericsLengthStack, 0,
13642 			this.genericsLengthStack = new int[stackLength + GenericsStackIncrement], 0,
13643 			stackLength);
13644 	}
13645 	this.genericsLengthStack[this.genericsLengthPtr] = pos;
13646 }
pushOnGenericsStack(ASTNode node)13647 protected void pushOnGenericsStack(ASTNode node) {
13648 	/*add a new obj on top of the generics stack
13649 	genericsPtr points on the top*/
13650 
13651 	int stackLength = this.genericsStack.length;
13652 	if (++this.genericsPtr >= stackLength) {
13653 		System.arraycopy(
13654 			this.genericsStack, 0,
13655 			this.genericsStack = new ASTNode[stackLength + GenericsStackIncrement], 0,
13656 			stackLength);
13657 	}
13658 	this.genericsStack[this.genericsPtr] = node;
13659 
13660 	stackLength = this.genericsLengthStack.length;
13661 	if (++this.genericsLengthPtr >= stackLength) {
13662 		System.arraycopy(
13663 			this.genericsLengthStack, 0,
13664 			this.genericsLengthStack = new int[stackLength + GenericsStackIncrement], 0,
13665 			stackLength);
13666 	}
13667 	this.genericsLengthStack[this.genericsLengthPtr] = 1;
13668 }
pushOnIntStack(int pos)13669 protected void pushOnIntStack(int pos) {
13670 
13671 	int stackLength = this.intStack.length;
13672 	if (++this.intPtr >= stackLength) {
13673 		System.arraycopy(
13674 			this.intStack, 0,
13675 			this.intStack = new int[stackLength + StackIncrement], 0,
13676 			stackLength);
13677 	}
13678 	this.intStack[this.intPtr] = pos;
13679 }
pushOnRealBlockStack(int i)13680 protected void pushOnRealBlockStack(int i){
13681 
13682 	int stackLength = this.realBlockStack.length;
13683 	if (++this.realBlockPtr >= stackLength) {
13684 		System.arraycopy(
13685 			this.realBlockStack, 0,
13686 			this.realBlockStack = new int[stackLength + StackIncrement], 0,
13687 			stackLength);
13688 	}
13689 	this.realBlockStack[this.realBlockPtr] = i;
13690 }
recoverStatements()13691 protected void recoverStatements() {
13692 	class MethodVisitor extends ASTVisitor {
13693 		public ASTVisitor typeVisitor;
13694 
13695 		TypeDeclaration enclosingType; // used only for initializer
13696 
13697 		TypeDeclaration[] types = new TypeDeclaration[0];
13698 		int typePtr = -1;
13699 		@Override
13700 		public void endVisit(ConstructorDeclaration constructorDeclaration, ClassScope scope) {
13701 			endVisitMethod(constructorDeclaration, scope);
13702 		}
13703 		@Override
13704 		public void endVisit(Initializer initializer, MethodScope scope) {
13705 			if (initializer.block == null) return;
13706 			TypeDeclaration[] foundTypes = null;
13707 			int length = 0;
13708 			if(this.typePtr > -1) {
13709 				length = this.typePtr + 1;
13710 				foundTypes = new TypeDeclaration[length];
13711 				System.arraycopy(this.types, 0, foundTypes, 0, length);
13712 			}
13713 			ReferenceContext oldContext = Parser.this.referenceContext;
13714 			Parser.this.recoveryScanner.resetTo(initializer.bodyStart, initializer.bodyEnd);
13715 			Scanner oldScanner = Parser.this.scanner;
13716 			Parser.this.scanner = Parser.this.recoveryScanner;
13717 			parseStatements(
13718 					this.enclosingType,
13719 					initializer.bodyStart,
13720 					initializer.bodyEnd,
13721 					foundTypes,
13722 					Parser.this.compilationUnit);
13723 			Parser.this.scanner = oldScanner;
13724 			Parser.this.referenceContext = oldContext;
13725 
13726 			for (int i = 0; i < length; i++) {
13727 				foundTypes[i].traverse(this.typeVisitor, scope);
13728 			}
13729 		}
13730 		@Override
13731 		public void endVisit(MethodDeclaration methodDeclaration, ClassScope scope) {
13732 			endVisitMethod(methodDeclaration, scope);
13733 		}
13734 		private void endVisitMethod(AbstractMethodDeclaration methodDeclaration, ClassScope scope) {
13735 			TypeDeclaration[] foundTypes = null;
13736 			int length = 0;
13737 			if(this.typePtr > -1) {
13738 				length = this.typePtr + 1;
13739 				foundTypes = new TypeDeclaration[length];
13740 				System.arraycopy(this.types, 0, foundTypes, 0, length);
13741 			}
13742 			ReferenceContext oldContext = Parser.this.referenceContext;
13743 			Parser.this.recoveryScanner.resetTo(methodDeclaration.bodyStart, methodDeclaration.bodyEnd);
13744 			Scanner oldScanner = Parser.this.scanner;
13745 			Parser.this.scanner = Parser.this.recoveryScanner;
13746 			parseStatements(
13747 					methodDeclaration,
13748 					methodDeclaration.bodyStart,
13749 					methodDeclaration.bodyEnd,
13750 					foundTypes,
13751 					Parser.this.compilationUnit);
13752 			Parser.this.scanner = oldScanner;
13753 			Parser.this.referenceContext = oldContext;
13754 
13755 			for (int i = 0; i < length; i++) {
13756 				foundTypes[i].traverse(this.typeVisitor, scope);
13757 			}
13758 		}
13759 		@Override
13760 		public boolean visit(ConstructorDeclaration constructorDeclaration, ClassScope scope) {
13761 			this.typePtr = -1;
13762 			return true;
13763 		}
13764 		@Override
13765 		public boolean visit(Initializer initializer, MethodScope scope) {
13766 			this.typePtr = -1;
13767 			if (initializer.block == null) return false;
13768 			return true;
13769 		}
13770 		@Override
13771 		public boolean visit(MethodDeclaration methodDeclaration,ClassScope scope) {
13772 			this.typePtr = -1;
13773 			return true;
13774 		}
13775 		private boolean visit(TypeDeclaration typeDeclaration) {
13776 			if(this.types.length <= ++this.typePtr) {
13777 				int length = this.typePtr;
13778 				System.arraycopy(this.types, 0, this.types = new TypeDeclaration[length * 2 + 1], 0, length);
13779 			}
13780 			this.types[this.typePtr] = typeDeclaration;
13781 			return false;
13782 		}
13783 		@Override
13784 		public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
13785 			return this.visit(typeDeclaration);
13786 		}
13787 		@Override
13788 		public boolean visit(TypeDeclaration typeDeclaration, ClassScope scope) {
13789 			return this.visit(typeDeclaration);
13790 		}
13791 	}
13792 	class TypeVisitor extends ASTVisitor {
13793 		public MethodVisitor methodVisitor;
13794 
13795 		TypeDeclaration[] types = new TypeDeclaration[0];
13796 		int typePtr = -1;
13797 
13798 		@Override
13799 		public void endVisit(TypeDeclaration typeDeclaration, BlockScope scope) {
13800 			endVisitType();
13801 		}
13802 		@Override
13803 		public void endVisit(TypeDeclaration typeDeclaration, ClassScope scope) {
13804 			endVisitType();
13805 		}
13806 		private void endVisitType() {
13807 			this.typePtr--;
13808 		}
13809 		@Override
13810 		public boolean visit(ConstructorDeclaration constructorDeclaration, ClassScope scope) {
13811 			if(constructorDeclaration.isDefaultConstructor()) return false;
13812 
13813 			constructorDeclaration.traverse(this.methodVisitor, scope);
13814 			return false;
13815 		}
13816 		@Override
13817 		public boolean visit(Initializer initializer, MethodScope scope) {
13818 			if (initializer.block == null) return false;
13819 			this.methodVisitor.enclosingType = this.types[this.typePtr];
13820 			initializer.traverse(this.methodVisitor, scope);
13821 			return false;
13822 		}
13823 		@Override
13824 		public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
13825 			methodDeclaration.traverse(this.methodVisitor, scope);
13826 			return false;
13827 		}
13828 		private boolean visit(TypeDeclaration typeDeclaration) {
13829 			if(this.types.length <= ++this.typePtr) {
13830 				int length = this.typePtr;
13831 				System.arraycopy(this.types, 0, this.types = new TypeDeclaration[length * 2 + 1], 0, length);
13832 			}
13833 			this.types[this.typePtr] = typeDeclaration;
13834 			return true;
13835 		}
13836 		@Override
13837 		public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
13838 			return this.visit(typeDeclaration);
13839 		}
13840 		@Override
13841 		public boolean visit(TypeDeclaration typeDeclaration, ClassScope scope) {
13842 			return this.visit(typeDeclaration);
13843 		}
13844 	}
13845 
13846 	MethodVisitor methodVisitor = new MethodVisitor();
13847 	TypeVisitor typeVisitor = new TypeVisitor();
13848 	methodVisitor.typeVisitor = typeVisitor;
13849 	typeVisitor.methodVisitor = methodVisitor;
13850 
13851 	if(this.referenceContext instanceof AbstractMethodDeclaration) {
13852 		((AbstractMethodDeclaration)this.referenceContext).traverse(methodVisitor, (ClassScope)null);
13853 	} else if(this.referenceContext instanceof TypeDeclaration) {
13854 		TypeDeclaration typeContext = (TypeDeclaration)this.referenceContext;
13855 
13856 		int length = typeContext.fields.length;
13857 		for (int i = 0; i < length; i++) {
13858 			final FieldDeclaration fieldDeclaration = typeContext.fields[i];
13859 			switch(fieldDeclaration.getKind()) {
13860 				case AbstractVariableDeclaration.INITIALIZER:
13861 					Initializer initializer = (Initializer) fieldDeclaration;
13862 					if (initializer.block == null) break;
13863 					methodVisitor.enclosingType = typeContext;
13864 					initializer.traverse(methodVisitor, (MethodScope)null);
13865 					break;
13866 			}
13867 		}
13868 	}
13869 }
13870 
recoveryExitFromVariable()13871 public void recoveryExitFromVariable() {
13872 	if(this.currentElement != null && this.currentElement.parent != null) {
13873 		if(this.currentElement instanceof RecoveredLocalVariable) {
13874 
13875 			int end = ((RecoveredLocalVariable)this.currentElement).localDeclaration.sourceEnd;
13876 			this.currentElement.updateSourceEndIfNecessary(end);
13877 			this.currentElement = this.currentElement.parent;
13878 		} else if(this.currentElement instanceof RecoveredField
13879 			&& !(this.currentElement instanceof RecoveredInitializer)) {
13880 			// Do not move focus to parent if we are still inside an array initializer
13881 			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292087
13882 			if (this.currentElement.bracketBalance <= 0) {
13883 				int end = ((RecoveredField)this.currentElement).fieldDeclaration.sourceEnd;
13884 				this.currentElement.updateSourceEndIfNecessary(end);
13885 				this.currentElement = this.currentElement.parent;
13886 			}
13887 		}
13888 	}
13889 }
13890 /* Token check performed on every token shift once having entered
13891  * recovery mode.
13892  */
recoveryTokenCheck()13893 public void recoveryTokenCheck() {
13894 	switch (this.currentToken) {
13895 		case TokenNameStringLiteral :
13896 			if (this.recordStringLiterals &&
13897 					this.checkExternalizeStrings &&
13898 					this.lastPosistion < this.scanner.currentPosition &&
13899 					!this.statementRecoveryActivated) {
13900 				StringLiteral stringLiteral = createStringLiteral(
13901 					this.scanner.getCurrentTokenSourceString(),
13902 					this.scanner.startPosition,
13903 					this.scanner.currentPosition - 1,
13904 					Util.getLineNumber(this.scanner.startPosition, this.scanner.lineEnds, 0, this.scanner.linePtr));
13905 				this.compilationUnit.recordStringLiteral(stringLiteral, this.currentElement != null);
13906 			}
13907 			break;
13908 		case TokenNameLBRACE :
13909 			RecoveredElement newElement = null;
13910 			if(!this.ignoreNextOpeningBrace) {
13911 				newElement = this.currentElement.updateOnOpeningBrace(this.scanner.startPosition - 1, this.scanner.currentPosition - 1);
13912 			}
13913 			this.lastCheckPoint = this.scanner.currentPosition;
13914 			if (newElement != null){ // null means nothing happened
13915 				this.restartRecovery = true; // opening brace detected
13916 				this.currentElement = newElement;
13917 			}
13918 			break;
13919 
13920 		case TokenNameRBRACE :
13921 			if (this.ignoreNextClosingBrace) {
13922 				this.ignoreNextClosingBrace = false;
13923 				break;
13924 			}
13925 			this.rBraceStart = this.scanner.startPosition - 1;
13926 			this.rBraceEnd = this.scanner.currentPosition - 1;
13927 			this.endPosition = flushCommentsDefinedPriorTo(this.rBraceEnd);
13928 			newElement =
13929 				this.currentElement.updateOnClosingBrace(this.scanner.startPosition, this.rBraceEnd);
13930 				this.lastCheckPoint = this.scanner.currentPosition;
13931 			if (newElement != this.currentElement){
13932 				this.currentElement = newElement;
13933 //				if (newElement instanceof RecoveredField && this.dietInt <= 0) {
13934 //					if (((RecoveredField)newElement).fieldDeclaration.type == null) { // enum constant
13935 //						this.isInsideEnumConstantPart = true; // restore status
13936 //					}
13937 //				}
13938 			}
13939 			break;
13940 		case TokenNameSEMICOLON :
13941 			this.endStatementPosition = this.scanner.currentPosition - 1;
13942 			this.endPosition = this.scanner.startPosition - 1;
13943 			RecoveredType currentType = currentRecoveryType();
13944 			if(currentType != null) {
13945 				currentType.insideEnumConstantPart = false;
13946 			}
13947 			//$FALL-THROUGH$
13948 		default : {
13949 			if (this.rBraceEnd > this.rBraceSuccessorStart && this.scanner.currentPosition != this.scanner.startPosition){
13950 				this.rBraceSuccessorStart = this.scanner.startPosition;
13951 			}
13952 			break;
13953 		}
13954 	}
13955 	this.ignoreNextOpeningBrace = false;
13956 }
13957 // A P I
reportSyntaxErrors(boolean isDietParse, int oldFirstToken)13958 protected void reportSyntaxErrors(boolean isDietParse, int oldFirstToken) {
13959 	if(this.referenceContext instanceof MethodDeclaration) {
13960 		MethodDeclaration methodDeclaration = (MethodDeclaration) this.referenceContext;
13961 		if((methodDeclaration.bits & ASTNode.ErrorInSignature) != 0){
13962 			return;
13963 		}
13964 	}
13965 	this.compilationUnit.compilationResult.lineSeparatorPositions = this.scanner.getLineEnds();
13966 	this.scanner.recordLineSeparator = false;
13967 
13968 	int start = this.scanner.initialPosition;
13969 	int end = this.scanner.eofPosition == Integer.MAX_VALUE ? this.scanner.eofPosition : this.scanner.eofPosition - 1;
13970 	if(isDietParse) {
13971 		TypeDeclaration[] types = this.compilationUnit.types;
13972 		int[][] intervalToSkip = org.eclipse.jdt.internal.compiler.parser.diagnose.RangeUtil.computeDietRange(types);
13973 		DiagnoseParser diagnoseParser = new DiagnoseParser(this, oldFirstToken, start, end, intervalToSkip[0], intervalToSkip[1], intervalToSkip[2], this.options);
13974 		diagnoseParser.diagnoseParse(false);
13975 
13976 		reportSyntaxErrorsForSkippedMethod(types);
13977 		this.scanner.resetTo(start, end);
13978 	} else {
13979 		DiagnoseParser diagnoseParser = new DiagnoseParser(this, oldFirstToken, start, end, this.options);
13980 		diagnoseParser.diagnoseParse(this.options.performStatementsRecovery);
13981 	}
13982 }
reportSyntaxErrorsForSkippedMethod(TypeDeclaration[] types)13983 private void reportSyntaxErrorsForSkippedMethod(TypeDeclaration[] types){
13984 	if(types != null) {
13985 		for (int i = 0; i < types.length; i++) {
13986 			TypeDeclaration[] memberTypes = types[i].memberTypes;
13987 			if(memberTypes != null) {
13988 				reportSyntaxErrorsForSkippedMethod(memberTypes);
13989 			}
13990 
13991 			AbstractMethodDeclaration[] methods = types[i].methods;
13992 			if(methods != null) {
13993 				for (int j = 0; j < methods.length; j++) {
13994 					AbstractMethodDeclaration method = methods[j];
13995 					if((method.bits & ASTNode.ErrorInSignature) != 0) {
13996 						if(method.isAnnotationMethod()) {
13997 							DiagnoseParser diagnoseParser = new DiagnoseParser(this, TokenNameQUESTION, method.declarationSourceStart, method.declarationSourceEnd, this.options);
13998 							diagnoseParser.diagnoseParse(this.options.performStatementsRecovery);
13999 						} else {
14000 							DiagnoseParser diagnoseParser = new DiagnoseParser(this, TokenNameDIVIDE, method.declarationSourceStart, method.declarationSourceEnd, this.options);
14001 							diagnoseParser.diagnoseParse(this.options.performStatementsRecovery);
14002 						}
14003 
14004 					}
14005 				}
14006 			}
14007 
14008 			FieldDeclaration[] fields = types[i].fields;
14009 			if (fields != null) {
14010 				int length = fields.length;
14011 				for (int j = 0; j < length; j++) {
14012 					if (fields[j] instanceof Initializer) {
14013 						Initializer initializer = (Initializer)fields[j];
14014 						if((initializer.bits & ASTNode.ErrorInSignature) != 0){
14015 							DiagnoseParser diagnoseParser = new DiagnoseParser(this, TokenNameRIGHT_SHIFT, initializer.declarationSourceStart, initializer.declarationSourceEnd, this.options);
14016 							diagnoseParser.diagnoseParse(this.options.performStatementsRecovery);
14017 						}
14018 					}
14019 				}
14020 			}
14021 		}
14022 	}
14023 }
14024 /**
14025  * Reset modifiers buffer and comment stack. Should be call only for nodes that claim both.
14026  */
resetModifiers()14027 protected void resetModifiers() {
14028 	this.modifiers = ClassFileConstants.AccDefault;
14029 	this.modifiersSourceStart = -1; // <-- see comment into modifiersFlag(int)
14030 	this.scanner.commentPtr = -1;
14031 }
14032 /*
14033  * Reset context so as to resume to regular parse loop
14034  */
resetStacks()14035 protected void resetStacks() {
14036 
14037 	this.astPtr = -1;
14038 	this.astLengthPtr = -1;
14039 	this.patternPtr = -1;
14040 	this.patternLengthPtr = -1;
14041 	this.expressionPtr = -1;
14042 	this.expressionLengthPtr = -1;
14043 	this.typeAnnotationLengthPtr = -1;
14044 	this.typeAnnotationPtr = -1;
14045 	this.identifierPtr = -1;
14046 	this.identifierLengthPtr	= -1;
14047 	this.intPtr = -1;
14048 
14049 	this.nestedMethod[this.nestedType = 0] = 0; // need to reset for further reuse
14050 	this.variablesCounter[this.nestedType] = 0;
14051 	this.switchNestingLevel = 0;
14052 	this.switchWithTry = false;
14053 
14054 	this.dimensions = 0 ;
14055 	this.realBlockStack[this.realBlockPtr = 0] = 0;
14056 	this.recoveredStaticInitializerStart = 0;
14057 	this.listLength = 0;
14058 	this.listTypeParameterLength = 0;
14059 
14060 	this.genericsIdentifiersLengthPtr = -1;
14061 	this.genericsLengthPtr = -1;
14062 	this.genericsPtr = -1;
14063 	this.valueLambdaNestDepth = -1;
14064 	this.recordNestedMethodLevels = new HashMap<>();
14065 }
14066 /*
14067  * Reset context so as to resume to regular parse loop
14068  * If unable to reset for resuming, answers false.
14069  *
14070  * Move checkpoint location, reset internal stacks and
14071  * decide which grammar goal is activated.
14072  */
resumeAfterRecovery()14073 protected int resumeAfterRecovery() {
14074 	if(!this.methodRecoveryActivated && !this.statementRecoveryActivated) {
14075 
14076 		// reset internal stacks
14077 		resetStacks();
14078 		resetModifiers();
14079 
14080 		/* attempt to move checkpoint location */
14081 		if (!moveRecoveryCheckpoint()) {
14082 			return HALT;
14083 		}
14084 
14085 		// only look for headers
14086 		if (this.referenceContext instanceof CompilationUnitDeclaration){
14087 			goForHeaders();
14088 			this.diet = true; // passed this point, will not consider method bodies
14089 			this.dietInt = 0;
14090 			return RESTART;
14091 		}
14092 
14093 		// does not know how to restart
14094 		return HALT;
14095 	} else if(!this.statementRecoveryActivated) {
14096 
14097 		// reset internal stacks
14098 		resetStacks();
14099 		resetModifiers();
14100 
14101 		/* attempt to move checkpoint location */
14102 		if (!moveRecoveryCheckpoint()) {
14103 			return HALT;
14104 		}
14105 
14106 		// only look for headers
14107 		goForHeaders();
14108 		return RESTART;
14109 	} else {
14110 		return HALT;
14111 	}
14112 }
resumeOnSyntaxError()14113 protected int resumeOnSyntaxError() {
14114 	if (this.haltOnSyntaxError)
14115 		return HALT;
14116 	/* request recovery initialization */
14117 	if (this.currentElement == null){
14118 		// Reset javadoc before restart parsing after recovery
14119 		this.javadoc = null;
14120 
14121 		// do not investigate deeper in statement recovery
14122 		if (this.statementRecoveryActivated) return HALT;
14123 
14124 		// build some recovered elements
14125 		this.currentElement = buildInitialRecoveryState();
14126 	}
14127 	/* do not investigate deeper in recovery when no recovered element */
14128 	if (this.currentElement == null) return HALT;
14129 
14130 	/* manual forced recovery restart - after headers */
14131 	if (this.restartRecovery){
14132 		this.restartRecovery = false;
14133 	}
14134 	/* update recovery state with current error state of the parser */
14135 	updateRecoveryState();
14136 	if (getFirstToken() == TokenNameAND) {
14137 		if (this.referenceContext instanceof CompilationUnitDeclaration) {
14138 			TypeDeclaration typeDeclaration = new TypeDeclaration(this.referenceContext.compilationResult());
14139 			typeDeclaration.name = Util.EMPTY_STRING.toCharArray();
14140 			this.currentElement = this.currentElement.add(typeDeclaration, 0);
14141 		}
14142 	}
14143 
14144 	if (this.lastPosistion < this.scanner.currentPosition) {
14145 		this.lastPosistion = this.scanner.currentPosition;
14146 		this.scanner.lastPosition = this.scanner.currentPosition;
14147 	}
14148 
14149 	/* attempt to reset state in order to resume to parse loop */
14150 	return resumeAfterRecovery();
14151 }
setMethodsFullRecovery(boolean enabled)14152 public void setMethodsFullRecovery(boolean enabled) {
14153 	this.options.performMethodsFullRecovery = enabled;
14154 }
setStatementsRecovery(boolean enabled)14155 public void setStatementsRecovery(boolean enabled) {
14156 	if(enabled) this.options.performMethodsFullRecovery = true;
14157 	this.options.performStatementsRecovery = enabled;
14158 }
14159 @Override
toString()14160 public String toString() {
14161 
14162 
14163 	String s = "lastCheckpoint : int = " + String.valueOf(this.lastCheckPoint) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
14164 	s = s + "identifierStack : char["+(this.identifierPtr + 1)+"][] = {"; //$NON-NLS-1$ //$NON-NLS-2$
14165 	for (int i = 0; i <= this.identifierPtr; i++) {
14166 		s = s + "\"" + String.valueOf(this.identifierStack[i]) + "\","; //$NON-NLS-1$ //$NON-NLS-2$
14167 	}
14168 	s = s + "}\n"; //$NON-NLS-1$
14169 
14170 	s = s + "identifierLengthStack : int["+(this.identifierLengthPtr + 1)+"] = {"; //$NON-NLS-1$ //$NON-NLS-2$
14171 	for (int i = 0; i <= this.identifierLengthPtr; i++) {
14172 		s = s + this.identifierLengthStack[i] + ","; //$NON-NLS-1$
14173 	}
14174 	s = s + "}\n"; //$NON-NLS-1$
14175 
14176 	s = s + "astLengthStack : int["+(this.astLengthPtr + 1)+"] = {"; //$NON-NLS-1$ //$NON-NLS-2$
14177 	for (int i = 0; i <= this.astLengthPtr; i++) {
14178 		s = s + this.astLengthStack[i] + ","; //$NON-NLS-1$
14179 	}
14180 	s = s + "}\n"; //$NON-NLS-1$
14181 	s = s + "astPtr : int = " + String.valueOf(this.astPtr) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
14182 
14183 	s = s + "intStack : int["+(this.intPtr + 1)+"] = {"; //$NON-NLS-1$ //$NON-NLS-2$
14184 	for (int i = 0; i <= this.intPtr; i++) {
14185 		s = s + this.intStack[i] + ","; //$NON-NLS-1$
14186 	}
14187 	s = s + "}\n"; //$NON-NLS-1$
14188 
14189 	s = s + "expressionLengthStack : int["+(this.expressionLengthPtr + 1)+"] = {"; //$NON-NLS-1$ //$NON-NLS-2$
14190 	for (int i = 0; i <= this.expressionLengthPtr; i++) {
14191 		s = s + this.expressionLengthStack[i] + ","; //$NON-NLS-1$
14192 	}
14193 	s = s + "}\n"; //$NON-NLS-1$
14194 
14195 	s = s + "expressionPtr : int = " + String.valueOf(this.expressionPtr) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
14196 
14197 	s = s + "genericsIdentifiersLengthStack : int["+(this.genericsIdentifiersLengthPtr + 1)+"] = {"; //$NON-NLS-1$ //$NON-NLS-2$
14198 	for (int i = 0; i <= this.genericsIdentifiersLengthPtr; i++) {
14199 		s = s + this.genericsIdentifiersLengthStack[i] + ","; //$NON-NLS-1$
14200 	}
14201 	s = s + "}\n"; //$NON-NLS-1$
14202 
14203 	s = s + "genericsLengthStack : int["+(this.genericsLengthPtr + 1)+"] = {"; //$NON-NLS-1$ //$NON-NLS-2$
14204 	for (int i = 0; i <= this.genericsLengthPtr; i++) {
14205 		s = s + this.genericsLengthStack[i] + ","; //$NON-NLS-1$
14206 	}
14207 	s = s + "}\n"; //$NON-NLS-1$
14208 
14209 	s = s + "genericsPtr : int = " + String.valueOf(this.genericsPtr) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
14210 
14211 	s = s + "\n\n\n----------------Scanner--------------\n" + this.scanner.toString(); //$NON-NLS-1$
14212 	return s;
14213 
14214 }
14215 /*
14216  * Update recovery state based on current parser/scanner state
14217  */
updateRecoveryState()14218 protected void updateRecoveryState() {
14219 
14220 	/* expose parser state to recovery state */
14221 	this.currentElement.updateFromParserState();
14222 
14223 	/* check and update recovered state based on current token,
14224 		this action is also performed when shifting token after recovery
14225 		got activated once.
14226 	*/
14227 	recoveryTokenCheck();
14228 }
updateSourceDeclarationParts(int variableDeclaratorsCounter)14229 protected void updateSourceDeclarationParts(int variableDeclaratorsCounter) {
14230 	//fields is a definition of fields that are grouped together like in
14231 	//public int[] a, b[], c
14232 	//which results into 3 fields.
14233 
14234 	FieldDeclaration field;
14235 	int endTypeDeclarationPosition =
14236 		-1 + this.astStack[this.astPtr - variableDeclaratorsCounter + 1].sourceStart;
14237 	for (int i = 0; i < variableDeclaratorsCounter - 1; i++) {
14238 		//last one is special(see below)
14239 		field = (FieldDeclaration) this.astStack[this.astPtr - i - 1];
14240 		field.endPart1Position = endTypeDeclarationPosition;
14241 		field.endPart2Position = -1 + this.astStack[this.astPtr - i].sourceStart;
14242 	}
14243 	//last one
14244 	(field = (FieldDeclaration) this.astStack[this.astPtr]).endPart1Position =
14245 		endTypeDeclarationPosition;
14246 	field.endPart2Position = field.declarationSourceEnd;
14247 
14248 }
updateSourcePosition(Expression exp)14249 protected void updateSourcePosition(Expression exp) {
14250 	//update the source Position of the expression
14251 
14252 	//this.intStack : int int
14253 	//-->
14254 	//this.intStack :
14255 
14256 	exp.sourceEnd = this.intStack[this.intPtr--];
14257 	exp.sourceStart = this.intStack[this.intPtr--];
14258 }
copyState(Parser from)14259 public void copyState(Parser from) {
14260 
14261 	Parser parser = from;
14262 
14263 	// Stack pointers.
14264 
14265 	this.stateStackTop = parser.stateStackTop;
14266 	this.unstackedAct = parser.unstackedAct;
14267 	this.identifierPtr = parser.identifierPtr;
14268 	this.identifierLengthPtr = parser.identifierLengthPtr;
14269 	this.astPtr = parser.astPtr;
14270 	this.astLengthPtr = parser.astLengthPtr;
14271 	this.patternPtr = parser.patternPtr;
14272 	this.patternLengthPtr = parser.patternLengthPtr;
14273 	this.expressionPtr = parser.expressionPtr;
14274 	this.expressionLengthPtr = parser.expressionLengthPtr;
14275 	this.genericsPtr = parser.genericsPtr;
14276 	this.genericsLengthPtr = parser.genericsLengthPtr;
14277 	this.genericsIdentifiersLengthPtr = parser.genericsIdentifiersLengthPtr;
14278 	this.typeAnnotationPtr = parser.typeAnnotationPtr;
14279 	this.typeAnnotationLengthPtr = parser.typeAnnotationLengthPtr;
14280 	this.intPtr = parser.intPtr;
14281 	this.nestedType = parser.nestedType;
14282 	this.switchNestingLevel = parser.switchNestingLevel;
14283 	this.switchWithTry = parser.switchWithTry;
14284 	this.realBlockPtr = parser.realBlockPtr;
14285 	this.valueLambdaNestDepth = parser.valueLambdaNestDepth;
14286 
14287 	// Stacks.
14288 
14289 	int length;
14290 	System.arraycopy(parser.stack, 0, this.stack = new int [length = parser.stack.length], 0, length);
14291 	System.arraycopy(parser.identifierStack, 0, this.identifierStack = new char [length = parser.identifierStack.length][], 0, length);
14292 	System.arraycopy(parser.identifierLengthStack, 0, this.identifierLengthStack = new int [length = parser.identifierLengthStack.length], 0, length);
14293 	System.arraycopy(parser.identifierPositionStack, 0, this.identifierPositionStack = new long[length = parser.identifierPositionStack.length], 0, length);
14294 	System.arraycopy(parser.astStack, 0, this.astStack = new ASTNode [length = parser.astStack.length], 0, length);
14295 	System.arraycopy(parser.astLengthStack, 0, this.astLengthStack = new int [length = parser.astLengthStack.length], 0, length);
14296 	System.arraycopy(parser.expressionStack, 0, this.expressionStack = new Expression [length = parser.expressionStack.length], 0, length);
14297 	System.arraycopy(parser.expressionLengthStack, 0, this.expressionLengthStack = new int [length = parser.expressionLengthStack.length], 0, length);
14298 	System.arraycopy(parser.genericsStack, 0, this.genericsStack = new ASTNode [length = parser.genericsStack.length], 0, length);
14299 	System.arraycopy(parser.genericsLengthStack, 0, this.genericsLengthStack = new int [length = parser.genericsLengthStack.length], 0, length);
14300 	System.arraycopy(parser.genericsIdentifiersLengthStack, 0, this.genericsIdentifiersLengthStack = new int [length = parser.genericsIdentifiersLengthStack.length], 0, length);
14301 	System.arraycopy(parser.typeAnnotationStack, 0, this.typeAnnotationStack = new Annotation [length = parser.typeAnnotationStack.length], 0, length);
14302 	System.arraycopy(parser.typeAnnotationLengthStack, 0, this.typeAnnotationLengthStack = new int [length = parser.typeAnnotationLengthStack.length], 0, length);
14303 	System.arraycopy(parser.intStack, 0, this.intStack = new int [length = parser.intStack.length], 0, length);
14304 	System.arraycopy(parser.nestedMethod, 0, this.nestedMethod = new int [length = parser.nestedMethod.length], 0, length);
14305 	System.arraycopy(parser.realBlockStack, 0, this.realBlockStack = new int [length = parser.realBlockStack.length], 0, length);
14306 	System.arraycopy(parser.stateStackLengthStack, 0, this.stateStackLengthStack = new int [length = parser.stateStackLengthStack.length], 0, length);
14307 	System.arraycopy(parser.variablesCounter, 0, this.variablesCounter = new int [length = parser.variablesCounter.length], 0, length);
14308 	System.arraycopy(parser.stack, 0, this.stack = new int [length = parser.stack.length], 0, length);
14309 	System.arraycopy(parser.stack, 0, this.stack = new int [length = parser.stack.length], 0, length);
14310 	System.arraycopy(parser.stack, 0, this.stack = new int [length = parser.stack.length], 0, length);
14311 
14312 	// Loose variables.
14313 
14314 	this.listLength = parser.listLength;
14315 	this.listTypeParameterLength = parser.listTypeParameterLength;
14316 	this.dimensions = parser.dimensions;
14317 	this.recoveredStaticInitializerStart = parser.recoveredStaticInitializerStart;
14318 
14319 	// Parser.resetStacks is not clearing the modifiers, but AssistParser.resumeAfterRecovery is - why ? (the former doesn't)
14320 	// this.modifiers = parser.modifiers;
14321 	// this.modifiersSourceStart = parser.modifiersSourceStart;
14322 }
14323 
automatonState()14324 public int automatonState() {
14325 	return this.stack[this.stateStackTop];
14326 }
automatonWillShift(int token, int lastAction)14327 public boolean automatonWillShift(int token, int lastAction) {
14328 	int stackTop = this.stateStackTop;        // local copy of stack pointer
14329 	int stackTopState = this.stack[stackTop]; // single cell non write through "alternate stack" - the automaton's stack pointer either stays fixed during this manoeuvre or monotonically decreases.
14330 	int highWaterMark = stackTop;
14331 	// A rotated version of the automaton - cf. parse()'s for(;;)
14332 	if (lastAction <= NUM_RULES) { // in recovery mode, we could take a detour to here, with a pending reduce action.
14333 		stackTop --;
14334 		lastAction += ERROR_ACTION;
14335 	}
14336 	for (;;) {
14337 		if (lastAction > ERROR_ACTION) {
14338 			lastAction -= ERROR_ACTION;    /* reduce or shift-reduce on loop entry from above, reduce on loop back */
14339 			do { /* reduce */
14340 				stackTop -= rhs[lastAction] - 1;
14341 				if (stackTop < highWaterMark) {
14342 					stackTopState = this.stack[highWaterMark = stackTop];
14343 				} // else stackTopState is upto date already.
14344 				lastAction = ntAction(stackTopState, lhs[lastAction]);
14345 			} while (lastAction <= NUM_RULES);
14346 		}
14347 		highWaterMark = ++stackTop;
14348 		stackTopState = lastAction; // "push"
14349 		lastAction = tAction(lastAction, token); // can be looked up from a precomputed cache.
14350 		if (lastAction <= NUM_RULES) {
14351 			stackTop --;
14352 		    lastAction += ERROR_ACTION;
14353 			continue;
14354 		}
14355 		// Error => false, Shift, Shift/Reduce => true, Accept => impossible.
14356 		return lastAction != ERROR_ACTION;
14357 	}
14358 }
14359 @Override
isParsingJava14()14360 public boolean isParsingJava14() {
14361 	return this.parsingJava14Plus;
14362 }
14363 @Override
isParsingModuleDeclaration()14364 public boolean isParsingModuleDeclaration() {
14365 	// It can be a null in case of a Vanguard parser, which means no module to be dealt with.
14366 	return (this.parsingJava9Plus && this.compilationUnit != null && this.compilationUnit.isModuleInfo());
14367 }
14368 }
14369