View | Details | Raw Unified | Return to bug 36142 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/dom/ASTMatcherTest.java (-5 / +54 lines)
Lines 48-53 Link Here
48
	String E2S;
48
	String E2S;
49
	Type T1;
49
	Type T1;
50
	String T1S;
50
	String T1S;
51
	Type T2;
52
	String T2S;
53
	ParameterizedType PT1;
54
	String PT1S;
51
	Statement S1;
55
	Statement S1;
52
	String S1S;
56
	String S1S;
53
	Statement S2;
57
	Statement S2;
Lines 82-87 Link Here
82
	String JD1S;
86
	String JD1S;
83
	Javadoc JD2;
87
	Javadoc JD2;
84
	String JD2S;
88
	String JD2S;
89
	TypeParameter TP1;
90
	String TP1S;
91
	TypeParameter TP2;
92
	String TP2S;
85
	
93
	
86
	final StringBuffer b = new StringBuffer();
94
	final StringBuffer b = new StringBuffer();
87
	
95
	
Lines 103-108 Link Here
103
		E2S = "(nSYYnS)"; //$NON-NLS-1$
111
		E2S = "(nSYYnS)"; //$NON-NLS-1$
104
		T1 = ast.newSimpleType(ast.newSimpleName("Z")); //$NON-NLS-1$
112
		T1 = ast.newSimpleType(ast.newSimpleName("Z")); //$NON-NLS-1$
105
		T1S = "(tS(nSZZnS)tS)"; //$NON-NLS-1$
113
		T1S = "(tS(nSZZnS)tS)"; //$NON-NLS-1$
114
		T2 = ast.newSimpleType(ast.newSimpleName("Y")); //$NON-NLS-1$
115
		T2S = "(tS(nSYYnS)tS)"; //$NON-NLS-1$
116
		PT1 = ast.newParameterizedType(ast.newSimpleName("Z")); //$NON-NLS-1$
117
		PT1S = "(tM(nSZZnS)tM)"; //$NON-NLS-1$
106
		S1 = ast.newContinueStatement();
118
		S1 = ast.newContinueStatement();
107
		S1S = "(sCNsCN)"; //$NON-NLS-1$
119
		S1S = "(sCNsCN)"; //$NON-NLS-1$
108
		S2 = ast.newBreakStatement();
120
		S2 = ast.newBreakStatement();
Lines 163-168 Link Here
163
		JD2.setComment("/**Y*/"); //$NON-NLS-1$
175
		JD2.setComment("/**Y*/"); //$NON-NLS-1$
164
		JD2S = "(JD/**Y*//**Y*/JD)"; //$NON-NLS-1$
176
		JD2S = "(JD/**Y*//**Y*/JD)"; //$NON-NLS-1$
165
177
178
		TP1 = ast.newTypeParameter();
179
		TP1.setName(ast.newSimpleName("x")); //$NON-NLS-1$
180
		TP1S = "[(tTP[(nSxxnS)]tTP)]"; //$NON-NLS-1$
181
182
		TP2 = ast.newTypeParameter();
183
		TP2.setName(ast.newSimpleName("y")); //$NON-NLS-1$
184
		TP2S = "[(tTP[(nSyynS)]tTP)]"; //$NON-NLS-1$
166
	}
185
	}
167
	
186
	
168
	protected void tearDown() {
187
	protected void tearDown() {
Lines 304-309 Link Here
304
		public boolean match(PackageDeclaration node, Object other) {
323
		public boolean match(PackageDeclaration node, Object other) {
305
			return standardBody(node, other, superMatch ? super.match(node, other) : false);
324
			return standardBody(node, other, superMatch ? super.match(node, other) : false);
306
		}
325
		}
326
		public boolean match(ParameterizedType node, Object other) {
327
			return standardBody(node, other, superMatch ? super.match(node, other) : false);
328
		}
307
		public boolean match(ParenthesizedExpression node, Object other) {
329
		public boolean match(ParenthesizedExpression node, Object other) {
308
			return standardBody(node, other, superMatch ? super.match(node, other) : false);
330
			return standardBody(node, other, superMatch ? super.match(node, other) : false);
309
		}
331
		}
Lines 319-324 Link Here
319
		public boolean match(QualifiedName node, Object other) {
341
		public boolean match(QualifiedName node, Object other) {
320
			return standardBody(node, other, superMatch ? super.match(node, other) : false);
342
			return standardBody(node, other, superMatch ? super.match(node, other) : false);
321
		}
343
		}
344
		public boolean match(QualifiedType node, Object other) {
345
			return standardBody(node, other, superMatch ? super.match(node, other) : false);
346
		}
322
		public boolean match(ReturnStatement node, Object other) {
347
		public boolean match(ReturnStatement node, Object other) {
323
			return standardBody(node, other, superMatch ? super.match(node, other) : false);
348
			return standardBody(node, other, superMatch ? super.match(node, other) : false);
324
		}
349
		}
Lines 370-375 Link Here
370
		public boolean match(TypeLiteral node, Object other) {
395
		public boolean match(TypeLiteral node, Object other) {
371
			return standardBody(node, other, superMatch ? super.match(node, other) : false);
396
			return standardBody(node, other, superMatch ? super.match(node, other) : false);
372
		}
397
		}
398
		public boolean match(TypeParameter node, Object other) {
399
			return standardBody(node, other, superMatch ? super.match(node, other) : false);
400
		}
373
		public boolean match(VariableDeclarationExpression node, Object other) {
401
		public boolean match(VariableDeclarationExpression node, Object other) {
374
			return standardBody(node, other, superMatch ? super.match(node, other) : false);
402
			return standardBody(node, other, superMatch ? super.match(node, other) : false);
375
		}
403
		}
Lines 468-474 Link Here
468
	}
496
	}
469
497
470
	public void testSimpleType() {
498
	public void testSimpleType() {
471
		Type x1 = ast.newSimpleType(ast.newName(new String[]{"Z"})); //$NON-NLS-1$
499
		Type x1 = ast.newSimpleType(N1);
472
		basicMatch(x1);
500
		basicMatch(x1);
473
	}
501
	}
474
502
Lines 478-483 Link Here
478
		basicMatch(x1);
506
		basicMatch(x1);
479
	}
507
	}
480
508
509
	public void testParameterizedType() {
510
		ParameterizedType x1 = ast.newParameterizedType(ast.newSimpleName("X")); //$NON-NLS-1$
511
		basicMatch(x1);
512
	}
513
514
	public void testQualifiedType() {
515
		Type x1 = ast.newQualifiedType(T1, N1);
516
		basicMatch(x1);
517
	}
518
481
	// EXPRESSIONS and STATEMENTS
519
	// EXPRESSIONS and STATEMENTS
