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

com.github.mictaege.arete_gradle.ReferenceTargets.kt Maven / Gradle / Ivy

The newest version!
package com.github.mictaege.arete_gradle

import com.github.mictaege.arete.SeeAlso
import com.github.mictaege.arete.SeeAlsoDeclaration

class ReferenceTargets(plan: SpecificationPlan, annotations: Array) {
    constructor(plan: SpecificationPlan, annotation: SeeAlsoDeclaration) : this(plan, annotation.value)
    constructor(plan: SpecificationPlan, annotation: SeeAlso) : this(plan, arrayOf(annotation))

    val refs = annotations.map { r -> ReferenceTarget(plan, r) }
}

class ReferenceTarget(plan: SpecificationPlan, annotation: SeeAlso) {
    val type = annotation.value.java
    val className = annotation.value.java.canonicalName
    val validTarget = plan.findStepByType(type) != null
    val target = plan.findStepByType(type)
    val displayName = target?.displayName.orEmpty()
    val targetUrl = when {
            target == null -> ""
            target.type == StepType.SPEC -> "./${target.uniqueHash}.html"
            else -> {
                val spec = plan.findSpecByChild(target)
                if (spec == null) {
                    ""
                } else {
                    "./${spec.uniqueHash}.html#${target.uniqueHash}"
                }
            }
        }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy