Community
Participate
Working Groups
why is TypeName a subnode of ClassInstanceCreation? i was expecting Type instead
Because the only thing that is allowed in a ClassInstanceCreation expression is the name of a reference type. Primitive types are not legitimate (not instantiable), and array types are instantiated in separate ArrayCreation expression nodes that are structurally dissimilar to ClassInstanceCreation.
sorry, i mean SimpleType, not Type
The least general abstract node type, like Name and Type, is generally used where ever possible. So, for example, the superclass and superinterfaces properties of a TypeDeclaration are declared Name (abstract) rather than SimpleType (concrete) or a Type (abstract, but too general). Likewise, the name property of a ClassInstanceCreation node is declared as Name, rather than SimpleType or Type.
in this case, a class being abstract or not is simply an implementation detail for me - as a user of that API i see no difference at all. so, while i presume there were arguments for that decision, this one seems faulty. when i traverse an ast trying to find all places where types are referenced i expected that visiting Type and QualifiedName nodes would be sufficient to see all nodes. currently, i also have to visit ClassInstanceCreation and look inside those nodes. that being said - i can live with the current solution, no problems :)
Closed. Not a bug.