482
520
483
	public void testAnonymousClassDeclaration() {
521
	public void testAnonymousClassDeclaration() {
Lines 553-559 Link Here
553
	public void testClassInstanceCreation() {
591
	public void testClassInstanceCreation() {
554
		ClassInstanceCreation x1 = ast.newClassInstanceCreation();
592
		ClassInstanceCreation x1 = ast.newClassInstanceCreation();
555
		x1.setExpression(E1);
593
		x1.setExpression(E1);
556
		x1.setName(N1);
594
		x1.setType(PT1);
557
		x1.setAnonymousClassDeclaration(ACD1);
595
		x1.setAnonymousClassDeclaration(ACD1);
558
		basicMatch(x1);
596
		basicMatch(x1);
559
	}
597
	}
Lines 663-668 Link Here
663
	public void testMethodDeclaration() {
701
	public void testMethodDeclaration() {
664
		MethodDeclaration x1 = ast.newMethodDeclaration();
702
		MethodDeclaration x1 = ast.newMethodDeclaration();
665
		x1.setJavadoc(JD1);
703
		x1.setJavadoc(JD1);
704
		x1.typeParameters().add(TP1);
705
		x1.typeParameters().add(TP2);
666
		x1.setReturnType(T1);
706
		x1.setReturnType(T1);
667
		x1.setName(N1);
707
		x1.setName(N1);
668
		x1.parameters().add(V1);
708
		x1.parameters().add(V1);
Lines 792-800 Link Here
792
		TypeDeclaration x1 = ast.newTypeDeclaration();
832
		TypeDeclaration x1 = ast.newTypeDeclaration();
793
		x1.setJavadoc(JD1);
833
		x1.setJavadoc(JD1);
794
		x1.setName(N1);
834
		x1.setName(N1);
795
		x1.setSuperclass(N2);
835
		x1.typeParameters().add(TP1);
796
		x1.superInterfaces().add(N3);
836
		x1.typeParameters().add(TP2);
797
		x1.superInterfaces().add(ast.newSimpleName("J")); //$NON-NLS-1$
837
		x1.setSuperclassType(PT1);
838
		x1.superInterfaceTypes().add(T1);
839
		x1.superInterfaceTypes().add(T2);
798
		x1.bodyDeclarations().add(FD1);
840
		x1.bodyDeclarations().add(FD1);
799
		x1.bodyDeclarations().add(FD2);
841
		x1.bodyDeclarations().add(FD2);
800
		basicMatch(x1);
842
		basicMatch(x1);
Lines 806-811 Link Here
806
	public void testTypeLiteral() {
848
	public void testTypeLiteral() {
807
		TypeLiteral x1 = ast.newTypeLiteral();
849
		TypeLiteral x1 = ast.newTypeLiteral();
808
		x1.setType(T1);
850
		x1.setType(T1);
851
		basicMatch(x1);
852
	}
853
	public void testTypeParameter() {
854
		TypeParameter x1 = ast.newTypeParameter();
855
		x1.setName(N1);
856
		x1.typeBounds().add(T1);
857
		x1.typeBounds().add(T2);
809
		basicMatch(x1);
858
		basicMatch(x1);
810
	}
859
	}
811
	public void testVariableDeclarationFragment() {
860
	public void testVariableDeclarationFragment() {
(-)src/org/eclipse/jdt/core/tests/dom/ASTNodesCollectorVisitor.java (-1 / +17 lines)
Lines 124-130 Link Here
124
	 * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core.dom.ClassInstanceCreation)
124
	 * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core.dom.ClassInstanceCreation)
125
	 */
125
	 */
126
	public void endVisit(ClassInstanceCreation node) {
126
	public void endVisit(ClassInstanceCreation node) {
127
		node.setName(node.getAST().newSimpleName("XXX")); //$NON-NLS-1$
127
		node.setType(
128
			node.getAST().newSimpleType(
129
				node.getAST().newSimpleName("XXX"))); //$NON-NLS-1$
128
	}
130
	}
129
131
130
	/**
132
	/**
Lines 271-276 Link Here
271
	}
273
	}
272
274
273
	/**
275
	/**
276
	 * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core.dom.ParameterizedType)
277
	 * @since 2.2
278
	 */
279
	public void endVisit(ParameterizedType node) {
280
	}
281
282
	/**
274
	 * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core.dom.ParenthesizedExpression)
283
	 * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core.dom.ParenthesizedExpression)
275
	 */
284
	 */
276
	public void endVisit(ParenthesizedExpression node) {
285
	public void endVisit(ParenthesizedExpression node) {
Lines 423-428 Link Here
423
	 * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core.dom.TypeLiteral)
432
	 * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core.dom.TypeLiteral)
424
	 */
433
	 */
425
	public void endVisit(TypeLiteral node) {
434
	public void endVisit(TypeLiteral node) {
435
	}
436
437
	/**
438
	 * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core.dom.TypeParameter)
439
	 * @since 2.2
440
	 */
441
	public void endVisit(TypeParameter node) {
426
	}
442
	}
427
443
428
	/**
444
	/**
(-)src/org/eclipse/jdt/core/tests/dom/ASTTest.java (-16 / +288 lines)
Lines 330-335 Link Here
330
		}
330
		}
331
	
331
	
332
		/**
332
		/**
333
		 * @see org.eclipse.jdt.core.dom.ASTMatcher#match(ParameterizedType, Object)
334
		 * @since 2.2
335
		 */
336
		public boolean match(ParameterizedType node, Object other) {
337
			checkPositions(node, other);
338
			return super.match(node, other);
339
		}
340
	
341
		/**
333
		 * @see org.eclipse.jdt.core.dom.ASTMatcher#match(ParenthesizedExpression, Object)
342
		 * @see org.eclipse.jdt.core.dom.ASTMatcher#match(ParenthesizedExpression, Object)
334
		 */
343
		 */
335
		public boolean match(ParenthesizedExpression node, Object other) {
344
		public boolean match(ParenthesizedExpression node, Object other) {
Lines 370-375 Link Here
370
		}
379
		}
371
	
380
	
372
		/**
381
		/**
382
		 * @see org.eclipse.jdt.core.dom.ASTMatcher#match(QualifiedType, Object)
383
		 */
384
		public boolean match(QualifiedType node, Object other) {
385
			checkPositions(node, other);
386
			return super.match(node, other);
387
		}
388
	
389
		/**
373
		 * @see org.eclipse.jdt.core.dom.ASTMatcher#match(ReturnStatement, Object)
390
		 * @see org.eclipse.jdt.core.dom.ASTMatcher#match(ReturnStatement, Object)
374
		 */
391
		 */
375
		public boolean match(ReturnStatement node, Object other) {
392
		public boolean match(ReturnStatement node, Object other) {
Lines 506-511 Link Here
506
		}
523
		}
507
	
524
	
508
		/**
525
		/**
526
		 * @see org.eclipse.jdt.core.dom.ASTMatcher#match(TypeParameter, Object)
527
		 * @since 2.2
528
		 */
529
		public boolean match(TypeParameter node, Object other) {
530
			checkPositions(node, other);
531
			return super.match(node, other);
532
		}
533
	
534
		/**
509
		 * @see org.eclipse.jdt.core.dom.ASTMatcher#match(VariableDeclarationExpression, Object)
535
		 * @see org.eclipse.jdt.core.dom.ASTMatcher#match(VariableDeclarationExpression, Object)
510
		 */
536
		 */
511
		public boolean match(VariableDeclarationExpression node, Object other) {
537
		public boolean match(VariableDeclarationExpression node, Object other) {
Lines 1138-1144 Link Here
1138
		assertTrue(x.isDeclaration() == true);
1164
		assertTrue(x.isDeclaration() == true);
1139
		fd.setName(ast.newSimpleName("b")); //$NON-NLS-1$
1165
		fd.setName(ast.newSimpleName("b")); //$NON-NLS-1$
1140
		assertTrue(x.isDeclaration() == false);
1166
		assertTrue(x.isDeclaration() == false);
1141
		
1142
	}		
1167
	}		
1143
1168
1144
	public void testQualifiedName() {
1169
	public void testQualifiedName() {
Lines 1199-1205 Link Here
1199
				x.setName((SimpleName) value);
1224
				x.setName((SimpleName) value);
1200
			}
1225
			}
1201
		});
1226
		});
