Skip to content

Commit

Permalink
2.5 (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreypfau authored Jan 15, 2025
1 parent c26e99c commit 4414af4
Show file tree
Hide file tree
Showing 610 changed files with 7,325 additions and 3,236 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# TON Plugin for the IntelliJ IDEs Changelog

## [2.5.0]

### Added
- Tolk 0.7 support
- Tolk type inference & completion
- Tolk type hints for variables & functions
- TL-B schema inspections
- TL-B constructor tag generator

### Fixed
- A lot of minor bugs

## [2.4.0]

### Added
Expand Down
10 changes: 10 additions & 0 deletions blueprint/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugins {
id("org.jetbrains.intellij.platform.module")
}

dependencies {
intellijPlatform {
val version = providers.gradleProperty("platformVersion")
intellijIdeaCommunity(version)
}
}
181 changes: 68 additions & 113 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import org.gradle.configurationcache.extensions.capitalized

import org.jetbrains.changelog.Changelog
import org.jetbrains.grammarkit.tasks.GenerateLexerTask
import org.jetbrains.grammarkit.tasks.GenerateParserTask
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.time.Clock
import java.time.Instant

val publishChannel = prop("publishChannel")
val ideaVersion = prop("ideaVersion")
val pluginVersion = prop("pluginVersion").let { pluginVersion ->
if (publishChannel != "release" && publishChannel != "stable") {
val buildSuffix = prop("buildNumber") {
Expand All @@ -19,92 +18,95 @@ val pluginVersion = prop("pluginVersion").let { pluginVersion ->
}
}
version = pluginVersion
println("pluginVersion=$version")

plugins {
kotlin("jvm") version "1.9.22"
id("org.jetbrains.intellij") version "1.17.3"
kotlin("jvm") version "2.0.10"
id("org.jetbrains.intellij.platform")
id("org.jetbrains.grammarkit") version "2022.3.2.2"
id("org.jetbrains.changelog") version "2.2.0"
idea
id("org.jetbrains.changelog") version "2.2.1"
}

allprojects {
apply(plugin = "kotlin")

repositories {
maven("https://cache-redirector.jetbrains.com/intellij-dependencies")
mavenCentral()
maven(url = "https://jitpack.io")
tasks.withType<KotlinCompile> {
compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
compilerOptions.freeCompilerArgs.add("-Xjvm-default=all")
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "17"
kotlinOptions.freeCompilerArgs += "-Xjvm-default=all"
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}

dependencies {
implementation("me.alllex.parsus:parsus-jvm:0.6.1")
implementation("com.github.andreypfau.tlb:tlb-jvm:54070d9405")
sourceSets {
main {
kotlin.srcDir("src")
java.srcDirs("gen")
resources.srcDir("resources")
}
test {
kotlin.srcDir("test")
resources.srcDir("testResources")
}
}
tasks {
test {
useJUnitPlatform()
}
}
}

sourceSets {
main {
java.srcDirs("src/gen")
tasks {
buildSearchableOptions {
enabled = false
}
}

idea {
module {
isDownloadSources = true
generatedSourceDirs.add(file("src/gen"))
dependencies {
intellijPlatform {
val version = providers.gradleProperty("platformVersion")
create(IntelliJPlatformType.IntellijIdeaUltimate, version)

pluginModule(implementation(project(":util")))
pluginModule(implementation(project(":asm")))
pluginModule(implementation(project(":tolk")))
pluginModule(implementation(project(":func")))
pluginModule(implementation(project(":tact")))
pluginModule(implementation(project(":boc")))
pluginModule(implementation(project(":tlb")))
pluginModule(implementation(project(":fift")))
pluginModule(implementation(project(":blueprint")))
pluginModule(implementation(project(":fc2tolk-js")))
}
}

intellij {
version.set(ideaVersion)
type.set("IU")
plugins.set(
listOf(
"JavaScript",
"com.google.ide-perf:1.3.1",
"izhangzhihao.rainbow.brackets:2023.3.2"
intellijPlatform {
pluginConfiguration {
id = "org.ton.intellij-ton"
name = "TON"
version = project.version.toString()
description = """
TON Blockchain Development Plugin for IntelliJ: Adds support for TON blockchain programming languages,
including FunC, Tolk, Fift, Tact, and TL-B schemas.
Ideal for Web3 developers working within the TON ecosystem.
""".trimIndent()
changeNotes.set(
provider {
changelog.renderItem(changelog.getLatest(), Changelog.OutputType.HTML)
}
)
)
}

val generateFuncLexer = generateLexer("Func")
val generateFuncParser = generateParser("Func")

val generateTactLexer = generateLexer("Tact")
val generateTactParser = generateParser("Tact")

val generateFiftLexer = generateLexer("Fift")
val generateFiftParser = generateParser("Fift")

val generateTlbLexer = generateLexer("Tlb")
val generateTlbParser = generateParser("Tlb")

val generateAsmLexer = generateLexer("Asm")
val generateAsmParser = generateParser("Asm")

val generateTolkLexer = generateLexer("Tolk")
val generateTolkParser = generateParser("Tolk")

val compileKotlin = tasks.named("compileKotlin") {
dependsOn(
generateFuncParser, generateFuncLexer,
generateTactParser, generateTactLexer,
generateFiftParser, generateFiftLexer,
generateTlbParser, generateTlbLexer,
generateAsmParser, generateAsmLexer,
generateTolkParser, generateTolkLexer,
)
ideaVersion {
sinceBuild.set("243")
untilBuild = provider { null }
}
vendor {
name = "TON Core"
url = "https://github.com/ton-blockchain/intellij-ton"
email = "[email protected]"
}
}
}

val compileJava = tasks.named("compileJava")

changelog {
version.set(version)
path.set("${project.projectDir}/CHANGELOG.md")
Expand All @@ -115,52 +117,5 @@ changelog {
groups.set(listOf("Added", "Changed", "Deprecated", "Removed", "Fixed", "Security"))
}

tasks {
runIde { enabled = true }
prepareSandbox { enabled = true }
patchPluginXml {
sinceBuild.set("232")
untilBuild.set("")
changeNotes.set(provider {
changelog.renderItem(changelog.run {
getLatest()
}, Changelog.OutputType.HTML)
})
}
buildSearchableOptions {
enabled = prop("enableBuildSearchableOptions").toBoolean()
}
configurations.runtimeClasspath.get().forEach {
println(it)
}
jar {
from({
configurations.runtimeClasspath.get().filter { file ->
!file.nameWithoutExtension.startsWith("kotlin-stdlib") &&
!file.nameWithoutExtension.startsWith("annotations")
}.map {
if (it.isDirectory) it
else zipTree(it)
}
})
}
}

fun prop(name: String, default: (() -> String?)? = null) = extra.properties[name] as? String
?: default?.invoke() ?: error("Property `$name` is not defined in gradle.properties")

fun generateParser(language: String, suffix: String = "", config: GenerateParserTask.() -> Unit = {}) =
task<GenerateParserTask>("generate${language.capitalized()}Parser${suffix.capitalized()}") {
sourceFile.set(file("src/main/grammar/${language}Parser.bnf"))
targetRootOutputDir.set(file("src/gen"))
pathToParser.set("/org/ton/intellij/${language.lowercase()}/parser/${language}Parser.java")
pathToPsiRoot.set("/org/ton/intellij/${language.lowercase()}/psi")
purgeOldFiles.set(true)
config()
}

fun generateLexer(language: String) = task<GenerateLexerTask>("generate${language}Lexer") {
sourceFile.set(file("src/main/grammar/${language}Lexer.flex"))
targetOutputDir.set(file("src/gen/org/ton/intellij/${language.lowercase()}/lexer"))
purgeOldFiles.set(true)
}
12 changes: 7 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
org.gradle.jvmargs=-Xmx4096m
pluginGroup=org.ton
pluginVersion=2.4.3
pluginVersion=2.5.0
publishChannel=release
publishToken=token
enableBuildSearchableOptions=false
# Existent IDE versions can be found in the following repos:
# https://www.jetbrains.com/intellij-repository/releases/
# https://www.jetbrains.com/intellij-repository/snapshots/
ideaVersion=2024.2.4
# https://plugins.jetbrains.com/plugin/227-psiviewer/versions
psiViewerPluginVersion=231-SNAPSHOT
ideaVersion=2024.3
kotlin.stdlib.default.dependency=false
buildNumber=1
buildNumber=17

platformType=IC
platformVersion=2024.3
org.gradle.parallel=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
37 changes: 37 additions & 0 deletions modules/asm/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import org.jetbrains.grammarkit.tasks.GenerateLexerTask
import org.jetbrains.grammarkit.tasks.GenerateParserTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("org.jetbrains.intellij.platform.module")
id("org.jetbrains.grammarkit")
}

dependencies {
intellijPlatform {
val version = providers.gradleProperty("platformVersion")
intellijIdeaCommunity(version)
}
compileOnly(project(":util"))
}

val generateAsmParser = task<GenerateParserTask>("generateAsmParser") {
sourceFile.set(file("src/org/ton/intellij/asm/parser/AsmParser.bnf"))
targetRootOutputDir.set(file("gen"))
pathToParser.set("/org/ton/intellij/asm/parser/AsmParser.java")
pathToPsiRoot.set("/org/ton/intellij/asm/psi")
purgeOldFiles.set(true)
dependsOn(":util:composedJar")
}

//tasks.findByPath(":util:composedJar")?.mustRunAfter(generateAsmParser)

val generateAsmLexer = task<GenerateLexerTask>("generateAsmLexer") {
sourceFile.set(file("src/org/ton/intellij/asm/lexer/AsmLexer.flex"))
targetOutputDir.set(file("gen/org/ton/intellij/asm/lexer"))
purgeOldFiles.set(true)
}

tasks.withType<KotlinCompile>().configureEach {
dependsOn(generateAsmParser, generateAsmLexer)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
language="TVM assembly"
extensions="tvm"/>
<lang.parserDefinition language="TVM assembly"
implementationClass="org.ton.intellij.asm.AsmParserDefinition"/>
implementationClass="org.ton.intellij.asm.parser.AsmParserDefinition"/>
<lang.syntaxHighlighterFactory language="TVM assembly"
implementationClass="org.ton.intellij.asm.AsmSyntaxHighlighterFactory"/>
<completion.contributor language="TVM assembly"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import com.intellij.codeInsight.completion.*
import com.intellij.codeInsight.lookup.LookupElementBuilder
import com.intellij.patterns.PlatformPatterns
import com.intellij.util.ProcessingContext
import org.ton.intellij.asm.psi.AsmElementTypes

class AsmCompletionContributor : CompletionContributor() {
init {
extend(
CompletionType.BASIC,
PlatformPatterns.psiElement().withElementType(AsmElementTypes.UNKNOWN_IDENTIFIER),
PlatformPatterns.psiElement().withElementType(AsmElementTypes.WORD),
object : CompletionProvider<CompletionParameters>() {
override fun addCompletions(
parameters: CompletionParameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ package org.ton.intellij.asm

import com.intellij.psi.tree.IFileElementType

object AsmFileElementType : IFileElementType(AsmLanguage) {
}
object AsmFileElementType : IFileElementType(AsmLanguage)
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import com.intellij.openapi.editor.colors.TextAttributesKey
import com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase
import com.intellij.psi.tree.IElementType
import org.ton.intellij.asm.lexer.AsmLexer
import org.ton.intellij.asm.psi.AsmElementTypes

object AsmHighlighter : SyntaxHighlighterBase() {
override fun getHighlightingLexer(): Lexer {
Expand All @@ -30,6 +32,8 @@ object AsmHighlighter : SyntaxHighlighterBase() {
private val INSTRUCTION =
createTextAttributesKey("ASM.INSTRUCTION", XmlHighlighterColors.HTML_TAG)
private val NUMBER = createTextAttributesKey("ASM.NUMBER", DefaultLanguageHighlighterColors.NUMBER)
private val STACK_REGISTER = createTextAttributesKey("ASM.STACK_REGISTER", DefaultLanguageHighlighterColors.CONSTANT)
private val CONTROL_REGISTER = createTextAttributesKey("ASM.STACK_REGISTER", DefaultLanguageHighlighterColors.CONSTANT)
private val STACK_REGISTER =
createTextAttributesKey("ASM.STACK_REGISTER", DefaultLanguageHighlighterColors.CONSTANT)
private val CONTROL_REGISTER =
createTextAttributesKey("ASM.STACK_REGISTER", DefaultLanguageHighlighterColors.CONSTANT)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ object AsmInstructionsCsv {
split[6],
split[7],
split[8]
).also {
println("parsed: $it")
}
)
}

data class Instruction(
Expand Down
Loading

0 comments on commit 4414af4

Please sign in to comment.