MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / cmdClear

Method cmdClear

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

Source from the content-addressed store, hash-verified

1921 }
1922
1923 cmdClear(args) {
1924 if (args.length < 1) {
1925 this.commandError('Syntax: clear <file:line> | clear <line> | clear <function> | clear all');
1926 return;
1927 }
1928
1929 if (args[0] === 'all') {
1930 this.breakpoints.length = 0;
1931 this.doClearAllBreakpoints();
1932 // Restore exception breakpoint if enabled
1933 if (this.exceptionsMode === 'on')
1934 this.doSetBreakpoint("exceptions", "0");
1935 if (this.breakOnStart)
1936 this.doSetBreakpoint("start", "0");
1937 this.report('clear', { all: true }, undefined, () => {
1938 console.log('All breakpoints cleared.');
1939 this.showPrompt();
1940 });
1941 return;
1942 }
1943
1944 let path, line;
1945 const spec = args[0];
1946
1947 if (spec.includes(':')) {
1948 const lastColon = spec.lastIndexOf(':');
1949 path = spec.substring(0, lastColon);
1950 const lineStr = spec.substring(lastColon + 1);
1951 if (isNaN(parseInt(lineStr))) {
1952 this.commandError('Invalid line number.');
1953 return;
1954 }
1955 line = parseInt(lineStr);
1956
1957 const resolved = this.resolveFilePath(path, false);
1958 if (resolved === null)
1959 return;
1960 path = resolved;
1961 }
1962 else if (!isNaN(parseInt(spec))) {
1963 path = this.currentPath;
1964 if (!path) {
1965 this.commandError('No current file. Use "clear file:line" or "clear function".');
1966 return;
1967 }
1968 if (spec.startsWith('+') || spec.startsWith('-')) {
1969 if (!this.currentLine) {
1970 this.commandError('No current line known for relative command.');
1971 return;
1972 }
1973 line = parseInt(this.currentLine) + parseInt(spec);
1974 }
1975 else {
1976 line = parseInt(spec);
1977 }
1978 }
1979 else {
1980 // Function breakpoint

Callers 1

handleCommandMethod · 0.95

Calls 10

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

Tested by

no test coverage detected