1227
	}		
1228
1229
	public void testQualifiedType() {
1230
		long previousCount = ast.modificationCount();
1231
		final QualifiedType x = ast.newQualifiedType(
1232
			ast.newSimpleType(ast.newSimpleName("q")), //$NON-NLS-1$
1233
			ast.newSimpleName("i")); //$NON-NLS-1$
1234
		assertTrue(ast.modificationCount() > previousCount);
1235
		previousCount = ast.modificationCount();
1236
		assertTrue(x instanceof Type);
1237
		assertTrue(x.getAST() == ast);
1238
		assertTrue(x.getParent() == null);
1239
		assertTrue(x.getQualifier().getParent() == x);
1240
		assertTrue(x.getName().getParent() == x);
1241
		assertTrue(x.getName().isDeclaration() == false);
1242
		assertTrue(x.getNodeType() == ASTNode.QUALIFIED_TYPE);
1243
		// make sure that reading did not change modification count
1244
		assertTrue(ast.modificationCount() == previousCount);
1245
1246
		genericPropertyTest(x, new Property("Qualifier", true, Type.class) { //$NON-NLS-1$
1247
			public ASTNode sample(AST targetAst, boolean parented) {
1248
				SimpleType result = 
1249
					targetAst.newSimpleType(
1250
						targetAst.newSimpleName("a")); //$NON-NLS-1$
1251
				if (parented) {
1252
					targetAst.newArrayType(result);
1253
				}
1254
				return result;
1255
			}
1256
			public ASTNode wrap() {
1257
				QualifiedType s1 = ast.newQualifiedType(x, ast.newSimpleName("z")); //$NON-NLS-1$
1258
				return s1;
1259
			}
1260
			public void unwrap() {
1261
				QualifiedType s1 = (QualifiedType) x.getParent();
1262
				s1.setQualifier(ast.newSimpleType(ast.newSimpleName("z"))); //$NON-NLS-1$
1263
			}
1264
			public ASTNode get() {
1265
				return x.getQualifier();
1266
			}
1267
			public void set(ASTNode value) {
1268
				x.setQualifier((Type) value);
1269
			}
1270
		});
1202
		
1271
		
1272
		genericPropertyTest(x, new Property("Name", true, SimpleName.class) { //$NON-NLS-1$
1273
			public ASTNode sample(AST targetAst, boolean parented) {
1274
				SimpleName result = targetAst.newSimpleName("foo"); //$NON-NLS-1$
1275
				if (parented) {
1276
					targetAst.newExpressionStatement(result);
1277
				}
1278
				return result;
1279
			}
1280
			public ASTNode get() {
1281
				return x.getName();
1282
			}
1283
			public void set(ASTNode value) {
1284
				x.setName((SimpleName) value);
1285
			}
1286
		});
1203
	}		
1287
	}		
1204
1288
1205
	public void testNullLiteral() {
1289
	public void testNullLiteral() {
Lines 1482-1487 Link Here
1482
		assertTrue(x.isSimpleType());
1566
		assertTrue(x.isSimpleType());
1483
		assertTrue(!x.isArrayType());
1567
		assertTrue(!x.isArrayType());
1484
		assertTrue(!x.isPrimitiveType());
1568
		assertTrue(!x.isPrimitiveType());
1569
		assertTrue(!x.isParameterizedType());
1485
		assertTrue(x.getNodeType() == ASTNode.SIMPLE_TYPE);
1570
		assertTrue(x.getNodeType() == ASTNode.SIMPLE_TYPE);
1486
		// make sure that reading did not change modification count
1571
		// make sure that reading did not change modification count
1487
		assertTrue(ast.modificationCount() == previousCount);
1572
		assertTrue(ast.modificationCount() == previousCount);
Lines 1515-1520 Link Here
1515
		assertTrue(!x.isSimpleType());
1600
		assertTrue(!x.isSimpleType());
1516
		assertTrue(!x.isArrayType());
1601
		assertTrue(!x.isArrayType());
1517
		assertTrue(x.isPrimitiveType());
1602
		assertTrue(x.isPrimitiveType());
1603
		assertTrue(!x.isParameterizedType());
1518
		assertTrue(x.getNodeType() == ASTNode.PRIMITIVE_TYPE);
1604
		assertTrue(x.getNodeType() == ASTNode.PRIMITIVE_TYPE);
1519
		// make sure that reading did not change modification count
1605
		// make sure that reading did not change modification count
1520
		assertTrue(ast.modificationCount() == previousCount);
1606
		assertTrue(ast.modificationCount() == previousCount);
Lines 1589-1594 Link Here
1589
		assertTrue(!x.isSimpleType());
1675
		assertTrue(!x.isSimpleType());
1590
		assertTrue(x.isArrayType());
1676
		assertTrue(x.isArrayType());
1591
		assertTrue(!x.isPrimitiveType());
1677
		assertTrue(!x.isPrimitiveType());
1678
		assertTrue(!x.isParameterizedType());
1592
		assertTrue(x.getNodeType() == ASTNode.ARRAY_TYPE);
1679
		assertTrue(x.getNodeType() == ASTNode.ARRAY_TYPE);
1593
1680
1594
		assertTrue(x.getDimensions() == 1);
1681
		assertTrue(x.getDimensions() == 1);
Lines 1626-1631 Link Here
1626
		assertTrue(x.getElementType().isPrimitiveType());
1713
		assertTrue(x.getElementType().isPrimitiveType());
1627
	}		
1714
	}		
