Skip to content

Commit

Permalink
2.0 (#123)
Browse files Browse the repository at this point in the history
* WIP

* func

* FuncFunction stub indexes

* Reference resolving

* New inspections

* variable & parameters resolve

* constant & global var resolving

* forall type references

* function completion provider & fix #44

* annotator

* fix

* fix grammar

* fix chain call grammar

* fix syntax highlighting

* arguments inspection

* parameter hints

* rename refactoring

* smart function call insertion handler

* keyword completion

* completion improvements

* fix indents

* blueprint

* index constants

* documentation rendering

* fix markdown links

* Replace guard clause with function call & pragma version fix #52

* default auto-complete for keyword

* fix inv expression

* working tilda call

* fixed calls

* inbuilt functions doc

* quote handler

* recursive call line marker

* fix modify function args

* fix variable completion

* Basic Tact support

* Global variables and constants declared in including files aren't found (fix #113)

* IDE doesn't allow renaming an identifier if it contains ":" #114

* IDE doesn't allow renaming an identifier if it contains ":" fix #114

* light/dark tact icon

* backport tlb,fift,boc

* new plugin icon

* Update README.md

* 2.0

* README.md update
  • Loading branch information
andreypfau authored Aug 17, 2023
1 parent 50403be commit 2878e23
Show file tree
Hide file tree
Showing 225 changed files with 8,333 additions and 8,458 deletions.
20 changes: 15 additions & 5 deletions .idea/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# TON Development Changelog

## [2.0]

### Complete plugin rework

- Documentation rendering
- Tact support
- Blueprint project support
- A lot of bug-fixes and small futures

## [1.0.3]

### Added
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
# TON Development for the IntelliJ IDEs
# TON Plugin for the IntelliJ IDEs

[![JetBrains plugins][plugin-version-svg]][plugin-repo]
[![JetBrains plugins][plugin-downloads-svg]][plugin-repo]
[![Based on TON][ton-svg]][ton]

### Available on JetBrains Marketplace

https://plugins.jetbrains.com/plugin/18541-ton-development
https://plugins.jetbrains.com/plugin/18541-ton

### Languages supported

- FunC
- Fift
- Tact
- TL-B Schemas

---

### Installation

- Using IDE built-in plugin system:
- Using an IDE built-in plugin system:

<kbd>Settings/Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>Marketplace</kbd> > <kbd>Search for "TON Development"</kbd> >
<kbd>Settings/Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>Marketplace</kbd> > <kbd>Search for "TON"</kbd> >
<kbd>Install Plugin</kbd>

- Manually:
Expand Down
194 changes: 72 additions & 122 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,64 +1,47 @@
import org.gradle.configurationcache.extensions.capitalized
import org.jetbrains.grammarkit.tasks.GenerateLexerTask
import org.jetbrains.grammarkit.tasks.GenerateParserTask
import org.jetbrains.intellij.tasks.PublishPluginTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.time.Clock
import java.time.Instant

val channel = prop("publishChannel")
val isCI = System.getenv("CI") != null
val psiViewerPlugin = "PsiViewer:${prop("psiViewerPluginVersion")}"
val graziePlugin = "tanvd.grazi"
val publishChannel = prop("publishChannel")
val ideaVersion = prop("ideaVersion")

val Project.dependencyCachePath
get(): String {
val cachePath = file("${rootProject.projectDir}/deps")
// If cache path doesn't exist, we need to create it manually
// because otherwise gradle-intellij-plugin will ignore it
if (!cachePath.exists()) {
cachePath.mkdirs()
val pluginVersion = prop("pluginVersion").let { pluginVersion ->
if (publishChannel != "release" && publishChannel != "stable") {
val buildSuffix = prop("buildNumber") {
Instant.now(Clock.systemUTC()).toString().substring(2, 16).replace("[-T:]".toRegex(), "")
}
return cachePath.absolutePath
"$pluginVersion-${publishChannel.uppercase()}+$buildSuffix"
} else {
pluginVersion
}
}
version = pluginVersion
println("pluginVersion=$version")

plugins {
kotlin("jvm") version "1.6.21"
kotlin("plugin.serialization") version "1.6.21"
id("org.jetbrains.intellij") version "1.5.3"
id("org.jetbrains.grammarkit") version "2021.2.2"
id("org.jetbrains.changelog") version "1.3.1"
kotlin("jvm") version "1.9.0"
id("org.jetbrains.intellij") version "1.15.0"
id("org.jetbrains.grammarkit") version "2022.3.1"
}

group = prop("pluginGroup")
version = prop("pluginVersion")
allprojects {
apply(plugin = "kotlin")

if (channel != "release" && channel != "stable") {
val buildSuffix = prop("buildNumber") {
Instant.now(Clock.systemUTC()).toString().substring(2, 16).replace("[-T:]".toRegex(), "")
repositories {
maven("https://cache-redirector.jetbrains.com/intellij-dependencies")
mavenCentral()
}
version = "$version-${channel.toUpperCase()}+$buildSuffix"
}

println("intellij-ton version: $version")

repositories {
mavenCentral()
maven("https://cache-redirector.jetbrains.com/intellij-dependencies")
}

configurations {
all {
// Allows using project dependencies instead of IDE dependencies during compilation and test running
resolutionStrategy.sortArtifacts(ResolutionStrategy.SortOrder.DEPENDENCY_FIRST)
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "17"
kotlinOptions.freeCompilerArgs += "-Xjvm-default=all"
}
}

dependencies {
implementation(kotlin("stdlib"))
implementation("com.charleskorn.kaml:kaml:0.43.0")

testImplementation(kotlin("test-junit"))
dependencies {
implementation(kotlin("stdlib-jdk8"))
}
}

sourceSets {
Expand All @@ -67,107 +50,74 @@ sourceSets {
}
}

intellij {
version.set(ideaVersion)
val pluginList = listOf(
psiViewerPlugin,
graziePlugin,
)
plugins.set(pluginList)
downloadSources.set(!isCI)
updateSinceUntilBuild.set(false)
instrumentCode.set(false)
ideaDependencyCachePath.set(dependencyCachePath)
sandboxDir.set("$buildDir/$ideaVersion-sandbox")
}

idea {
module {
generatedSourceDirs.add(file("src/gen"))
}
}

changelog {
version.set(version)
path.set("${project.projectDir}/CHANGELOG.md")
header.set(provider { "[${version.get()}]" })
itemPrefix.set("-")
keepUnreleasedSection.set(true)
unreleasedTerm.set("[Unreleased]")
groups.set(listOf("Added", "Changed", "Deprecated", "Removed", "Fixed", "Security"))
}

configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
intellij {
version.set(ideaVersion)
type.set("IU")
plugins.set(
listOf(
"JavaScript",
"com.google.ide-perf:1.3.1",
"izhangzhihao.rainbow.brackets:2023.3.2"
)
)
}

val generateFuncLexer = generateLexer("Func")
val generateFiftLexer = generateLexer("Fift")
val generateTlbLexer = generateLexer("Tlb")
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")

fun generateLexer(language: String) = task<GenerateLexerTask>("generate${language}Lexer") {
source.set("src/main/grammars/${language}Lexer.flex")
targetDir.set("src/gen/org/ton/intellij/${language.toLowerCase()}/lexer")
targetClass.set("_${language}Lexer")
purgeOldFiles.set(true)
val compileKotlin = tasks.named("compileKotlin") {
dependsOn(
generateFuncParser, generateFuncLexer,
generateTactParser, generateTactLexer,
generateFiftParser, generateFiftLexer,
generateTlbParser, generateTlbLexer,
)
}

fun generateParser(language: String) = task<GenerateParserTask>("generate${language}Parser") {
source.set("src/main/grammars/${language}Parser.bnf")
targetRoot.set("src/gen")
pathToParser.set("/org/ton/intellij/${language}/parser/${language}Parser.java")
pathToPsiRoot.set("/org/ton/intellij/${language}/psi")
purgeOldFiles.set(true)
}
val compileJava = tasks.named("compileJava")

tasks {
runIde { enabled = true }
prepareSandbox { enabled = true }
withType<KotlinCompile> {
dependsOn(
generateFuncLexer,
generateFiftLexer,
generateTlbLexer,

generateFuncParser,
generateFiftParser,
generateTlbParser
)
patchPluginXml {
sinceBuild.set("231")
}
buildSearchableOptions {
enabled = prop("enableBuildSearchableOptions").toBoolean()
}
patchPluginXml {
sinceBuild.set("212")
changeNotes.set(provider {
changelog.run {
getLatest()
}.toHTML()
})
}
withType<PublishPluginTask> {
token.set(prop("publishToken"))
channels.set(listOf(channel))
}
compileKotlin {
kotlinOptions.jvmTarget = "11"
}
test {
useJUnitPlatform()
}
task("resolveDependencies") {
doLast {
rootProject.allprojects
.map { it.configurations }
.flatMap { it.filter { c -> c.isCanBeResolved } }
.forEach { it.resolve() }
}
}
}

fun prop(name: String, default: (()->String?)? = null) = extra.properties[name] as? String
?: default?.invoke() ?: error("Property `$name` is not defined in gradle.properties")
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"))
targetRoot.set("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"))
targetDir.set("src/gen/org/ton/intellij/${language.lowercase()}/lexer")
targetClass.set("_${language}Lexer")
purgeOldFiles.set(true)
}
10 changes: 6 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
org.gradle.jvmargs=-Xmx4096m
pluginGroup=org.ton
pluginVersion=1.0.3
publishChannel=snapshot
pluginVersion=2.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=IC-2022.1
ideaVersion=232-EAP-SNAPSHOT
# https://plugins.jetbrains.com/plugin/227-psiviewer/versions
psiViewerPluginVersion=221-SNAPSHOT
psiViewerPluginVersion=232.2-SNAPSHOT
kotlin.stdlib.default.dependency=false
buildNumber=0
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-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 5 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ rootProject.name = "intellij-ton"

gradle.startParameter.showStacktrace = ShowStacktrace.ALWAYS_FULL

enableFeaturePreview("VERSION_CATALOGS")
pluginManagement {
repositories {
gradlePluginPortal()
}
}
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 2878e23

Please sign in to comment.