Copilot commented on code in PR #1671:
URL: https://github.com/apache/daffodil-vscode/pull/1671#discussion_r3137914539
##########
src/adapter/activateDaffodilDebug.ts:
##########
@@ -16,6 +16,8 @@ import * as dataEditClient from '../dataEditor'
import * as tdmlEditor from '../tdmlEditor'
import * as rootCompletion from '../rootCompletion'
import { tmpdir } from 'os'
+import JSZip from 'jszip'
+import { rm } from 'node:fs/promises'
Review Comment:
`jszip` is imported here, but it is not listed in `package.json`
dependencies/devDependencies (and doesn’t appear elsewhere in the repo). This
will break installs/builds unless the dependency is added (and lockfile
updated).
##########
src/adapter/activateDaffodilDebug.ts:
##########
@@ -39,10 +42,32 @@ import xmlFormat from 'xml-formatter'
import { CommandsProvider } from '../views/commands'
import * as daffodilDebugErrors from './daffodilDebugErrors'
import { TDMLProvider } from '../tdmlEditor/TDMLProvider'
+import { getTestCaseDisplayData } from '../tdmlEditor/utilities/tdmlXmlUtils'
export const outputChannel: vscode.OutputChannel =
vscode.window.createOutputChannel('Daffodil')
+async function createDirectory(directoryPath: string): Promise<void> {
+ try {
+ await fs.mkdirSync(directoryPath, { recursive: true })
+ console.log(`Directory created successfully at ${directoryPath}`)
+ } catch (error) {
+ console.error(`Error creating directory:`, error)
Review Comment:
`createDirectory` is marked `async` but calls `fs.mkdirSync()` (sync API)
and then `await`s it. This is misleading and still blocks the extension host
thread. Consider switching to `await fs.promises.mkdir(..., {recursive:true})`
and letting errors propagate (or return a success/failure) instead of just
logging.
```suggestion
await fs.promises.mkdir(directoryPath, { recursive: true })
console.log(`Directory created successfully at ${directoryPath}`)
} catch (error) {
console.error(`Error creating directory:`, error)
throw error
```
##########
src/adapter/activateDaffodilDebug.ts:
##########
@@ -323,12 +351,166 @@ export function activateDaffodilDebug(
console.log(reason)
})
}
+ }
+ ),
+ vscode.commands.registerCommand(
+ 'extension.dfdl-debug.zipTDML',
+ async (resource: vscode.Uri) => {
+ if (!fs.existsSync(getTmpTDMLFilePath())) {
+ vscode.window.showErrorMessage(
+ `TDML ERROR: Test suite not found. Ensure that the TDML action is
set to "generate" for your DFDL debugging launch configuration before copying.`
+ )
+ console.error(
+ `TDML ERROR: Test suite not found. ${TMP_TDML_FILENAME} was not
found in ${tmpdir()} for Copy TDML operation.`
+ )
+ return
+ }
+ let targetResource: vscode.Uri | undefined = resource
+
+ if (!targetResource) {
+ if (vscode.window.activeTextEditor) {
+ targetResource = vscode.window.activeTextEditor.document.uri
+ } else {
+ const tdmlUri = TDMLProvider.getDocumentUri()
+ if (tdmlUri) {
+ targetResource = tdmlUri
+ }
+ }
+ }
+
+ const resolvedResource = targetResource
+
+ // create temp zip folder
+ let tmpDir = path.dirname(getTmpTDMLFilePath())
+ createDirectory(tmpDir + '_zipdir')
+ let zipDir = path.join(tmpDir, '_zipdir')
+
+ // copy TDML file to zip folder
+ await copyFileAsync(
+ resolvedResource.fsPath,
+ path.join(zipDir, path.basename(resolvedResource.fsPath))
+ )
Review Comment:
`resolvedResource` can be `undefined` if the command is invoked without a
resource and there is no active editor/TDMLProvider URI. It’s dereferenced
immediately (`resolvedResource.fsPath`) which will throw. Add an explicit guard
with a user-facing error message and `return` when no TDML file is resolvable.
##########
src/adapter/activateDaffodilDebug.ts:
##########
@@ -323,12 +351,166 @@ export function activateDaffodilDebug(
console.log(reason)
})
}
+ }
+ ),
+ vscode.commands.registerCommand(
+ 'extension.dfdl-debug.zipTDML',
+ async (resource: vscode.Uri) => {
+ if (!fs.existsSync(getTmpTDMLFilePath())) {
+ vscode.window.showErrorMessage(
+ `TDML ERROR: Test suite not found. Ensure that the TDML action is
set to "generate" for your DFDL debugging launch configuration before copying.`
+ )
+ console.error(
+ `TDML ERROR: Test suite not found. ${TMP_TDML_FILENAME} was not
found in ${tmpdir()} for Copy TDML operation.`
+ )
+ return
+ }
+ let targetResource: vscode.Uri | undefined = resource
+
+ if (!targetResource) {
+ if (vscode.window.activeTextEditor) {
+ targetResource = vscode.window.activeTextEditor.document.uri
+ } else {
+ const tdmlUri = TDMLProvider.getDocumentUri()
+ if (tdmlUri) {
+ targetResource = tdmlUri
+ }
+ }
+ }
+
+ const resolvedResource = targetResource
+
+ // create temp zip folder
+ let tmpDir = path.dirname(getTmpTDMLFilePath())
+ createDirectory(tmpDir + '_zipdir')
+ let zipDir = path.join(tmpDir, '_zipdir')
Review Comment:
The temp dir creation uses two different paths: `createDirectory(tmpDir +
'_zipdir')` creates e.g. `/tmp_zipdir`, but `zipDir` is `/tmp/_zipdir`. That
mismatch means `zipDir` may not exist when copying/writing files. Use a single
`zipDir` value (e.g. `const zipDir = tmpDir + '_zipdir'` or
`path.join(tmpDir,'_zipdir')`) and create that exact directory.
```suggestion
const zipDir = path.join(tmpDir, '_zipdir')
await createDirectory(zipDir)
```
##########
doc/Wiki.md:
##########
@@ -468,7 +467,16 @@ The original default test case from the temp directory
will be appended to the s
</details>
-Once the Daffodil Parse has finished, an infoset will be created, and a test
case will be added to the existing TDML file. To create an archive for a TDML
file with multiple test cases, the same guidelines for creating an archive from
a TDML file created from a 'Generate TDML' operation should be followed. All
DFDL schema files, input data files, the TDML file, and, optionally, the
infosets should be added to the archive. Additionally, any directory structure
should be preserved in the archive to allow for the relative paths in the TDML
file to be resolved.
+### Zipping the TDML file & associated files
+
+To generate a compressed archive of the TDML test cases, you simply need to
have the TDML file opened (and in the active tab) in either the TDML editor or
a text editor. Then you open the command pallet and find the "Zip TDML file"
command and execute it.
+The system will automatically collect the appropriate files: first the TDML
file itself, then the files specified by the test case(s) in the file. Each
test case will have it's associated schema, data, and infoset files placed into
a folder with the name of the test case. The TDML file contents will be
automatically edited to show the updated location of these files.
Review Comment:
Spelling/grammar: “command pallet” should be “command palette”, and “it’s
associated schema” should be “its associated schema” (possessive).
```suggestion
To generate a compressed archive of the TDML test cases, you simply need to
have the TDML file opened (and in the active tab) in either the TDML editor or
a text editor. Then you open the command palette and find the "Zip TDML file"
command and execute it.
The system will automatically collect the appropriate files: first the TDML
file itself, then the files specified by the test case(s) in the file. Each
test case will have its associated schema, data, and infoset files placed into
a folder with the name of the test case. The TDML file contents will be
automatically edited to show the updated location of these files.
```
##########
src/adapter/activateDaffodilDebug.ts:
##########
@@ -323,12 +351,166 @@ export function activateDaffodilDebug(
console.log(reason)
})
}
+ }
+ ),
+ vscode.commands.registerCommand(
+ 'extension.dfdl-debug.zipTDML',
+ async (resource: vscode.Uri) => {
+ if (!fs.existsSync(getTmpTDMLFilePath())) {
+ vscode.window.showErrorMessage(
+ `TDML ERROR: Test suite not found. Ensure that the TDML action is
set to "generate" for your DFDL debugging launch configuration before copying.`
+ )
+ console.error(
+ `TDML ERROR: Test suite not found. ${TMP_TDML_FILENAME} was not
found in ${tmpdir()} for Copy TDML operation.`
+ )
+ return
+ }
+ let targetResource: vscode.Uri | undefined = resource
+
+ if (!targetResource) {
+ if (vscode.window.activeTextEditor) {
+ targetResource = vscode.window.activeTextEditor.document.uri
+ } else {
+ const tdmlUri = TDMLProvider.getDocumentUri()
+ if (tdmlUri) {
+ targetResource = tdmlUri
+ }
+ }
+ }
+
+ const resolvedResource = targetResource
+
+ // create temp zip folder
+ let tmpDir = path.dirname(getTmpTDMLFilePath())
+ createDirectory(tmpDir + '_zipdir')
+ let zipDir = path.join(tmpDir, '_zipdir')
+
+ // copy TDML file to zip folder
+ await copyFileAsync(
+ resolvedResource.fsPath,
+ path.join(zipDir, path.basename(resolvedResource.fsPath))
+ )
+
+ // read TDML file to see what files are required...
+ await readTDMLFileContents(
+ path.join(zipDir, path.basename(resolvedResource.fsPath))
+ ).then(async (xmlBuffer) => {
+ await getTestCaseDisplayData(xmlBuffer).then((testSuiteData) => {
+ testSuiteData.testCases.forEach((testCase) => {
+ // create subdir for testcase
+ let testCaseDir = path.join(zipDir, testCase.testCaseName)
+ createDirectory(testCaseDir)
+ // copy schema file
+ let xsdFile = testCase.testCaseModel
+ let xsdFileSrc = path.join(
+ path.dirname(resolvedResource.fsPath),
+ xsdFile
+ )
+ let xsdFileDest = path.join(testCaseDir, path.basename(xsdFile))
+ try {
+ fs.copyFileSync(xsdFileSrc, xsdFileDest)
+ console.log(`'${xsdFileSrc}' was copied to '${xsdFileDest}'`)
+ } catch (err) {
+ console.error('Error copying file:', err)
+ }
+
+ // edit path in copied TDML file
+ let updatedBuffer = xmlBuffer.replace(
+ `model="${xsdFile}"`,
+ `model="${path.join(testCase.testCaseName,
path.basename(xsdFile))}"`
+ )
+ xmlBuffer = updatedBuffer
+
+ // copy data file
+ testCase.dataDocuments.forEach((dataDocuments) => {
+ let dataFile = path.basename(dataDocuments.trim())
+ let dataFileSrc = path.join(
+ path.dirname(resolvedResource.fsPath),
+ dataDocuments.trim()
+ )
+ let dataFileDest = path.join(
+ testCaseDir,
+ path.basename(dataFile)
+ )
+ try {
+ fs.copyFileSync(dataFileSrc, dataFileDest)
+ console.log(
+ `'${dataFileSrc}' was copied to '${dataFileDest}'`
+ )
+ } catch (err) {
+ console.error(`Error copying file:'${dataFileSrc}'`, err)
+ }
+
+ // edit path in copied TDML file
+ let updatedBuffer = xmlBuffer.replace(
+ dataDocuments.trim(),
+ path.join(testCase.testCaseName, dataFile)
+ )
Review Comment:
Using `path.join(...)` to write paths into TDML XML will emit backslashes on
Windows. Those become literal characters in the TDML and can break portability
(and may not be valid in XML/TDML contexts). Prefer writing POSIX-style
relative paths (e.g., `path.posix.join(...)` or manual `'/'` joining)
regardless of OS.
##########
src/adapter/activateDaffodilDebug.ts:
##########
@@ -323,12 +351,166 @@ export function activateDaffodilDebug(
console.log(reason)
})
}
+ }
+ ),
+ vscode.commands.registerCommand(
+ 'extension.dfdl-debug.zipTDML',
+ async (resource: vscode.Uri) => {
+ if (!fs.existsSync(getTmpTDMLFilePath())) {
+ vscode.window.showErrorMessage(
+ `TDML ERROR: Test suite not found. Ensure that the TDML action is
set to "generate" for your DFDL debugging launch configuration before copying.`
+ )
+ console.error(
+ `TDML ERROR: Test suite not found. ${TMP_TDML_FILENAME} was not
found in ${tmpdir()} for Copy TDML operation.`
+ )
+ return
+ }
+ let targetResource: vscode.Uri | undefined = resource
+
+ if (!targetResource) {
+ if (vscode.window.activeTextEditor) {
+ targetResource = vscode.window.activeTextEditor.document.uri
+ } else {
+ const tdmlUri = TDMLProvider.getDocumentUri()
+ if (tdmlUri) {
+ targetResource = tdmlUri
+ }
+ }
+ }
+
+ const resolvedResource = targetResource
+
+ // create temp zip folder
+ let tmpDir = path.dirname(getTmpTDMLFilePath())
+ createDirectory(tmpDir + '_zipdir')
+ let zipDir = path.join(tmpDir, '_zipdir')
+
+ // copy TDML file to zip folder
+ await copyFileAsync(
+ resolvedResource.fsPath,
+ path.join(zipDir, path.basename(resolvedResource.fsPath))
+ )
+
+ // read TDML file to see what files are required...
+ await readTDMLFileContents(
+ path.join(zipDir, path.basename(resolvedResource.fsPath))
+ ).then(async (xmlBuffer) => {
+ await getTestCaseDisplayData(xmlBuffer).then((testSuiteData) => {
+ testSuiteData.testCases.forEach((testCase) => {
+ // create subdir for testcase
+ let testCaseDir = path.join(zipDir, testCase.testCaseName)
+ createDirectory(testCaseDir)
+ // copy schema file
+ let xsdFile = testCase.testCaseModel
+ let xsdFileSrc = path.join(
+ path.dirname(resolvedResource.fsPath),
+ xsdFile
+ )
+ let xsdFileDest = path.join(testCaseDir, path.basename(xsdFile))
+ try {
+ fs.copyFileSync(xsdFileSrc, xsdFileDest)
+ console.log(`'${xsdFileSrc}' was copied to '${xsdFileDest}'`)
+ } catch (err) {
+ console.error('Error copying file:', err)
+ }
Review Comment:
This command performs multiple synchronous filesystem operations
(`copyFileSync`, `writeFileSync`, `readdirSync`, etc.) on the extension host
thread. For large schemas/data files this can freeze VS Code. Prefer async APIs
(`fs.promises.*` / `vscode.workspace.fs`) and `await` them, showing progress
via `withProgress` if needed.
##########
src/adapter/activateDaffodilDebug.ts:
##########
@@ -323,12 +351,166 @@ export function activateDaffodilDebug(
console.log(reason)
})
}
+ }
+ ),
+ vscode.commands.registerCommand(
+ 'extension.dfdl-debug.zipTDML',
+ async (resource: vscode.Uri) => {
+ if (!fs.existsSync(getTmpTDMLFilePath())) {
+ vscode.window.showErrorMessage(
+ `TDML ERROR: Test suite not found. Ensure that the TDML action is
set to "generate" for your DFDL debugging launch configuration before copying.`
+ )
+ console.error(
+ `TDML ERROR: Test suite not found. ${TMP_TDML_FILENAME} was not
found in ${tmpdir()} for Copy TDML operation.`
+ )
+ return
+ }
+ let targetResource: vscode.Uri | undefined = resource
+
+ if (!targetResource) {
+ if (vscode.window.activeTextEditor) {
+ targetResource = vscode.window.activeTextEditor.document.uri
+ } else {
+ const tdmlUri = TDMLProvider.getDocumentUri()
+ if (tdmlUri) {
+ targetResource = tdmlUri
+ }
+ }
+ }
+
+ const resolvedResource = targetResource
+
+ // create temp zip folder
+ let tmpDir = path.dirname(getTmpTDMLFilePath())
+ createDirectory(tmpDir + '_zipdir')
+ let zipDir = path.join(tmpDir, '_zipdir')
+
+ // copy TDML file to zip folder
+ await copyFileAsync(
+ resolvedResource.fsPath,
+ path.join(zipDir, path.basename(resolvedResource.fsPath))
+ )
+
+ // read TDML file to see what files are required...
+ await readTDMLFileContents(
+ path.join(zipDir, path.basename(resolvedResource.fsPath))
+ ).then(async (xmlBuffer) => {
+ await getTestCaseDisplayData(xmlBuffer).then((testSuiteData) => {
+ testSuiteData.testCases.forEach((testCase) => {
+ // create subdir for testcase
+ let testCaseDir = path.join(zipDir, testCase.testCaseName)
+ createDirectory(testCaseDir)
+ // copy schema file
+ let xsdFile = testCase.testCaseModel
+ let xsdFileSrc = path.join(
+ path.dirname(resolvedResource.fsPath),
+ xsdFile
+ )
+ let xsdFileDest = path.join(testCaseDir, path.basename(xsdFile))
+ try {
+ fs.copyFileSync(xsdFileSrc, xsdFileDest)
+ console.log(`'${xsdFileSrc}' was copied to '${xsdFileDest}'`)
+ } catch (err) {
+ console.error('Error copying file:', err)
+ }
+
+ // edit path in copied TDML file
+ let updatedBuffer = xmlBuffer.replace(
+ `model="${xsdFile}"`,
+ `model="${path.join(testCase.testCaseName,
path.basename(xsdFile))}"`
+ )
+ xmlBuffer = updatedBuffer
+
+ // copy data file
+ testCase.dataDocuments.forEach((dataDocuments) => {
+ let dataFile = path.basename(dataDocuments.trim())
+ let dataFileSrc = path.join(
+ path.dirname(resolvedResource.fsPath),
+ dataDocuments.trim()
+ )
+ let dataFileDest = path.join(
+ testCaseDir,
+ path.basename(dataFile)
+ )
+ try {
+ fs.copyFileSync(dataFileSrc, dataFileDest)
+ console.log(
+ `'${dataFileSrc}' was copied to '${dataFileDest}'`
+ )
+ } catch (err) {
+ console.error(`Error copying file:'${dataFileSrc}'`, err)
+ }
+
+ // edit path in copied TDML file
+ let updatedBuffer = xmlBuffer.replace(
+ dataDocuments.trim(),
+ path.join(testCase.testCaseName, dataFile)
+ )
+ xmlBuffer = updatedBuffer
+ })
+
+ // copy infoset file
+ testCase.dfdlInfosets.forEach((dfdlInfosets) => {
+ let infoFile = path.basename(dfdlInfosets.trim())
+ let infoSrc = path.join(
+ path.dirname(resolvedResource.fsPath),
+ dfdlInfosets.trim()
+ )
+ let infoDest = path.join(
+ testCaseDir,
+ path.basename(dfdlInfosets.trim())
+ )
+ try {
+ fs.copyFileSync(infoSrc, infoDest)
+ console.log(`'${infoSrc}' was copied to '${infoDest}'`)
+ } catch (err) {
+ console.error(`Error copying file:'${infoSrc}'`, err)
+ }
+ // edit path in copied TDML file
+ let infoUpdatedBuffer = xmlBuffer.replace(
+ dfdlInfosets.trim(),
+ path.join(testCase.testCaseName, infoFile)
+ )
+ xmlBuffer = infoUpdatedBuffer
+ })
+ })
+ })
+ // write updated info back to TDML file
+ try {
+ // Synchronously writes data to a file, replacing it if it already
exists
+ fs.writeFileSync(
+ path.join(zipDir, path.basename(resolvedResource.fsPath)),
+ xmlBuffer,
+ { encoding: 'utf8' }
+ )
+ console.log('Updated schema file written successfully')
+ } catch (err) {
+ console.error('Error writing updated schema file:', err)
+ }
+ })
+
+ // zip folders
+ const zip = new JSZip()
- // fs.copyFile(
- // getTmpTDMLFilePath(),
- // targetResource as unknown as string,
- // (_) => {}
- // )
+ // Add the folder content recursively
+ addFolderToZip(zipDir, zip)
+
+ // Generate and save
+ let targetZip = targetResource.fsPath.replace(/tdml$/, 'tdml.zip')
+ zip.generateAsync({ type: 'nodebuffer' }).then((content) => {
+ fs.writeFileSync(targetZip, content)
+ })
+ console.log(`Zip file written successfully: '${targetZip}'`)
+ vscode.window.showInformationMessage(
+ `Zip file successfully created: '${targetZip}'`
+ )
+ // remove temp files
+ try {
+ await rm(zipDir, { recursive: true, force: true })
+ console.log(`Temp directory successfully removed: '${zipDir}'`)
+ } catch (err) {
+ console.error(`Error while deleting '${zipDir}' directory: ${err}`)
Review Comment:
`zip.generateAsync(...)` is not awaited, but a success message is shown
immediately and the temp folder is deleted right after. If ZIP generation or
`writeFileSync` fails, the user will still see success and there’s no error
handling. `await` the ZIP generation/write, wrap in try/catch, and only then
show the success message + delete temp files.
```suggestion
// Generate, save, and then clean up
let targetZip = targetResource.fsPath.replace(/tdml$/, 'tdml.zip')
try {
const content = await zip.generateAsync({ type: 'nodebuffer' })
fs.writeFileSync(targetZip, content)
console.log(`Zip file written successfully: '${targetZip}'`)
vscode.window.showInformationMessage(
`Zip file successfully created: '${targetZip}'`
)
await rm(zipDir, { recursive: true, force: true })
console.log(`Temp directory successfully removed: '${zipDir}'`)
} catch (err) {
console.error(
`Error while creating zip file '${targetZip}' or deleting temp
directory '${zipDir}': ${err}`
)
vscode.window.showErrorMessage(
`Failed to create zip file: '${targetZip}'`
)
```
##########
src/adapter/activateDaffodilDebug.ts:
##########
@@ -323,12 +351,166 @@ export function activateDaffodilDebug(
console.log(reason)
})
}
+ }
+ ),
+ vscode.commands.registerCommand(
+ 'extension.dfdl-debug.zipTDML',
+ async (resource: vscode.Uri) => {
+ if (!fs.existsSync(getTmpTDMLFilePath())) {
+ vscode.window.showErrorMessage(
+ `TDML ERROR: Test suite not found. Ensure that the TDML action is
set to "generate" for your DFDL debugging launch configuration before copying.`
+ )
+ console.error(
+ `TDML ERROR: Test suite not found. ${TMP_TDML_FILENAME} was not
found in ${tmpdir()} for Copy TDML operation.`
+ )
+ return
Review Comment:
The zip command currently refuses to run unless `${TMP_TDML_FILENAME}`
exists in the OS temp dir (`getTmpTDMLFilePath()`). Zipping should be based on
the selected/open TDML file, not whether a previous “generate TDML” run created
a temp file. Also the error message mentions “before copying”, which doesn’t
match this command.
##########
src/adapter/activateDaffodilDebug.ts:
##########
@@ -323,12 +351,166 @@ export function activateDaffodilDebug(
console.log(reason)
})
}
+ }
+ ),
+ vscode.commands.registerCommand(
+ 'extension.dfdl-debug.zipTDML',
+ async (resource: vscode.Uri) => {
+ if (!fs.existsSync(getTmpTDMLFilePath())) {
+ vscode.window.showErrorMessage(
+ `TDML ERROR: Test suite not found. Ensure that the TDML action is
set to "generate" for your DFDL debugging launch configuration before copying.`
+ )
+ console.error(
+ `TDML ERROR: Test suite not found. ${TMP_TDML_FILENAME} was not
found in ${tmpdir()} for Copy TDML operation.`
+ )
+ return
+ }
+ let targetResource: vscode.Uri | undefined = resource
+
+ if (!targetResource) {
+ if (vscode.window.activeTextEditor) {
+ targetResource = vscode.window.activeTextEditor.document.uri
+ } else {
+ const tdmlUri = TDMLProvider.getDocumentUri()
+ if (tdmlUri) {
+ targetResource = tdmlUri
+ }
+ }
+ }
+
+ const resolvedResource = targetResource
+
+ // create temp zip folder
+ let tmpDir = path.dirname(getTmpTDMLFilePath())
+ createDirectory(tmpDir + '_zipdir')
+ let zipDir = path.join(tmpDir, '_zipdir')
+
+ // copy TDML file to zip folder
+ await copyFileAsync(
+ resolvedResource.fsPath,
+ path.join(zipDir, path.basename(resolvedResource.fsPath))
+ )
+
+ // read TDML file to see what files are required...
+ await readTDMLFileContents(
+ path.join(zipDir, path.basename(resolvedResource.fsPath))
+ ).then(async (xmlBuffer) => {
+ await getTestCaseDisplayData(xmlBuffer).then((testSuiteData) => {
+ testSuiteData.testCases.forEach((testCase) => {
+ // create subdir for testcase
+ let testCaseDir = path.join(zipDir, testCase.testCaseName)
+ createDirectory(testCaseDir)
+ // copy schema file
+ let xsdFile = testCase.testCaseModel
+ let xsdFileSrc = path.join(
+ path.dirname(resolvedResource.fsPath),
+ xsdFile
+ )
+ let xsdFileDest = path.join(testCaseDir, path.basename(xsdFile))
+ try {
+ fs.copyFileSync(xsdFileSrc, xsdFileDest)
+ console.log(`'${xsdFileSrc}' was copied to '${xsdFileDest}'`)
+ } catch (err) {
+ console.error('Error copying file:', err)
+ }
+
+ // edit path in copied TDML file
+ let updatedBuffer = xmlBuffer.replace(
+ `model="${xsdFile}"`,
+ `model="${path.join(testCase.testCaseName,
path.basename(xsdFile))}"`
+ )
+ xmlBuffer = updatedBuffer
Review Comment:
`String.prototype.replace()` only replaces the first occurrence. If multiple
test cases reference the same schema path, or if the `model="..."` appears
multiple times, later occurrences won’t be updated. Consider either using
`replaceAll`/a global regex, or (preferably) updating paths via XML parsing so
you can reliably rewrite attributes/elements.
##########
src/svelte/src/utilities/highlights.ts:
##########
@@ -137,12 +137,12 @@ export const viewportByteIndicators = new
ViewportByteIndications()
type CategoryOffsetParition = {
start: number
end: number
- assignByte: (byte: Uint8Array) => void
+ assignByte: (byte: number) => number
}
function generateSelectionCategoryParition(
start: number,
end: number,
- assignmentFn: (byte: Uint8Array) => void
+ assignmentFn: (byte: number) => number
): CategoryOffsetParition {
Review Comment:
Typo in identifier names: `CategoryOffsetParition` /
`generateSelectionCategoryParition` should be `...Partition`. Since this
type/function is only used within this file, renaming should be low-impact and
improves readability/searchability.
--
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]