1 /*******************************************************************************
2  * Copyright (c) 2000, 2014 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  *******************************************************************************/
14 package org.eclipse.jdt.core.tests.compiler.parser;
15 
16 
17 import java.util.Map;
18 
19 import junit.framework.Test;
20 
21 import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
22 
23 
24 
25 @SuppressWarnings({ "unchecked", "rawtypes" })
26 public class EnumCompletionParserTest extends AbstractCompletionTest {
EnumCompletionParserTest(String testName)27 public EnumCompletionParserTest(String testName) {
28 	super(testName);
29 }
suite()30 public static Test suite() {
31 	return buildAllCompliancesTestSuite(EnumCompletionParserTest.class);
32 }
33 
34 @Override
getCompilerOptions()35 protected Map getCompilerOptions() {
36 	Map options = super.getCompilerOptions();
37 	options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5);
38 	options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);
39 	options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5);
40 	return options;
41 }
42 
43 /*
44  * https://bugs.eclipse.org/bugs/show_bug.cgi?id=83321
45  */
test0001()46 public void test0001(){
47 	String str =
48 		"public class Completion {\n" +
49 		"	/*here*/\n" +
50 		"}\n" +
51 		"enum Natural {\n" +
52 		"	ONE;\n" +
53 		"}\n";
54 
55 	String completeBehind = "/*here*/";
56 	int cursorLocation = str.indexOf("/*here*/") + completeBehind.length() - 1;
57 	String expectedCompletionNodeToString = "<CompleteOnType:>";
58 	String expectedParentNodeToString = "<NONE>";
59 	String completionIdentifier = "";
60 	String expectedReplacedSource = "";
61 	String expectedUnitDisplayString =
62 		"public class Completion {\n" +
63 		"  <CompleteOnType:>;\n" +
64 		"  public Completion() {\n" +
65 		"  }\n" +
66 		"}\n" +
67 		"enum Natural {\n" +
68 		"  ONE(),\n" +
69 		"  Natural() {\n" +
70 		"  }\n" +
71 		"  <clinit>() {\n" +
72 		"  }\n" +
73 		"}\n";
74 
75 	checkDietParse(
76 			str.toCharArray(),
77 			cursorLocation,
78 			expectedCompletionNodeToString,
79 			expectedParentNodeToString,
80 			expectedUnitDisplayString,
81 			completionIdentifier,
82 			expectedReplacedSource,
83 	"diet ast");
84 }
85 //https://bugs.eclipse.org/bugs/show_bug.cgi?id=84554
test0002()86 public void test0002(){
87 	String str =
88 		"public class Test {\n" +
89 		"	void foo() {\n" +
90 		"	  switch(c) {\n" +
91 		"	  	case FOO :\n" +
92 		"	  	  break;\n" +
93 		"	  }\n" +
94 		"	}\n" +
95 		"}\n";
96 
97 	String completeBehind = "FOO";
98 	int cursorLocation = str.indexOf("FOO") + completeBehind.length() - 1;
99 	String expectedCompletionNodeToString = "<NONE>";
100 	String expectedParentNodeToString = "<NONE>";
101 	String completionIdentifier = "<NONE>";
102 	String expectedReplacedSource = "<NONE>";
103 	String expectedUnitDisplayString =
104 		"public class Test {\n" +
105 		"  public Test() {\n" +
106 		"  }\n" +
107 		"  void foo() {\n" +
108 		"  }\n" +
109 		"}\n";
110 
111 	checkDietParse(
112 			str.toCharArray(),
113 			cursorLocation,
114 			expectedCompletionNodeToString,
115 			expectedParentNodeToString,
116 			expectedUnitDisplayString,
117 			completionIdentifier,
118 			expectedReplacedSource,
119 	"diet ast");
120 
121 	expectedCompletionNodeToString = "<CompleteOnName:FOO>";
122 	expectedParentNodeToString =
123 		"switch (c) {\n" +
124 		"case <CompleteOnName:FOO> :\n" +
125 		"}";
126 	completionIdentifier = "FOO";
127 	expectedReplacedSource = "FOO";
128 	expectedUnitDisplayString =
129 		"public class Test {\n" +
130 		"  public Test() {\n" +
131 		"  }\n" +
132 		"  void foo() {\n" +
133 		"    {\n" +
134 		"      switch (c) {\n" +
135 		"      case <CompleteOnName:FOO> :\n" +
136 		"      }\n" +
137 		"    }\n" +
138 		"  }\n" +
139 		"}\n";
140 
141 	checkMethodParse(
142 			str.toCharArray(),
143 			cursorLocation,
144 			expectedCompletionNodeToString,
145 			expectedParentNodeToString,
146 			expectedUnitDisplayString,
147 			completionIdentifier,
148 			expectedReplacedSource,
149 			"full ast");
150 }
151 //https://bugs.eclipse.org/bugs/show_bug.cgi?id=84554
test0003()152 public void test0003(){
153 	String str =
154 		"public class Test {\n" +
155 		"	void foo() {\n" +
156 		"	  switch(c) {\n" +
157 		"	  	case BAR :\n" +
158 		"	  	case FOO :\n" +
159 		"	  	  break;\n" +
160 		"	  }\n" +
161 		"	}\n" +
162 		"}\n";
163 
164 	String completeBehind = "FOO";
165 	int cursorLocation = str.indexOf("FOO") + completeBehind.length() - 1;
166 	String expectedCompletionNodeToString = "<NONE>";
167 	String expectedParentNodeToString = "<NONE>";
168 	String completionIdentifier = "<NONE>";
169 	String expectedReplacedSource = "<NONE>";
170 	String expectedUnitDisplayString =
171 		"public class Test {\n" +
172 		"  public Test() {\n" +
173 		"  }\n" +
174 		"  void foo() {\n" +
175 		"  }\n" +
176 		"}\n";
177 
178 	checkDietParse(
179 			str.toCharArray(),
180 			cursorLocation,
181 			expectedCompletionNodeToString,
182 			expectedParentNodeToString,
183 			expectedUnitDisplayString,
184 			completionIdentifier,
185 			expectedReplacedSource,
186 	"diet ast");
187 
188 	expectedCompletionNodeToString = "<CompleteOnName:FOO>";
189 	expectedParentNodeToString =
190 		"switch (c) {\n" +
191 		"case BAR :\n" +
192 		"case <CompleteOnName:FOO> :\n" +
193 		"}";
194 	completionIdentifier = "FOO";
195 	expectedReplacedSource = "FOO";
196 	expectedUnitDisplayString =
197 		"public class Test {\n" +
198 		"  public Test() {\n" +
199 		"  }\n" +
200 		"  void foo() {\n" +
201 		"    {\n" +
202 		"      switch (c) {\n" +
203 		"      case BAR :\n" +
204 		"      case <CompleteOnName:FOO> :\n" +
205 		"      }\n" +
206 		"    }\n" +
207 		"  }\n" +
208 		"}\n";
209 
210 	checkMethodParse(
211 			str.toCharArray(),
212 			cursorLocation,
213 			expectedCompletionNodeToString,
214 			expectedParentNodeToString,
215 			expectedUnitDisplayString,
216 			completionIdentifier,
217 			expectedReplacedSource,
218 			"full ast");
219 }
220 //https://bugs.eclipse.org/bugs/show_bug.cgi?id=84554
test0004()221 public void test0004(){
222 	String str =
223 		"public class Test {\n" +
224 		"	void foo() {\n" +
225 		"	  switch(c) {\n" +
226 		"	  	case BAR :\n" +
227 		"	  	  break;\n" +
228 		"	  	case FOO :\n" +
229 		"	  	  break;\n" +
230 		"	  }\n" +
231 		"	}\n" +
232 		"}\n";
233 
234 	String completeBehind = "FOO";
235 	int cursorLocation = str.indexOf("FOO") + completeBehind.length() - 1;
236 	String expectedCompletionNodeToString = "<NONE>";
237 	String expectedParentNodeToString = "<NONE>";
238 	String completionIdentifier = "<NONE>";
239 	String expectedReplacedSource = "<NONE>";
240 	String expectedUnitDisplayString =
241 		"public class Test {\n" +
242 		"  public Test() {\n" +
243 		"  }\n" +
244 		"  void foo() {\n" +
245 		"  }\n" +
246 		"}\n";
247 
248 	checkDietParse(
249 			str.toCharArray(),
250 			cursorLocation,
251 			expectedCompletionNodeToString,
252 			expectedParentNodeToString,
253 			expectedUnitDisplayString,
254 			completionIdentifier,
255 			expectedReplacedSource,
256 	"diet ast");
257 
258 	expectedCompletionNodeToString = "<CompleteOnName:FOO>";
259 	expectedParentNodeToString =
260 		"switch (c) {\n" +
261 		"case BAR :\n" +
262 		"    break;\n" +
263 		"case <CompleteOnName:FOO> :\n" +
264 		"}";
265 	completionIdentifier = "FOO";
266 	expectedReplacedSource = "FOO";
267 	expectedUnitDisplayString =
268 		"public class Test {\n" +
269 		"  public Test() {\n" +
270 		"  }\n" +
271 		"  void foo() {\n" +
272 		"    {\n" +
273 		"      switch (c) {\n" +
274 		"      case BAR :\n" +
275 		"          break;\n" +
276 		"      case <CompleteOnName:FOO> :\n" +
277 		"      }\n" +
278 		"    }\n" +
279 		"  }\n" +
280 		"}\n";
281 
282 	checkMethodParse(
283 			str.toCharArray(),
284 			cursorLocation,
285 			expectedCompletionNodeToString,
286 			expectedParentNodeToString,
287 			expectedUnitDisplayString,
288 			completionIdentifier,
289 			expectedReplacedSource,
290 			"full ast");
291 }
292 //https://bugs.eclipse.org/bugs/show_bug.cgi?id=84554
test0005()293 public void test0005(){
294 	String str =
295 		"public class Test {\n" +
296 		"	void foo() {\n" +
297 		"	  switch(c) {\n" +
298 		"	  	case BAR :\n" +
299 		"	  	  break;\n" +
300 		"	  	case FOO :\n" +
301 		"	  }\n" +
302 		"	}\n" +
303 		"}\n";
304 
305 	String completeBehind = "FOO";
306 	int cursorLocation = str.indexOf("FOO") + completeBehind.length() - 1;
307 	String expectedCompletionNodeToString = "<NONE>";
308 	String expectedParentNodeToString = "<NONE>";
309 	String completionIdentifier = "<NONE>";
310 	String expectedReplacedSource = "<NONE>";
311 	String expectedUnitDisplayString =
312 		"public class Test {\n" +
313 		"  public Test() {\n" +
314 		"  }\n" +
315 		"  void foo() {\n" +
316 		"  }\n" +
317 		"}\n";
318 
319 	checkDietParse(
320 			str.toCharArray(),
321 			cursorLocation,
322 			expectedCompletionNodeToString,
323 			expectedParentNodeToString,
324 			expectedUnitDisplayString,
325 			completionIdentifier,
326 			expectedReplacedSource,
327 	"diet ast");
328 
329 	expectedCompletionNodeToString = "<CompleteOnName:FOO>";
330 	expectedParentNodeToString =
331 		"switch (c) {\n" +
332 		"case BAR :\n" +
333 		"    break;\n" +
334 		"case <CompleteOnName:FOO> :\n" +
335 		"}";
336 	completionIdentifier = "FOO";
337 	expectedReplacedSource = "FOO";
338 	expectedUnitDisplayString =
339 		"public class Test {\n" +
340 		"  public Test() {\n" +
341 		"  }\n" +
342 		"  void foo() {\n" +
343 		"    {\n" +
344 		"      switch (c) {\n" +
345 		"      case BAR :\n" +
346 		"          break;\n" +
347 		"      case <CompleteOnName:FOO> :\n" +
348 		"      }\n" +
349 		"    }\n" +
350 		"  }\n" +
351 		"}\n";
352 
353 	checkMethodParse(
354 			str.toCharArray(),
355 			cursorLocation,
356 			expectedCompletionNodeToString,
357 			expectedParentNodeToString,
358 			expectedUnitDisplayString,
359 			completionIdentifier,
360 			expectedReplacedSource,
361 			"full ast");
362 }
363 //https://bugs.eclipse.org/bugs/show_bug.cgi?id=84554
test0006()364 public void test0006(){
365 	String str =
366 		"public class Test {\n" +
367 		"	void foo() {\n" +
368 		"	  switch(c) {\n" +
369 		"	  	case BAR :\n" +
370 		"	  	  break;\n" +
371 		"	  	case FOO\n" +
372 		"	  }\n" +
373 		"	}\n" +
374 		"}\n";
375 
376 	String completeBehind = "FOO";
377 	int cursorLocation = str.indexOf("FOO") + completeBehind.length() - 1;
378 	String expectedCompletionNodeToString = "<NONE>";
379 	String expectedParentNodeToString = "<NONE>";
380 	String completionIdentifier = "<NONE>";
381 	String expectedReplacedSource = "<NONE>";
382 	String expectedUnitDisplayString =
383 		"public class Test {\n" +
384 		"  public Test() {\n" +
385 		"  }\n" +
386 		"  void foo() {\n" +
387 		"  }\n" +
388 		"}\n";
389 
390 	checkDietParse(
391 			str.toCharArray(),
392 			cursorLocation,
393 			expectedCompletionNodeToString,
394 			expectedParentNodeToString,
395 			expectedUnitDisplayString,
396 			completionIdentifier,
397 			expectedReplacedSource,
398 	"diet ast");
399 
400 	expectedCompletionNodeToString = "<CompleteOnName:FOO>";
401 	expectedParentNodeToString =
402 		"switch (c) {\n" +
403 		"case BAR :\n" +
404 		"    break;\n" +
405 		"case <CompleteOnName:FOO> :\n" +
406 		"}";
407 	completionIdentifier = "FOO";
408 	expectedReplacedSource = "FOO";
409 	expectedUnitDisplayString =
410 		"public class Test {\n" +
411 		"  public Test() {\n" +
412 		"  }\n" +
413 		"  void foo() {\n" +
414 		"    {\n" +
415 		"      switch (c) {\n" +
416 		"      case BAR :\n" +
417 		"          break;\n" +
418 		"      case <CompleteOnName:FOO> :\n" +
419 		"      }\n" +
420 		"    }\n" +
421 		"  }\n" +
422 		"}\n";
423 
424 	checkMethodParse(
425 			str.toCharArray(),
426 			cursorLocation,
427 			expectedCompletionNodeToString,
428 			expectedParentNodeToString,
429 			expectedUnitDisplayString,
430 			completionIdentifier,
431 			expectedReplacedSource,
432 			"full ast");
433 }
434 //https://bugs.eclipse.org/bugs/show_bug.cgi?id=84554
test0007()435 public void test0007(){
436 	String str =
437 		"public class Test {\n" +
438 		"	void foo() {\n" +
439 		"	  switch(c) {\n" +
440 		"	  	case BAR0 :\n" +
441 		"	      switch(c) {\n" +
442 		"	        case BAR :\n" +
443 		"	  	      break;\n" +
444 		"	  	    case FOO\n" +
445 		"	      }\n" +
446 		"	  	  break;\n" +
447 		"	  	case BAR2 :\n" +
448 		"	  	  break;\n" +
449 		"	  }\n" +
450 		"	}\n" +
451 		"}\n";
452 
453 	String completeBehind = "FOO";
454 	int cursorLocation = str.indexOf("FOO") + completeBehind.length() - 1;
455 	String expectedCompletionNodeToString = "<NONE>";
456 	String expectedParentNodeToString = "<NONE>";
457 	String completionIdentifier = "<NONE>";
458 	String expectedReplacedSource = "<NONE>";
459 	String expectedUnitDisplayString =
460 		"public class Test {\n" +
461 		"  public Test() {\n" +
462 		"  }\n" +
463 		"  void foo() {\n" +
464 		"  }\n" +
465 		"}\n";
466 
467 	checkDietParse(
468 			str.toCharArray(),
469 			cursorLocation,
470 			expectedCompletionNodeToString,
471 			expectedParentNodeToString,
472 			expectedUnitDisplayString,
473 			completionIdentifier,
474 			expectedReplacedSource,
475 	"diet ast");
476 
477 	expectedCompletionNodeToString = "<CompleteOnName:FOO>";
478 	expectedParentNodeToString =
479 		"switch (c) {\n" +
480 		"case BAR :\n" +
481 		"    break;\n" +
482 		"case <CompleteOnName:FOO> :\n" +
483 		"}";
484 	completionIdentifier = "FOO";
485 	expectedReplacedSource = "FOO";
486 	expectedUnitDisplayString =
487 		"public class Test {\n" +
488 		"  public Test() {\n" +
489 		"  }\n" +
490 		"  void foo() {\n" +
491 		"    {\n" +
492 		"      {\n" +
493 		"        switch (c) {\n" +
494 		"        case BAR :\n" +
495 		"            break;\n" +
496 		"        case <CompleteOnName:FOO> :\n" +
497 		"        }\n" +
498 		"      }\n" +
499 		"    }\n" +
500 		"  }\n" +
501 		"}\n";
502 
503 	checkMethodParse(
504 			str.toCharArray(),
505 			cursorLocation,
506 			expectedCompletionNodeToString,
507 			expectedParentNodeToString,
508 			expectedUnitDisplayString,
509 			completionIdentifier,
510 			expectedReplacedSource,
511 			"full ast");
512 }
513 //https://bugs.eclipse.org/bugs/show_bug.cgi?id=84554
test0008()514 public void test0008(){
515 	String str =
516 		"public enum Test {\n" +
517 		"	A() {\n" +
518 		"	  void foo() {\n" +
519 		"	    zzz\n" +
520 		"	  }\n" +
521 		"	}\n" +
522 		"}\n";
523 
524 	String completeBehind = "zzz";
525 	int cursorLocation = str.indexOf("zzz") + completeBehind.length() - 1;
526 	String expectedCompletionNodeToString = "<CompleteOnName:zzz>";
527 	String expectedParentNodeToString = "<NONE>";
528 	String completionIdentifier = "zzz";
529 	String expectedReplacedSource = "zzz";
530 	String expectedUnitDisplayString =
531 		"public enum Test {\n" +
532 		"  A() {\n" +
533 		"    void foo() {\n" +
534 		"      <CompleteOnName:zzz>;\n" +
535 		"    }\n" +
536 		"  },\n" +
537 		"  public Test() {\n" +
538 		"  }\n" +
539 		"  <clinit>() {\n" +
540 		"  }\n" +
541 		"}\n";
542 
543 	checkDietParse(
544 			str.toCharArray(),
545 			cursorLocation,
546 			expectedCompletionNodeToString,
547 			expectedParentNodeToString,
548 			expectedUnitDisplayString,
549 			completionIdentifier,
550 			expectedReplacedSource,
551 	"diet ast");
552 }
553 //https://bugs.eclipse.org/bugs/show_bug.cgi?id=84554
test0009()554 public void test0009(){
555 	String str =
556 		"public enum Test {\n" +
557 		"	B,\n" +
558 		"	A() {\n" +
559 		"	  void foo() {\n" +
560 		"	    zzz\n" +
561 		"	  }\n" +
562 		"	}\n" +
563 		"}\n";
564 
565 	String completeBehind = "zzz";
566 	int cursorLocation = str.indexOf("zzz") + completeBehind.length() - 1;
567 	String expectedCompletionNodeToString = "<CompleteOnName:zzz>";
568 	String expectedParentNodeToString = "<NONE>";
569 	String completionIdentifier = "zzz";
570 	String expectedReplacedSource = "zzz";
571 	String expectedUnitDisplayString =
572 		"public enum Test {\n" +
573 		"  B(),\n" +
574 		"  A() {\n" +
575 		"    void foo() {\n" +
576 		"      <CompleteOnName:zzz>;\n" +
577 		"    }\n" +
578 		"  },\n" +
579 		"  public Test() {\n" +
580 		"  }\n" +
581 		"  <clinit>() {\n" +
582 		"  }\n" +
583 		"}\n";
584 
585 	checkDietParse(
586 			str.toCharArray(),
587 			cursorLocation,
588 			expectedCompletionNodeToString,
589 			expectedParentNodeToString,
590 			expectedUnitDisplayString,
591 			completionIdentifier,
592 			expectedReplacedSource,
593 	"diet ast");
594 }
595 //https://bugs.eclipse.org/bugs/show_bug.cgi?id=84554
test0010()596 public void test0010(){
597 	String str =
598 		"public enum Test {\n" +
599 		"	#\n" +
600 		"	B,\n" +
601 		"	A() {\n" +
602 		"	  void foo() {\n" +
603 		"	    zzz\n" +
604 		"	  }\n" +
605 		"	}\n" +
606 		"}\n";
607 
608 	String completeBehind = "zzz";
609 	int cursorLocation = str.indexOf("zzz") + completeBehind.length() - 1;
610 	String expectedCompletionNodeToString = "<CompleteOnName:zzz>";
611 	String expectedParentNodeToString = "<NONE>";
612 	String completionIdentifier = "zzz";
613 	String expectedReplacedSource = "zzz";
614 	String expectedUnitDisplayString =
615 		"public enum Test {\n" +
616 		"  B(),\n" +
617 		"  A() {\n" +
618 		"    void foo() {\n" +
619 		"      <CompleteOnName:zzz>;\n" +
620 		"    }\n" +
621 		"  },\n" +
622 		"  public Test() {\n" +
623 		"  }\n" +
624 		"  <clinit>() {\n" +
625 		"  }\n" +
626 		"}\n";
627 
628 	checkDietParse(
629 			str.toCharArray(),
630 			cursorLocation,
631 			expectedCompletionNodeToString,
632 			expectedParentNodeToString,
633 			expectedUnitDisplayString,
634 			completionIdentifier,
635 			expectedReplacedSource,
636 	"diet ast");
637 }
638 //https://bugs.eclipse.org/bugs/show_bug.cgi?id=84554
test0011()639 public void test0011(){
640 	String str =
641 		"public enum Test {\n" +
642 		"	B() {\n" +
643 		"	  void foo() {\n" +
644 		"	  }\n" +
645 		"	},\n" +
646 		"	A() {\n" +
647 		"	  void foo() {\n" +
648 		"	    zzz\n" +
649 		"	  }\n" +
650 		"	}\n" +
651 		"}\n";
652 
653 	String completeBehind = "zzz";
654 	int cursorLocation = str.indexOf("zzz") + completeBehind.length() - 1;
655 	String expectedCompletionNodeToString = "<CompleteOnName:zzz>";
656 	String expectedParentNodeToString = "<NONE>";
657 	String completionIdentifier = "zzz";
658 	String expectedReplacedSource = "zzz";
659 	String expectedUnitDisplayString =
660 		"public enum Test {\n" +
661 		"  B() {\n" +
662 		"    void foo() {\n" +
663 		"    }\n" +
664 		"  },\n" +
665 		"  A() {\n" +
666 		"    void foo() {\n" +
667 		"      <CompleteOnName:zzz>;\n" +
668 		"    }\n" +
669 		"  },\n" +
670 		"  public Test() {\n" +
671 		"  }\n" +
672 		"  <clinit>() {\n" +
673 		"  }\n" +
674 		"}\n";
675 
676 	checkDietParse(
677 			str.toCharArray(),
678 			cursorLocation,
679 			expectedCompletionNodeToString,
680 			expectedParentNodeToString,
681 			expectedUnitDisplayString,
682 			completionIdentifier,
683 			expectedReplacedSource,
684 	"diet ast");
685 }
686 //https://bugs.eclipse.org/bugs/show_bug.cgi?id=84554
test0012()687 public void test0012(){
688 	String str =
689 		"public enum Test {\n" +
690 		"	#\n" +
691 		"	B() {\n" +
692 		"	  void foo() {\n" +
693 		"	  }\n" +
694 		"	},\n" +
695 		"	A() {\n" +
696 		"	  void foo() {\n" +
697 		"	    zzz\n" +
698 		"	  }\n" +
699 		"	}\n" +
700 		"}\n";
701 
702 	String completeBehind = "zzz";
703 	int cursorLocation = str.indexOf("zzz") + completeBehind.length() - 1;
704 	String expectedCompletionNodeToString = "<CompleteOnName:zzz>";
705 	String expectedParentNodeToString = "<NONE>";
706 	String completionIdentifier = "zzz";
707 	String expectedReplacedSource = "zzz";
708 	String expectedUnitDisplayString =
709 		"public enum Test {\n" +
710 		"  B() {\n" +
711 		"    void foo() {\n" +
712 		"    }\n" +
713 		"  },\n" +
714 		"  A() {\n" +
715 		"    void foo() {\n" +
716 		"      <CompleteOnName:zzz>;\n" +
717 		"    }\n" +
718 		"  },\n" +
719 		"  public Test() {\n" +
720 		"  }\n" +
721 		"  <clinit>() {\n" +
722 		"  }\n" +
723 		"}\n";
724 
725 	checkDietParse(
726 			str.toCharArray(),
727 			cursorLocation,
728 			expectedCompletionNodeToString,
729 			expectedParentNodeToString,
730 			expectedUnitDisplayString,
731 			completionIdentifier,
732 			expectedReplacedSource,
733 	"diet ast");
734 }
735 //https://bugs.eclipse.org/bugs/show_bug.cgi?id=84554
test0013()736 public void test0013(){
737 	String str =
738 		"public enum Test {\n" +
739 		"	#\n" +
740 		"	B() {\n" +
741 		"	  void foo() {\n" +
742 		"	    #\n" +
743 		"	  }\n" +
744 		"	},\n" +
745 		"	A() {\n" +
746 		"	  void foo() {\n" +
747 		"	    zzz\n" +
748 		"	  }\n" +
749 		"	}\n" +
750 		"}\n";
751 
752 	String completeBehind = "zzz";
753 	int cursorLocation = str.indexOf("zzz") + completeBehind.length() - 1;
754 	String expectedCompletionNodeToString = "<CompleteOnName:zzz>";
755 	String expectedParentNodeToString = "<NONE>";
756 	String completionIdentifier = "zzz";
757 	String expectedReplacedSource = "zzz";
758 	String expectedUnitDisplayString =
759 		"public enum Test {\n" +
760 		"  B() {\n" +
761 		"    void foo() {\n" +
762 		"    }\n" +
763 		"  },\n" +
764 		"  A() {\n" +
765 		"    void foo() {\n" +
766 		"      <CompleteOnName:zzz>;\n" +
767 		"    }\n" +
768 		"  },\n" +
769 		"  public Test() {\n" +
770 		"  }\n" +
771 		"  <clinit>() {\n" +
772 		"  }\n" +
773 		"}\n";
774 
775 	checkDietParse(
776 			str.toCharArray(),
777 			cursorLocation,
778 			expectedCompletionNodeToString,
779 			expectedParentNodeToString,
780 			expectedUnitDisplayString,
781 			completionIdentifier,
782 			expectedReplacedSource,
783 	"diet ast");
784 }
785 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=100868
test0014()786 public void test0014(){
787 	String str =
788 		"public enum Enum1 {\n"+
789 		"  A {\n"+
790 		"    tos\n"+
791 		"  };\n"+
792 		"}\n";
793 
794 	String completeBehind = "tos";
795 	int cursorLocation = str.indexOf("tos") + completeBehind.length() - 1;
796 	String expectedCompletionNodeToString = "<CompleteOnType:tos>";
797 	String expectedParentNodeToString = "<NONE>";
798 	String completionIdentifier = "tos";
799 	String expectedReplacedSource = "tos";
800 	String expectedUnitDisplayString =
801 		"public enum Enum1 {\n" +
802 		"  A() {\n" +
803 		"    <CompleteOnType:tos>;\n" +
804 		"  },\n" +
805 		"  public Enum1() {\n" +
806 		"  }\n" +
807 		"  <clinit>() {\n" +
808 		"  }\n" +
809 		"}\n";
810 
811 	checkDietParse(
812 			str.toCharArray(),
813 			cursorLocation,
814 			expectedCompletionNodeToString,
815 			expectedParentNodeToString,
816 			expectedUnitDisplayString,
817 			completionIdentifier,
818 			expectedReplacedSource,
819 	"diet ast");
820 }
821 }
822