All Downloads are FREE. Search and download functionalities are using the official Maven repository.

godot.entrygenerator.checks.NullablePropertyCheck.kt Maven / Gradle / Ivy

There is a newer version: 0.10.0-4.3.0
Show newest version
package godot.entrygenerator.checks

import godot.entrygenerator.ext.isCoreType
import godot.entrygenerator.ext.isGodotPrimitive
import godot.entrygenerator.model.RegisterPropertyAnnotation
import godot.entrygenerator.model.SourceFile
import godot.entrygenerator.utils.Logger

class NullablePropertyCheck(logger: Logger, sourceFiles: List): BaseCheck(logger, sourceFiles) {
    override fun execute(): Boolean {
        var hasIssue = false
        sourceFiles
            .flatMap { it.registeredClasses }
            .flatMap { it.properties }
            .filter { registeredProperty -> registeredProperty.annotations.filterIsInstance().isNotEmpty() }
            .forEach { exportedProperty ->
                if (exportedProperty.type.isNullable && (exportedProperty.type.isCoreType() || exportedProperty.type.isGodotPrimitive())) {
                    hasIssue = true
                    logger.error(exportedProperty, "Registered property which is a Kotlin/Java primitive or Godot core type cannot be nullable. Assign a default value")
                }
            }
        return hasIssue
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy