package io.gitlab.arturbosch.detekt.core

import org.jetbrains.kotlin.fileClasses.javaFileFacadeFqName
import org.jetbrains.kotlin.psi.KtFile

/**
 * @author Artur Bosch
 */

fun KtFile.unnormalizedContent(): String {
	val lineSeparator = this.getUserData(KtCompiler.LINE_SEPARATOR)
	require(lineSeparator != null) { "No line separator entry for ktFile ${this.javaFileFacadeFqName.asString()}" }
	return this.text.replace("\n", lineSeparator!!)
}

val KtFile.relativePath: String?
	get() = this.getUserData(KtCompiler.RELATIVE_PATH)

package io.gitlab.arturbosch.detekt.core

import org.jetbrains.kotlin.com.intellij.openapi.util.text.StringUtilRt
import org.jetbrains.kotlin.fileClasses.javaFileFacadeFqName
import org.jetbrains.kotlin.psi.KtFile

/**
 * @author Artur Bosch
 */

fun KtFile.unnormalizedContent(): String {
	val lineSeparator = this.getUserData(KtCompiler.LINE_SEPARATOR)
	require(lineSeparator != null) { "No line separator entry for ktFile ${this.javaFileFacadeFqName.asString()}" }
	return StringUtilRt.convertLineSeparators("\n", lineSeparator!!)
}

val KtFile.relativePath: String?
	get() = this.getUserData(KtCompiler.RELATIVE_PATH)

Convert Kotlin source code strings to Unix line endings
Convert Kotlin source code strings to Unix line endings

On Windows, Git is often configured with core.autocrlf = true, resulting
in test resource files like ConditionalReturns.kt to have DOS line
endings. Passing the content of such files to createFileFromText() fails
because it can only handle Unix line endings. So convert the line
endings beforehand.

Use idea intern line separator replacement

Mauin/detekt,arturbosch/detekt,Mauin/detekt,MyDogTom/detekt,arturbosch/detekt,Mauin/detekt,arturbosch/detekt,rock3r/detekt,rock3r/detekt,Mauin/detekt,rock3r/detekt