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

Method cmdDelete

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

Source from the content-addressed store, hash-verified

1862 }
1863
1864 cmdDelete(args) {
1865 if (args.length < 1) {
1866 this.commandError('Syntax: delete <id...> | delete all');
1867 return;
1868 }
1869
1870 if (args[0] === 'all') {
1871 this.breakpoints.length = 0;
1872 this.doClearAllBreakpoints();
1873 // Restore exception breakpoint if enabled
1874 if (this.exceptionsMode === 'on')
1875 this.doSetBreakpoint("exceptions", "0");
1876 if (this.breakOnStart)
1877 this.doSetBreakpoint("start", "0");
1878 this.report('delete', { all: true }, undefined, () => {
1879 console.log('All breakpoints cleared.');
1880 this.showPrompt();
1881 });
1882 return;
1883 }
1884
1885 const ids = [];
1886 for (const arg of args) {
1887 const id = parseInt(arg);
1888 if (isNaN(id) || id <= 0) {
1889 this.commandError(`Invalid breakpoint number ${arg}.`);
1890 return;
1891 }
1892 const bpIndex = this.breakpoints.findIndex(b => b.id === id);
1893 if (bpIndex < 0) {
1894 this.commandError(`No breakpoint number ${arg}.`);
1895 return;
1896 }
1897 ids.push(id);
1898 }
1899
1900 const deletedList = [];
1901 for (const id of ids) {
1902 const idx = this.breakpoints.findIndex(b => b.id === id);
1903 if (idx >= 0) {
1904 const bp = this.breakpoints[idx];
1905 this.breakpoints.splice(idx, 1);
1906 this.doClearBreakpoint(bp.path, bp.line);
1907 deletedList.push({ path: bp.path, line: bp.line, shortPath: this.shortPath(bp.path) });
1908 }
1909 }
1910
1911 this.report('delete', { deleted: deletedList }, undefined, (data) => {
1912 this.clearLine();
1913 for (const bp of data.deleted) {
1914 if (bp.line === 0)
1915 console.log(`Breakpoint deleted on function ${bp.path}`);
1916 else
1917 console.log(`Breakpoint deleted at ${bp.shortPath}:${bp.line}`);
1918 }
1919 this.showPrompt();
1920 });
1921 }

Callers 1

handleCommandMethod · 0.95

Calls 11

commandErrorMethod · 0.95
reportMethod · 0.95
showPromptMethod · 0.95
shortPathMethod · 0.95
clearLineMethod · 0.95
doClearAllBreakpointsMethod · 0.80
doSetBreakpointMethod · 0.80
logMethod · 0.65
findIndexMethod · 0.65
pushMethod · 0.45
doClearBreakpointMethod · 0.45

Tested by

no test coverage detected