MCPcopy Index your code
hub / github.com/Moddable-OpenSource/moddable / cmdBreak

Method cmdBreak

tools/xsbug-log/xsbug-debugmachine.js:1644–1738  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

1642 }
1643
1644 cmdBreak(args) {
1645 if (args.length < 1) {
1646 // No args: list breakpoints
1647 this.cmdInfoBreakpoints();
1648 return;
1649 }
1650
1651 // Parse "if <expr>" suffix from args
1652 let conditionExpr = null;
1653 const ifIndex = args.indexOf('if');
1654 if (ifIndex > 0) {
1655 conditionExpr = args.slice(ifIndex + 1).join(' ');
1656 args = args.slice(0, ifIndex);
1657 if (!conditionExpr) {
1658 this.commandError('Missing expression after "if".');
1659 return;
1660 }
1661 }
1662
1663 let path, line;
1664 const spec = args[0];
1665
1666 if (spec.includes(':')) {
1667 const lastColon = spec.lastIndexOf(':');
1668 path = spec.substring(0, lastColon);
1669 const lineStr = spec.substring(lastColon + 1);
1670 if (isNaN(parseInt(lineStr))) {
1671 this.commandError('Invalid line number.');
1672 return;
1673 }
1674 line = parseInt(lineStr);
1675
1676 // Resolve short filenames against known files
1677 const resolved = this.resolveFilePath(path, true);
1678 if (resolved === null) {
1679 this.showPrompt();
1680 return;
1681 }
1682 path = resolved;
1683 }
1684 else if (!isNaN(parseInt(spec))) {
1685 // Just a line number: use current file
1686 path = this.currentPath;
1687 if (!path) {
1688 this.commandError('No current file. Use "break file:line" or "break function".');
1689 return;
1690 }
1691 if (spec.startsWith('+') || spec.startsWith('-')) {
1692 if (!this.currentLine) {
1693 this.commandError('No current line known for relative breakpoint.');
1694 return;
1695 }
1696 line = parseInt(this.currentLine) + parseInt(spec);
1697 }
1698 else {
1699 line = parseInt(spec);
1700 }
1701 }

Callers 1

handleCommandMethod · 0.95

Calls 13

cmdInfoBreakpointsMethod · 0.95
commandErrorMethod · 0.95
resolveFilePathMethod · 0.95
showPromptMethod · 0.95
reportMethod · 0.95
shortPathMethod · 0.95
clearLineMethod · 0.95
findMethod · 0.80
doSetBreakpointMethod · 0.80
sliceMethod · 0.65
logMethod · 0.65

Tested by

no test coverage detected