lsp4jakarta icon indicating copy to clipboard operation
lsp4jakarta copied to clipboard

Dependency Injection: Diagnostic for `@Inject` constructors with non-injectable parameters

Open KidoVin01 opened this issue 4 years ago • 1 comments

Bean Constructors

A bean constructor may have any number of parameters. All parameters of a bean constructor are injection points.

Diagnostics

  1. Identify constructors annotated with @Inject
  2. Check if each parameter of the constructor is a valid managed bean
  3. If not, deliver an error diagnostics at the parameter

Quick Fix

  • Suggest removing @Inject

Example

public class Greeting {
        // Error here as String is not injectable
        @Inject
	public Greeting (String name) {}
}

Note: Will have to make changes to the quick fix implemented in #108 as it does not check if the constructor takes in parameters that are injectable

KidoVin01 avatar Nov 26 '21 22:11 KidoVin01

  1. Check if each parameter of the constructor is a valid managed bean

Can you please clarify what conditions to check for to verify a valid managed bean

kathrynkodama avatar Nov 29 '21 14:11 kathrynkodama