TrailingCommaInspection: shouldn't be associated with formatter settings
#KT-34744
This commit is contained in:
+17
@@ -19,6 +19,7 @@ import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.startup.StartupManager
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.openapi.vfs.VfsUtilCore
|
||||
import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess
|
||||
@@ -270,6 +271,22 @@ fun configureCompilerOptions(fileText: String, project: Project, module: Module)
|
||||
return false
|
||||
}
|
||||
|
||||
fun <T> configureRegistryAndRun(fileText: String, body: () -> T) {
|
||||
val registers = InTextDirectivesUtils.findListWithPrefixes(fileText, "// REGISTRY:")
|
||||
.map { it.split(' ') }
|
||||
.map { Registry.get(it.first()) to it.last() }
|
||||
try {
|
||||
for ((register, value) in registers) {
|
||||
register.setValue(value)
|
||||
}
|
||||
body()
|
||||
} finally {
|
||||
for ((register, _) in registers) {
|
||||
register.resetToDefault()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun rollbackCompilerOptions(project: Project, module: Module) {
|
||||
configureLanguageAndApiVersion(project, module, LanguageVersion.LATEST_STABLE.versionString)
|
||||
|
||||
|
||||
+17
@@ -19,6 +19,7 @@ import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.startup.StartupManager
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.openapi.vfs.VfsUtilCore
|
||||
import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess
|
||||
@@ -272,6 +273,22 @@ fun configureCompilerOptions(fileText: String, project: Project, module: Module)
|
||||
return false
|
||||
}
|
||||
|
||||
fun <T> configureRegistryAndRun(fileText: String, body: () -> T) {
|
||||
val registers = InTextDirectivesUtils.findListWithPrefixes(fileText, "// REGISTRY:")
|
||||
.map { it.split(' ') }
|
||||
.map { Registry.get(it.first()) to it.last() }
|
||||
try {
|
||||
for ((register, value) in registers) {
|
||||
register.setValue(value)
|
||||
}
|
||||
body()
|
||||
} finally {
|
||||
for ((register, _) in registers) {
|
||||
register.resetToDefault()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun rollbackCompilerOptions(project: Project, module: Module) {
|
||||
configureLanguageAndApiVersion(project, module, LanguageVersion.LATEST_STABLE.versionString)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user