take jakarta version of inject annotation into account (+ a few more constants for jakarta/javax annotations to be supported)

This commit is contained in:
Martin Lippert
2024-07-19 11:15:48 +02:00
parent e3a4d69694
commit 5509423601
4 changed files with 15 additions and 5 deletions

View File

@@ -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";
@@ -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";
}

View File

@@ -266,7 +266,9 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
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);

View File

@@ -392,7 +392,7 @@ public class AutowiredHoverProvider implements HoverProvider {
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);
}
}
}

View File

@@ -449,7 +449,7 @@ public class ASTUtils {
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;
}
}