1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-05-06 21:34:02 +02:00

Better paths

This commit is contained in:
filipp 2023-05-12 17:47:15 +03:00
parent 4d907213c3
commit 2716255e22
3 changed files with 7 additions and 4 deletions
annotation-processors/src/main/kotlin/com/intellij/vim

View File

@ -11,6 +11,7 @@ package com.intellij.vim
import org.yaml.snakeyaml.DumperOptions
import org.yaml.snakeyaml.Yaml
import java.io.File
import java.nio.file.Path
class FileWriter {
fun getYAML(comment: String, any: Any): String {
@ -20,8 +21,8 @@ class FileWriter {
return comment + yaml.dump(any)
}
fun writeFile(filePath: String, content: String) {
val file = File(filePath)
fun writeFile(filePath: Path, content: String) {
val file = File(filePath.toUri())
file.writeText(content)
}
}

View File

@ -19,6 +19,7 @@ import com.google.devtools.ksp.symbol.KSFile
import com.google.devtools.ksp.symbol.KSVisitorVoid
import com.intellij.vim.FileWriter
import com.intellij.vim.annotations.ExCommand
import kotlin.io.path.Path
class ExCommandProcessor(private val environment: SymbolProcessorEnvironment): SymbolProcessor {
companion object {
@ -33,7 +34,7 @@ class ExCommandProcessor(private val environment: SymbolProcessorEnvironment): S
override fun process(resolver: Resolver): List<KSAnnotated> {
resolver.getAllFiles().forEach { it.accept(visitor, Unit) }
val filePath = environment.options["generated_directory"]!! + "/" + environment.options["ex_commands_file"]!!
val filePath = Path(environment.options["generated_directory"]!!, environment.options["ex_commands_file"]!!)
writer.writeFile(filePath, writer.getYAML(comment, commandToClass))
return emptyList()
}

View File

@ -21,6 +21,7 @@ import com.intellij.vim.FileWriter
import com.intellij.vim.annotations.VimscriptFunction
import org.yaml.snakeyaml.DumperOptions
import org.yaml.snakeyaml.Yaml
import kotlin.io.path.Path
class VimscriptFunctionProcessor(private val environment: SymbolProcessorEnvironment) : SymbolProcessor {
companion object {
@ -36,7 +37,7 @@ class VimscriptFunctionProcessor(private val environment: SymbolProcessorEnviron
override fun process(resolver: Resolver): List<KSAnnotated> {
resolver.getAllFiles().forEach { it.accept(visitor, Unit) }
val filePath = environment.options["generated_directory"]!! + "/" + environment.options["vimscript_functions_file"]!!
val filePath = Path(environment.options["generated_directory"]!!, environment.options["vimscript_functions_file"]!!)
writer.writeFile(filePath, writer.getYAML(comment, nameToClass))
return emptyList()
}