Skip to content

Commit 5509423

Browse files
committed
take jakarta version of inject annotation into account (+ a few more constants for jakarta/javax annotations to be supported)
1 parent e3a4d69 commit 5509423

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

Diff for: headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/Annotations.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ public class Annotations {
3838
public static final String DATA_QUERY = "org.springframework.data.jpa.repository.Query";
3939

4040
public static final String AUTOWIRED = "org.springframework.beans.factory.annotation.Autowired";
41-
public static final String INJECT = "javax.inject.Inject";
42-
4341
public static final String QUALIFIER = "org.springframework.beans.factory.annotation.Qualifier";
4442

4543
public static final String SPRING_REQUEST_MAPPING = "org.springframework.web.bind.annotation.RequestMapping";
@@ -73,5 +71,15 @@ public class Annotations {
7371
public static final String VALUE = "org.springframework.beans.factory.annotation.Value";
7472
public static final String SCOPE = "org.springframework.context.annotation.Scope";
7573
public static final String DEPENDS_ON = "org.springframework.context.annotation.DependsOn";
74+
75+
public static final String RESOURCE_JAVAX = "javax.annotation.Resource";
76+
public static final String RESOURCE_JAKARTA = "jakarta.annotation.Resource";
77+
78+
public static final String INJECT_JAVAX = "javax.inject.Inject";
79+
public static final String INJECT_JAKARTA = "jakarta.inject.Inject";
80+
public static final String NAMED_JAVAX = "javax.inject.Named";
81+
public static final String NAMED_JAKARTA = "jakarta.inject.Named";
82+
83+
7684

7785
}

Diff for: headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/BootJavaLanguageServerComponents.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,9 @@ protected BootJavaHoverProvider createHoverHandler(JavaProjectFinder javaProject
266266
providers.put(Annotations.PROFILE, new ActiveProfilesProvider());
267267

268268
providers.put(Annotations.AUTOWIRED, autowiredHoverProvider);
269-
providers.put(Annotations.INJECT, autowiredHoverProvider);
269+
providers.put(Annotations.INJECT_JAVAX, autowiredHoverProvider);
270+
providers.put(Annotations.INJECT_JAKARTA, autowiredHoverProvider);
271+
270272
providers.put(Annotations.COMPONENT, componentInjectionsHoverProvider);
271273
providers.put(Annotations.BEAN, beanInjectedIntoHoverProvider);
272274

Diff for: headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/autowired/AutowiredHoverProvider.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ private boolean hasAutowiredAnnotation(MethodDeclaration constructor) {
392392
ITypeBinding typeBinding = ((MarkerAnnotation) modifier).resolveTypeBinding();
393393
if (typeBinding != null) {
394394
String fqName = typeBinding.getQualifiedName();
395-
return Annotations.AUTOWIRED.equals(fqName) || Annotations.INJECT.equals(fqName);
395+
return Annotations.AUTOWIRED.equals(fqName) || Annotations.INJECT_JAVAX.equals(fqName) || Annotations.INJECT_JAKARTA.equals(fqName);
396396
}
397397
}
398398
}

Diff for: headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/utils/ASTUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ public static InjectionPoint[] findInjectionPoints(TypeDeclaration type, TextDoc
449449
fieldAnnotations.add(annotation);
450450

451451
String qualifiedName = annotation.resolveTypeBinding().getQualifiedName();
452-
if (Annotations.AUTOWIRED.equals(qualifiedName)) {
452+
if (Annotations.AUTOWIRED.equals(qualifiedName) || Annotations.INJECT_JAVAX.equals(qualifiedName) || Annotations.INJECT_JAKARTA.equals(qualifiedName)) {
453453
autowiredField = true;
454454
}
455455
}

0 commit comments

Comments
 (0)