1628
1715
1716
	public void testParameterizedType() {
1717
		long previousCount = ast.modificationCount();
1718
		final ParameterizedType x = ast.newParameterizedType(ast.newSimpleName("String")); //$NON-NLS-1$
1719
		assertTrue(ast.modificationCount() > previousCount);
1720
		previousCount = ast.modificationCount();
1721
		assertTrue(x instanceof Type);
1722
		assertTrue(x.getAST() == ast);
1723
		assertTrue(x.getParent() == null);
1724
		assertTrue(x.getName().getParent() == x);
1725
		assertTrue(!x.isSimpleType());
1726
		assertTrue(!x.isArrayType());
1727
		assertTrue(!x.isPrimitiveType());
1728
		assertTrue(x.isParameterizedType());
1729
		assertTrue(x.getNodeType() == ASTNode.PARAMETERIZED_TYPE);
1730
		assertTrue(x.typeArguments().size() == 0);
1731
		// make sure that reading did not change modification count
1732
		assertTrue(ast.modificationCount() == previousCount);
1733
1734
		genericPropertyTest(x, new Property("Name", true, Name.class) { //$NON-NLS-1$
1735
			public ASTNode sample(AST targetAst, boolean parented) {
1736
				SimpleName result = targetAst.newSimpleName("a"); //$NON-NLS-1$
1737
				if (parented) {
1738
					targetAst.newExpressionStatement(result);
1739
				}
1740
				return result;
1741
			}
1742
			public ASTNode get() {
1743
				return x.getName();
1744
			}
1745
			public void set(ASTNode value) {
1746
				x.setName((Name) value);
1747
			}
1748
		});
1749
		genericPropertyListTest(x, x.typeArguments(),
1750
		  new Property("Arguments", true, Type.class) { //$NON-NLS-1$
1751
			public ASTNode sample(AST targetAst, boolean parented) {
1752
				PrimitiveType result = targetAst.newPrimitiveType(PrimitiveType.INT);
1753
				if (parented) {
1754
					targetAst.newArrayType(result);
1755
				}
1756
				return result;
1757
			}
1758
			public ASTNode wrap() {
1759
				// return Type that embeds x
1760
				ParameterizedType s1 = ast.newParameterizedType(ast.newSimpleName("foo")); //$NON-NLS-1$
1761
				s1.typeArguments().add(x);
1762
				return s1;
1763
			}
1764
			public void unwrap() {
1765
				ParameterizedType s1 = (ParameterizedType) x.getParent();
1766
				s1.typeArguments().remove(x);
1767
			}
1768
		});
1769
	}		
1770
	
1629
	public void testPackageDeclaration() {
1771
	public void testPackageDeclaration() {
1630
		long previousCount = ast.modificationCount();
1772
		long previousCount = ast.modificationCount();
1631
		final PackageDeclaration x = ast.newPackageDeclaration();
1773
		final PackageDeclaration x = ast.newPackageDeclaration();
Lines 1827-1834 Link Here
1827
		assertTrue(x.isInterface() == false);
1969
		assertTrue(x.isInterface() == false);
1828
		assertTrue(x.getName().getParent() == x);
1970
		assertTrue(x.getName().getParent() == x);
1829
		assertTrue(x.getName().isDeclaration() == true);
1971
		assertTrue(x.getName().isDeclaration() == true);
1972
		assertTrue(x.typeParameters().size() == 0);
1973
		assertTrue(x.getSuperclassType() == null);
1830
		assertTrue(x.getSuperclass() == null);
1974
		assertTrue(x.getSuperclass() == null);
1831
		assertTrue(x.getJavadoc() == null);
1975
		assertTrue(x.getJavadoc() == null);
1976
		assertTrue(x.superInterfaceTypes().size() == 0);
1832
		assertTrue(x.superInterfaces().size() == 0);
1977
		assertTrue(x.superInterfaces().size() == 0);
1833
		assertTrue(x.bodyDeclarations().size()== 0);
1978
		assertTrue(x.bodyDeclarations().size()== 0);
1834
		assertTrue(x.getNodeType() == ASTNode.TYPE_DECLARATION);
1979
		assertTrue(x.getNodeType() == ASTNode.TYPE_DECLARATION);
Lines 1871-1903 Link Here
1871
			}
2016
			}
1872
		});
2017
		});
1873
		
2018
		
1874
		genericPropertyTest(x, new Property("Superclass", false, Name.class) { //$NON-NLS-1$
2019
		genericPropertyListTest(x, x.typeParameters(),
2020
		  new Property("TypeParameters", true, TypeParameter.class) { //$NON-NLS-1$
1875
			public ASTNode sample(AST targetAst, boolean parented) {
2021
			public ASTNode sample(AST targetAst, boolean parented) {
1876
				SimpleName result = targetAst.newSimpleName("foo"); //$NON-NLS-1$
2022
				TypeParameter result = targetAst.newTypeParameter();
1877
				if (parented) {
2023
				if (parented) {
1878
					targetAst.newExpressionStatement(result);
2024
					targetAst.newMethodDeclaration().typeParameters().add(result);
2025
				}
2026
				return result;
2027
			}
2028
		});
2029
		
2030
		genericPropertyTest(x, new Property("SuperclassType", false, Type.class) { //$NON-NLS-1$
2031
			public ASTNode sample(AST targetAst, boolean parented) {
2032
				SimpleType result = targetAst.newSimpleType(targetAst.newSimpleName("foo")); //$NON-NLS-1$
2033
				if (parented) {
2034
					targetAst.newArrayType(result);
1879
				}
2035
				}
1880
				return result;
2036
				return result;
1881
			}
2037
			}
1882
			public ASTNode get() {
2038
			public ASTNode get() {
1883
				return x.getSuperclass();
2039
				return x.getSuperclassType();
1884
			}
2040
			}
1885
			public void set(ASTNode value) {
2041
			public void set(ASTNode value) {
1886
				x.setSuperclass((Name) value);
2042
				x.setSuperclassType((Type) value);
1887
			}
2043
			}
1888
		});
2044
		});
1889
		
2045
		
