Skip to content

Commit

Permalink
Use Java target to 11 (#653)
Browse files Browse the repository at this point in the history
* Use Java target to 11

* Fix `childrenOfType` is inlining code built with Java 17

* Delete setting up Kotlin Jvm Toolchain

* Upgrade Java version to 23 on GitHub Actions workflows
  • Loading branch information
JavierSegoviaCordoba authored Dec 24, 2024
1 parent 70e4a53 commit 52dd732
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
- name: Set up JDK 23
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
java-version: 23

- name: Setup gradle
uses: gradle/actions/setup-gradle@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/SNAPSHOT.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
- name: Set up JDK 23
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
java-version: 23

- name: Setup gradle
uses: gradle/actions/setup-gradle@v4
Expand Down
13 changes: 12 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
alias(libs.plugins.kotlinJvm) apply false
alias(libs.plugins.spotless)
Expand Down Expand Up @@ -35,7 +37,16 @@ allprojects {
subprojects {
apply(plugin: "org.jetbrains.kotlin.jvm")

kotlin.jvmToolchain(17)
tasks.withType(JavaCompile).configureEach {
sourceCompatibility = '11'
targetCompatibility = '11'
}

tasks.withType(KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = '11'
}
}

tasks.withType(Test).configureEach {
testLogging {
Expand Down
2 changes: 2 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
alias(libs.plugins.kotlinJvm)
alias(libs.plugins.grammarKitComposer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package com.alecstrong.sql.psi.sample.headless

import com.alecstrong.sql.psi.core.psi.SqlLiteralExpr
import com.alecstrong.sql.psi.sample.core.psi.CustomExpr
import com.intellij.psi.util.childrenOfType
import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil
import java.io.File
import kotlin.reflect.KClass
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.fail
Expand All @@ -21,7 +23,7 @@ class SampleHeadlessParserTest {
stmt.createTableStmt != null -> {
val createTableStmt = stmt.createTableStmt!!
for (columnDef in createTableStmt.columnDefList) {
val literalExpr = columnDef.childrenOfType<SqlLiteralExpr>().single()
val literalExpr = columnDef.childrenOfType(SqlLiteralExpr::class).single()
assertEquals(42, literalExpr.literalValue.numericLiteral!!.text.toInt())
}
}
Expand All @@ -32,7 +34,7 @@ class SampleHeadlessParserTest {
for (expr in exprs) {
if (expr is CustomExpr) {
val fooRule = expr.fooRule
val literalExpr = fooRule.childrenOfType<SqlLiteralExpr>().single().childrenOfType<SqlLiteralExpr>().single()
val literalExpr = fooRule.childrenOfType(SqlLiteralExpr::class).single().childrenOfType(SqlLiteralExpr::class).single()
assertEquals(13, literalExpr.literalValue.numericLiteral!!.text.toInt())
}
}
Expand All @@ -42,3 +44,5 @@ class SampleHeadlessParserTest {
}
}
}

fun <T : PsiElement> PsiElement.childrenOfType(kClass: KClass<T>): List<T> = PsiTreeUtil.getChildrenOfTypeAsList(this, kClass.java)

0 comments on commit 52dd732

Please sign in to comment.