Skip to content

Commit

Permalink
Fix parsing problem.
Browse files Browse the repository at this point in the history
  • Loading branch information
gchallen committed Oct 21, 2022
1 parent e838d4f commit 67310a3
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 7 deletions.
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.7.20" apply false
id("org.jmailen.kotlinter") version "3.12.0" apply false
id("com.github.ben-manes.versions") version "0.42.0"
id("com.github.ben-manes.versions") version "0.43.0"
id("io.gitlab.arturbosch.detekt") version "1.21.0"
id("com.google.devtools.ksp") version "1.7.20-1.0.6" apply false
id("com.google.devtools.ksp") version "1.7.20-1.0.7" apply false
}
allprojects {
repositories {
Expand All @@ -18,7 +18,7 @@ allprojects {
}
subprojects {
group = "com.github.cs125-illinois.jeed"
version = "2022.10.2"
version = "2022.10.3"
tasks.withType<Test> {
useJUnitPlatform()
enableAssertions = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2022.10.2
version=2022.10.3
2 changes: 1 addition & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies {
implementation("com.puppycrawl.tools:checkstyle:10.3.4")
implementation("com.pinterest.ktlint:ktlint-core:0.47.1")
implementation("com.pinterest.ktlint:ktlint-ruleset-standard:0.47.1")
implementation("com.github.jknack:handlebars:4.3.0")
implementation("com.github.jknack:handlebars:4.3.1")
implementation("com.squareup.moshi:moshi-kotlin:1.14.0")
implementation("org.ow2.asm:asm:9.4")
implementation("org.ow2.asm:asm-tree:9.4")
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/kotlin/Snippet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ ${" ".repeat(snippetArguments.indent * 2)}@JvmStatic fun main() {""".lines().let
parseTree.statement().mapNotNull { it.declaration()?.classDeclaration() }.forEach {
klassLines.add(it.start.line..it.stop.line)
}
parseTree.statement().mapNotNull { it.declaration()?.interfaceDeclaration() }.forEach {
klassLines.add(it.start.line..it.stop.line)
}

var sawMainLines = false
val topLevelStart = parseTree.statement()?.firstOrNull()?.start?.line ?: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2022.10.2
version=2022.10.3
17 changes: 17 additions & 0 deletions core/src/test/kotlin/TestSnippet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,23 @@ comment
it.errors.first().message shouldBe "mismatched input '/'"
}
}
"should allow Kotlin interfaces to work" {
Source.fromKotlinSnippet(
"""
fun interface Modify {
fun modify(value: Int): Int
}
val first = Modify { value -> value + 1 }
val second = Modify { value -> value - 10 }

println(first.modify(10))
println(second.modify(3))
""".trim()
).kompile().execute().also { executionResult ->
executionResult should haveCompleted()
executionResult should haveOutput("11\n-7")
}
}
})

fun haveParseErrorOnLine(line: Int) = object : Matcher<SnippetTransformationFailed> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2022.10.2
version=2022.10.3

0 comments on commit 67310a3

Please sign in to comment.