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

org.jetbrains.kotlin.lombok.processor.SyntheticParts.kt Maven / Gradle / Ivy

There is a newer version: 2.1.0-RC2
Show newest version
/*
 * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
 * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
 */

package org.jetbrains.kotlin.lombok.processor

import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor

class SyntheticParts(
    val methods: List = emptyList(),
    val staticFunctions: List = emptyList(),
    val constructors: List = emptyList(),
    val classes: List = emptyList(),
) {

    operator fun plus(other: SyntheticParts): SyntheticParts = SyntheticParts(
        methods + other.methods,
        staticFunctions + other.staticFunctions,
        constructors + other.constructors,
        classes + other.classes
    )

    companion object {
        val Empty = SyntheticParts()
    }
}

class SyntheticPartsBuilder {
    private val methods = mutableListOf()
    private val staticFunctions = mutableListOf()
    private val constructors = mutableListOf()
    private val classes = mutableListOf()

    fun addMethod(method: SimpleFunctionDescriptor) {
        methods += method
    }

    fun addStaticFunction(function: SimpleFunctionDescriptor) {
        staticFunctions += function
    }

    fun addConstructor(constructor: ClassConstructorDescriptor) {
        constructors += constructor
    }

    fun addClass(clazz: ClassDescriptor) {
        classes += clazz
    }

    fun build(): SyntheticParts = SyntheticParts(methods, staticFunctions, constructors, classes)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy