quilt-standard-libraries icon indicating copy to clipboard operation
quilt-standard-libraries copied to clipboard

Enhancing ParameterInvokingEvent

Open i509VCB opened this issue 4 years ago • 3 comments

From #9 some people had questions about the name of ParameterInvokingEvent, so this issue is here to facilitate discussion on how to enhance that marker interface.

Since I intended this to also be for static analysis, it may be worth having a way to specify which parameters are invoked upon so static analysis tools can do things like warn if a user is implementing a callback interface on a type which is not actually parameter invokable.

This could invoke adding an element specifying the indices of invokable parameters on the field or method return value for T or something else. e.g.

@ParameterInvokingEvent(indices = {0, 2}) // The first parameter and 3rd

i509VCB avatar Jul 23 '21 00:07 i509VCB

Suggestion: a when parameter that allows you to specify if the parameter(s) are invoked before or after all other listeners:

@ParameterInvokingEvent(incides = {0, 2}, when = { When.BEFORE, When.AFTER })
// 1st param is invoked before all other listeners, 3rd param is invoked after all other listeners

Leo40Git avatar Aug 01 '21 19:08 Leo40Git

Suggestion: a when parameter that allows you to specify if the parameter(s) are invoked before or after all other listeners:

@ParameterInvokingEvent(incides = {0, 2}, when = { When.BEFORE, When.AFTER })
// 1st param is invoked before all other listeners, 3rd param is invoked after all other listeners

Would this be that useful for static analysis though? Considering that indices is mainly for tools, and you could specify the order of invocation in the documentation anyway.

BasiqueEvangelist avatar Aug 01 '21 20:08 BasiqueEvangelist

From #9 some people had questions about the name of ParameterInvokingEvent, so this issue is here to facilitate discussion on how to enhance that marker interface.

Since I intended this to also be for static analysis, it may be worth having a way to specify which parameters are invoked upon so static analysis tools can do things like warn if a user is implementing a callback interface on a type which is not actually parameter invokable.

This could invoke adding an element specifying the indices of invokable parameters on the field or method return value for T or something else. e.g.

@ParameterInvokingEvent(indices = {0, 2}) // The first parameter and 3rd

How would the annotation be useful for static analysis? I mean, it would make sense if it was on the actual trait type (the ScaryEvents.Spooked interface for the example), but wouldn't putting it on the event field/method mean that tools would have to scan for events that have that handler type?

BasiqueEvangelist avatar Aug 15 '21 20:08 BasiqueEvangelist