1890
		genericPropertyListTest(x, x.superInterfaces(),
2046
		// deprecated superclass name property
1891
		  new Property("SuperInterfaces", true, Name.class) { //$NON-NLS-1$
2047
		// ensure that changing the name affects the type, and conversely
2048
		x.setSuperclassType(null);
2049
		assertTrue(x.getSuperclassType() == null);
2050
		assertTrue(x.getSuperclass() == null);
2051
		Name n0 = ast.newSimpleName("n0");
2052
		Type t0 = ast.newSimpleType(n0);
2053
		x.setSuperclassType(t0);
2054
		assertTrue(x.getSuperclassType() == t0);
2055
		assertTrue(x.getSuperclass() == n0);
2056
		Name n1 = ast.newSimpleName("n1");
2057
		x.setSuperclass(n1);
2058
		assertTrue(x.getSuperclassType() == t0);
2059
		assertTrue(x.getSuperclass() == n1);
2060
		x.setSuperclass(null);
2061
		assertTrue(x.getSuperclassType() == null);
2062
		assertTrue(x.getSuperclass() == null);
2063
		
2064
		genericPropertyListTest(x, x.superInterfaceTypes(),
2065
		  new Property("SuperInterfaceTypes", true, Type.class) { //$NON-NLS-1$
1892
			public ASTNode sample(AST targetAst, boolean parented) {
2066
			public ASTNode sample(AST targetAst, boolean parented) {
1893
				SimpleName result = targetAst.newSimpleName("foo"); //$NON-NLS-1$
2067
				SimpleType result = targetAst.newSimpleType(targetAst.newSimpleName("foo")); //$NON-NLS-1$
1894
				if (parented) {
2068
				if (parented) {
1895
					targetAst.newExpressionStatement(result);
2069
					targetAst.newArrayType(result);
1896
				}
2070
				}
1897
				return result;
2071
				return result;
1898
			}
2072
			}
1899
		});
2073
		});
1900
		
2074
		
2075
		// deprecated superinterface names property
2076
		// ensure that changing the name affects the type, and conversely
2077
		x.superInterfaceTypes().clear();
2078
		assertTrue(x.superInterfaceTypes().size() == 0);
2079
		assertTrue(x.superInterfaces().size() == 0);
2080
		n0 = ast.newSimpleName("n0");
2081
		t0 = ast.newSimpleType(n0);
2082
		x.superInterfaceTypes().add(t0);
2083
		assertTrue(x.superInterfaceTypes().size() == 1);
2084
		assertTrue(x.superInterfaces().size() == 1);
2085
		assertTrue(x.superInterfaceTypes().get(0) == t0);
2086
		assertTrue(x.superInterfaces().get(0) == n0);
2087
		n1 = ast.newSimpleName("n1");
2088
		x.superInterfaces().add(n1);
2089
		assertTrue(x.superInterfaceTypes().size() == 2);
2090
		assertTrue(x.superInterfaces().size() == 2);
2091
		assertTrue(x.superInterfaceTypes().get(0) == t0);
2092
		assertTrue(x.superInterfaces().get(0) == n0);
2093
		assertTrue(x.superInterfaces().get(1) == n1);
2094
		assertTrue(n1.getParent() instanceof SimpleType);
2095
		assertTrue(n1.getParent().getParent() == x);
2096
		x.superInterfaces().remove(n1);
2097
		assertTrue(x.superInterfaceTypes().size() == 1);
2098
		assertTrue(x.superInterfaces().size() == 1);
2099
		assertTrue(x.superInterfaceTypes().get(0) == t0);
2100
		assertTrue(x.superInterfaces().get(0) == n0);
2101
		assertTrue(n1.getParent() == null);
2102
		x.superInterfaces().remove(n0);
2103
		assertTrue(x.superInterfaceTypes().size() == 0);
2104
		assertTrue(x.superInterfaces().size() == 0);
