stevedlawrence commented on code in PR #1452:
URL: https://github.com/apache/daffodil-vscode/pull/1452#discussion_r2416866386


##########
debugger/src/main/scala-3/org.apache.daffodil.debugger.dap/Support.scala:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** This file contains support code for making a majority of Scala shareable 
between different versions of Scala and
+  * Daffodil. The main difference comes in package names, converting certain 
variables, etc. This file has all the
+  * helper code for that for Scala 3.
+  */
+
+package org.apache.daffodil.debugger.dap
+
+import java.io._
+import java.nio.file.Path
+import org.apache.daffodil.api._
+import org.apache.daffodil.io.InputSourceDataInputStream
+import scala.jdk.CollectionConverters._
+
+object Support {
+  /* Daffodil DataProcessor wrapper methods */
+  def dataProcessorWithDebugger(p: DataProcessor, debugger: Debugger, 
variables: Map[String, String]): DataProcessor =
+    p.withDebugger(debugger)
+      .withExternalVariables(variables.asJava)
+      .withValidation("daffodil")
+
+  /* Daffodil InputSourceDataInputStream wrapper methods */
+  def getInputSourceDataInputStream(data: InputStream): 
InputSourceDataInputStream = InputSourceDataInputStream(data)

Review Comment:
   The correct Daffodil 4.x way to get an InputSourceDataInputStream is:
   
   ```scala
   Daffodil.newInputSourceDataInputStream(data)
   ```
   
   Technically what you have works, but it's not part of the public API so 
could change in the future.



##########
src/daffodilDebugger/utils.ts:
##########
@@ -59,33 +106,59 @@ export async function runDebugger(
   dfdlDebugger: DFDLDebugger,
   createTerminal: boolean = false
 ): Promise<vscode.Terminal> {
-  const dfdlVersion = daffodilVersion(filePath)
+  const dfdlScalaVersions = daffodilScalaVersions(filePath)
+
+  if (
+    !dfdlDebugger.timeout.endsWith('s') &&
+    !dfdlDebugger.timeout.endsWith('m') &&
+    !dfdlDebugger.timeout.endsWith('s')
+  ) {
+    vscode.window.showErrorMessage(
+      `DFDL Debugger Timeout ${dfdlDebugger.timeout} does not end in either s 
for seconds, m for minutes or h for hours.
+      Appending s to end of timeout string.`
+    )
+    dfdlDebugger.timeout = `${dfdlDebugger.timeout}s`
+  }
+
+  // Locates the $JAVA_HOME, or if not defined, the highest version available.
+  const javaHome: IJavaHomeInfo | undefined = await getJavaHome()
+
+  const isAtLeastJdk17: boolean = parseFloat(javaHome?.version ?? '0') >= 17
+  outputChannel.appendLine(
+    `[DEBUG] Choosing java home at ${javaHome?.path}, version 
${javaHome?.version}, is at least JDK 17: ${isAtLeastJdk17}`
+  )
+
+  let dfdlVersion = dfdlDebugger.version
+  let dfdlVersionKey = await getDaffodilVersionKey(dfdlVersion)
+  let scalaVersion = dfdlScalaVersions[dfdlVersionKey]
+
+  outputChannel.appendLine(
+    `[INFO] Using Scala ${scalaVersion} + Daffodil ${dfdlVersion} debugger`
+  )
+
+  /**
+   * The Scala 3 with Daffodil >= 4.0.0 debugger can only be ran on JDK 17 or 
greater. So if the java version
+   * being used is less than 17, fallback to the Scala 2.13 and Daffodil 
3.11.0 debugger and notify the user.
+   */
+  if (dfdlVersionKey == '>=4.0.0' && !isAtLeastJdk17) {
+    dfdlVersion = '3.11.0'
+    dfdlVersionKey = '>=3.11.0,<4.0.0'
+    scalaVersion = dfdlScalaVersions[dfdlVersionKey]
+    const message =
+      'Using the Scala 2.13+Daffodil 3.11.0 debugger as the version of JDK 
being used is not >= JDK 17'

Review Comment:
   Could you just error and say dfdlVersion is not compatible with JDK version? 
Warnings are easy to miss so a user could think they are running on 4.0.0 but 
actually be running on 3.11.0 and not even realize it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to