Boot Properties defined in Java Records

This commit is contained in:
aboyko
2023-01-16 12:31:47 -05:00
parent 37cb485346
commit fa4e01d06d
37 changed files with 1270 additions and 141 deletions

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2023 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -18,6 +18,7 @@ import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.ClassType;
import org.jboss.jandex.FieldInfo;
import org.jboss.jandex.MethodInfo;
import org.jboss.jandex.MethodParameterInfo;
import org.jboss.jandex.ParameterizedType;
import org.jboss.jandex.PrimitiveType;
import org.jboss.jandex.Type;
@@ -25,6 +26,7 @@ import org.jboss.jandex.TypeVariable;
import org.jboss.jandex.UnresolvedTypeVariable;
import org.jboss.jandex.VoidType;
import org.jboss.jandex.WildcardType;
import org.springframework.ide.vscode.commons.java.Flags;
class BindingKeyUtils {
@@ -43,10 +45,15 @@ class BindingKeyUtils {
public static String getBindingKey(FieldInfo field) {
StringBuilder sb = new StringBuilder();
sb.append(getBindingKey(field.declaringClass()));
sb.append('.');
sb.append(field.name());
sb.append(')');
sb.append(getGeneralTypeBindingKey(field.type()));
if (field.declaringClass().isRecord() && !Flags.isStatic(field.flags())) {
sb.append('#');
sb.append(field.name());
} else {
sb.append('.');
sb.append(field.name());
sb.append(')');
sb.append(getGeneralTypeBindingKey(field.type()));
}
return sb.toString();
}
@@ -56,8 +63,8 @@ class BindingKeyUtils {
sb.append('.');
sb.append(method.name());
sb.append('(');
for (Type parameter : method.parameters()) {
sb.append(getGeneralTypeBindingKey(parameter));
for (MethodParameterInfo parameter : method.parameters()) {
sb.append(getGeneralTypeBindingKey(parameter.type()));
}
sb.append(')');
sb.append(getGeneralTypeBindingKey(method.returnType()));

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016-2018 Pivotal, Inc.
* Copyright (c) 2016, 2023 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -89,7 +89,7 @@ public class MethodImpl implements IMethod {
@Override
public Stream<IJavaType> parameters() {
return method.parameters().stream().map(Wrappers::wrap);
return method.parameters().stream().map(p -> Wrappers.wrap(p.type()));
}
@Override

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2018 Pivotal, Inc.
* Copyright (c) 2016, 2023 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -73,8 +73,7 @@ class TypeImpl implements IType {
@Override
public Stream<IAnnotation> getAnnotations() {
// TODO: check correctness!
List<AnnotationInstance> annotations = info.annotations().get(info.name());
List<AnnotationInstance> annotations = info.annotations();
return annotations == null ? Stream.empty() : annotations.stream().map(a -> Wrappers.wrap(a, javadocProvider));
}
@@ -97,6 +96,10 @@ class TypeImpl implements IType {
public boolean isAnnotation() {
return Flags.isAnnotation(info.flags());
}
public boolean isRecord() {
return info.isRecord();
}
@Override
public String getFullyQualifiedName() {
@@ -111,9 +114,15 @@ class TypeImpl implements IType {
@Override
public Stream<IField> getFields() {
return info.fields().stream().map(f -> {
return Wrappers.wrap(this, f, javadocProvider);
});
if (info.isRecord()) {
return info.recordComponents().stream().map(rc -> {
return Wrappers.wrap(this, rc.field(), javadocProvider);
});
} else {
return info.fields().stream().map(f -> {
return Wrappers.wrap(this, f, javadocProvider);
});
}
}
@Override

View File

@@ -24,6 +24,7 @@ public interface IType extends IMember {
boolean isEnum();
boolean isInterface();
boolean isAnnotation();
boolean isRecord();
/**
* Returns the fully qualified name of this type,

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2021 Pivotal, Inc.
* Copyright (c) 2019, 2023 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -524,6 +524,11 @@ public class Wrappers {
return data.getSuperInterfaceNames();
}
@Override
public boolean isRecord() {
return data.isRecord();
}
};
}
@@ -630,6 +635,11 @@ public class Wrappers {
return descriptor.getSuperInterfaceNames();
}
@Override
public boolean isRecord() {
return descriptor.isRecord();
}
};
}