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

com.jtransc.ast.ast_annotation.kt Maven / Gradle / Ivy

There is a newer version: 0.6.8
Show newest version
package com.jtransc.ast

import com.jtransc.ds.toTypedArray2
import kotlin.reflect.KProperty1

data class AstAnnotation(
	val type: AstType.REF,
	val elements: Map,
    val runtimeVisible: Boolean
)

operator fun List?.get(name: FqName): AstAnnotation? {
	val ref = AstType.REF(name)
	return this?.firstOrNull { it.type == ref }
}

operator fun List?.get(name: FqName, field: String): Any? {
	val value = this?.get(name)?.elements?.get(field)
	return when (value) {
		null -> null
		is List<*> -> value.toTypedArray2()
		else -> value
	}
}

operator fun List?.contains(name: FqName): Boolean {
	return this.get(name) != null
}

operator inline fun  List?.get(field: KProperty1): T? {
	if (this != null) {
		return this?.get(C::class.java.name.fqname, field.name) as T?
	} else {
		return null
	}
}

inline fun  List?.contains(): Boolean {
	return C::class.java.name.fqname in this
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy