Skip to content

Commit

Permalink
Add generated JSON files to gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
lippfi committed Nov 10, 2023
1 parent 876e16f commit 93c83f7
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 172 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

# Generated by gradle task "generateGrammarSource"
src/main/java/com/maddyhome/idea/vim/vimscript/parser/generated
# Generated JSONs for lazy classloading
/vim-engine/src/main/resources/ksp-generated
/src/main/resources/ksp-generated

# Created by github automation
settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.google.devtools.ksp.symbol.KSVisitorVoid
import com.intellij.vim.annotations.CommandOrMotion
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import java.nio.file.Files
import kotlin.io.path.Path
import kotlin.io.path.writeText

Expand All @@ -31,7 +32,11 @@ class CommandOrMotionProcessor(private val environment: SymbolProcessorEnvironme

override fun process(resolver: Resolver): List<KSAnnotated> {
resolver.getAllFiles().forEach { it.accept(visitor, Unit) }
val filePath = Path(environment.options["generated_directory"]!!, environment.options["commands_file"]!!)

val generatedDirPath = Path(environment.options["generated_directory"]!!)
Files.createDirectories(generatedDirPath)

val filePath = generatedDirPath.resolve(environment.options["commands_file"]!!)
val fileContent = json.encodeToString(commands)
filePath.writeText(fileContent)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.google.devtools.ksp.symbol.KSVisitorVoid
import com.intellij.vim.annotations.ExCommand
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import java.nio.file.Files
import kotlin.io.path.Path
import kotlin.io.path.writeText

Expand All @@ -31,7 +32,11 @@ class ExCommandProcessor(private val environment: SymbolProcessorEnvironment): S

override fun process(resolver: Resolver): List<KSAnnotated> {
resolver.getAllFiles().forEach { it.accept(visitor, Unit) }
val filePath = Path(environment.options["generated_directory"]!!, environment.options["ex_commands_file"]!!)

val generatedDirPath = Path(environment.options["generated_directory"]!!)
Files.createDirectories(generatedDirPath)

val filePath = generatedDirPath.resolve(environment.options["ex_commands_file"]!!)
val fileContent = json.encodeToString(commandToClass)
filePath.writeText(fileContent)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.google.devtools.ksp.symbol.KSVisitorVoid
import com.intellij.vim.annotations.VimscriptFunction
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import java.nio.file.Files
import kotlin.io.path.Path
import kotlin.io.path.writeText

Expand All @@ -31,7 +32,11 @@ class VimscriptFunctionProcessor(private val environment: SymbolProcessorEnviron

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 generatedDirPath = Path(environment.options["generated_directory"]!!)
Files.createDirectories(generatedDirPath)

val filePath = generatedDirPath.resolve(environment.options["vimscript_functions_file"]!!)
val fileContent = json.encodeToString(nameToClass)
filePath.writeText(fileContent)

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ plugins {
}

ksp {
arg("generated_directory", "$projectDir/src/main/resources")
arg("generated_directory", "$projectDir/src/main/resources/ksp-generated")
arg("vimscript_functions_file", "intellij_vimscript_functions.json")
arg("ex_commands_file", "intellij_ex_commands.json")
arg("commands_file", "intellij_commands.json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
package com.maddyhome.idea.vim.action

public object IntellijCommandProvider : CommandProvider {
override val exCommandListFileName: String = "intellij_commands.json"
override val commandListFileName: String = "intellij_commands.json"
}
11 changes: 0 additions & 11 deletions src/main/resources/intellij_ex_commands.json

This file was deleted.

6 changes: 0 additions & 6 deletions src/main/resources/intellij_vimscript_functions.json

This file was deleted.

2 changes: 1 addition & 1 deletion vim-engine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repositories {
}

ksp {
arg("generated_directory", "$projectDir/src/main/resources")
arg("generated_directory", "$projectDir/src/main/resources/ksp-generated")
arg("vimscript_functions_file", "engine_vimscript_functions.json")
arg("ex_commands_file", "engine_ex_commands.json")
arg("commands_file", "engine_commands.json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import kotlinx.serialization.json.decodeFromStream
import java.io.InputStream

public interface CommandProvider {
public val exCommandListFileName: String
public val commandListFileName: String

@OptIn(ExperimentalSerializationApi::class)
public fun getCommands(): Collection<LazyVimCommand> {
Expand All @@ -39,8 +39,7 @@ public interface CommandProvider {
}

private fun getFile(): InputStream {
return object {}.javaClass.classLoader.getResourceAsStream(exCommandListFileName)
return object {}.javaClass.classLoader.getResourceAsStream("ksp-generated/$commandListFileName")
?: throw RuntimeException("Failed to fetch ex commands from ${javaClass.name}")
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
package com.maddyhome.idea.vim.action

public object EngineCommandProvider : CommandProvider {
override val exCommandListFileName: String = "engine_commands.json"
override val commandListFileName: String = "engine_commands.json"
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public interface ExCommandProvider {
}

private fun getFile(): InputStream {
return object {}.javaClass.classLoader.getResourceAsStream(exCommandsFileName)
return object {}.javaClass.classLoader.getResourceAsStream("ksp-generated/$exCommandsFileName")
?: throw RuntimeException("Failed to fetch ex-commands for ${javaClass.name}")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public interface VimscriptFunctionProvider {
}

private fun getFile(): InputStream {
return object {}.javaClass.classLoader.getResourceAsStream(functionListFileName)
return object {}.javaClass.classLoader.getResourceAsStream("ksp-generated/$functionListFileName")
?: throw RuntimeException("Failed to fetch functions for ${javaClass.name}")
}
}
}
126 changes: 0 additions & 126 deletions vim-engine/src/main/resources/engine_ex_commands.json

This file was deleted.

14 changes: 0 additions & 14 deletions vim-engine/src/main/resources/engine_vimscript_functions.json

This file was deleted.

0 comments on commit 93c83f7

Please sign in to comment.