lsp4jakarta icon indicating copy to clipboard operation
lsp4jakarta copied to clipboard

Depedency Injection: Diagnostic for Circular `@Inject` Dependencies

Open KidoVin01 opened this issue 4 years ago • 2 comments

Circular Dependencies

Detecting and resolving circular dependencies is left as an exercise for the injector implementation. Circular dependencies between two constructors is an obvious problem, but you can also have a circular dependency between injectable fields or methods:

   class A {
     @Inject B b;
   }
   class B {
     @Inject A a;
   }

Diagnostics

  • Identify @Inject field/method/constructor
  • If dependency class contains @Inject field/method/constructor, navigate through the recursive dependency class
  • If a circular dependency is detected, deliver diagnostic errors at each dependency class that a circular dependency is detected

Note 1: The injected dependencies must be matching Note 2: The diagnostics and error identification depends on #159 for reading class information across files.

Related to #153

KidoVin01 avatar Sep 28 '21 02:09 KidoVin01

See #159, will we encounter the same problem here where we may not have knowledge of both Class A and Class B?

kathrynkodama avatar Sep 29 '21 15:09 kathrynkodama

Will now depend on #159

KidoVin01 avatar Oct 21 '21 00:10 KidoVin01