Skip to content

Commit 00b28fc

Browse files
committed
enh: Add context on classgraph errors
1 parent ee26038 commit 00b28fc

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

kt/entry-generation/godot-class-graph-symbol-processor/src/main/kotlin/godot/annotation/processor/classgraph/extensions/AnnotationExtensions.kt

+5-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import io.github.classgraph.AnnotationInfo
4444
import io.github.classgraph.ClassRefTypeSignature
4545
import io.github.classgraph.FieldInfo
4646

47-
fun AnnotationInfo.mapToGodotAnnotation(parentDeclaration: Any): GodotAnnotation? {
47+
fun AnnotationInfo.mapToGodotAnnotation(parentDeclaration: Any, declarationString: String): GodotAnnotation? {
4848
@Suppress("UNCHECKED_CAST")
4949
return when (name) {
5050
RegisterClass::class.java.name -> RegisterClassAnnotation(
@@ -67,7 +67,7 @@ fun AnnotationInfo.mapToGodotAnnotation(parentDeclaration: Any): GodotAnnotation
6767
EnumFlag::class.java.name -> {
6868
if (parentDeclaration !is FieldInfo) {
6969
ErrorsDatabase.add(
70-
"EnumFlag annotation should be placed on property."
70+
"EnumFlag annotation has been set on $declarationString. It should be placed on property only."
7171
)
7272
return EnumFlagHintStringAnnotation(enumValueNames = listOf(), source = this)
7373
}
@@ -76,9 +76,10 @@ fun AnnotationInfo.mapToGodotAnnotation(parentDeclaration: Any): GodotAnnotation
7676

7777
require(typeDescriptor is ClassRefTypeSignature)
7878

79-
if (typeDescriptor.fullyQualifiedClassName != SET) {
79+
val fullyQualifiedClassName = typeDescriptor.fullyQualifiedClassName
80+
if (fullyQualifiedClassName != SET) {
8081
ErrorsDatabase.add(
81-
"Property annotated with EnumFlag should be of type $SET"
82+
"Property annotated with EnumFlag should be of type $SET, $declarationString is of type $fullyQualifiedClassName"
8283
)
8384
return EnumFlagHintStringAnnotation(enumValueNames = listOf(), source = this)
8485
}

kt/entry-generation/godot-class-graph-symbol-processor/src/main/kotlin/godot/annotation/processor/classgraph/extensions/ClassExtentions.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fun ClassInfo.mapToClazz(settings: Settings): Clazz {
2424
val supertypes = superclasses.union(interfaces).map { it.mapToClazz(settings) }
2525

2626
val annotations = annotationInfo
27-
.mapNotNull { it.mapToGodotAnnotation(this) as? ClassAnnotation }
27+
.mapNotNull { it.mapToGodotAnnotation(this, fqName) as? ClassAnnotation }
2828

2929
val methods = methodInfo
3030
.filter { it.hasAnnotation(RegisterFunction::class.java) }

kt/entry-generation/godot-class-graph-symbol-processor/src/main/kotlin/godot/annotation/processor/classgraph/extensions/FieldExtensions.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import io.github.classgraph.MethodInfo
1919
fun FieldInfo.mapToRegisteredProperty(settings: Settings, classInfo: ClassInfo): RegisteredProperty {
2020
// Map annotations
2121
val annotations = getAnnotations(classInfo)
22-
.mapNotNull { it.mapToGodotAnnotation(this) as? PropertyAnnotation }
22+
.mapNotNull { it.mapToGodotAnnotation(this, fqName) as? PropertyAnnotation }
2323
.toMutableList()
2424

2525
// Handle enums and collections with enums
@@ -121,7 +121,7 @@ fun FieldInfo.mapFieldToRegisteredSignal(settings: Settings, classInfo: ClassInf
121121
.getValue(signalParametersName) as Array<String>
122122
).toList(),
123123
isOverridee = isOverridee,
124-
annotations = annotations.mapNotNull { it.mapToGodotAnnotation(this) as? PropertyAnnotation },
124+
annotations = annotations.mapNotNull { it.mapToGodotAnnotation(this, fqName) as? PropertyAnnotation },
125125
symbolProcessorSource = this
126126
)
127127
}

kt/entry-generation/godot-class-graph-symbol-processor/src/main/kotlin/godot/annotation/processor/classgraph/extensions/MethodExtensions.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import io.github.classgraph.MethodInfo
99

1010
fun MethodInfo.mapMethodToRegisteredFunction(currentClass: ClassInfo, settings: Settings): RegisteredFunction {
1111
val parameters = parameterInfo.map { it.mapToValueParameter(settings) }
12-
val annotations = annotationInfo.mapNotNull { it.mapToGodotAnnotation(this) as? FunctionAnnotation }
12+
val annotations = annotationInfo.mapNotNull { it.mapToGodotAnnotation(this, fqName) as? FunctionAnnotation }
1313

1414
val typeDescriptor = TypeDescriptor(this)
1515
return RegisteredFunction(

0 commit comments

Comments
 (0)