On Tue, 7 Feb 2023 12:23:05 GMT, Adam Sotona <asot...@openjdk.org> wrote:

>> Uhm - I can't see these usages... something seems to be off with my IDE 
>> configuration. I did a grep and I now saw the uses. That said, having the 
>> Kind/Location inside AttributedElement still looks weird to me. The "places 
>> where an attribute can appear" is a property of an `Attribute`, not of an 
>> attributed element (which is used to model elements which can have 
>> attributes).
>
> `AttributedElement::attributedElementKind` identifies the one kind of the 
> attributes holder.
> The "places where an attribute can appear" is available through 
> `AttributeMapper::whereApplicable` and matched against 
> `AttributedElement::attributedElementKind`.
> We may consider to hide or remove this auxiliary method, as 
> `AttributedElement::attributedElementKind` might be computed from the 
> ClassfileElement instance type.

Still, there seems to be a modelling issue here. The property of "where could 
this attribute go" is a property of the attribute. Of course, for usability 
reason, an AttributedElement might expose a predicate saying "I only accept 
attributes of these kinds". But it seems to me as if the API has this 
relationship backwards, due to _where_ the Kind interface is being defined. I 
think if `Kind` was defined in `AttributeMapper` it would be a tad easier to 
understand. And, perhaps, the `attributedElementKind` name should be changed to 
something like `applicableAttributeKinds` or something like that.

-------------

PR: https://git.openjdk.org/jdk/pull/10982

Reply via email to