Bug 421101

Summary: [dom ast] Use generics in DOM APIs
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P4 CC: akurtakov, carsten.hammer, daniel_megert
Version: 4.4   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 416586, 421017    
Bug Blocks:    

Description Markus Keller CLA 2013-11-05 13:09:35 EST
Using generics in DOM APIs sounds as easy as turning "(element type: XXX)" comments into proper type arguments, but there are quite a few caveats:

ChildPropertyDescriptor and ChildListPropertyDescriptor should also get a type parameter, so that APIs like ASTRewrite#getListRewrite(ASTNode, ChildListPropertyDescriptor) can return a properly-typed ListRewrite<T>.

Some child list properties have type IExtendedModifier or IDocElement (bug 416586), which are not subtypes of ASTNode. We probably need a new super-interface IASTNode. But this introduces problems in all APIs that currently use ASTNode.

A few helper methods like ASTNode#copySubtree(AST, ASTNode) or ASTRewrite#createCopyTarget(ASTNode) should get a method type parameter.
Comment 1 Markus Keller CLA 2015-12-15 14:38:30 EST
https://wiki.eclipse.org/Generify_A_Java_Project#Required_Projects contains a few helpful regular expressions for this undertaking.

> ChildPropertyDescriptor and ChildListPropertyDescriptor should also get a type
> parameter

StructuralPropertyDescriptor probably also needs a type parameter <N extends IASTNode> for the nodeClass field. Then, the Child(List)PropertyDescriptor classes would get two type parameters. The only thing that this changes is everything.

The "// stuff nodeClass at head of list for future ref" in ASTNode#createPropertyList(..) would make this part of ASTNodes' implementation effectively unchecked. Code like this should be replaced by a proper fluent builder:
 
	static {
		List properyList = new ArrayList(2);
		createPropertyList(BooleanLiteral.class, properyList);
		addProperty(BOOLEAN_VALUE_PROPERTY, properyList);
		PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
	}
Comment 2 Stephan Herrmann CLA 2020-05-02 16:41:32 EDT
*** Bug 562669 has been marked as a duplicate of this bug. ***