stevedlawrence commented on issue #615: URL: https://github.com/apache/daffodil-vscode/issues/615#issuecomment-4479357895
Yep, each `Parser` /`Unparser` has a `context: RuntimeData` member, and `RuntimeData` has a number of members to access schema file locations for that processor, provided by the `HasSchemaFileLocation` mixin: https://github.com/apache/daffodil/blob/d8bc0c199d96ffd3ca9f72a63bb899aedb8fb8b8/daffodil-core/src/main/scala/org/apache/daffodil/lib/exceptions/SchemaFileLocatable.scala#L27-L34 So for to get the file/line information the startElement debug hook, you could do something like: ```scala override def startElement(state: PState, parser: Parser): Unit = { val fileLocation = parser.context.fileDescription val lineNumber= parser.context.lineDescription ... } ``` Note that depending on the Daffodil version and how the saved parser was built the file locations might be "depersonalized", meaning they are relative paths instead of absolute paths. For example older versions of Daffodil might have a fileDescription of ``` file:///home/user/path/to/dfdl/schemas/foo/src/main/resources/format/xsd/schema.dfdl.xsd ``` But newer versions will just have ``` format/xsd/schema.dfdl.xsd ``` These both can kindof lead to complications for the extension. With the former path, the saved parser might have been built on a different machine with different paths so they might not exist with whatever system you're currently debugging on. So you might have to relativeize those absolute paths somehow. And with the later, you have to be told where the root of your source files are then scan those directories for the relative paths. Note that modern versions of Daffodil created by the CLI or by packageDaffodilBin using the sbt-daffodil should use extension use relative paths. -- 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]
