Skip to content

Commit

Permalink
take jakarta version of inject annotation into account (+ a few more …
Browse files Browse the repository at this point in the history
…constants for jakarta/javax annotations to be supported)
  • Loading branch information
martinlippert committed Jul 19, 2024
1 parent e3a4d69 commit 5509423
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public class Annotations {
public static final String DATA_QUERY = "org.springframework.data.jpa.repository.Query";

public static final String AUTOWIRED = "org.springframework.beans.factory.annotation.Autowired";
public static final String INJECT = "javax.inject.Inject";

public static final String QUALIFIER = "org.springframework.beans.factory.annotation.Qualifier";

public static final String SPRING_REQUEST_MAPPING = "org.springframework.web.bind.annotation.RequestMapping";
Expand Down Expand Up @@ -73,5 +71,15 @@ public class Annotations {
public static final String VALUE = "org.springframework.beans.factory.annotation.Value";
public static final String SCOPE = "org.springframework.context.annotation.Scope";
public static final String DEPENDS_ON = "org.springframework.context.annotation.DependsOn";

public static final String RESOURCE_JAVAX = "javax.annotation.Resource";
public static final String RESOURCE_JAKARTA = "jakarta.annotation.Resource";

public static final String INJECT_JAVAX = "javax.inject.Inject";
public static final String INJECT_JAKARTA = "jakarta.inject.Inject";
public static final String NAMED_JAVAX = "javax.inject.Named";
public static final String NAMED_JAKARTA = "jakarta.inject.Named";



}
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ protected BootJavaHoverProvider createHoverHandler(JavaProjectFinder javaProject
providers.put(Annotations.PROFILE, new ActiveProfilesProvider());

providers.put(Annotations.AUTOWIRED, autowiredHoverProvider);
providers.put(Annotations.INJECT, autowiredHoverProvider);
providers.put(Annotations.INJECT_JAVAX, autowiredHoverProvider);
providers.put(Annotations.INJECT_JAKARTA, autowiredHoverProvider);

providers.put(Annotations.COMPONENT, componentInjectionsHoverProvider);
providers.put(Annotations.BEAN, beanInjectedIntoHoverProvider);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ private boolean hasAutowiredAnnotation(MethodDeclaration constructor) {
ITypeBinding typeBinding = ((MarkerAnnotation) modifier).resolveTypeBinding();
if (typeBinding != null) {
String fqName = typeBinding.getQualifiedName();
return Annotations.AUTOWIRED.equals(fqName) || Annotations.INJECT.equals(fqName);
return Annotations.AUTOWIRED.equals(fqName) || Annotations.INJECT_JAVAX.equals(fqName) || Annotations.INJECT_JAKARTA.equals(fqName);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ public static InjectionPoint[] findInjectionPoints(TypeDeclaration type, TextDoc
fieldAnnotations.add(annotation);

String qualifiedName = annotation.resolveTypeBinding().getQualifiedName();
if (Annotations.AUTOWIRED.equals(qualifiedName)) {
if (Annotations.AUTOWIRED.equals(qualifiedName) || Annotations.INJECT_JAVAX.equals(qualifiedName) || Annotations.INJECT_JAKARTA.equals(qualifiedName)) {
autowiredField = true;
}
}
Expand Down

0 comments on commit 5509423

Please sign in to comment.