Skip to content

Commit 6cc3086

Browse files
committed
Don't include java.lang.Object in supertypes serialization
Signed-off-by: aboyko <[email protected]>
1 parent c56fc65 commit 6cc3086

File tree

1 file changed

+13
-4
lines changed
  • headless-services/commons/commons-lsp-extensions/src/main/java/org/springframework/ide/vscode/commons/protocol/spring

1 file changed

+13
-4
lines changed

headless-services/commons/commons-lsp-extensions/src/main/java/org/springframework/ide/vscode/commons/protocol/spring/Bean.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
package org.springframework.ide.vscode.commons.protocol.spring;
1212

1313
import java.util.Set;
14+
import java.util.stream.Collectors;
1415

1516
import org.eclipse.lsp4j.DocumentSymbol;
1617
import org.eclipse.lsp4j.Location;
1718
import org.eclipse.lsp4j.SymbolKind;
1819

20+
import com.google.common.collect.ImmutableSet;
1921
import com.google.gson.Gson;
2022

2123
public class Bean extends AbstractSpringIndexElement implements SymbolElement {
@@ -28,6 +30,7 @@ public class Bean extends AbstractSpringIndexElement implements SymbolElement {
2830
private final AnnotationMetadata[] annotations;
2931
private final boolean isConfiguration;
3032
private final String symbolLabel;
33+
private final boolean isInterface;
3134

3235
public Bean(
3336
String name,
@@ -44,6 +47,7 @@ public Bean(
4447
this.location = location;
4548
this.isConfiguration = isConfiguration;
4649
this.symbolLabel = symbolLabel;
50+
this.isInterface = supertypes == null || !supertypes.contains(Object.class.getName());
4751

4852
if (injectionPoints != null && injectionPoints.length == 0) {
4953
this.injectionPoints = null;
@@ -52,11 +56,12 @@ public Bean(
5256
this.injectionPoints = injectionPoints;
5357
}
5458

55-
if (supertypes != null && supertypes.size() == 0) {
59+
Set<String> sanitizedSuperTypes = supertypes == null ? null : supertypes.stream().filter(t -> !t.equals(Object.class.getName())).collect(Collectors.toUnmodifiableSet());
60+
if (sanitizedSuperTypes != null && sanitizedSuperTypes.size() == 0) {
5661
this.supertypes = null;
5762
}
5863
else {
59-
this.supertypes = supertypes;
64+
this.supertypes = sanitizedSuperTypes;
6065
}
6166

6267
if (annotations != null && annotations.length == 0) {
@@ -84,7 +89,7 @@ public InjectionPoint[] getInjectionPoints() {
8489
}
8590

8691
public boolean isTypeCompatibleWith(String type) {
87-
return type != null && ((this.type != null && this.type.equals(type)) || (getSupertypes().contains(type)));
92+
return type != null && ((this.type != null && this.type.equals(type)) || (supertypes != null && supertypes.contains(type)) || (Object.class.getName().equals(type) && !isInterface));
8893
}
8994

9095
public AnnotationMetadata[] getAnnotations() {
@@ -96,7 +101,11 @@ public boolean isConfiguration() {
96101
}
97102

98103
public Set<String> getSupertypes() {
99-
return supertypes == null ? DefaultValues.EMPTY_SUPERTYPES : supertypes;
104+
if (supertypes == null) {
105+
return isInterface ? DefaultValues.EMPTY_SUPERTYPES : DefaultValues.OBJECT_SUPERTYPE;
106+
} else {
107+
return isInterface ? supertypes : ImmutableSet.<String>builder().addAll(supertypes).add(Object.class.getName()).build();
108+
}
100109
}
101110

102111
public String getSymbolLabel() {

0 commit comments

Comments
 (0)