collapse zig and zon modules together, we are NOT doing micro-modules!

This commit is contained in:
FalsePattern 2024-10-30 16:40:45 +01:00
parent 971bf5dbc1
commit 112c523a59
Signed by: falsepattern
GPG key ID: E930CDEC50C50E23
64 changed files with 136 additions and 93 deletions

View file

@ -80,8 +80,7 @@ dependencies {
plugin(lsp4ijPluginString)
}
implementation(project(":zig"))
implementation(project(":zon"))
implementation(project(":core"))
implementation(project(":lsp"))
}

View file

@ -0,0 +1,100 @@
import org.jetbrains.grammarkit.tasks.GenerateLexerTask
import org.jetbrains.grammarkit.tasks.GenerateParserTask
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
plugins {
id("org.jetbrains.grammarkit")
}
dependencies {
intellijPlatform {
create(IntelliJPlatformType.IntellijIdeaCommunity, providers.gradleProperty("ideaCommunityVersion"))
}
}
//region grammars
run {
val grammarGenRoot = layout.buildDirectory.dir("generated/sources/grammarkit")
val rootPackagePath = "com/falsepattern/zigbrains"
val grammarSources = layout.projectDirectory.dir("src/main/grammar")
val parserDir = grammarGenRoot.map {it.dir("zig/parser")}
val lexerDir = grammarGenRoot.map {it.dir("zig/lexer")}
val lexerStringDir = grammarGenRoot.map {it.dir("zig/lexerstring")}
val zonParserDir = grammarGenRoot.map {it.dir("zon/parser")}
val zonLexerDir = grammarGenRoot.map {it.dir("zon/lexer")}
val grammarGenDirs = listOf(parserDir, lexerDir, lexerStringDir, zonParserDir, zonLexerDir)
sourceSets {
main {
java {
grammarGenDirs.forEach { srcDir(it) }
}
}
}
idea {
module {
grammarGenDirs.forEach {
val file = it.get().asFile
sourceDirs.add(file)
generatedSourceDirs.add(file)
}
sourceDirs.add(grammarSources.asFile)
}
}
tasks {
// region grammarkit
generateLexer {
purgeOldFiles = true
sourceFile = grammarSources.file("Zig.flex")
targetOutputDir = lexerDir.map { it.dir("$rootPackagePath/zig/lexer") }
}
register<GenerateLexerTask>("generateLexerString") {
purgeOldFiles = true
sourceFile = grammarSources.file("ZigString.flex")
targetOutputDir = lexerStringDir.map { it.dir("$rootPackagePath/zig/lexerstring") }
}
generateParser {
purgeOldFiles = true
sourceFile = grammarSources.file("Zig.bnf")
targetRootOutputDir = parserDir
pathToParser = "$rootPackagePath/zig/parser/ZigParser.java"
pathToPsiRoot = "$rootPackagePath/zig/psi"
}
register<GenerateLexerTask>("generateZonLexer") {
purgeOldFiles = true
sourceFile = grammarSources.file("Zon.flex")
targetOutputDir = zonLexerDir.map { it.dir("$rootPackagePath/zon/lexer") }
}
register<GenerateParserTask>("generateZonParser") {
purgeOldFiles = true
sourceFile = grammarSources.file("Zon.bnf")
targetRootOutputDir = zonParserDir
pathToParser = "$rootPackagePath/zon/parser/ZonParser.java"
pathToPsiRoot = "$rootPackagePath/zon/psi"
}
register<DefaultTask>("generateGrammars") {
group = "grammarkit"
dependsOn("generateLexer", "generateLexerString", "generateParser")
dependsOn("generateZonLexer", "generateZonParser")
}
compileJava {
dependsOn("generateGrammars")
}
compileKotlin {
dependsOn("generateGrammars")
}
}
}
//endregion grammars

View file

@ -0,0 +1,30 @@
/*
* This file is part of ZigBrains.
*
* Copyright (C) 2023-2024 FalsePattern
* All Rights Reserved
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* ZigBrains is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, only version 3 of the License.
*
* ZigBrains is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ZigBrains. If not, see <https://www.gnu.org/licenses/>.
*/
package com.falsepattern.zigbrains
import com.intellij.openapi.util.IconLoader
object Icons {
val ZIG = IconLoader.getIcon("/icons/zig.svg", Icons::class.java)
val ZON = IconLoader.getIcon("/icons/zon.svg", Icons::class.java)
}

View file

