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

org.jetbrains.kotlin.diagnostics.OffsetsOnlyPositioningStrategy.kt Maven / Gradle / Ivy

There is a newer version: 2.1.0-RC
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.diagnostics

import com.intellij.openapi.util.TextRange
import org.jetbrains.kotlin.AbstractKtSourceElement
import org.jetbrains.kotlin.KtLightSourceElement
import org.jetbrains.kotlin.KtPsiSourceElement

open class OffsetsOnlyPositioningStrategy : AbstractSourceElementPositioningStrategy() {
    open fun markKtDiagnostic(element: AbstractKtSourceElement, diagnostic: KtDiagnostic): List {
        return mark(element.startOffset, element.endOffset)
    }

    open fun mark(
        startOffset: Int,
        endOffset: Int,
    ): List {
        return markElement(startOffset, endOffset)
    }

    override fun markDiagnostic(diagnostic: KtDiagnostic): List = markKtDiagnostic(diagnostic.element, diagnostic)

    override fun isValid(element: AbstractKtSourceElement): Boolean = true
}

fun markElement(
    startOffset: Int,
    endOffset: Int,
): List = markRange(startOffset, endOffset)

fun markRange(
    startOffset: Int,
    endOffset: Int,
): List {
    return listOf(markSingleElement(startOffset, endOffset))
}

fun markSingleElement(
    startOffset: Int,
    endOffset: Int,
): TextRange {
    return TextRange(startOffset, endOffset)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy