package com.intellij.codeInspection.tests.kotlin import com.intellij.jvm.analysis.internal.testFramework.SystemGetPropertyInspectionTestBase import com.intellij.jvm.analysis.testFramework.JvmLanguage class KotlinSystemGetPropertyInspectionTest : SystemGetPropertyInspectionTestBase() { fun `test highlighting`() { myFixture.testHighlighting(JvmLanguage.KOTLIN, """ fun foo() { System.getProperty("file.separator") System.getProperty("path.separator") System.getProperty("line.separator") System.getProperty("file.encoding") } """.trimIndent()) } fun `test quickfix file-separator`() { myFixture.testQuickFix(JvmLanguage.KOTLIN, """ fun foo() { System.getProperty("file.separator") } """.trimIndent(), """ import java.nio.file.FileSystems fun foo() { FileSystems.getDefault().getSeparator() } """.trimIndent(), "Replace with 'java.nio.file.FileSystems.getDefault().getSeparator()'", true) } fun `test quickfix path-separator`() { myFixture.testQuickFix(JvmLanguage.KOTLIN, """ fun foo() { System.getProperty("path.separator") } """.trimIndent(), """ import java.io.File fun foo() { File.pathSeparator } """.trimIndent(), "Replace with 'java.io.File.pathSeparator'", true) } fun `test quickfix line-separator`() { myFixture.testQuickFix(JvmLanguage.KOTLIN, """ fun foo() { System.getProperty("line.separator") } """.trimIndent(), """ fun foo() { System.lineSeparator() } """.trimIndent(), "Replace with 'java.lang.System.lineSeparator()'", true) } fun `test quickfix file-encoding`() { myFixture.testQuickFix(JvmLanguage.KOTLIN, """ fun foo() { System.getProperty("file.encoding") } """.trimIndent(), """ import java.nio.charset.Charset fun foo() { Charset.defaultCharset().displayName() } """.trimIndent(), "Replace with 'java.nio.charset.Charset.defaultCharset().displayName()'", true) } }