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

Inline the writeFile function

This commit is contained in:
Alex Plate 2023-06-06 12:16:14 +03:00
parent 51c464f8d2
commit 911915266a
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
3 changed files with 5 additions and 22 deletions
annotation-processors/src/main/kotlin/com/intellij/vim

View File

@ -1,17 +0,0 @@
/*
* Copyright 2003-2023 The IdeaVim authors
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE.txt file or at
* https://opensource.org/licenses/MIT.
*/
package com.intellij.vim
import java.io.File
import java.nio.file.Path
fun writeFile(filePath: Path, content: String) {
val file = File(filePath.toUri())
file.writeText(content)
}

View File

@ -18,10 +18,10 @@ import com.google.devtools.ksp.symbol.KSClassDeclaration
import com.google.devtools.ksp.symbol.KSFile
import com.google.devtools.ksp.symbol.KSVisitorVoid
import com.intellij.vim.annotations.ExCommand
import com.intellij.vim.writeFile
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import kotlin.io.path.Path
import kotlin.io.path.writeText
class ExCommandProcessor(private val environment: SymbolProcessorEnvironment): SymbolProcessor {
private val visitor = EXCommandVisitor()
@ -33,7 +33,7 @@ class ExCommandProcessor(private val environment: SymbolProcessorEnvironment): S
resolver.getAllFiles().forEach { it.accept(visitor, Unit) }
val filePath = Path(environment.options["generated_directory"]!!, environment.options["ex_commands_file"]!!)
val fileContent = json.encodeToString(commandToClass)
writeFile(filePath, fileContent)
filePath.writeText(fileContent)
return emptyList()
}

View File

@ -18,22 +18,22 @@ import com.google.devtools.ksp.symbol.KSClassDeclaration
import com.google.devtools.ksp.symbol.KSFile
import com.google.devtools.ksp.symbol.KSVisitorVoid
import com.intellij.vim.annotations.VimscriptFunction
import com.intellij.vim.writeFile
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import kotlin.io.path.Path
import kotlin.io.path.writeText
class VimscriptFunctionProcessor(private val environment: SymbolProcessorEnvironment) : SymbolProcessor {
private val visitor = VimscriptFunctionVisitor()
private val nameToClass = mutableMapOf<String, String>()
private val json = Json { prettyPrint = true }
override fun process(resolver: Resolver): List<KSAnnotated> {
resolver.getAllFiles().forEach { it.accept(visitor, Unit) }
val filePath = Path(environment.options["generated_directory"]!!, environment.options["vimscript_functions_file"]!!)
val fileContent = json.encodeToString(nameToClass)
writeFile(filePath, fileContent)
filePath.writeText(fileContent)
return emptyList()
}