You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by sh...@apache.org on 2023/07/07 18:00:17 UTC
[daffodil-vscode] branch main updated: Refactor code a bit
This is an automated email from the ASF dual-hosted git repository.
shanedell pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil-vscode.git
The following commit(s) were added to refs/heads/main by this push:
new 515eadc Refactor code a bit
515eadc is described below
commit 515eadc1b45fd5dc0e26cd67c31c9b2f4e1aaaa2
Author: Shane Dell <sh...@gmail.com>
AuthorDate: Thu Jul 6 15:38:44 2023 -0400
Refactor code a bit
- Move debugger scala source code from server/core to debugger.
- Move typescript files related to the daffodilDebugger to src/daffodilDebugger.
- Create better way for sending over config files to getConfig method.
- Update way default values for the getConfig is set.
- Remove files that weren't needed anymore:
- src/adapter/debugAdapter
- src/tests/suite/adapter.test.ts
- Remove old debug factories that were not used.
- Move InlineDebugAdapterFactory to src/adapter/extension.ts
- Remove some unused params from functions
Closes #665
---
README.md | 2 +-
build.sbt | 10 +-
build/package/.vscodeignore | 2 +-
.../src/main/resources/bindings.xjb | 0
.../src/main/resources/logback.xml | 0
.../Compiler.scala | 0
.../org.apache.daffodil.debugger.dap/DAPodil.scala | 0
.../ErrorEvents.scala | 0
.../org.apache.daffodil.debugger.dap/Next.scala | 0
.../org.apache.daffodil.debugger.dap/Parse.scala | 0
.../org.apache.daffodil.debugger.dap/logging.scala | 0
.../main/scala/org.apache.daffodil.tdml/TDML.scala | 0
.../core => debugger}/src/templates/bash-template | 0
.../core => debugger}/src/templates/bat-template | 0
.../core => debugger}/src/test/data/emptyData.xml | 0
.../src/test/data/emptyInfoset.xml | 0
.../src/test/data/emptySchema.dfdl.xsd | 0
.../core => debugger}/src/test/data/notInfoset.xml | 0
.../org.apache.daffodil.debugger/ParseSuite.scala | 8 +-
.../scala/org.apache.daffodil.tdml/TDMLSuite.scala | 30 ++--
project/Rat.scala | 14 +-
src/adapter/activateDaffodilDebug.ts | 107 +++++++--------
src/adapter/daffodilEvent.ts | 2 +-
src/adapter/debugAdapter.ts | 75 ----------
src/adapter/extension.ts | 151 ++-------------------
.../Next.scala => src/classes/vscode-launch.ts | 40 +++---
src/{ => daffodilDebugger}/daffodil.ts | 0
.../debugger.ts} | 94 +++++++------
.../Next.scala => src/daffodilDebugger/index.ts | 24 +---
.../utils.ts} | 8 +-
src/hexView.ts | 7 +-
src/infoset.ts | 2 +-
src/language/providers/attributeCompletion.ts | 12 +-
src/language/providers/elementCompletion.ts | 23 ++--
.../providers/intellisense/attributeItems.ts | 2 +-
src/language/providers/intellisense/commonItems.ts | 2 +-
.../providers/intellisense/elementItems.ts | 2 +-
src/language/providers/utils.ts | 2 +-
src/launchWizard/launchWizard.ts | 6 +-
src/tests/suite/adapter.test.ts | 96 -------------
src/tests/suite/daffodil.test.ts | 2 +-
src/tests/suite/daffodilDebugger.test.ts | 60 ++++----
src/tests/suite/language/items.test.ts | 6 +-
src/tests/suite/utils.test.ts | 2 +-
src/utils.ts | 125 +++++++----------
45 files changed, 287 insertions(+), 629 deletions(-)
diff --git a/README.md b/README.md
index 5d75eb0..e663207 100644
--- a/README.md
+++ b/README.md
@@ -73,7 +73,7 @@ Run full package
* Packages Extension
* Creates Files
```
- server/core/target/universal/daffodil-debugger-*.zip
+ debugger/target/universal/daffodil-debugger-*.zip
apache-daffodil-vscode-*.vsix
```
diff --git a/build.sbt b/build.sbt
index 81aa9dc..e334acb 100644
--- a/build.sbt
+++ b/build.sbt
@@ -77,11 +77,11 @@ lazy val `daffodil-debugger` = project
.in(file("."))
.settings(commonSettings, ratSettings)
.settings(publish / skip := true)
- .dependsOn(core)
- .aggregate(core)
+ .dependsOn(debugger)
+ .aggregate(debugger)
-lazy val core = project
- .in(file("server/core"))
+lazy val debugger = project
+ .in(file("debugger"))
.enablePlugins(BuildInfoPlugin, JavaAppPackaging, UniversalPlugin, ClasspathJarPlugin, SbtXjcPlugin)
.settings(commonSettings)
.settings(xjcSettings)
@@ -117,7 +117,7 @@ lazy val xjcSettings =
xjcCommandLine += "-nv",
xjcCommandLine += "-p",
xjcCommandLine += "org.apache.daffodil.tdml",
- xjcBindings += "server/core/src/main/resources/bindings.xjb",
+ xjcBindings += "debugger/src/main/resources/bindings.xjb",
xjcLibs := Seq(
"org.glassfish.jaxb" % "jaxb-xjc" % "2.2.11",
"com.sun.xml.bind" % "jaxb-impl" % "2.2.11",
diff --git a/build/package/.vscodeignore b/build/package/.vscodeignore
index 44fcf63..2ead549 100644
--- a/build/package/.vscodeignore
+++ b/build/package/.vscodeignore
@@ -21,7 +21,7 @@
!NOTICE
!package.json
!README.md
-!server/core/target/universal/daffodil-debugger-*.zip
+!debugger/target/universal/daffodil-debugger-*.zip
!language/*
!language/syntaxes/*
!src/launchWizard/launchWizard.js
diff --git a/server/core/src/main/resources/bindings.xjb b/debugger/src/main/resources/bindings.xjb
similarity index 100%
rename from server/core/src/main/resources/bindings.xjb
rename to debugger/src/main/resources/bindings.xjb
diff --git a/server/core/src/main/resources/logback.xml b/debugger/src/main/resources/logback.xml
similarity index 100%
rename from server/core/src/main/resources/logback.xml
rename to debugger/src/main/resources/logback.xml
diff --git a/server/core/src/main/scala/org.apache.daffodil.debugger.dap/Compiler.scala b/debugger/src/main/scala/org.apache.daffodil.debugger.dap/Compiler.scala
similarity index 100%
rename from server/core/src/main/scala/org.apache.daffodil.debugger.dap/Compiler.scala
rename to debugger/src/main/scala/org.apache.daffodil.debugger.dap/Compiler.scala
diff --git a/server/core/src/main/scala/org.apache.daffodil.debugger.dap/DAPodil.scala b/debugger/src/main/scala/org.apache.daffodil.debugger.dap/DAPodil.scala
similarity index 100%
rename from server/core/src/main/scala/org.apache.daffodil.debugger.dap/DAPodil.scala
rename to debugger/src/main/scala/org.apache.daffodil.debugger.dap/DAPodil.scala
diff --git a/server/core/src/main/scala/org.apache.daffodil.debugger.dap/ErrorEvents.scala b/debugger/src/main/scala/org.apache.daffodil.debugger.dap/ErrorEvents.scala
similarity index 100%
rename from server/core/src/main/scala/org.apache.daffodil.debugger.dap/ErrorEvents.scala
rename to debugger/src/main/scala/org.apache.daffodil.debugger.dap/ErrorEvents.scala
diff --git a/server/core/src/main/scala/org.apache.daffodil.debugger.dap/Next.scala b/debugger/src/main/scala/org.apache.daffodil.debugger.dap/Next.scala
similarity index 100%
copy from server/core/src/main/scala/org.apache.daffodil.debugger.dap/Next.scala
copy to debugger/src/main/scala/org.apache.daffodil.debugger.dap/Next.scala
diff --git a/server/core/src/main/scala/org.apache.daffodil.debugger.dap/Parse.scala b/debugger/src/main/scala/org.apache.daffodil.debugger.dap/Parse.scala
similarity index 100%
rename from server/core/src/main/scala/org.apache.daffodil.debugger.dap/Parse.scala
rename to debugger/src/main/scala/org.apache.daffodil.debugger.dap/Parse.scala
diff --git a/server/core/src/main/scala/org.apache.daffodil.debugger.dap/logging.scala b/debugger/src/main/scala/org.apache.daffodil.debugger.dap/logging.scala
similarity index 100%
rename from server/core/src/main/scala/org.apache.daffodil.debugger.dap/logging.scala
rename to debugger/src/main/scala/org.apache.daffodil.debugger.dap/logging.scala
diff --git a/server/core/src/main/scala/org.apache.daffodil.tdml/TDML.scala b/debugger/src/main/scala/org.apache.daffodil.tdml/TDML.scala
similarity index 100%
rename from server/core/src/main/scala/org.apache.daffodil.tdml/TDML.scala
rename to debugger/src/main/scala/org.apache.daffodil.tdml/TDML.scala
diff --git a/server/core/src/templates/bash-template b/debugger/src/templates/bash-template
similarity index 100%
rename from server/core/src/templates/bash-template
rename to debugger/src/templates/bash-template
diff --git a/server/core/src/templates/bat-template b/debugger/src/templates/bat-template
similarity index 100%
rename from server/core/src/templates/bat-template
rename to debugger/src/templates/bat-template
diff --git a/server/core/src/test/data/emptyData.xml b/debugger/src/test/data/emptyData.xml
similarity index 100%
rename from server/core/src/test/data/emptyData.xml
rename to debugger/src/test/data/emptyData.xml
diff --git a/server/core/src/test/data/emptyInfoset.xml b/debugger/src/test/data/emptyInfoset.xml
similarity index 100%
rename from server/core/src/test/data/emptyInfoset.xml
rename to debugger/src/test/data/emptyInfoset.xml
diff --git a/server/core/src/test/data/emptySchema.dfdl.xsd b/debugger/src/test/data/emptySchema.dfdl.xsd
similarity index 100%
rename from server/core/src/test/data/emptySchema.dfdl.xsd
rename to debugger/src/test/data/emptySchema.dfdl.xsd
diff --git a/server/core/src/test/data/notInfoset.xml b/debugger/src/test/data/notInfoset.xml
similarity index 100%
rename from server/core/src/test/data/notInfoset.xml
rename to debugger/src/test/data/notInfoset.xml
diff --git a/server/core/src/test/scala/org.apache.daffodil.debugger/ParseSuite.scala b/debugger/src/test/scala/org.apache.daffodil.debugger/ParseSuite.scala
similarity index 94%
rename from server/core/src/test/scala/org.apache.daffodil.debugger/ParseSuite.scala
rename to debugger/src/test/scala/org.apache.daffodil.debugger/ParseSuite.scala
index ea67d0c..ce86c3a 100644
--- a/server/core/src/test/scala/org.apache.daffodil.debugger/ParseSuite.scala
+++ b/debugger/src/test/scala/org.apache.daffodil.debugger/ParseSuite.scala
@@ -24,8 +24,8 @@ class ParseSuite extends FunSuite {
val name = "Default Config"
val request = "launch"
val launchType = "dfdl"
- var program = Paths.get("./server/core/src/test/data/emptySchema.dfdl.xsd").toAbsolutePath().toString()
- var data = Paths.get("./server/core/src/test/data/emptyData.xml").toAbsolutePath().toString()
+ var program = Paths.get("./debugger/src/test/data/emptySchema.dfdl.xsd").toAbsolutePath().toString()
+ var data = Paths.get("./debugger/src/test/data/emptyData.xml").toAbsolutePath().toString()
val debugServer = 4711
val infosetFormat = "xml"
var infosetOutputType = "none"
@@ -46,8 +46,8 @@ class ParseSuite extends FunSuite {
var testTDMLObject = new JsonObject()
override def beforeEach(context: BeforeEach): Unit = {
- program = Paths.get("./server/core/src/test/data/emptySchema.dfdl.xsd").toAbsolutePath().toString()
- data = Paths.get("./server/core/src/test/data/emptyData.xml").toAbsolutePath().toString()
+ program = Paths.get("./debugger/src/test/data/emptySchema.dfdl.xsd").toAbsolutePath().toString()
+ data = Paths.get("./debugger/src/test/data/emptyData.xml").toAbsolutePath().toString()
infosetOutputType = "none"
infosetOutputPath = "testPath/infoset.xml"
tdmlAction = ""
diff --git a/server/core/src/test/scala/org.apache.daffodil.tdml/TDMLSuite.scala b/debugger/src/test/scala/org.apache.daffodil.tdml/TDMLSuite.scala
similarity index 82%
rename from server/core/src/test/scala/org.apache.daffodil.tdml/TDMLSuite.scala
rename to debugger/src/test/scala/org.apache.daffodil.tdml/TDMLSuite.scala
index fa2fdef..9676b42 100644
--- a/server/core/src/test/scala/org.apache.daffodil.tdml/TDMLSuite.scala
+++ b/debugger/src/test/scala/org.apache.daffodil.tdml/TDMLSuite.scala
@@ -27,12 +27,12 @@ import scala.xml.XML
import java.nio.charset.StandardCharsets
class TDMLSuite extends munit.FunSuite {
- val basePath = Paths.get("./server/core/").toAbsolutePath()
- val basePathStr = "server/core/"
- val infosetPath = Paths.get("./server/core/src/test/data/emptyInfoset.xml").toAbsolutePath()
- val schemaPath = Paths.get("./server/core/src/test/data/emptySchema.xml").toAbsolutePath()
- val dataPath = Paths.get("./server/core/src/test/data/emptyData.xml").toAbsolutePath()
- val notInfosetPath = Paths.get("./server/core/src/test/data/notInfoset.xml").toAbsolutePath()
+ val basePath = Paths.get("./debugger/").toAbsolutePath()
+ val basePathStr = "debugger/"
+ val infosetPath = Paths.get("./debugger/src/test/data/emptyInfoset.xml").toAbsolutePath()
+ val schemaPath = Paths.get("./debugger/src/test/data/emptySchema.xml").toAbsolutePath()
+ val dataPath = Paths.get("./debugger/src/test/data/emptyData.xml").toAbsolutePath()
+ val notInfosetPath = Paths.get("./debugger/src/test/data/notInfoset.xml").toAbsolutePath()
val tdmlName = "TestTDMLName"
val tdmlDescription = "Test TDML Description"
val tdmlPath = Paths.get("./testTDML.tdml").toAbsolutePath()
@@ -46,31 +46,31 @@ class TDMLSuite extends munit.FunSuite {
)
val tdmlSingleTestCase = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns1:testSuite xmlns:ns1="http://www.ibm.com/xmlns/dfdl/testData" xmlns:ns2="urn:ogf:dfdl:2013:imp:daffodil.apache.org:2018:ext" xmlns:ns3="http://www.ogf.org/dfdl/dfdl-1.0/" xmlns:ns4="http://www.ogf.org/dfdl/dfdl-1.0/extensions" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns6="urn:ogf:dfdl:2013:imp:daffodil.apache.org:2018:int" suiteName="TestTDMLName" defaultRoundTrip="onePass">
- <ns1:parserTestCase name="TestTDMLName" root="file" model="server/core/src/test/data/emptySchema.xml" roundTrip="onePass" description="Test TDML Description">
+ <ns1:parserTestCase name="TestTDMLName" root="file" model="debugger/src/test/data/emptySchema.xml" roundTrip="onePass" description="Test TDML Description">
<ns1:document>
- <ns1:documentPart type="file">server/core/src/test/data/emptyData.xml</ns1:documentPart>
+ <ns1:documentPart type="file">debugger/src/test/data/emptyData.xml</ns1:documentPart>
</ns1:document>
<ns1:infoset>
- <ns1:dfdlInfoset type="file">server/core/src/test/data/emptyInfoset.xml</ns1:dfdlInfoset>
+ <ns1:dfdlInfoset type="file">debugger/src/test/data/emptyInfoset.xml</ns1:dfdlInfoset>
</ns1:infoset>
</ns1:parserTestCase>
</ns1:testSuite>"""
val tdmlDoubleTestCase = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns1:testSuite xmlns:ns1="http://www.ibm.com/xmlns/dfdl/testData" xmlns:ns2="urn:ogf:dfdl:2013:imp:daffodil.apache.org:2018:ext" xmlns:ns3="http://www.ogf.org/dfdl/dfdl-1.0/" xmlns:ns4="http://www.ogf.org/dfdl/dfdl-1.0/extensions" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns6="urn:ogf:dfdl:2013:imp:daffodil.apache.org:2018:int" suiteName="TestTDMLName" defaultRoundTrip="onePass">
- <ns1:parserTestCase name="TestTDMLName" root="file" model="server/core/src/test/data/emptySchema.xml" roundTrip="onePass" description="Test TDML Description">
+ <ns1:parserTestCase name="TestTDMLName" root="file" model="debugger/src/test/data/emptySchema.xml" roundTrip="onePass" description="Test TDML Description">
<ns1:document>
- <ns1:documentPart type="file">server/core/src/test/data/emptyData.xml</ns1:documentPart>
+ <ns1:documentPart type="file">debugger/src/test/data/emptyData.xml</ns1:documentPart>
</ns1:document>
<ns1:infoset>
- <ns1:dfdlInfoset type="file">server/core/src/test/data/emptyInfoset.xml</ns1:dfdlInfoset>
+ <ns1:dfdlInfoset type="file">debugger/src/test/data/emptyInfoset.xml</ns1:dfdlInfoset>
</ns1:infoset>
</ns1:parserTestCase>
- <ns1:parserTestCase name="TestTDMLName" root="file" model="server/core/src/test/data/emptySchema.xml" roundTrip="onePass" description="Test TDML Description">
+ <ns1:parserTestCase name="TestTDMLName" root="file" model="debugger/src/test/data/emptySchema.xml" roundTrip="onePass" description="Test TDML Description">
<ns1:document>
- <ns1:documentPart type="file">server/core/src/test/data/emptyData.xml</ns1:documentPart>
+ <ns1:documentPart type="file">debugger/src/test/data/emptyData.xml</ns1:documentPart>
</ns1:document>
<ns1:infoset>
- <ns1:dfdlInfoset type="file">server/core/src/test/data/emptyInfoset.xml</ns1:dfdlInfoset>
+ <ns1:dfdlInfoset type="file">debugger/src/test/data/emptyInfoset.xml</ns1:dfdlInfoset>
</ns1:infoset>
</ns1:parserTestCase>
</ns1:testSuite>"""
diff --git a/project/Rat.scala b/project/Rat.scala
index 4a25f90..241916f 100644
--- a/project/Rat.scala
+++ b/project/Rat.scala
@@ -22,6 +22,12 @@ object Rat {
lazy val excludes = Seq(
// git files
file(".git"),
+ // metals generated directory
+ file(".metal"),
+ // vscode-test generated directory
+ file(".vscode-test"),
+ // generate version file from sbt
+ file("src/version.ts"),
/** Can't add license headers in JSON files. Adding a license attribute breaks things in some of these files as
* well.
*/
@@ -43,10 +49,10 @@ object Rat {
file("build/package/NOLICENSE"),
file("build/package/NONOTICE"),
file("src/tests/data/test.txt"),
- file("server/core/src/test/data/emptyData.xml"),
- file("server/core/src/test/data/emptyInfoset.xml"),
- file("server/core/src/test/data/notInfoset.xml"),
- file("server/core/src/test/data/emptySchema.dfdl.xsd")
+ file("debugger/src/test/data/emptyData.xml"),
+ file("debugger/src/test/data/emptyInfoset.xml"),
+ file("debugger/src/test/data/notInfoset.xml"),
+ file("debugger/src/test/data/emptySchema.dfdl.xsd")
)
lazy val MIT_LICENSE_NAME = "MIT License"
diff --git a/src/adapter/activateDaffodilDebug.ts b/src/adapter/activateDaffodilDebug.ts
index 8eab68c..900a552 100644
--- a/src/adapter/activateDaffodilDebug.ts
+++ b/src/adapter/activateDaffodilDebug.ts
@@ -15,16 +15,15 @@ import {
WorkspaceFolder,
} from 'vscode'
import { getDataFileFromFolder, getDebugger } from '../daffodilDebugger'
-import * as hexView from '../hexView'
import * as infoset from '../infoset'
import * as dfdlLang from '../language/dfdl'
import * as launchWizard from '../launchWizard/launchWizard'
import * as dataEditClient from '../dataEdit/client'
import { getConfig, getCurrentConfig, setCurrentConfig } from '../utils'
-import { DaffodilDebugSession } from './daffodilDebug'
import { FileAccessor } from './daffodilRuntime'
import { TDMLConfig } from '../classes/tdmlConfig'
import { handleDebugEvent } from './daffodilEvent'
+import { InlineDebugAdapterFactory } from './extension'
/** Method to file path for program and data
* Details:
@@ -97,17 +96,20 @@ function createDebugRunFileConfigs(
vscode.debug.startDebugging(
undefined,
- getConfig(
- 'Run File',
- 'launch',
- 'dfdl',
- targetResource.fsPath,
- false,
- false,
- 'xml',
- { type: 'file', path: '${workspaceFolder}/' + infosetFile },
- tdmlConfig
- ),
+ getConfig({
+ name: 'Run File',
+ request: 'launch',
+ type: 'dfdl',
+ program: targetResource.fsPath,
+ data: false,
+ debugServer: false,
+ infosetFormat: 'xml',
+ infosetOutput: {
+ type: 'file',
+ path: '${workspaceFolder}/' + infosetFile,
+ },
+ tdmlConfig: tdmlConfig,
+ }),
{ noDebug: noDebug }
)
}
@@ -278,16 +280,19 @@ export function activateDaffodilDebug(
): ProviderResult<DebugConfiguration[]> {
if (!vscode.workspace.workspaceFolders) {
return [
- getConfig(
- 'Daffodil Launch',
- 'launch',
- 'dfdl',
- '${file}',
- false,
- false,
- 'xml',
- { type: 'file', path: '${file}-infoset.xml' }
- ),
+ getConfig({
+ name: 'Daffodil Launch',
+ request: 'launch',
+ type: 'dfdl',
+ program: '${file}',
+ data: false,
+ debugServer: false,
+ infosetFormat: 'xml',
+ infosetOutput: {
+ type: 'file',
+ path: '${file}-infoset.xml',
+ },
+ }),
]
}
@@ -299,16 +304,19 @@ export function activateDaffodilDebug(
}-infoset.xml`
return [
- getConfig(
- 'Daffodil Launch',
- 'launch',
- 'dfdl',
- '${file}',
- false,
- false,
- 'xml',
- { type: 'file', path: '${workspaceFolder}/' + infosetFile }
- ),
+ getConfig({
+ name: 'Daffodil Launch',
+ request: 'launch',
+ type: 'dfdl',
+ program: '${file}',
+ data: false,
+ debugServer: false,
+ infosetFormat: 'xml',
+ infosetOutput: {
+ type: 'file',
+ path: '${workspaceFolder}/' + infosetFile,
+ },
+ }),
]
},
},
@@ -409,7 +417,7 @@ class DaffodilConfigurationProvider
): ProviderResult<DebugConfiguration> {
// if launch.json is missing or empty
if (!config.type && !config.request && !config.name) {
- config = getConfig('Launch', 'launch', 'dfdl')
+ config = getConfig({ name: 'Launch', request: 'launch', type: 'dfdl' })
}
if (!config.debugServer) {
@@ -445,16 +453,14 @@ class DaffodilConfigurationProvider
) {
return getDataFileFromFolder(dataFolder).then((dataFile) => {
config.data = dataFile
- setCurrentConfig(config)
- return getDebugger(this.context, config).then((result) => {
- return config
+ return getDebugger(this.context, config).then((_) => {
+ return setCurrentConfig(config)
})
})
}
- return getDebugger(this.context, config).then((result) => {
- setCurrentConfig(config)
- return config
+ return getDebugger(this.context, config).then((_) => {
+ return setCurrentConfig(config)
})
}
}
@@ -478,24 +484,3 @@ export const workspaceFileAccessor: FileAccessor = {
}
},
}
-
-// TODO: Move to extension.ts
-class InlineDebugAdapterFactory
- implements vscode.DebugAdapterDescriptorFactory
-{
- context: vscode.ExtensionContext
- hexViewer: hexView.DebuggerHexView
-
- constructor(context: vscode.ExtensionContext) {
- this.context = context
- this.hexViewer = new hexView.DebuggerHexView(context)
- }
-
- createDebugAdapterDescriptor(
- _session: vscode.DebugSession
- ): ProviderResult<vscode.DebugAdapterDescriptor> {
- return new vscode.DebugAdapterInlineImplementation(
- new DaffodilDebugSession(workspaceFileAccessor)
- )
- }
-}
diff --git a/src/adapter/daffodilEvent.ts b/src/adapter/daffodilEvent.ts
index 45ddeaa..5d3d743 100644
--- a/src/adapter/daffodilEvent.ts
+++ b/src/adapter/daffodilEvent.ts
@@ -18,7 +18,7 @@
import * as vscode from 'vscode'
import * as fs from 'fs'
-import * as daf from '../daffodil'
+import * as daf from '../daffodilDebugger'
import { ensureFile, tmpFile } from '../utils'
export function handleDebugEvent(e: vscode.DebugSessionCustomEvent) {
diff --git a/src/adapter/debugAdapter.ts b/src/adapter/debugAdapter.ts
deleted file mode 100644
index 85ce9b8..0000000
--- a/src/adapter/debugAdapter.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-// NOTE: Might be able to removed. Only used for a test
-
-/*---------------------------------------------------------------------------------------------
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for license information.
- *--------------------------------------------------------------------------------------------*/
-
-import { DaffodilDebugSession } from './daffodilDebug'
-
-import { readFile } from 'fs'
-import * as Net from 'net'
-import { FileAccessor } from './daffodilRuntime'
-
-/*
- * debugAdapter.js is the entrypoint of the debug adapter when it runs as a separate process.
- */
-
-/*
- * Since here we run the debug adapter as a separate ("external") process, it has no access to VS Code API.
- * So we can only use node.js API for accessing files.
- */
-const fsAccessor: FileAccessor = {
- async readFile(path: string): Promise<string> {
- return new Promise((resolve, reject) => {
- readFile(path, (err, data) => {
- if (err) {
- reject(err)
- } else {
- resolve(data.toString())
- }
- })
- })
- },
-}
-
-/*
- * When the debug adapter is run as an external process,
- * normally the helper function DebugSession.run(...) takes care of everything:
- *
- * DaffodilDebugSession.run(DaffodilDebugSession);
- *
- * but here the helper is not flexible enough to deal with a debug session constructors with a parameter.
- * So for now we copied and modified the helper:
- */
-
-// first parse command line arguments to see whether the debug adapter should run as a server
-let port = 0
-const args = process.argv.slice(2)
-args.forEach(function (val, index, array) {
- const portMatch = /^--server=(\d{4,5})$/.exec(val)
- if (portMatch) {
- port = parseInt(portMatch[1], 10)
- }
-})
-
-if (port > 0) {
- // start a server that creates a new session for every connection request
- console.error(`waiting for debug protocol on port ${port}`)
- Net.createServer((socket) => {
- console.error('>> accepted connection from client')
- socket.on('end', () => {
- console.error('>> client connection closed\n')
- })
- const session = new DaffodilDebugSession(fsAccessor)
- session.setRunAsServer(true)
- session.start(socket, socket)
- }).listen(port)
-} else {
- // start a single session that communicates via stdin/stdout
- const session = new DaffodilDebugSession(fsAccessor)
- process.on('SIGTERM', () => {
- session.shutdown()
- })
- session.start(process.stdin, process.stdout)
-}
diff --git a/src/adapter/extension.ts b/src/adapter/extension.ts
index bedd81d..8526a2c 100644
--- a/src/adapter/extension.ts
+++ b/src/adapter/extension.ts
@@ -5,14 +5,9 @@
'use strict'
-import * as Net from 'net'
import * as vscode from 'vscode'
-import * as htmlView from '../hexView'
+import * as hexView from '../hexView'
import * as position from '../position'
-import { randomBytes } from 'crypto'
-import { tmpdir } from 'os'
-import { join } from 'path'
-import { platform } from 'process'
import { ProviderResult } from 'vscode'
import { DaffodilDebugSession } from './daffodilDebug'
import {
@@ -24,41 +19,14 @@ import {
* The compile time flag 'runMode' controls how the debug adapter is run.
* Please note: the test suite only supports 'external' mode.
*/
-const runMode: 'external' | 'server' | 'namedPipeServer' | 'inline' = 'inline'
export async function activate(context: vscode.ExtensionContext) {
// activate position
position.activate(context)
// debug adapters can be run in different ways by using a vscode.DebugAdapterDescriptorFactory:
- switch (runMode) {
- case 'server':
- // run the debug adapter as a server inside the extension and communicate via a socket
- activateDaffodilDebug(
- context,
- new DaffodilDebugAdapterServerDescriptorFactory(context)
- )
- break
-
- case 'namedPipeServer':
- // run the debug adapter as a server inside the extension and communicate via a named pipe (Windows) or UNIX domain socket (non-Windows)
- activateDaffodilDebug(
- context,
- new DaffodilDebugAdapterNamedPipeServerDescriptorFactory(context)
- )
- break
-
- case 'inline':
- // run the debug adapter inside the extension and directly talk to it
- activateDaffodilDebug(context)
- break
-
- case 'external':
- default:
- // run the debug adapter as a separate process
- activateDaffodilDebug(context, new DebugAdapterExecutableFactory(context))
- break
- }
+ // however we currently only support our inline debugger
+ activateDaffodilDebug(context)
}
export function deactivate() {
@@ -66,123 +34,22 @@ export function deactivate() {
position.deactivate()
}
-// NOTE: Can this be removed? Its never used we only ever use inline and provide no way to change it
-class DebugAdapterExecutableFactory
+export class InlineDebugAdapterFactory
implements vscode.DebugAdapterDescriptorFactory
{
context: vscode.ExtensionContext
- htmlViewer: htmlView.DebuggerHexView
+ hexViewer: hexView.DebuggerHexView
constructor(context: vscode.ExtensionContext) {
this.context = context
- this.htmlViewer = new htmlView.DebuggerHexView(context)
+ this.hexViewer = new hexView.DebuggerHexView(context)
}
- // The following use of a DebugAdapter factory shows how to control what debug adapter executable is used.
- // Since the code implements the default behavior, it is absolutely not neccessary and we show it here only for educational purpose.
-
createDebugAdapterDescriptor(
- _session: vscode.DebugSession,
- executable: vscode.DebugAdapterExecutable | undefined
+ _session: vscode.DebugSession
): ProviderResult<vscode.DebugAdapterDescriptor> {
- // param "executable" contains the executable optionally specified in the package.json (if any)
-
- // use the executable specified in the package.json if it exists or determine it based on some other information (e.g. the session)
- if (!executable) {
- const command = 'absolute path to my DA executable'
- const args = ['some args', 'another arg']
- const options = {
- cwd: 'working directory for executable',
- env: { envVariable: 'some value' },
- }
- executable = new vscode.DebugAdapterExecutable(command, args, options)
- }
-
- // make VS Code launch the DA executable
- return executable
- }
-}
-
-// NOTE: Can this be removed? Its never used we only ever use inline and provide no way to change it
-class DaffodilDebugAdapterServerDescriptorFactory
- implements vscode.DebugAdapterDescriptorFactory
-{
- private server?: Net.Server
- context: vscode.ExtensionContext
- htmlViewer: htmlView.DebuggerHexView
-
- constructor(context: vscode.ExtensionContext) {
- this.context = context
- this.htmlViewer = new htmlView.DebuggerHexView(context)
- }
-
- createDebugAdapterDescriptor(
- session: vscode.DebugSession,
- executable: vscode.DebugAdapterExecutable | undefined
- ): vscode.ProviderResult<vscode.DebugAdapterDescriptor> {
- if (!this.server) {
- // start listening on a random port
- this.server = Net.createServer((socket) => {
- const session = new DaffodilDebugSession(workspaceFileAccessor)
- session.setRunAsServer(true)
- session.start(socket as NodeJS.ReadableStream, socket)
- }).listen(0)
- }
-
- // make VS Code connect to debug server
- return new vscode.DebugAdapterServer(
- (this.server.address() as Net.AddressInfo).port
+ return new vscode.DebugAdapterInlineImplementation(
+ new DaffodilDebugSession(workspaceFileAccessor)
)
}
-
- dispose() {
- if (this.server) {
- this.server.close()
- }
- }
-}
-
-// NOTE: Can this be removed? Its never used we only ever use inline and provide no way to change it
-class DaffodilDebugAdapterNamedPipeServerDescriptorFactory
- implements vscode.DebugAdapterDescriptorFactory
-{
- private server?: Net.Server
- context: vscode.ExtensionContext
- htmlViewer: htmlView.DebuggerHexView
-
- constructor(context: vscode.ExtensionContext) {
- this.context = context
- this.htmlViewer = new htmlView.DebuggerHexView(context)
- }
-
- createDebugAdapterDescriptor(
- session: vscode.DebugSession,
- executable: vscode.DebugAdapterExecutable | undefined
- ): vscode.ProviderResult<vscode.DebugAdapterDescriptor> {
- if (!this.server) {
- // start listening on a random named pipe path
- const pipeName = randomBytes(10).toString('utf8')
- const pipePath =
- platform === 'win32'
- ? join('\\\\.\\pipe\\', pipeName)
- : join(tmpdir(), pipeName)
-
- this.server = Net.createServer((socket) => {
- const session = new DaffodilDebugSession(workspaceFileAccessor)
- session.setRunAsServer(true)
- session.start(<NodeJS.ReadableStream>socket, socket)
- }).listen(pipePath)
- }
-
- // make VS Code connect to debug server
- // TODO: enable named pipe support as soon as VS Code 1.49 is out
- //return new vscode.DebugAdapterNamedPipeServer(this.server.address() as string);
- return undefined
- }
-
- dispose() {
- if (this.server) {
- this.server.close()
- }
- }
}
diff --git a/server/core/src/main/scala/org.apache.daffodil.debugger.dap/Next.scala b/src/classes/vscode-launch.ts
similarity index 55%
copy from server/core/src/main/scala/org.apache.daffodil.debugger.dap/Next.scala
copy to src/classes/vscode-launch.ts
index bc0ef24..e2e277f 100644
--- a/server/core/src/main/scala/org.apache.daffodil.debugger.dap/Next.scala
+++ b/src/classes/vscode-launch.ts
@@ -15,24 +15,30 @@
* limitations under the License.
*/
-package org.apache.daffodil.debugger.dap
+import { TDMLConfig } from './tdmlConfig'
+import { DataEditorConfig } from './dataEditor'
-import cats.effect._
-
-/** Produce the next value in a series, like for data identifiers. */
-trait Next[A] {
- def next(): IO[A]
-
- def map[B](f: A => B): Next[B] =
- () => next().map(f)
+export interface InfosetOutput {
+ type: string
+ file: string
}
-object Next {
- // TODO: optional starting value
- def int: IO[Next[Int]] =
- for {
- ids <- Ref[IO].of(0)
- } yield new Next[Int] {
- def next: IO[Int] = ids.getAndUpdate(_ + 1)
- }
+export interface VSCodeLaunchConfigArgs {
+ name: string
+ request: string
+ type: string
+ program: string | boolean
+ data: string | boolean
+ debugServer: number | boolean
+ infosetFormat: string | null
+ infosetOutput: InfosetOutput | null
+ tdmlConfig: TDMLConfig | null
+ dataEditorConfig: DataEditorConfig | null
+ stopOnEntry: boolean
+ useExistingServer: boolean
+ trace: boolean
+ openHexView: boolean
+ openInfosetView: boolean
+ openInfosetDiffView: boolean
+ daffodilDebugClasspath: string
}
diff --git a/src/daffodil.ts b/src/daffodilDebugger/daffodil.ts
similarity index 100%
rename from src/daffodil.ts
rename to src/daffodilDebugger/daffodil.ts
diff --git a/src/daffodilDebugger.ts b/src/daffodilDebugger/debugger.ts
similarity index 82%
rename from src/daffodilDebugger.ts
rename to src/daffodilDebugger/debugger.ts
index 99a76a8..7116cb3 100644
--- a/src/daffodilDebugger.ts
+++ b/src/daffodilDebugger/debugger.ts
@@ -19,7 +19,7 @@ import * as vscode from 'vscode'
import * as fs from 'fs'
import XDGAppPaths from 'xdg-app-paths'
import * as path from 'path'
-import { regexp, unzipFile } from './utils'
+import { regexp, unzipFile } from '../utils'
import {
buildDebugger,
daffodilArtifact,
@@ -27,7 +27,7 @@ import {
runDebugger,
stopDebugger,
stopDebugging,
-} from './daffodilDebuggerUtils'
+} from './utils'
const xdgAppPaths = XDGAppPaths({ name: 'daffodil-dap' })
@@ -155,6 +155,52 @@ async function getTDMLConfig(
return true
}
+async function getDaffodilDebugClasspath(
+ config: vscode.DebugConfiguration,
+ workspaceFolder: string
+): Promise<string> {
+ let daffodilDebugClasspath = ''
+
+ //check if each classpath still exists
+ if (config.daffodilDebugClasspath) {
+ config.daffodilDebugClasspath.split(':').forEach((entry: string) => {
+ let fullpathEntry = entry.replaceAll(
+ '${workspaceFolder}',
+ workspaceFolder
+ )
+
+ if (!fs.existsSync(fullpathEntry)) {
+ throw new Error(`File or directory: ${fullpathEntry} doesn't exist`)
+ }
+ })
+
+ daffodilDebugClasspath = config.daffodilDebugClasspath.includes(
+ '${workspaceFolder}'
+ )
+ ? config.daffodilDebugClasspath.replace(
+ regexp['workspace'],
+ workspaceFolder
+ )
+ : config.daffodilDebugClasspath
+ }
+
+ // make sure infoset output directory is present
+ if (config.infosetOutput.type == 'file') {
+ let dir = path.dirname(
+ config.infosetOutput.path.includes('${workspaceFolder}')
+ ? config.infosetOutput.path.replace(
+ '${workspaceFolder}',
+ workspaceFolder
+ )
+ : config.infosetOutput.path
+ )
+
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true })
+ }
+
+ return daffodilDebugClasspath
+}
+
// Function for getting the daffodil-debugger
export async function getDebugger(
context: vscode.ExtensionContext,
@@ -179,7 +225,7 @@ export async function getDebugger(
// Get daffodil-debugger zip from extension files
const filePath = path
.join(
- context.asAbsolutePath('./server/core/target/universal'),
+ context.asAbsolutePath('./debugger/target/universal'),
artifact.archive
)
.toString()
@@ -202,44 +248,10 @@ export async function getDebugger(
: vscode.Uri.parse('').fsPath
// Get daffodilDebugger class paths to be added to the debugger
- let daffodilDebugClasspath = ''
-
- //check if each classpath still exists
- if (config.daffodilDebugClasspath) {
- config.daffodilDebugClasspath.split(':').forEach((entry: string) => {
- let fullpathEntry = entry.replaceAll(
- '${workspaceFolder}',
- workspaceFolder
- )
-
- if (!fs.existsSync(fullpathEntry)) {
- throw new Error(`File or directory: ${fullpathEntry} doesn't exist`)
- }
- })
-
- daffodilDebugClasspath = config.daffodilDebugClasspath.includes(
- '${workspaceFolder}'
- )
- ? config.daffodilDebugClasspath.replace(
- regexp['workspace'],
- workspaceFolder
- )
- : config.daffodilDebugClasspath
- }
-
- // make sure infoset output directory is present
- if (config.infosetOutput.type == 'file') {
- let dir = path.dirname(
- config.infosetOutput.path.includes('${workspaceFolder}')
- ? config.infosetOutput.path.replace(
- '${workspaceFolder}',
- vscode.workspace.workspaceFolders[0].uri.fsPath
- )
- : config.infosetOutput.path
- )
-
- if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true })
- }
+ const daffodilDebugClasspath = await getDaffodilDebugClasspath(
+ config,
+ workspaceFolder
+ )
// Start debugger in terminal based on scriptName
diff --git a/server/core/src/main/scala/org.apache.daffodil.debugger.dap/Next.scala b/src/daffodilDebugger/index.ts
similarity index 65%
rename from server/core/src/main/scala/org.apache.daffodil.debugger.dap/Next.scala
rename to src/daffodilDebugger/index.ts
index bc0ef24..36ed541 100644
--- a/server/core/src/main/scala/org.apache.daffodil.debugger.dap/Next.scala
+++ b/src/daffodilDebugger/index.ts
@@ -15,24 +15,6 @@
* limitations under the License.
*/
-package org.apache.daffodil.debugger.dap
-
-import cats.effect._
-
-/** Produce the next value in a series, like for data identifiers. */
-trait Next[A] {
- def next(): IO[A]
-
- def map[B](f: A => B): Next[B] =
- () => next().map(f)
-}
-
-object Next {
- // TODO: optional starting value
- def int: IO[Next[Int]] =
- for {
- ids <- Ref[IO].of(0)
- } yield new Next[Int] {
- def next: IO[Int] = ids.getAndUpdate(_ + 1)
- }
-}
+export * from './daffodil'
+export * from './debugger'
+export * from './utils'
diff --git a/src/daffodilDebuggerUtils.ts b/src/daffodilDebugger/utils.ts
similarity index 94%
rename from src/daffodilDebuggerUtils.ts
rename to src/daffodilDebugger/utils.ts
index 9e7bf68..7053b0c 100644
--- a/src/daffodilDebuggerUtils.ts
+++ b/src/daffodilDebugger/utils.ts
@@ -19,11 +19,11 @@ import * as vscode from 'vscode'
import * as fs from 'fs'
import * as path from 'path'
import * as child_process from 'child_process'
-import { LIB_VERSION } from './version'
-import { deactivate } from './adapter/extension'
+import { LIB_VERSION } from '../version'
+import { deactivate } from '../adapter/extension'
import { getDaffodilVersion } from './daffodil'
-import { Artifact } from './classes/artifact'
-import { osCheck, runScript } from './utils'
+import { Artifact } from '../classes/artifact'
+import { osCheck, runScript } from '../utils'
export const daffodilVersion = (filePath: string): string => {
return getDaffodilVersion(filePath)
diff --git a/src/hexView.ts b/src/hexView.ts
index f58f3d0..bd8661d 100644
--- a/src/hexView.ts
+++ b/src/hexView.ts
@@ -16,11 +16,10 @@
*/
import * as vscode from 'vscode'
-import * as daf from './daffodil'
+import * as daf from './daffodilDebugger'
import * as fs from 'fs'
import * as hexy from 'hexy'
import XDGAppPaths from 'xdg-app-paths'
-import { ConfigEvent, DaffodilData } from './daffodil'
const xdgAppPaths = XDGAppPaths({ name: 'daffodil-dap' })
import { onDebugStartDisplay } from './utils'
@@ -145,7 +144,7 @@ export class DebuggerHexView {
}
// Method for extracting the data file used
- setDataFile(cfg: ConfigEvent) {
+ setDataFile(cfg: daf.ConfigEvent) {
this.dataFile = cfg.launchArgs.dataPath
}
@@ -230,7 +229,7 @@ export class DebuggerHexView {
}
// Method to display the hex of the current data position sent from the debugger
- async onDisplayHex(session: vscode.DebugSession, body: DaffodilData) {
+ async onDisplayHex(session: vscode.DebugSession, body: daf.DaffodilData) {
if (!vscode.workspace.workspaceFolders) {
return
}
diff --git a/src/infoset.ts b/src/infoset.ts
index d1d338b..629cc6f 100644
--- a/src/infoset.ts
+++ b/src/infoset.ts
@@ -16,7 +16,7 @@
*/
import * as vscode from 'vscode'
-import * as daf from './daffodil'
+import * as daf from './daffodilDebugger'
import * as fs from 'fs'
import { Uri } from 'vscode'
import {
diff --git a/src/language/providers/attributeCompletion.ts b/src/language/providers/attributeCompletion.ts
index d3ff53b..d38dac6 100644
--- a/src/language/providers/attributeCompletion.ts
+++ b/src/language/providers/attributeCompletion.ts
@@ -47,14 +47,12 @@ function getCompletionItems(
nsPrefix
)
- attributeCompletion(additionalItems, nsPrefix, dfdlPrefix).items.forEach(
- (e) => {
- if (itemsToUse.includes(e.item)) {
- const completionItem = createCompletionItem(e, preVal, nsPrefix)
- compItems.push(completionItem)
- }
+ attributeCompletion(dfdlPrefix).items.forEach((e) => {
+ if (itemsToUse.includes(e.item)) {
+ const completionItem = createCompletionItem(e, preVal, nsPrefix)
+ compItems.push(completionItem)
}
- )
+ })
return compItems
}
diff --git a/src/language/providers/elementCompletion.ts b/src/language/providers/elementCompletion.ts
index f9f836a..3192b0e 100644
--- a/src/language/providers/elementCompletion.ts
+++ b/src/language/providers/elementCompletion.ts
@@ -106,23 +106,20 @@ function getElementCompletionItems(
definedVariables,
nsPrefix
)
- let dfdlFormatString: string = ''
- elementCompletion(definedVariables, dfdlFormatString, nsPrefix).items.forEach(
- (e) => {
- for (let i = 0; i < itemsToUse.length; ++i) {
- if (e.item.includes(itemsToUse[i])) {
- if (
- (e.item.includes('dfdl:') && itemsToUse[i].includes('dfdl:')) ||
- !e.item.includes('dfdl')
- ) {
- const completionItem = createCompletionItem(e, preVal, nsPrefix)
- compItems.push(completionItem)
- }
+ elementCompletion(definedVariables, nsPrefix).items.forEach((e) => {
+ for (let i = 0; i < itemsToUse.length; ++i) {
+ if (e.item.includes(itemsToUse[i])) {
+ if (
+ (e.item.includes('dfdl:') && itemsToUse[i].includes('dfdl:')) ||
+ !e.item.includes('dfdl')
+ ) {
+ const completionItem = createCompletionItem(e, preVal, nsPrefix)
+ compItems.push(completionItem)
}
}
}
- )
+ })
return compItems
}
diff --git a/src/language/providers/intellisense/attributeItems.ts b/src/language/providers/intellisense/attributeItems.ts
index 27ee6d1..e17d47b 100644
--- a/src/language/providers/intellisense/attributeItems.ts
+++ b/src/language/providers/intellisense/attributeItems.ts
@@ -16,7 +16,7 @@
*/
// prettier-ignore
-export const attributeCompletion = (additionalItems, nsPrefix: string, dfdlPrefix: string) => {
+export const attributeCompletion = (dfdlPrefix: string) => {
return {
items: [
{
diff --git a/src/language/providers/intellisense/commonItems.ts b/src/language/providers/intellisense/commonItems.ts
index b3f50d4..c748412 100644
--- a/src/language/providers/intellisense/commonItems.ts
+++ b/src/language/providers/intellisense/commonItems.ts
@@ -16,7 +16,7 @@
*/
// prettier-ignore
-export const commonCompletion = (additionalItems, nsPrefix: string) => {
+export const commonCompletion = (additionalItems) => {
return {
items: [
{
diff --git a/src/language/providers/intellisense/elementItems.ts b/src/language/providers/intellisense/elementItems.ts
index ca82eb6..db6e52a 100644
--- a/src/language/providers/intellisense/elementItems.ts
+++ b/src/language/providers/intellisense/elementItems.ts
@@ -16,7 +16,7 @@
*/
// prettier-ignore
-export const elementCompletion = (definedVariables, dfdlFormatString, nsPrefix) => {
+export const elementCompletion = (definedVariables, nsPrefix) => {
return {
items: [
{
diff --git a/src/language/providers/utils.ts b/src/language/providers/utils.ts
index b50d4a4..09f71e6 100644
--- a/src/language/providers/utils.ts
+++ b/src/language/providers/utils.ts
@@ -614,7 +614,7 @@ export function getCommonItems(
) {
let compItems: vscode.CompletionItem[] = []
- commonCompletion(additionalItems, nsPrefix).items.forEach((e) => {
+ commonCompletion(additionalItems).items.forEach((e) => {
if (itemsToUse.includes(e.item)) {
const completionItem = createCompletionItem(e, preVal, nsPrefix)
compItems.push(completionItem)
diff --git a/src/launchWizard/launchWizard.ts b/src/launchWizard/launchWizard.ts
index 73b896a..7772f8a 100644
--- a/src/launchWizard/launchWizard.ts
+++ b/src/launchWizard/launchWizard.ts
@@ -19,7 +19,11 @@ import * as fs from 'fs'
import * as vscode from 'vscode'
import { getConfig, osCheck } from '../utils'
-const defaultConf = getConfig('Wizard Config', 'launch', 'dfdl')
+const defaultConf = getConfig({
+ name: 'Wizard Config',
+ request: 'launch',
+ type: 'dfdl',
+})
// Function that will activate/open the launch config wizard
export async function activate(ctx: vscode.ExtensionContext) {
diff --git a/src/tests/suite/adapter.test.ts b/src/tests/suite/adapter.test.ts
deleted file mode 100644
index e13786e..0000000
--- a/src/tests/suite/adapter.test.ts
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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.
- */
-
-import * as assert from 'assert'
-import * as path from 'path'
-import { DebugClient } from '@vscode/debugadapter-testsupport'
-import { TEST_SCHEMA, PROJECT_ROOT } from './common'
-import { setup } from 'mocha'
-
-suite('Daffodil Debug Adapter', () => {
- const DEBUG_ADAPTER = path.join(PROJECT_ROOT, 'out/adapter/debugAdapter.js')
-
- let client: DebugClient
-
- setup(() => {
- client = new DebugClient('node', DEBUG_ADAPTER, 'dfdl')
- return client.start()
- })
-
- teardown(() => client.stop())
-
- suite('basic', () => {
- test('unknown request should produce error', (done) => {
- client
- .send('illegal_request')
- .then(() => {
- done(new Error('does not report error on unknown request'))
- })
- .catch(() => {
- done()
- })
- })
- })
-
- suite('initialize', () => {
- test('should return supported features', () => {
- return client.initializeRequest().then((response) => {
- response.body = response.body || {}
- assert.strictEqual(response.body.supportsConfigurationDoneRequest, true)
- })
- })
-
- test("should produce error for invalid 'pathFormat'", (done) => {
- client
- .initializeRequest({
- adapterID: 'dfdl',
- linesStartAt1: true,
- columnsStartAt1: true,
- pathFormat: 'url',
- })
- .then((response) => {
- done(
- new Error("does not report error on invalid 'pathFormat' attribute")
- )
- })
- .catch((err) => {
- // error expected
- done()
- })
- })
- })
-
- suite('launch', () => {
- test('should run program to the end', () => {
- return Promise.all([
- client.configurationSequence(),
- client.launch({ program: TEST_SCHEMA }),
- client.waitForEvent('terminated'),
- ])
- })
-
- test('should stop on entry', () => {
- const ENTRY_LINE = 1
-
- return Promise.all([
- client.configurationSequence(),
- client.launch({ program: TEST_SCHEMA, stopOnEntry: true }),
- client.assertStoppedLocation('entry', { line: ENTRY_LINE }),
- ])
- })
- })
-})
diff --git a/src/tests/suite/daffodil.test.ts b/src/tests/suite/daffodil.test.ts
index 9287228..dd36f84 100644
--- a/src/tests/suite/daffodil.test.ts
+++ b/src/tests/suite/daffodil.test.ts
@@ -17,7 +17,7 @@
import * as vscode from 'vscode'
import * as assert from 'assert'
-import * as daffodil from '../../daffodil'
+import * as daffodil from '../../daffodilDebugger'
import * as fs from 'fs'
import * as path from 'path'
import { Artifact } from '../../classes/artifact'
diff --git a/src/tests/suite/daffodilDebugger.test.ts b/src/tests/suite/daffodilDebugger.test.ts
index b8c731a..f697ace 100644
--- a/src/tests/suite/daffodilDebugger.test.ts
+++ b/src/tests/suite/daffodilDebugger.test.ts
@@ -26,7 +26,7 @@ import {
daffodilVersion,
runDebugger,
stopDebugging,
-} from '../../daffodilDebuggerUtils'
+} from '../../daffodilDebugger'
import { before, after } from 'mocha'
// Not using the debug adapter like adapter.test.ts as it will not fully connect the debugger
@@ -36,7 +36,7 @@ suite('Daffodil Debugger', () => {
const SCALA_PATH = path.join(
PROJECT_ROOT,
- 'server/core/target/universal',
+ 'debugger/target/universal',
artifact.archive
)
const EXTRACTED_FOLDER = path.join(PROJECT_ROOT, artifact.name)
@@ -84,22 +84,24 @@ suite('Daffodil Debugger', () => {
test('should output xml infoset', async () => {
await vscode.debug.startDebugging(
undefined,
- getConfig(
- 'Run',
- 'launch',
- 'dfdl',
- TEST_SCHEMA,
- DATA,
- 4711,
- 'xml',
- {
+ getConfig({
+ name: 'Run',
+ request: 'launch',
+ type: 'dfdl',
+ program: TEST_SCHEMA,
+ data: DATA,
+ debugServer: 4711,
+ infosetFormat: 'xml',
+ infosetOutput: {
type: 'file',
path: XML_INFOSET_PATH,
},
- tdmlConf,
- dataEditorConfig
- ),
- { noDebug: true }
+ tdmlConfig: tdmlConf,
+ dataEditorConfig: dataEditorConfig,
+ }),
+ {
+ noDebug: true,
+ }
)
assert.strictEqual(fs.existsSync(XML_INFOSET_PATH), true)
@@ -108,22 +110,24 @@ suite('Daffodil Debugger', () => {
test('should output json infoset', async () => {
await vscode.debug.startDebugging(
undefined,
- getConfig(
- 'Run',
- 'launch',
- 'dfdl',
- TEST_SCHEMA,
- DATA,
- 4712,
- 'json',
- {
+ getConfig({
+ name: 'Run',
+ request: 'launch',
+ type: 'dfdl',
+ program: TEST_SCHEMA,
+ data: DATA,
+ debugServer: 4712,
+ infosetFormat: 'json',
+ infosetOutput: {
type: 'file',
path: JSON_INFOSET_PATH,
},
- tdmlConf,
- dataEditorConfig
- ),
- { noDebug: true }
+ tdmlConfig: tdmlConf,
+ dataEditorConfig: dataEditorConfig,
+ }),
+ {
+ noDebug: true,
+ }
)
assert.strictEqual(fs.existsSync(JSON_INFOSET_PATH), true)
diff --git a/src/tests/suite/language/items.test.ts b/src/tests/suite/language/items.test.ts
index 02c2926..3f85722 100644
--- a/src/tests/suite/language/items.test.ts
+++ b/src/tests/suite/language/items.test.ts
@@ -132,18 +132,18 @@ suite('Items Test Suite', () => {
test('all commonItems available', async () => {
let itemNames: string[] = []
- commonCompletion('', 'xs:').items.forEach((r) => itemNames.push(r.item))
+ commonCompletion('').items.forEach((r) => itemNames.push(r.item))
assert.strictEqual(itemNames.includes('type'), true)
})
test('all elementItems available', async () => {
- elementCompletion('', '', '').items.forEach((item) => {
+ elementCompletion('', '').items.forEach((item) => {
assert.strictEqual(expectedElementItems.includes(item.item), true)
})
})
test('all attributeItems available', async () => {
- attributeCompletion('', '', 'dfdl:').items.forEach((item) => {
+ attributeCompletion('dfdl:').items.forEach((item) => {
assert.strictEqual(expectedAttributeItems.includes(item.item), true)
})
})
diff --git a/src/tests/suite/utils.test.ts b/src/tests/suite/utils.test.ts
index c51aafb..8b7df36 100644
--- a/src/tests/suite/utils.test.ts
+++ b/src/tests/suite/utils.test.ts
@@ -50,7 +50,7 @@ suite('Utils Test Suite', () => {
}
test('Default config', async () => {
- var config = utils.getConfig(name, request, type)
+ var config = utils.getConfig({ name: name, request: request, type: type })
assert.strictEqual(JSON.stringify(defaultConfig), JSON.stringify(config))
})
diff --git a/src/utils.ts b/src/utils.ts
index c300ca8..5a78967 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -21,8 +21,7 @@ import * as unzip from 'unzip-stream'
import * as os from 'os'
import * as child_process from 'child_process'
import path from 'path'
-import { TDMLConfig } from './classes/tdmlConfig'
-import { DataEditorConfig } from './classes/dataEditor'
+import { VSCodeLaunchConfigArgs } from './classes/vscode-launch'
const defaultConf = vscode.workspace.getConfiguration()
let currentConfig: vscode.DebugConfiguration
@@ -37,14 +36,16 @@ export const regexp = {
}
// Function to retrieve to the current debug config
-export function getCurrentConfig() {
+export function getCurrentConfig(): vscode.DebugConfiguration {
return currentConfig
}
// Function to set the current debug config
-export function setCurrentConfig(config) {
+export function setCurrentConfig(
+ config: vscode.DebugConfiguration
+): vscode.DebugConfiguration {
currentConfig = config
- return currentConfig
+ return config
}
// Function to run vscode command and catch the error to not cause other issues
@@ -80,26 +81,10 @@ export async function onDebugStartDisplay(viewsToCheck: string[]) {
})
}
-// Method for retrieving the config when launch.json does not exist
-export function getConfig(
- name,
- request,
- type,
- program: string = '',
- data: string | boolean = false,
- debugServer: number | boolean = false,
- infosetFormat: string | null = null,
- infosetOutput: object | null = null,
- tdmlConfig: TDMLConfig | null = null,
- dataEditorConfig: DataEditorConfig | null = null,
- stopOnEntry = false,
- useExistingServer = false,
- trace = false,
- openHexView = false,
- openInfosetView = false,
- openInfosetDiffView = false,
- daffodilDebugClasspath: string = ''
-) {
+export function getConfig(jsonArgs: object): vscode.DebugConfiguration {
+ const launchConfigArgs: VSCodeLaunchConfigArgs = JSON.parse(
+ JSON.stringify(jsonArgs)
+ )
// Keep 'none' here as a default so that we don't always add the tdmlConfig block
let tdmlAction = defaultConf.get('tdmlAction', 'none')
let tdmlPropsNeeded = false
@@ -111,61 +96,45 @@ export function getConfig(
tdmlPropsNeeded = true
}
- let jsonConfig = {
- name: name,
- request: request,
- type: type,
- program: program
- ? program
- : defaultConf.get('program', '${command:AskForProgramName}'),
- data: data ? data : defaultConf.get('data', '${command:AskForDataName}'),
- debugServer: debugServer
- ? debugServer
- : defaultConf.get('debugServer', 4711),
- infosetFormat: infosetFormat ? infosetFormat : 'xml',
- infosetOutput: infosetOutput
- ? infosetOutput
- : {
- type: defaultConf.get('infosetOutputType', 'none'),
- path: defaultConf.get(
- 'infosetOutputFilePath',
- '${workspaceFolder}/target/infoset.xml'
- ),
- },
- stopOnEntry: stopOnEntry
- ? stopOnEntry
- : defaultConf.get('stopOnEntry', true),
- useExistingServer: useExistingServer
- ? useExistingServer
- : defaultConf.get('useExistingServer', false),
- trace: trace ? trace : defaultConf.get('trace', true),
- openHexView: openHexView
- ? openHexView
- : defaultConf.get('openHexView', false),
- openInfosetView: openInfosetView
- ? openInfosetView
- : defaultConf.get('openInfosetView', false),
- openInfosetDiffView: openInfosetDiffView
- ? openInfosetDiffView
- : defaultConf.get('openInfosetDiffView', false),
- daffodilDebugClasspath: daffodilDebugClasspath
- ? daffodilDebugClasspath
- : defaultConf.get('daffodilDebugClasspath', ''),
- dataEditorConfig: dataEditorConfig
- ? dataEditorConfig
- : {
- port: defaultConf.get('dataEditorPort', 9000),
- logFile: defaultConf.get(
- 'dataEditorLogFile',
- '${workspaceFolder}/dataEditor-${omegaEditPort}.log'
- ),
- logLevel: defaultConf.get('dataEditorLogLevel', 'info'),
- },
+ const defaultValues = {
+ program: defaultConf.get('program', '${command:AskForProgramName}'),
+ data: defaultConf.get('data', '${command:AskForDataName}'),
+ debugServer: defaultConf.get('debugServer', 4711),
+ infosetFormat: 'xml',
+ infosetOutput: {
+ type: defaultConf.get('infosetOutputType', 'none'),
+ path: defaultConf.get(
+ 'infosetOutputFilePath',
+ '${workspaceFolder}/target/infoset.xml'
+ ),
+ },
+ stopOnEntry: defaultConf.get('stopOnEntry', true),
+ useExistingServer: defaultConf.get('useExistingServer', false),
+ trace: defaultConf.get('trace', true),
+ openHexView: defaultConf.get('openHexView', false),
+ openInfosetView: defaultConf.get('openInfosetView', false),
+ openInfosetDiffView: defaultConf.get('openInfosetDiffView', false),
+ daffodilDebugClasspath: defaultConf.get('daffodilDebugClasspath', ''),
+ dataEditorConfig: {
+ port: defaultConf.get('dataEditorPort', 9000),
+ logFile: defaultConf.get(
+ 'dataEditorLogFile',
+ '${workspaceFolder}/dataEditor-${omegaEditPort}.log'
+ ),
+ logLevel: defaultConf.get('dataEditorLogLevel', 'info'),
+ },
}
+ Object.entries(defaultValues).map(
+ ([key, defaultValue]) =>
+ (launchConfigArgs[key] = launchConfigArgs[key]
+ ? launchConfigArgs[key]
+ : defaultValue)
+ )
+
if (tdmlPropsNeeded) {
- jsonConfig['tdmlConfig'] = tdmlConfig
- ? tdmlConfig
+ launchConfigArgs.tdmlConfig = launchConfigArgs.tdmlConfig
+ ? launchConfigArgs.tdmlConfig
: {
action: tdmlAction,
name: defaultConf.get('tdmlName', '${command:AskforTDMLName}'),
@@ -177,7 +146,7 @@ export function getConfig(
}
}
- return jsonConfig
+ return JSON.parse(JSON.stringify(launchConfigArgs))
}
export async function unzipFile(zipFilePath: string, extractPath: string) {