2105
1901
		genericPropertyListTest(x, x.bodyDeclarations(),
2106
		genericPropertyListTest(x, x.bodyDeclarations(),
1902
		  new Property("BodyDeclarations", true, BodyDeclaration.class) { //$NON-NLS-1$
2107
		  new Property("BodyDeclarations", true, BodyDeclaration.class) { //$NON-NLS-1$
1903
			public ASTNode sample(AST targetAst, boolean parented) {
2108
			public ASTNode sample(AST targetAst, boolean parented) {
Lines 1964-1969 Link Here
1964
	
2169
	
1965
	}	
2170
	}	
1966
	
2171
	
2172
	public void testTypeParameter() {
2173
		long previousCount = ast.modificationCount();
2174
		final TypeParameter x = ast.newTypeParameter();
2175
		assertTrue(ast.modificationCount() > previousCount);
2176
		previousCount = ast.modificationCount();
2177
		assertTrue(x instanceof TypeParameter);
2178
		assertTrue(x.getAST() == ast);
2179
		assertTrue(x.getParent() == null);
2180
		assertTrue(x.getName().getParent() == x);
2181
		assertTrue(x.getNodeType() == ASTNode.TYPE_PARAMETER);
2182
		assertTrue(x.typeBounds().size() == 0);
2183
		// make sure that reading did not change modification count
2184
		assertTrue(ast.modificationCount() == previousCount);
2185
2186
		genericPropertyTest(x, new Property("Name", true, SimpleName.class) { //$NON-NLS-1$
2187
			public ASTNode sample(AST targetAst, boolean parented) {
2188
				SimpleName result = targetAst.newSimpleName("a"); //$NON-NLS-1$
2189
				if (parented) {
2190
					targetAst.newExpressionStatement(result);
2191
				}
2192
				return result;
2193
			}
2194
			public ASTNode get() {
2195
				return x.getName();
2196
			}
2197
			public void set(ASTNode value) {
2198
				x.setName((SimpleName) value);
2199
			}
2200
		});
2201
		genericPropertyListTest(x, x.typeBounds(),
2202
		  new Property("TypeBounds", true, Type.class) { //$NON-NLS-1$
2203
			public ASTNode sample(AST targetAst, boolean parented) {
2204
				Type result = targetAst.newSimpleType(targetAst.newSimpleName("foo"));
2205
				if (parented) {
2206
					targetAst.newArrayType(result);
2207
				}
2208
				return result;
2209
			}
2210
		});
2211
	}		
2212
	
1967
	public void testSingleVariableDeclaration() {
2213
	public void testSingleVariableDeclaration() {
1968
		long previousCount = ast.modificationCount();
2214
		long previousCount = ast.modificationCount();
1969
		final SingleVariableDeclaration x = ast.newSingleVariableDeclaration();
2215
		final SingleVariableDeclaration x = ast.newSingleVariableDeclaration();
Lines 2153-2158 Link Here
2153
		assertTrue(x.getParent() == null);
2399
		assertTrue(x.getParent() == null);
2154
		assertTrue(x.getModifiers() == Modifier.NONE);
2400
		assertTrue(x.getModifiers() == Modifier.NONE);
2155
		assertTrue(x.isConstructor() == false);
2401
		assertTrue(x.isConstructor() == false);
2402
		assertTrue(x.typeParameters().size() == 0);
2156
		assertTrue(x.getName().getParent() == x);
2403
		assertTrue(x.getName().getParent() == x);
2157
		assertTrue(x.getName().isDeclaration() == true);
2404
		assertTrue(x.getName().isDeclaration() == true);
2158
		assertTrue(x.getReturnType().getParent() == x);
2405
		assertTrue(x.getReturnType().getParent() == x);
Lines 2202-2207 Link Here
2202
2449
2203
		tJavadocComment(x);
2450
		tJavadocComment(x);
2204
						
2451
						
2452
		genericPropertyListTest(x, x.typeParameters(),
2453
		  new Property("TypeParameters", true, TypeParameter.class) { //$NON-NLS-1$
2454
			public ASTNode sample(AST targetAst, boolean parented) {
2455
				TypeParameter result = targetAst.newTypeParameter();
2456
				if (parented) {
2457
					targetAst.newMethodDeclaration().typeParameters().add(result);
2458
				}
2459
				return result;
2460
			}
2461
		});
2462
		
2205
		genericPropertyTest(x, new Property("Name", true, SimpleName.class) { //$NON-NLS-1$
2463
		genericPropertyTest(x, new Property("Name", true, SimpleName.class) { //$NON-NLS-1$
2206
			public ASTNode sample(AST targetAst, boolean parented) {
2464
			public ASTNode sample(AST targetAst, boolean parented) {
2207
				SimpleName result = targetAst.newSimpleName("foo"); //$NON-NLS-1$
2465
				SimpleName result = targetAst.newSimpleName("foo"); //$NON-NLS-1$
Lines 5605-5611 Link Here
5605
		assertTrue(x.getAST() == ast);
5863
		assertTrue(x.getAST() == ast);
5606
		assertTrue(x.getParent() == null);
5864
		assertTrue(x.getParent() == null);
5607
		assertTrue(x.getExpression() == null);
5865
		assertTrue(x.getExpression() == null);
5608
		assertTrue(x.getName().getParent() == x);
5866
		assertTrue(x.getType().getParent() == x);
5867
		// test deprecated method too
5868
		assertTrue(x.getName().getParent() == x.getType());
5609
		assertTrue(x.arguments().isEmpty());
5869
		assertTrue(x.arguments().isEmpty());
5610
		assertTrue(x.getAnonymousClassDeclaration() == null);
5870
		assertTrue(x.getAnonymousClassDeclaration() == null);
5611
		assertTrue(x.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION);
5871
		assertTrue(x.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION);
Lines 5638-5658 Link Here
5638
			}
5898
			}
5639
		});
5899
		});
5640
5900
5641
		genericPropertyTest(x, new Property("Name", true, Name.class) { //$NON-NLS-1$
5901
		genericPropertyTest(x, new Property("Type", true, Type.class) { //$NON-NLS-1$
5642
			public ASTNode sample(AST targetAst, boolean parented) {
5902
			public ASTNode sample(AST targetAst, boolean parented) {
5643
				SimpleName result = targetAst.newSimpleName("a"); //$NON-NLS-1$
5903
				SimpleType result = targetAst.newSimpleType(targetAst.newSimpleName("foo")); //$NON-NLS-1$
5644
				if (parented) {
5904
				if (parented) {
5645
					targetAst.newExpressionStatement(result);
5905
					targetAst.newArrayType(result);
5646
				}
5906
				}
5647
				return result;
5907
				return result;
5648
			}
5908
			}
5649
			public ASTNode get() {
5909
			public ASTNode get() {
5650
				return x.getName();
5910
				return x.getType();
5651
			}
5911
			}
5652
			public void set(ASTNode value) {
5912
			public void set(ASTNode value) {
5653
				x.setName((Name) value);
5913
				x.setType((Type) value);
5654
			}
5914
			}
5655
		});
5915
		});
5916
		
5917
		// deprecated name property
5918
		// ensure that changing the name affects the type, and conversely
5919
		Name n0 = ast.newSimpleName("n0");
5920
		Type t0 = ast.newSimpleType(n0);
5921
		x.setType(t0);
5922
		assertTrue(x.getType() == t0);
5923
		assertTrue(x.getName() == n0);
5924
		Name n1 = ast.newSimpleName("n1");
5925
		x.setName(n1);
5926
		assertTrue(x.getType() == t0);
5927
		assertTrue(x.getName() == n1);
5656
5928
5657
		genericPropertyListTest(x, x.arguments(),
5929
		genericPropertyListTest(x, x.arguments(),
5658
		  new Property("Arguments", true, Expression.class) { //$NON-NLS-1$
5930
		  new Property("Arguments", true, Expression.class) { //$NON-NLS-1$
(-)src/org/eclipse/jdt/core/tests/dom/ASTVisitorTest.java (-8 / +86 lines)
Lines 44-49 Link Here
44
	String E2S;
44
	String E2S;
45
	Type T1;
45
	Type T1;
46
	String T1S;
46
	String T1S;
47
	Type T2;
48
	String T2S;
49
	ParameterizedType PT1;
50
	String PT1S;
47
	Statement S1;
51
	Statement S1;
48
	String S1S;
52
	String S1S;
49
	Statement S2;
53
	Statement S2;
Lines 78-83 Link Here
78
	String JD2S;
82
	String JD2S;
79
	AnonymousClassDeclaration ACD1;
83
	AnonymousClassDeclaration ACD1;
80
	String ACD1S;
84
	String ACD1S;
85
	TypeParameter TP1;
86
	String TP1S;
87
	TypeParameter TP2;
88
	String TP2S;
81
	
89
	
82
	final StringBuffer b = new StringBuffer();
90
	final StringBuffer b = new StringBuffer();
83
	
91
	
Lines 99-104 Link Here
99
		E2S = "[(nSYYnS)]"; //$NON-NLS-1$
107
		E2S = "[(nSYYnS)]"; //$NON-NLS-1$
100
		T1 = ast.newSimpleType(ast.newSimpleName("Z")); //$NON-NLS-1$
108
		T1 = ast.newSimpleType(ast.newSimpleName("Z")); //$NON-NLS-1$
101
		T1S = "[(tS[(nSZZnS)]tS)]"; //$NON-NLS-1$
109
		T1S = "[(tS[(nSZZnS)]tS)]"; //$NON-NLS-1$
110
		T2 = ast.newSimpleType(ast.newSimpleName("X")); //$NON-NLS-1$
111
		T2S = "[(tS[(nSXXnS)]tS)]"; //$NON-NLS-1$
112
		PT1 = ast.newParameterizedType(ast.newSimpleName("Z")); //$NON-NLS-1$
113
		PT1S = "[(tM[(nSZZnS)]tM)]"; //$NON-NLS-1$
102
		S1 = ast.newContinueStatement();
114
		S1 = ast.newContinueStatement();
103
		S1S = "[(sCNsCN)]"; //$NON-NLS-1$
115
		S1S = "[(sCNsCN)]"; //$NON-NLS-1$
104
		S2 = ast.newBreakStatement();
116
		S2 = ast.newBreakStatement();
Lines 159-164 Link Here
159
		JD2.setComment("/**Y*/"); //$NON-NLS-1$
171
		JD2.setComment("/**Y*/"); //$NON-NLS-1$
160
		JD2S = "[(JD/**Y*//**Y*/JD)]"; //$NON-NLS-1$
172
		JD2S = "[(JD/**Y*//**Y*/JD)]"; //$NON-NLS-1$
161
173
174
		TP1 = ast.newTypeParameter();
175
		TP1.setName(ast.newSimpleName("x")); //$NON-NLS-1$
176
		TP1S = "[(tTP[(nSxxnS)]tTP)]"; //$NON-NLS-1$
177
178
		TP2 = ast.newTypeParameter();
179
		TP2.setName(ast.newSimpleName("y")); //$NON-NLS-1$
180
		TP2S = "[(tTP[(nSyynS)]tTP)]"; //$NON-NLS-1$
181
162
	}
182
	}
163
	
183
	
164
	protected void tearDown() {
184
	protected void tearDown() {
Lines 221-226 Link Here
221
			b.append(node.getPrimitiveTypeCode().toString());
241
			b.append(node.getPrimitiveTypeCode().toString());
222
			b.append("tP)"); //$NON-NLS-1$
242
			b.append("tP)"); //$NON-NLS-1$
223
		}
243
		}
244
		public boolean visit(QualifiedType node) {
245
			b.append("(tQ"); //$NON-NLS-1$
246
			return isVisitingChildren();
247
		}
248
		public void endVisit(QualifiedType node) {
249
			b.append("tQ)"); //$NON-NLS-1$
250
		}
224
251
225
		// EXPRESSIONS and STATEMENTS
252
		// EXPRESSIONS and STATEMENTS
226
253
Lines 326-332 Link Here
326
		public void endVisit(ClassInstanceCreation node) {
353
		public void endVisit(ClassInstanceCreation node) {
327
			b.append("eCI)"); //$NON-NLS-1$
354
			b.append("eCI)"); //$NON-NLS-1$
328
		}
355
		}
329
356
		
330
		public boolean visit(AnonymousClassDeclaration node) {
357
		public boolean visit(AnonymousClassDeclaration node) {
331
			b.append("(ACD"); //$NON-NLS-1$
358
			b.append("(ACD"); //$NON-NLS-1$
332
			return isVisitingChildren();
359
			return isVisitingChildren();
Lines 517-522 Link Here
517
			b.append("PD)"); //$NON-NLS-1$
544
			b.append("PD)"); //$NON-NLS-1$
518
		}
545
		}
519
546
547
		public boolean visit(ParameterizedType node) {
548
			b.append("(tM"); //$NON-NLS-1$
549
			return isVisitingChildren();
550
		}
551
		public void endVisit(ParameterizedType node) {
552
			b.append("tM)"); //$NON-NLS-1$
553
		}
554
520
		public boolean visit(ParenthesizedExpression node) {
555
		public boolean visit(ParenthesizedExpression node) {
521
			b.append("(ePA"); //$NON-NLS-1$
556
			b.append("(ePA"); //$NON-NLS-1$
522
			return isVisitingChildren();
557
			return isVisitingChildren();
Lines 667-672 Link Here
667
			b.append("eTL)"); //$NON-NLS-1$
702
			b.append("eTL)"); //$NON-NLS-1$
668
		}
703
		}
669
704
705
		public boolean visit(TypeParameter node) {
706
			b.append("(tTP"); //$NON-NLS-1$
707
			return isVisitingChildren();
708
		}
709
		public void endVisit(TypeParameter node) {
710
			b.append("tTP)"); //$NON-NLS-1$
711
		}
712
670
		public boolean visit(VariableDeclarationExpression node) {
713
		public boolean visit(VariableDeclarationExpression node) {
671
			b.append("(eVD"); //$NON-NLS-1$
714
			b.append("(eVD"); //$NON-NLS-1$
672
			return isVisitingChildren();
715
			return isVisitingChildren();
Lines 757-762 Link Here
757
		assertTrue("[(tA[(tPcharchartP)]tA)]".equals(result)); //$NON-NLS-1$
800
		assertTrue("[(tA[(tPcharchartP)]tA)]".equals(result)); //$NON-NLS-1$
758
	}
801
	}
759
802
803
	public void testParameterizedType() {
804
		ParameterizedType x1 = ast.newParameterizedType(N1);
805
		x1.typeArguments().add(T1);
806
		x1.typeArguments().add(T2);
807
		TestVisitor v1 = new TestVisitor();
808
		b.setLength(0);
809
		x1.accept(v1);
810
		String result = b.toString();
811
		assertTrue(result.equals("[(tM"+N1S+T1S+T2S+"tM)]")); //$NON-NLS-1$ //$NON-NLS-2$
812
	}
813
814
	public void testQualifiedType() {
815
		QualifiedType x1 = ast.newQualifiedType(T1, N1);
816
		TestVisitor v1 = new TestVisitor();
817
		b.setLength(0);
818
		x1.accept(v1);
819
		String result = b.toString();
820
		assertTrue(result.equals("[(tQ"+T1S+N1S+"tQ)]")); //$NON-NLS-1$ //$NON-NLS-2$
821
	}
822
760
	// EXPRESSIONS and STATEMENTS
823
	// EXPRESSIONS and STATEMENTS
761
824
762
	public void testArrayAccess() {
825
	public void testArrayAccess() {
Lines 878-890 Link Here
878
	public void testClassInstanceCreation() {
941
	public void testClassInstanceCreation() {
879
		ClassInstanceCreation x1 = ast.newClassInstanceCreation();
942
		ClassInstanceCreation x1 = ast.newClassInstanceCreation();
880
		x1.setExpression(E1);
943
		x1.setExpression(E1);
881
		x1.setName(N1);
944
		x1.setType(PT1);
882
		x1.setAnonymousClassDeclaration(ACD1);
945
		x1.setAnonymousClassDeclaration(ACD1);
883
		TestVisitor v1 = new TestVisitor();
946
		TestVisitor v1 = new TestVisitor();
884
		b.setLength(0);
947
		b.setLength(0);
885
		x1.accept(v1);
948
		x1.accept(v1);
886
		String result = b.toString();
949
		String result = b.toString();
887
		assertTrue(result.equals("[(eCI"+E1S+N1S+ACD1S+"eCI)]")); //$NON-NLS-1$ //$NON-NLS-2$
950
		assertTrue(result.equals("[(eCI"+E1S+PT1S+ACD1S+"eCI)]")); //$NON-NLS-1$ //$NON-NLS-2$
888
	}
951
	}
889
	public void testAnonymousClassDeclaration() {
952
	public void testAnonymousClassDeclaration() {
890
		AnonymousClassDeclaration x1 = ast.newAnonymousClassDeclaration();
953
		AnonymousClassDeclaration x1 = ast.newAnonymousClassDeclaration();
Lines 1083-1088 Link Here
1083
	public void testMethodDeclaration() {
1146
	public void testMethodDeclaration() {
1084
		MethodDeclaration x1 = ast.newMethodDeclaration();
1147
		MethodDeclaration x1 = ast.newMethodDeclaration();
1085
		x1.setJavadoc(JD1);
1148
		x1.setJavadoc(JD1);
1149
		x1.typeParameters().add(TP1);
1086
		x1.setReturnType(T1);
1150
		x1.setReturnType(T1);
1087
		x1.setName(N1);
1151
		x1.setName(N1);
1088
		x1.parameters().add(V1);
1152
		x1.parameters().add(V1);
Lines 1094-1100 Link Here
1094
		b.setLength(0);
1158
		b.setLength(0);
1095
		x1.accept(v1);
1159
		x1.accept(v1);
1096
		String result = b.toString();
1160
		String result = b.toString();
1097
		assertTrue(result.equals("[(MD"+JD1S+T1S+N1S+V1S+V2S+N2S+N3S+B1S+"MD)]")); //$NON-NLS-1$ //$NON-NLS-2$
1161
		assertTrue(result.equals("[(MD"+JD1S+TP1S+T1S+N1S+V1S+V2S+N2S+N3S+B1S+"MD)]")); //$NON-NLS-1$ //$NON-NLS-2$
1098
	}
1162
	}
1099
	public void testMethodInvocation() {
1163
	public void testMethodInvocation() {
1100
		MethodInvocation x1 = ast.newMethodInvocation();
1164
		MethodInvocation x1 = ast.newMethodInvocation();
Lines 1283-1298 Link Here
1283
		TypeDeclaration x1 = ast.newTypeDeclaration();
1347
		TypeDeclaration x1 = ast.newTypeDeclaration();
1284
		x1.setJavadoc(JD1);
1348
		x1.setJavadoc(JD1);
1285
		x1.setName(N1);
1349
		x1.setName(N1);
1286
		x1.setSuperclass(N2);
1350
		x1.typeParameters().add(TP1);
1287
		x1.superInterfaces().add(N3);
1351
		x1.setSuperclassType(PT1);
1288
		x1.superInterfaces().add(ast.newSimpleName("J")); //$NON-NLS-1$
1352
		x1.superInterfaceTypes().add(T1);
1353
		x1.superInterfaceTypes().add(T2); //$NON-NLS-1$
1289
		x1.bodyDeclarations().add(FD1);
1354
		x1.bodyDeclarations().add(FD1);
1290
		x1.bodyDeclarations().add(FD2);
1355
		x1.bodyDeclarations().add(FD2);
1291
		TestVisitor v1 = new TestVisitor();
1356
		TestVisitor v1 = new TestVisitor();
1292
		b.setLength(0);
1357
		b.setLength(0);
1293
		x1.accept(v1);
1358
		x1.accept(v1);
1294
		String result = b.toString();
1359
		String result = b.toString();
1295
		assertTrue(result.equals("[(TD"+JD1S+N1S+N2S+N3S+"[(nSJJnS)]"+FD1S+FD2S+"TD)]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1360
		assertTrue(result.equals("[(TD"+JD1S+N1S+TP1S+PT1S+T1S+T2S+FD1S+FD2S+"TD)]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1296
	}
1361
	}
1297
	public void testTypeDeclarationStatement() {
1362
	public void testTypeDeclarationStatement() {
1298
		TypeDeclarationStatement x1 = ast.newTypeDeclarationStatement(TD1);
1363
		TypeDeclarationStatement x1 = ast.newTypeDeclarationStatement(TD1);
Lines 1311-1316 Link Here
1311
		String result = b.toString();
1376
		String result = b.toString();
1312
		assertTrue(result.equals("[(eTL"+T1S+"eTL)]")); //$NON-NLS-1$ //$NON-NLS-2$
1377
		assertTrue(result.equals("[(eTL"+T1S+"eTL)]")); //$NON-NLS-1$ //$NON-NLS-2$
1313
	}
1378
	}
1379
	public void testTypeParameter() {
1380
		TypeParameter x1 = ast.newTypeParameter();
1381
		x1.setName(N1);
1382
		x1.typeBounds().add(PT1);
1383
		x1.typeBounds().add(T1);
1384
		x1.typeBounds().add(T2);
1385
		TestVisitor v1 = new TestVisitor();
1386
		b.setLength(0);
1387
		x1.accept(v1);
1388
		String result = b.toString();
1389
		assertTrue(result.equals("[(tTP"+N1S+PT1S+T1S+T2S+"tTP)]")); //$NON-NLS-1$ //$NON-NLS-2$
1390
	}
1391
1314
	public void testVariableDeclaration() {
1392
	public void testVariableDeclaration() {
1315
		SingleVariableDeclaration x1 = ast.newSingleVariableDeclaration();
1393
		SingleVariableDeclaration x1 = ast.newSingleVariableDeclaration();
1316
		x1.setType(T1);
1394
		x1.setType(T1);
(-)src/org/eclipse/jdt/core/tests/dom/BindingsCollectorVisitor.java (+16 lines)
Lines 303-308 Link Here
303
	}
303
	}
304
304
305
	/**
305
	/**
306
	 * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(ParameterizedType)
307
	 * @since 2.2
308
	 */
309
	public void endVisit(ParameterizedType node) {
310
		ITypeBinding typeBinding = node.resolveBinding();
311
		collectBindings(node, typeBinding);
312
	}
313
314
	/**
306
	 * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(ParenthesizedExpression)
315
	 * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(ParenthesizedExpression)
307
	 */
316
	 */
308
	public void endVisit(ParenthesizedExpression node) {
317
	public void endVisit(ParenthesizedExpression node) {
Lines 462-467 Link Here
462
	public void endVisit(TypeLiteral node) {
471
	public void endVisit(TypeLiteral node) {
463
		ITypeBinding typeBinding = node.resolveTypeBinding();
472
		ITypeBinding typeBinding = node.resolveTypeBinding();
464
		collectBindings(node, typeBinding);
473
		collectBindings(node, typeBinding);
474
	}
475
476
	/**
477
	 * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(TypeParameter)
478
	 * @since 2.2
479
	 */
480
	public void endVisit(TypeParameter node) {
465
	}
481
	}
466
482
467
	/**
483
	/**

Return to bug 36142