Skip to content

Commit

Permalink
Change from Ben to put enablePreview under a flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
gchallen committed Apr 25, 2020
2 parents aa80cf5 + 4559ac5 commit e718e64
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import java.io.StringWriter
import java.util.Properties

group = "com.github.cs125-illinois"
version = "2020.4.8"
version = "2020.4.9"

plugins {
kotlin("jvm")
Expand Down
10 changes: 9 additions & 1 deletion core/src/main/kotlin/Compile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ val systemCompilerVersion = systemCompilerName.let {
data class CompilationArguments(
val wError: Boolean = DEFAULT_WERROR,
@Suppress("ConstructorParameterNaming") val Xlint: String = DEFAULT_XLINT,
val enablePreview: Boolean = DEFAULT_ENABLE_PREVIEW,
@Transient val parentFileManager: JavaFileManager? = null,
@Transient val parentClassLoader: ClassLoader? = null,
val useCache: Boolean = useCompilationCache,
Expand All @@ -46,6 +47,7 @@ data class CompilationArguments(
companion object {
const val DEFAULT_WERROR = false
const val DEFAULT_XLINT = "all"
const val DEFAULT_ENABLE_PREVIEW = true
const val PREVIEW_STARTED = 11
}
override fun equals(other: Any?): Boolean {
Expand All @@ -55,13 +57,19 @@ data class CompilationArguments(
other as CompilationArguments

if (wError != other.wError) return false
if (enablePreview != other.enablePreview) return false
if (Xlint != other.Xlint) return false
if (useCache != other.useCache) return false
if (waitForCache != other.waitForCache) return false

return true
}
override fun hashCode(): Int {
var result = wError.hashCode()
result = 31 * result + enablePreview.hashCode()
result = 31 * result + Xlint.hashCode()
result = 31 * result + useCache.hashCode()
result = 31 * result + waitForCache.hashCode()
return result
}
}
Expand Down Expand Up @@ -114,7 +122,7 @@ private fun compile(
val options = mutableSetOf<String>()
options.add("-Xlint:${compilationArguments.Xlint}")

if (systemCompilerVersion >= CompilationArguments.PREVIEW_STARTED) {
if (compilationArguments.enablePreview && systemCompilerVersion >= CompilationArguments.PREVIEW_STARTED) {
options.addAll(listOf("--enable-preview", "--release", systemCompilerVersion.toString()))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2020.4.8
version=2020.4.9
43 changes: 40 additions & 3 deletions core/src/test/kotlin/TestCompile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ public class Test {
compiledSource should haveProvidedThisManyClasses(0)
}
}

"should compile sources that use Java 14 features" {
if (systemCompilerVersion < 14) {
throw SkipTestException("Cannot run this test until Java 14")
Expand All @@ -401,14 +400,52 @@ public class Test {
public static void main() {
testInstanceOfPatternMatching();
}
}""".trim()
)
}""".trim())
).compile()

compiledSource should haveDefinedExactlyTheseClasses(setOf("Test"))
compiledSource should haveProvidedThisManyClasses(0)
}
}
"should compile sources that use Java 14 preview features" {
if (systemCompilerVersion < 14) {
throw SkipTestException("Cannot run this test until Java 14")
} else {
val tripleQuote = "\"\"\""
val compiledSource = Source(
mapOf(
"Test.java" to """
public class Test {
public static void main() {
String textBlock = $tripleQuote
Hello world!
$tripleQuote;
}
}""".trim())
).compile()

compiledSource should haveDefinedExactlyTheseClasses(setOf("Test"))
compiledSource should haveProvidedThisManyClasses(0)
}
}
"should not support Java 14 preview features when preview is disabled" {
if (systemCompilerVersion < 14) {
throw SkipTestException("Cannot run this test until Java 14")
} else {
shouldThrow<CompilationFailed> {
val tripleQuote = "\"\"\""
Source(mapOf("Test.java" to """
public class Test {
public static void main() {
String textBlock = $tripleQuote
Hello world!
$tripleQuote;
}
}""".trim())
).compile(CompilationArguments(enablePreview = false))
}
}
}
})

fun haveCompilationErrorAt(source: String = SNIPPET_SOURCE, line: Int, column: Int? = null) =
Expand Down
2 changes: 1 addition & 1 deletion react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Geoffrey Challen <geoffrey.challen@gmail.com>",
"repository": "https://github.com/cs125-illinois/jeed",
"bugs": "https://github.com/cs125-illinois/jeed/issues",
"version": "2020.4.0",
"version": "2020.4.9",
"main": "dist/index.cjs.js",
"files": [
"dist/**/*"
Expand Down
1 change: 1 addition & 0 deletions react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export type SnippetArguments = Static<typeof SnippetArguments>
export const CompilationArguments = Partial({
wError: Boolean,
XLint: String,
enablePreview: Boolean,
useCache: Boolean,
waitForCache: Boolean,
})
Expand Down
1 change: 1 addition & 0 deletions react/tests/fixtures/requests/java/snippets/complete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ arguments:
compilation:
wError: true
Xlint: "none"
enablePreview: false
useCache: false
waitForCache: true
authToken: "testing"
Expand Down
2 changes: 1 addition & 1 deletion server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import java.io.StringWriter
import java.util.Properties

group = "edu.illinois.cs.cs125"
version = "2020.4.8"
version = "2020.4.9"

plugins {
kotlin("jvm")
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2020.4.8
version=2020.4.9

0 comments on commit e718e64

Please sign in to comment.