@ -1,5 +1,6 @@
package com.falsepattern.zigbrains.zig
import com.falsepattern.zigbrains.Icons
import com.intellij.openapi.fileTypes.LanguageFileType
object ZigFileType : LanguageFileType(ZigLanguage) {

View file

@ -1,6 +1,6 @@
package com.falsepattern.zigbrains.zig.highlighter
import com.falsepattern.zigbrains.zig.Icons
import com.falsepattern.zigbrains.Icons
import com.intellij.openapi.editor.colors.TextAttributesKey
import com.intellij.openapi.options.colors.AttributesDescriptor
import com.intellij.openapi.options.colors.ColorDescriptor

View file

@ -1,5 +1,6 @@
package com.falsepattern.zigbrains.zon
import com.falsepattern.zigbrains.Icons
import com.intellij.openapi.fileTypes.LanguageFileType
object ZonFileType: LanguageFileType(ZonLanguage) {

View file

@ -1,6 +1,6 @@
package com.falsepattern.zigbrains.zon.highlighting
import com.falsepattern.zigbrains.zon.Icons
import com.falsepattern.zigbrains.Icons
import com.intellij.openapi.options.colors.AttributesDescriptor
import com.intellij.openapi.options.colors.ColorDescriptor
import com.intellij.openapi.options.colors.ColorSettingsPage

View file

Before

Width:  |  Height:  |  Size: 850 B

After

Width:  |  Height:  |  Size: 850 B

View file

Before

Width:  |  Height:  |  Size: 858 B

After

Width:  |  Height:  |  Size: 858 B

View file

@ -1,74 +0,0 @@
import org.jetbrains.grammarkit.tasks.GenerateLexerTask
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
plugins {
id("org.jetbrains.grammarkit")
}
dependencies {
intellijPlatform {
create(IntelliJPlatformType.IntellijIdeaCommunity, providers.gradleProperty("ideaCommunityVersion"))
}
}
val grammarGenRoot = "generated/sources/grammarkit/zig"
val rootPackagePath = "com/falsepattern/zigbrains/zig"
val parserDir = layout.buildDirectory.dir("$grammarGenRoot/parser")
val lexerDir = layout.buildDirectory.dir("$grammarGenRoot/lexer")
val lexerStringDir = layout.buildDirectory.dir("$grammarGenRoot/lexerstring")
sourceSets {
main {
java {
srcDir(parserDir)
srcDir(lexerDir)
srcDir(lexerStringDir)
}
}
}
idea {
module {
sourceDirs.addAll(listOf(parserDir.get().asFile, lexerDir.get().asFile, lexerStringDir.get().asFile))
generatedSourceDirs.addAll(listOf(parserDir.get().asFile, lexerDir.get().asFile, lexerStringDir.get().asFile))
}
}
tasks {
generateLexer {
purgeOldFiles = true
sourceFile = file("src/main/grammar/Zig.flex")
targetOutputDir = layout.buildDirectory.dir("$grammarGenRoot/lexer/$rootPackagePath/lexer")
}
register<GenerateLexerTask>("generateLexerString") {
purgeOldFiles = true
sourceFile = file("src/main/grammar/ZigString.flex")
targetOutputDir = layout.buildDirectory.dir("$grammarGenRoot/lexerstring/$rootPackagePath/lexerstring")
}
generateParser {
purgeOldFiles = true
sourceFile = file("src/main/grammar/Zig.bnf")
targetRootOutputDir = layout.buildDirectory.dir("$grammarGenRoot/parser")
pathToParser = "$rootPackagePath/psi/ZigParser.java"
pathToPsiRoot = "$rootPackagePath/psi"
}
register<DefaultTask>("generateGrammars") {
group = "grammarkit"
dependsOn("generateLexer")
dependsOn("generateLexerString")
dependsOn("generateParser")
}
compileJava {
dependsOn("generateGrammars")
}
compileKotlin {
dependsOn("generateGrammars")
}
}

View file

@ -1,7 +0,0 @@
package com.falsepattern.zigbrains.zig
import com.intellij.openapi.util.IconLoader
object Icons {
val ZIG = IconLoader.getIcon("/icons/zig.svg", Icons::class.java)
}

View file

@ -1,7 +0,0 @@
package com.falsepattern.zigbrains.zon
import com.intellij.openapi.util.IconLoader
object Icons {
val ZON = IconLoader.getIcon("/icons/zon.svg", Icons::class.java)
}

View file

@ -3,7 +3,7 @@ plugins {
}
rootProject.name = "ZigBrains"
for (module in arrayOf("zig", "zon", "lsp")) {
for (module in arrayOf("core", "lsp")) {
include(module)
project(":$module").projectDir = file("modules/$module")
}