diff libgui/src/m-editor/file-editor-tab.cc @ 29458:c0f86150aa6c

begin allowing breakpoints to be set using file name * file-editor-tab.h, file-editor-tab.cc (file_editor_tab::bp_info): Delete struct and all uses. (file_editor_tab::handle_request_add_breakpoint): Use bp_table::remove_breakpoint_from_file instead of asking bp_info to parse file name. (file_editor_tab::remove_all_breakpoints): Use bp_table::remove_all_breakpoints_from_file instead of asking bp_info to parse file name. (file_editor_tab::add_breakpoint_event): Use bp_table::add_breakpint instead of asking bp_info to parse file name. (Fdbclear): Use bp_table::remove_breakpoints_from_function instead of bp_table::remove_breakpoint. * debug.cc (Fdbstop): Use bp_table::add_breakpoints_in_function instead of bp_table::add_breakpoint. * fcn-info.cc (out_of_date_check): Use bp_table::remove_all_breakpoints_from_function instead of bp_table::remove_all_breakpoints_in_file. * bp-table.h, bp-table.cc (bp_file_info): New class, adapted from file_editor_tab::bp_info struct. (bp_table::add_breakpoint_in_function, bp_table::add_breakpoints_in_function): Rename from add_breakpoint. (bp_table::remove_breakpoint_from_function, bp_table::remove_breakpoints_from_function): Rename from remove_breakpoint. Update all uses. (bp_table::remove_all_breakpoints_from_function): Rename from remove_all_breakpoints_in_file. Update all uses. (bp_table::add_breakpoint_in_file, bp_table::add_breakpoints_in_file, bp_table::remove_breakpoint_from_file, bp_table::remove_breakpoints_from_file, bp_table::remove_all_breakpoints_from_file): New functions. (bp_table::add_breakpoint, bp_table::remove_breakpoint, bp_table::remove_all_breakpoints_in_file): Deprecate.
author John W. Eaton <jwe@octave.org>
date Mon, 22 Mar 2021 00:34:38 -0400
parents 313b8b897733
children 46def32e6806
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Wed Mar 03 23:57:31 2021 -0500
+++ b/libgui/src/m-editor/file-editor-tab.cc	Mon Mar 22 00:34:38 2021 -0400
@@ -1122,67 +1122,27 @@
     m_edit_area->markerDeleteAll (marker::bookmark);
   }
 
-  file_editor_tab::bp_info::bp_info (const QString& fname, int l,
-                                     const QString& cond)
-    : line (l), file (fname.toStdString ()), condition (cond.toStdString ())
-  {
-    QFileInfo file_info (fname);
-
-    QString q_dir = file_info.absolutePath ();
-    QString q_function_name = file_info.fileName ();
-
-    // We have to cut off the suffix, because octave appends it.
-    q_function_name.chop (file_info.suffix ().length () + 1);
-
-    dir = q_dir.toStdString ();
-    function_name = q_function_name.toStdString ();
-
-    // Is the last component of DIR @foo?  If so, strip it and prepend it
-    // to the name of the function.
-
-    size_t pos = dir.rfind (sys::file_ops::dir_sep_chars ());
-
-    if (pos != std::string::npos && pos < dir.length () - 1)
-      {
-        if (dir[pos+1] == '@')
-          {
-            function_name = sys::file_ops::concat (dir.substr (pos+1), function_name);
-
-            dir = dir.substr (0, pos);
-          }
-      }
-  }
-
-  void file_editor_tab::handle_request_add_breakpoint (int line,
-                                                       const QString& condition)
+  void
+  file_editor_tab::handle_request_add_breakpoint (int line,
+                                                  const QString& condition)
   {
     if (! m_is_octave_file)
       return;
 
-    bp_info info (m_file_name, line, condition);
-
-    add_breakpoint_event (info);
+    add_breakpoint_event (line, condition);
   }
 
   void file_editor_tab::handle_request_remove_breakpoint (int line)
   {
-    bp_info info (m_file_name, line);
-
     emit interpreter_event
       ([=] (interpreter& interp)
        {
          // INTERPRETER THREAD
 
-         load_path& lp = interp.get_load_path ();
-
-         if (lp.contains_file_in_dir (info.file, info.dir))
-           {
-             tree_evaluator& tw = interp.get_evaluator ();
-
-             bp_table& bptab = tw.get_bp_table ();
-
-             bptab.remove_breakpoint (info.function_name, info.line);
-           }
+         tree_evaluator& tw = interp.get_evaluator ();
+         bp_table& bptab = tw.get_bp_table ();
+
+         bptab.remove_breakpoint_from_file (m_file_name.toStdString (), line);
        });
   }
 
@@ -1252,23 +1212,16 @@
     if (ID != this)
       return;
 
-    bp_info info (m_file_name);
-
     emit interpreter_event
       ([=] (interpreter& interp)
        {
          // INTERPRETER THREAD
 
-         load_path& lp = interp.get_load_path ();
-
-         if (lp.contains_file_in_dir (info.file, info.dir))
-           {
-             tree_evaluator& tw = interp.get_evaluator ();
-
-             bp_table& bptab = tw.get_bp_table ();
-
-             bptab.remove_all_breakpoints_in_file (info.function_name, true);
-           }
+         tree_evaluator& tw = interp.get_evaluator ();
+         bp_table& bptab = tw.get_bp_table ();
+
+         bptab.remove_all_breakpoints_from_file (m_file_name.toStdString (),
+                                                 true);
        });
   }
 
@@ -1360,7 +1313,7 @@
     auto_margin_width ();
   }
 
-  void file_editor_tab::add_breakpoint_event (const bp_info& info)
+  void file_editor_tab::add_breakpoint_event (int line, const QString& cond)
   {
     emit interpreter_event
       ([=] (interpreter& interp)
@@ -1370,20 +1323,14 @@
          // FIXME: note duplication with the code in
          // handle_context_menu_break_condition.
 
-         load_path& lp = interp.get_load_path ();
-
-         if (lp.contains_file_in_dir (info.file, info.dir))
-           {
-             tree_evaluator& tw = interp.get_evaluator ();
-
-             bp_table& bptab = tw.get_bp_table ();
-
-             int lineno = bptab.add_breakpoint (info.function_name, "",
-                                                info.line, info.condition);
-
-             if (lineno)
-               emit maybe_remove_next (lineno);
-           }
+         tree_evaluator& tw = interp.get_evaluator ();
+         bp_table& bptab = tw.get_bp_table ();
+
+         int lineno = bptab.add_breakpoint_in_file (m_file_name.toStdString (),
+                                                    line, cond.toStdString ());
+
+         if (lineno)
+           emit maybe_remove_next (lineno);
        });
   }