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 2022/02/09 14:45:46 UTC
[daffodil-vscode] branch main updated: Multi-file breakpoints: change Path to URI when referencing locations.
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 c1e3a3a Multi-file breakpoints: change Path to URI when referencing locations.
c1e3a3a is described below
commit c1e3a3a7164b1301137b6d379086f0de1a6054e7
Author: Adam Rosien <ad...@rosien.net>
AuthorDate: Sat Jan 29 17:02:32 2022 -0800
Multi-file breakpoints: change Path to URI when referencing locations.
Fixes #66.
---
.../org.apache.daffodil.debugger.dap/DAPodil.scala | 15 ++++++++-------
.../org.apache.daffodil.debugger.dap/Parse.scala | 19 ++++++++-----------
2 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/server/core/src/main/scala/org.apache.daffodil.debugger.dap/DAPodil.scala b/server/core/src/main/scala/org.apache.daffodil.debugger.dap/DAPodil.scala
index 44e7d8c..2726f24 100644
--- a/server/core/src/main/scala/org.apache.daffodil.debugger.dap/DAPodil.scala
+++ b/server/core/src/main/scala/org.apache.daffodil.debugger.dap/DAPodil.scala
@@ -249,7 +249,7 @@ class DAPodil(
case DAPodil.State.Launched(debugee) =>
for {
_ <- debugee.setBreakpoints(
- Path.of(args.source.path),
+ Path.of(args.source.path).toUri(),
args.breakpoints.toList.map(bp => DAPodil.Line(bp.line))
)
breakpoints = args.breakpoints.toList.zipWithIndex.map {
@@ -512,7 +512,7 @@ object DAPodil extends IOApp {
def step(): IO[Unit]
def continue(): IO[Unit]
def pause(): IO[Unit]
- def setBreakpoints(path: Path, lines: List[DAPodil.Line]): IO[Unit]
+ def setBreakpoints(uri: URI, lines: List[DAPodil.Line]): IO[Unit]
def eval(args: EvaluateArguments): IO[Option[Types.Variable]]
}
@@ -687,19 +687,20 @@ object DAPodil extends IOApp {
}
case class Line(value: Int) extends AnyVal
- case class Location(path: Path, line: Line)
+ case class Location(uri: URI, line: Line)
object Location {
implicit val show: Show[Location] = Show.fromToString
}
- case class Breakpoints(value: Map[Path, List[Line]]) {
- def set(path: Path, lines: List[Line]): Breakpoints =
- copy(value = value + (path -> lines))
+ case class Breakpoints(value: Map[URI, List[Line]]) {
+ def set(uri: URI, lines: List[Line]): Breakpoints =
+ copy(value = value + (uri.normalize -> lines))
def contains(location: Location): Boolean =
value.exists {
- case (path, lines) => path == location.path && lines.exists(_ == location.line)
+ case (uri, lines) =>
+ uri == location.uri && lines.exists(_ == location.line)
}
}
diff --git a/server/core/src/main/scala/org.apache.daffodil.debugger.dap/Parse.scala b/server/core/src/main/scala/org.apache.daffodil.debugger.dap/Parse.scala
index 2f17e78..caf0ffc 100644
--- a/server/core/src/main/scala/org.apache.daffodil.debugger.dap/Parse.scala
+++ b/server/core/src/main/scala/org.apache.daffodil.debugger.dap/Parse.scala
@@ -30,6 +30,7 @@ import fs2._
import fs2.concurrent._
import fs2.io.file.Files
import java.io._
+import java.net.URI
import java.nio.file._
import org.apache.daffodil.debugger.dap.{BuildInfo => DAPBuildInfo}
import org.apache.daffodil.debugger.Debugger
@@ -132,8 +133,8 @@ object Parse {
Some(DAPodil.Debugee.State.Stopped(DAPodil.Debugee.State.Stopped.Reason.Pause))
)
- def setBreakpoints(path: Path, lines: List[DAPodil.Line]): IO[Unit] =
- breakpoints.setBreakpoints(path, lines)
+ def setBreakpoints(uri: URI, lines: List[DAPodil.Line]): IO[Unit] =
+ breakpoints.setBreakpoints(uri, lines)
def eval(args: EvaluateArguments): IO[Option[Types.Variable]] =
args.expression match {
@@ -253,7 +254,7 @@ object Parse {
events <- Resource.eval(Queue.bounded[IO, Option[Event]](10))
debugger <- DaffodilDebugger
- .resource(args.schemaPath, state, events, breakpoints, control, infoset)
+ .resource(state, events, breakpoints, control, infoset)
parse <- Resource.eval(args.data.flatMap(in => Parse(args.schemaPath, in, debugger)))
parsing = args.infosetOutput match {
@@ -532,7 +533,6 @@ object Parse {
),
pstate.mpstate.delimiters.toList.zipWithIndex.map {
case (delimiter, i) =>
- println(s"$i: $delimiter")
Delimiter(if (i < pstate.mpstate.delimitersLocalIndexStack.top) "remote" else "local", delimiter)
}
)
@@ -555,7 +555,7 @@ object Parse {
case class Delimiter(kind: String, value: DFADelimiter)
trait Breakpoints {
- def setBreakpoints(path: Path, lines: List[DAPodil.Line]): IO[Unit]
+ def setBreakpoints(uri: URI, lines: List[DAPodil.Line]): IO[Unit]
def shouldBreak(location: DAPodil.Location): IO[Boolean]
}
@@ -564,8 +564,8 @@ object Parse {
for {
breakpoints <- Ref[IO].of(DAPodil.Breakpoints.empty)
} yield new Breakpoints {
- def setBreakpoints(path: Path, lines: List[DAPodil.Line]): IO[Unit] =
- breakpoints.update(bp => bp.set(path, lines))
+ def setBreakpoints(uri: URI, lines: List[DAPodil.Line]): IO[Unit] =
+ breakpoints.update(bp => bp.set(uri, lines))
def shouldBreak(location: DAPodil.Location): IO[Boolean] =
for {
@@ -709,7 +709,6 @@ object Parse {
* we use a `Dispatcher` to execute the effects at this "outermost" layer (with respect to the effects).
*/
class DaffodilDebugger(
- schemaPath: Path,
dispatcher: Dispatcher[IO],
state: QueueSink[IO, Option[DAPodil.Debugee.State]],
breakpoints: Breakpoints,
@@ -785,7 +784,7 @@ object Parse {
def createLocation(loc: SchemaFileLocation): DAPodil.Location =
DAPodil.Location(
- schemaPath,
+ URI.create(loc.uriString).normalize,
DAPodil.Line(loc.lineNumber.map(_.toInt).getOrElse(0))
)
@@ -797,7 +796,6 @@ object Parse {
object DaffodilDebugger {
def resource(
- schemaPath: Path,
state: QueueSink[IO, Option[DAPodil.Debugee.State]],
events: QueueSink[IO, Option[Event]],
breakpoints: Breakpoints,
@@ -807,7 +805,6 @@ object Parse {
for {
dispatcher <- Dispatcher[IO]
} yield new DaffodilDebugger(
- schemaPath,
dispatcher,
state,
breakpoints,