MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / debug

Method debug

ij/src/main/java/ij/plugin/frame/Editor.java:1779–1848  ·  view source on GitHub ↗
(Interpreter interp, int mode)

Source from the content-addressed store, hash-verified

1777 public void lostOwnership (Clipboard clip, Transferable cont) {}
1778
1779 public int debug(Interpreter interp, int mode) {
1780 if (IJ.debugMode)
1781 IJ.log("debug: "+interp.getLineNumber()+" "+mode+" "+interp);
1782 if (mode==RUN_TO_COMPLETION)
1783 return 0;
1784 int n = interp.getLineNumber();
1785 if (mode==RUN_TO_CARET) {
1786 if (n==runToLine) {
1787 mode = STEP;
1788 interp.setDebugMode(mode);
1789 } else
1790 return 0;
1791 }
1792 if (!isVisible()) { // abort macro if user closes window
1793 interp.abortMacro();
1794 return 0;
1795 }
1796 if (n==previousLine) {
1797 previousLine=0;
1798 return 0;
1799 }
1800 Window win = WindowManager.getActiveWindow();
1801 if (win!=this)
1802 IJ.wait(50);
1803 toFront();
1804 previousLine = n;
1805 String text = ta.getText();
1806 if (IJ.isWindows())
1807 text = text.replaceAll("\r\n", "\n");
1808 char[] chars = new char[text.length()];
1809 chars = text.toCharArray();
1810 int count=1;
1811 debugStart=0;
1812 int len = chars.length;
1813 debugEnd = len;
1814 for (int i=0; i<len; i++) {
1815 if (chars[i]=='\n') count++;
1816 if (count==n && debugStart==0)
1817 debugStart=i+1;
1818 else if (count==n+1) {
1819 debugEnd=i;
1820 break;
1821 }
1822 }
1823 //IJ.log("debug: "+debugStart+" "+debugEnd+" "+len+" "+count);
1824 if (debugStart==1) debugStart = 0;
1825 if ((debugStart==0||debugStart==len) && debugEnd==len)
1826 return 0; // skip code added with Interpreter.setAdditionalFunctions()
1827 ta.select(debugStart, debugEnd);
1828 if (debugWindow!=null && !debugWindow.isShowing()) {
1829 interp.setDebugger(null);
1830 debugWindow = null;
1831 } else
1832 debugWindow = interp.updateDebugWindow(interp.getVariables(), debugWindow);
1833 if (debugWindow!=null) {
1834 interp.updateArrayInspector();
1835 toFront();
1836 }

Callers

nothing calls this directly

Calls 15

logMethod · 0.95
getActiveWindowMethod · 0.95
waitMethod · 0.95
isWindowsMethod · 0.95
getLineNumberMethod · 0.80
abortMacroMethod · 0.80
replaceAllMethod · 0.80
isShowingMethod · 0.80
setDebuggerMethod · 0.80
updateDebugWindowMethod · 0.80
getVariablesMethod · 0.80
updateArrayInspectorMethod · 0.80

Tested by

no test coverage detected