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

io.gitlab.arturbosch.detekt.rules.KtModifierList.kt Maven / Gradle / Ivy

There is a newer version: 1.23.7
Show newest version
@file:Suppress("TooManyFunctions")

package io.gitlab.arturbosch.detekt.rules

import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtModifierListOwner
import org.jetbrains.kotlin.psi.psiUtil.isPublic

fun KtModifierListOwner.isPublicNotOverridden() =
    isPublicNotOverridden(false)

fun KtModifierListOwner.isPublicNotOverridden(considerProtectedAsPublic: Boolean) =
    if (considerProtectedAsPublic) {
        isPublic || isProtected()
    } else {
        isPublic
    } && !isOverride()

fun KtModifierListOwner.isAbstract() = hasModifier(KtTokens.ABSTRACT_KEYWORD)

fun KtModifierListOwner.isOverride() = hasModifier(KtTokens.OVERRIDE_KEYWORD)

fun KtModifierListOwner.isOpen() = hasModifier(KtTokens.OPEN_KEYWORD)

fun KtModifierListOwner.isExternal() = hasModifier(KtTokens.EXTERNAL_KEYWORD)

fun KtModifierListOwner.isOperator() = hasModifier(KtTokens.OPERATOR_KEYWORD)

fun KtModifierListOwner.isConstant() = hasModifier(KtTokens.CONST_KEYWORD)

fun KtModifierListOwner.isInternal() = hasModifier(KtTokens.INTERNAL_KEYWORD)

fun KtModifierListOwner.isLateinit() = hasModifier(KtTokens.LATEINIT_KEYWORD)

fun KtModifierListOwner.isInline() = hasModifier(KtTokens.INLINE_KEYWORD)

fun KtModifierListOwner.isExpect() = hasModifier(KtTokens.EXPECT_KEYWORD)

fun KtModifierListOwner.isActual() = hasModifier(KtTokens.ACTUAL_KEYWORD)

fun KtModifierListOwner.isProtected() = hasModifier(KtTokens.PROTECTED_KEYWORD)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy