How to use the @truffle/debug-utils.formatBreakpointLocation function in @truffle/debug-utils

To help you get started, we’ve selected a few @truffle/debug-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trufflesuite / truffle / packages / core / lib / debug / interpreter.js View on Github external
);
        return;
      }
    }

    //having constructed and adjusted breakpoint, here's now a
    //user-readable message describing its location
    let sourceNames = Object.assign(
      {},
      ...Object.values(this.session.view(solidity.info.sources)).map(
        ({ id, sourcePath }) => ({
          [id]: path.basename(sourcePath)
        })
      )
    );
    let locationMessage = DebugUtils.formatBreakpointLocation(
      breakpoint,
      true,
      currentSourceId,
      sourceNames
    );

    //one last check -- does this breakpoint already exist?
    let alreadyExists =
      breakpoints.filter(
        existingBreakpoint =>
          existingBreakpoint.sourceId === breakpoint.sourceId &&
          existingBreakpoint.line === breakpoint.line &&
          existingBreakpoint.node === breakpoint.node //may be undefined
      ).length > 0;

    //NOTE: in the "set breakpoint" case, the above check is somewhat
github trufflesuite / truffle / packages / core / lib / debug / printer.js View on Github external
printBreakpoints() {
    let sourceNames = Object.assign(
      {},
      ...Object.values(this.session.view(solidity.info.sources)).map(
        ({ id, sourcePath }) => ({
          [id]: path.basename(sourcePath)
        })
      )
    );
    let breakpoints = this.session.view(controller.breakpoints);
    if (breakpoints.length > 0) {
      for (let breakpoint of this.session.view(controller.breakpoints)) {
        let currentLocation = this.session.view(controller.current.location);
        let locationMessage = DebugUtils.formatBreakpointLocation(
          breakpoint,
          currentLocation.node !== undefined &&
            breakpoint.node === currentLocation.node.id,
          currentLocation.source.id,
          sourceNames
        );
        this.config.logger.log("  Breakpoint at " + locationMessage);
      }
    } else {
      this.config.logger.log("No breakpoints added.");
    }
  }