Boot Properties defined in Java Records
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
<dependency>
|
||||
<groupId>org.jboss</groupId>
|
||||
<artifactId>jandex</artifactId>
|
||||
<version>2.0.5.Final</version>
|
||||
<version>3.0.5</version>
|
||||
</dependency>
|
||||
<!-- HTML <-> Markdown conversion -->
|
||||
<dependency>
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package org.springframework.ide.vscode.commons.protocol.java;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
public class TypeDescriptorData extends MemberData {
|
||||
|
||||
@@ -19,6 +20,7 @@ public class TypeDescriptorData extends MemberData {
|
||||
private boolean annotation;
|
||||
private boolean interfaze;
|
||||
private boolean enam;
|
||||
private boolean record;
|
||||
private String superClassName;
|
||||
private String[] superInterfaceNames;
|
||||
|
||||
@@ -78,17 +80,20 @@ public class TypeDescriptorData extends MemberData {
|
||||
this.superInterfaceNames = superInterfaceNames;
|
||||
}
|
||||
|
||||
public boolean isRecord() {
|
||||
return record;
|
||||
}
|
||||
|
||||
public void setRecord(boolean record) {
|
||||
this.record = record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + (annotation ? 1231 : 1237);
|
||||
result = prime * result + (clazz ? 1231 : 1237);
|
||||
result = prime * result + (enam ? 1231 : 1237);
|
||||
result = prime * result + ((fqName == null) ? 0 : fqName.hashCode());
|
||||
result = prime * result + (interfaze ? 1231 : 1237);
|
||||
result = prime * result + ((superClassName == null) ? 0 : superClassName.hashCode());
|
||||
result = prime * result + Arrays.hashCode(superInterfaceNames);
|
||||
result = prime * result + Objects.hash(annotation, clazz, enam, fqName, interfaze, record, superClassName);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -101,27 +106,10 @@ public class TypeDescriptorData extends MemberData {
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
TypeDescriptorData other = (TypeDescriptorData) obj;
|
||||
if (annotation != other.annotation)
|
||||
return false;
|
||||
if (clazz != other.clazz)
|
||||
return false;
|
||||
if (enam != other.enam)
|
||||
return false;
|
||||
if (fqName == null) {
|
||||
if (other.fqName != null)
|
||||
return false;
|
||||
} else if (!fqName.equals(other.fqName))
|
||||
return false;
|
||||
if (interfaze != other.interfaze)
|
||||
return false;
|
||||
if (superClassName == null) {
|
||||
if (other.superClassName != null)
|
||||
return false;
|
||||
} else if (!superClassName.equals(other.superClassName))
|
||||
return false;
|
||||
if (!Arrays.equals(superInterfaceNames, other.superInterfaceNames))
|
||||
return false;
|
||||
return true;
|
||||
return annotation == other.annotation && clazz == other.clazz && enam == other.enam
|
||||
&& Objects.equals(fqName, other.fqName) && interfaze == other.interfaze && record == other.record
|
||||
&& Objects.equals(superClassName, other.superClassName)
|
||||
&& Arrays.equals(superInterfaceNames, other.superInterfaceNames);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user