[Lombok] Add implementation of plugin for FIR

This commit is contained in:
Dmitriy Novozhilov
2022-05-25 16:18:50 +03:00
committed by teamcity
parent e58e86932c
commit a84ece7233
41 changed files with 1685 additions and 42 deletions
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.lombok.utils
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
object LombokNames {
@@ -20,6 +21,16 @@ object LombokNames {
val REQUIRED_ARGS_CONSTRUCTOR = FqName("lombok.RequiredArgsConstructor")
val ACCESSORS_ID = ClassId.topLevel(ACCESSORS)
val GETTER_ID = ClassId.topLevel(GETTER)
val SETTER_ID = ClassId.topLevel(SETTER)
val WITH_ID = ClassId.topLevel(WITH)
val DATA_ID = ClassId.topLevel(DATA)
val VALUE_ID = ClassId.topLevel(VALUE)
val NO_ARGS_CONSTRUCTOR_ID = ClassId.topLevel(NO_ARGS_CONSTRUCTOR)
val ALL_ARGS_CONSTRUCTOR_ID = ClassId.topLevel(ALL_ARGS_CONSTRUCTOR)
val REQUIRED_ARGS_CONSTRUCTOR_ID = ClassId.topLevel(REQUIRED_ARGS_CONSTRUCTOR)
//taken from idea lombok plugin
val NON_NULL_ANNOTATIONS = listOf(
"androidx.annotation.NonNull",
@@ -0,0 +1,27 @@
/*
* 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.utils
object AccessorNames {
const val IS = "is"
const val GET = "get"
const val SET = "set"
}
fun toPropertyName(name: String, prefixesToStrip: List<String> = emptyList()): String =
name.stripPrefixes(prefixesToStrip).decapitalize()
fun toPropertyNameCapitalized(name: String, prefixesToStrip: List<String> = emptyList()): String =
name.stripPrefixes(prefixesToStrip).capitalize()
private fun String.stripPrefixes(prefixes: List<String>): String =
prefixes.firstOrNull { isPrefix(it) }?.let { prefix ->
drop(prefix.length)
} ?: this
private fun String.isPrefix(prefix: String): Boolean =
length > prefix.length && startsWith(prefix) && get(prefix.length).isUpperCase()