[mono/monodevelop] [2 commits] 8a1703c7: [Debugger] code cleanup

"Jeffrey Stedfast ([email protected])" <[email protected]> Thu, 7 Nov 2013 21:18:49 +0000
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <00000142346e8af7-27c4030a-353d-4c1e-8da0-40449c40ec7f-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/monodevelop
  Compare: https://github.com/mono/monodevelop/compare/fc4cc0213690...2872b361571b

   Commit: 8a1703c7bd6b7d53d4234a94dfb34e47b1b40096
   Author: Jeffrey Stedfast <[email protected]> (jstedfast)
     Date: 2013-11-07 20:36:41 GMT
      URL: https://github.com/mono/monodevelop/commit/8a1703c7bd6b7d53d4234a94dfb34e47b1b40096

[Debugger] code cleanup

Changed paths:
  M main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs

Modified: main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs
===================================================================
@@ -45,23 +45,25 @@
 namespace MonoDevelop.Debugger
 {
 	[System.ComponentModel.ToolboxItem (true)]
-	public class ObjectValueTreeView: Gtk.TreeView, ICompletionWidget
+	public class ObjectValueTreeView: TreeView, ICompletionWidget
 	{
-		List<string> valueNames = new List<string> ();
-		Dictionary<string,string> oldValues = new Dictionary<string,string> ();
-		List<ObjectValue> values = new List<ObjectValue> ();
-		Dictionary<ObjectValue,TreeRowReference> nodes = new Dictionary<ObjectValue, TreeRowReference> ();
-		Dictionary<string,ObjectValue> cachedValues = new Dictionary<string,ObjectValue> ();
-		Dictionary<ObjectValue, Task> expandTasks = new Dictionary<ObjectValue, Task> ();
-		TreeStore store;
-		TreeViewState state;
-		string createMsg;
+		readonly Dictionary<ObjectValue, TreeRowReference> nodes = new Dictionary<ObjectValue, TreeRowReference> ();
+		readonly Dictionary<string, ObjectValue> cachedValues = new Dictionary<string, ObjectValue> ();
+		readonly Dictionary<ObjectValue, Task> expandTasks = new Dictionary<ObjectValue, Task> ();
+		readonly Dictionary<string, string> oldValues = new Dictionary<string, string> ();
+		readonly List<ObjectValue> values = new List<ObjectValue> ();
+		readonly List<string> valueNames = new List<string> ();
+
+		readonly Gdk.Pixbuf noLiveIcon;
+		readonly Gdk.Pixbuf liveIcon;
+
+		readonly TreeViewState state;
+		readonly TreeStore store;
+		readonly string createMsg;
 		bool restoringState = false;
 		bool compact;
 		StackFrame frame;
 		bool disposed;
-		Gdk.Pixbuf noLiveIcon;
-		Gdk.Pixbuf liveIcon;
 		
 		bool columnsAdjusted;
 		bool columnSizesUpdating;
@@ -70,26 +72,26 @@ public class ObjectValueTreeView: Gtk.TreeView, ICompletionWidget
 		double valueColWidth;
 		double typeColWidth;
 		
-		CellRendererText crtExp;
-		CellRendererText crtValue;
-		CellRendererText crtType;
-		CellRendererIcon crpButton;
-		CellRendererIcon crpPin;
-		CellRendererIcon crpLiveUpdate;
-		CellRendererIcon crpViewer;
-		Gtk.Entry editEntry;
+		readonly CellRendererText crtExp;
+		readonly CellRendererText crtValue;
+		readonly CellRendererText crtType;
+		readonly CellRendererIcon crpButton;
+		readonly CellRendererIcon crpPin;
+		readonly CellRendererIcon crpLiveUpdate;
+		readonly CellRendererIcon crpViewer;
+		Entry editEntry;
 		Mono.Debugging.Client.CompletionData currentCompletionData;
 		
-		TreeViewColumn expCol;
-		TreeViewColumn valueCol;
-		TreeViewColumn typeCol;
-		TreeViewColumn pinCol;
+		readonly TreeViewColumn expCol;
+		readonly TreeViewColumn valueCol;
+		readonly TreeViewColumn typeCol;
+		readonly TreeViewColumn pinCol;
 		
-		string errorColor = "red";
-		string modifiedColor = "blue";
-		string disabledColor = "gray";
+		const string errorColor = "red";
+		const string modifiedColor = "blue";
+		const string disabledColor = "gray";
 		
-		static CommandEntrySet menuSet;
+		static readonly CommandEntrySet menuSet;
 		
 		const int NameCol = 0;
 		const int ValueCol = 1;
@@ -138,7 +140,7 @@ public ObjectValueTreeView ()
 			Pango.FontDescription newFont = this.Style.FontDescription.Copy ();
 			newFont.Size = (newFont.Size * 8) / 10;
 			
-			liveIcon = ImageService.GetPixbuf (Gtk.Stock.Execute, IconSize.Menu);
+			liveIcon = ImageService.GetPixbuf (Stock.Execute, IconSize.Menu);
 			noLiveIcon = ImageService.MakeTransparent (liveIcon, 0.5);
 			
 			expCol = new TreeViewColumn ();
@@ -161,12 +163,12 @@ public ObjectValueTreeView ()
 			valueCol = new TreeViewColumn ();
 			valueCol.Title = GettextCatalog.GetString ("Value");
 			crpViewer = new CellRendererIcon ();
-			crpViewer.IconId = Gtk.Stock.ZoomIn;
+			crpViewer.IconId = Stock.ZoomIn;
 			valueCol.PackStart (crpViewer, false);
 			valueCol.AddAttribute (crpViewer, "visible", ViewerButtonVisibleCol);
 			crpButton = new CellRendererIcon ();
-			crpButton.StockSize = (uint)Gtk.IconSize.Menu;
-			crpButton.IconId = Gtk.Stock.Refresh;
+			crpButton.StockSize = (uint) IconSize.Menu;
+			crpButton.IconId = Stock.Refresh;
 			valueCol.PackStart (crpButton, false);
 			valueCol.AddAttribute (crpButton, "visible", ValueButtonVisibleCol);
 			crtValue = new CellRendererText ();
@@ -397,16 +399,16 @@ public void LoadState ()
 				compact = value;
 				Pango.FontDescription newFont;
 				if (compact) {
-					newFont = this.Style.FontDescription.Copy ();
+					newFont = Style.FontDescription.Copy ();
 					newFont.Size = (newFont.Size * 8) / 10;
 					expCol.Sizing = TreeViewColumnSizing.Autosize;
 					valueCol.Sizing = TreeViewColumnSizing.Autosize;
 					valueCol.MaxWidth = 800;
-					crpButton.Pixbuf = ImageService.GetPixbuf (Gtk.Stock.Refresh).ScaleSimple (12, 12, Gdk.InterpType.Hyper);
-					crpViewer.Pixbuf = ImageService.GetPixbuf (Gtk.Stock.ZoomIn).ScaleSimple (12, 12, Gdk.InterpType.Hyper);
+					crpButton.Pixbuf = ImageService.GetPixbuf (Stock.Refresh).ScaleSimple (12, 12, Gdk.InterpType.Hyper);
+					crpViewer.Pixbuf = ImageService.GetPixbuf (Stock.ZoomIn).ScaleSimple (12, 12, Gdk.InterpType.Hyper);
 					ColumnsAutosize ();
 				} else {
-					newFont = this.Style.FontDescription;
+					newFont = Style.FontDescription;
 					expCol.Sizing = TreeViewColumnSizing.Fixed;
 					valueCol.Sizing = TreeViewColumnSizing.Fixed;
 					valueCol.MaxWidth = int.MaxValue;
@@ -719,7 +721,7 @@ void SetValues (TreeIter parent, TreeIter it, string name, ObjectValue val)
 				strval = val.Value;
 				valueColor = disabledColor;
 				if (val.CanRefresh)
-					valueButton = Gtk.Stock.Refresh;
+					valueButton = Stock.Refresh;
 				canEdit = false;
 			}
 			else if (val.IsEvaluating) {
@@ -905,19 +907,19 @@ string GetIterPath (TreeIter iter)
 			return sb.ToString ();
 		}
 
-		void OnExpEditing (object s, Gtk.EditingStartedArgs args)
+		void OnExpEditing (object s, EditingStartedArgs args)
 		{
 			TreeIter it;
 			if (!store.GetIterFromString (out it, args.Path))
 				return;
-			Gtk.Entry e = (Gtk.Entry) args.Editable;
+			Entry e = (Entry) args.Editable;
 			if (e.Text == createMsg)
 				e.Text = string.Empty;
 			
 			OnStartEditing (args);
 		}
 		
-		void OnExpEdited (object s, Gtk.EditedArgs args)
+		void OnExpEdited (object s, EditedArgs args)
 		{
 			OnEndEditing ();
 			
@@ -950,13 +952,13 @@ void OnExpEdited (object s, Gtk.EditedArgs args)
 		
 		bool editing;
 		
-		void OnValueEditing (object s, Gtk.EditingStartedArgs args)
+		void OnValueEditing (object s, EditingStartedArgs args)
 		{
 			TreeIter it;
 			if (!store.GetIterFromString (out it, args.Path))
 				return;
 			
-			var entry = (Gtk.Entry) args.Editable;
+			var entry = (Entry) args.Editable;
 			
 			ObjectValue val = store.GetValue (it, ObjectCol) as ObjectValue;
 			string strVal = val != null ? val.Value : null;
@@ -967,14 +969,16 @@ void OnValueEditing (object s, Gtk.EditingStartedArgs args)
 			OnStartEditing (args);
 		}
 		
-		void OnValueEdited (object s, Gtk.EditedArgs args)
+		void OnValueEdited (object s, EditedArgs args)
 		{
 			OnEndEditing ();
 			
 			TreeIter it;
 			if (!store.GetIterFromString (out it, args.Path))
 				return;
-			ObjectValue val = store.GetValue (it, ObjectCol) as ObjectValue;
+
+			ObjectValue val = (ObjectValue) store.GetValue (it, ObjectCol);
+
 			try {
 				string newVal = args.NewText;
 /*				if (newVal == null) {
@@ -986,6 +990,7 @@ void OnValueEdited (object s, Gtk.EditedArgs args)
 			} catch (Exception ex) {
 				LoggingService.LogError ("Could not set value for object '" + val.Name + "'", ex);
 			}
+
 			store.SetValue (it, ValueCol, val.DisplayValue);
 
 			// Update the color
@@ -1008,10 +1013,10 @@ void OnEditingCancelled (object s, EventArgs args)
 			OnEndEditing ();
 		}
 		
-		void OnStartEditing (Gtk.EditingStartedArgs args)
+		void OnStartEditing (EditingStartedArgs args)
 		{
 			editing = true;
-			editEntry = (Gtk.Entry) args.Editable;
+			editEntry = (Entry) args.Editable;
 			editEntry.KeyPressEvent += OnEditKeyPress;
 			editEntry.KeyReleaseEvent += OnEditKeyRelease;
 			if (StartEditing != null)
@@ -1048,7 +1053,7 @@ void OnEditKeyRelease (object sender, EventArgs e)
 		uint keyValue;
 
 		[GLib.ConnectBeforeAttribute]
-		void OnEditKeyPress (object s, Gtk.KeyPressEventArgs args)
+		void OnEditKeyPress (object s, KeyPressEventArgs args)
 		{
 			wasHandled = false;
 			key = args.Event.Key;
@@ -1069,7 +1074,7 @@ static bool IsCompletionChar (char c)
 
 		void PopupCompletion (Entry entry)
 		{
-			Gtk.Application.Invoke (delegate {
+			Application.Invoke (delegate {
 				char c = (char)Gdk.Keyval.ToUnicode (keyValue);
 				if (currentCompletionData == null && IsCompletionChar (c)) {
 					string exp = entry.Text.Substring (0, entry.CursorPosition);
@@ -1297,10 +1302,10 @@ protected void OnCopy ()
 				return;
 
 			if (selected.Length == 1) {
-				object focus = IdeApp.Workbench.RootWindow.Focus;
+				var editable = IdeApp.Workbench.RootWindow.Focus as Editable;
 
-				if (focus is Gtk.Editable) {
-					((Gtk.Editable) focus).CopyClipboard ();
+				if (editable != null) {
+					editable.CopyClipboard ();
 					return;
 				}
 			}
@@ -1524,7 +1529,8 @@ public void RemovePinnedWatch (TreeIter it)
 
 		protected virtual void OnCompletionContextChanged (EventArgs e)
 		{
-			EventHandler handler = this.CompletionContextChanged;
+			var handler = CompletionContextChanged;
+
 			if (handler != null)
 				handler (this, e);
 		}
@@ -1559,9 +1565,9 @@ char ICompletionWidget.GetChar (int offset)
 		{
 			string txt = editEntry.Text;
 			if (offset >= txt.Length)
-				return (char)0;
-			else
-				return txt [offset];
+				return '\0';
+
+			return txt [offset];
 		}
 		
 		CodeCompletionContext ICompletionWidget.CreateCodeCompletionContext (int triggerOffset)
@@ -1711,12 +1717,14 @@ public DebugCompletionDataList (Mono.Debugging.Client.CompletionData data)
 			get;
 			set;
 		}
-		static List<ICompletionKeyHandler> keyHandler = new List<ICompletionKeyHandler> ();
+
+		static readonly List<ICompletionKeyHandler> keyHandler = new List<ICompletionKeyHandler> ();
 		public IEnumerable<ICompletionKeyHandler> KeyHandler { get { return keyHandler;} }
 
 		public void OnCompletionListClosed (EventArgs e)
 		{
-			EventHandler handler = this.CompletionListClosed;
+			var handler = CompletionListClosed;
+
 			if (handler != null)
 				handler (this, e);
 		}
@@ -1726,7 +1734,7 @@ public void OnCompletionListClosed (EventArgs e)
 	
 	class DebugCompletionData : MonoDevelop.Ide.CodeCompletion.CompletionData
 	{
-		CompletionItem item;
+		readonly CompletionItem item;
 		
 		public DebugCompletionData (CompletionItem item)
 		{

   Commit: 2872b361571bae7c42ef92aa182ba061dfc6ad9d
   Author: Jeffrey Stedfast <[email protected]> (jstedfast)
     Date: 2013-11-07 21:16:21 GMT
      URL: https://github.com/mono/monodevelop/commit/2872b361571bae7c42ef92aa182ba061dfc6ad9d

[Debugger] Improved the look of the ExceptionCaughtDialog

Changed paths:
  M main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.csproj
  M main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ExceptionCaughtDialog.cs
  M main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs
  M main/src/addins/MonoDevelop.Debugger/gtk-gui/MonoDevelop.Debugger.ExceptionCaughtWidget.cs
  M main/src/addins/MonoDevelop.Debugger/gtk-gui/gui.stetic

Modified: main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.csproj
===================================================================
@@ -22,8 +22,8 @@
     <Execution>
       <Execution clr-version="Net_2_0" />
     </Execution>
-    <GenerateDocumentation>true</GenerateDocumentation>
     <NoWarn>1591;1573</NoWarn>
+    <DocumentationFile>..\..\..\build\AddIns\MonoDevelop.Debugger\MonoDevelop.Debugger.xml</DocumentationFile>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
@@ -36,8 +36,8 @@
       <Execution clr-version="Net_2_0" />
     </Execution>
     <DebugSymbols>true</DebugSymbols>
-    <GenerateDocumentation>true</GenerateDocumentation>
     <NoWarn>1591;1573</NoWarn>
+    <DocumentationFile>..\..\..\build\AddIns\MonoDevelop.Debugger\MonoDevelop.Debugger.xml</DocumentationFile>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
@@ -149,6 +149,7 @@
     <Compile Include="MonoDevelop.Debugger\DebuggerConsoleView.cs" />
     <Compile Include="MonoDevelop.Debugger.Visualizer\CStringVisualizer.cs" />
     <Compile Include="MonoDevelop.Debugger.Visualizer\ValueVisualizer.cs" />
+    <Compile Include="MonoDevelop.Debugger\InfoFrame.cs" />
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="MonoDevelop.Debugger.addin.xml">

Modified: main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ExceptionCaughtDialog.cs
===================================================================
@@ -38,29 +38,34 @@ namespace MonoDevelop.Debugger
 {
 	public partial class ExceptionCaughtWidget : Gtk.Bin
 	{
-		Gtk.TreeStore stackStore;
-		ExceptionInfo exception;
+		readonly Gtk.TreeStore stackStore;
+		readonly ExceptionInfo exception;
 		bool destroyed;
 		
 		public ExceptionCaughtWidget (ExceptionInfo exception)
 		{
 			this.Build ();
 
+			vboxExceptionInfo.Remove (labelMessage);
+			var frame = new InfoFrame (labelMessage);
+			frame.Show ();
+			vboxExceptionInfo.PackStart (frame, false, true, 0);
+
 			stackStore = new TreeStore (typeof(string), typeof(string), typeof(int), typeof(int));
 			treeStack.Model = stackStore;
 			var crt = new CellRendererText ();
+			crt.Ellipsize = Pango.EllipsizeMode.End;
+			crt.WrapWidth = -1;
 			treeStack.AppendColumn ("", crt, "markup", 0);
 			treeStack.ShowExpanders = false;
+			treeStack.RulesHint = true;
 			
 			valueView.AllowExpanding = true;
 			valueView.Frame = DebuggingService.CurrentFrame;
 			this.exception = exception;
 			
 			exception.Changed += HandleExceptionChanged;
-			treeStack.SizeAllocated += delegate(object o, SizeAllocatedArgs args) {
-				if (crt.WrapWidth != args.Allocation.Width)
-					crt.WrapWidth = args.Allocation.Width;
-			};
+			treeStack.SizeAllocated += (object o, SizeAllocatedArgs args) => crt.WrapWidth = args.Allocation.Width;
 			
 			Fill ();
 			treeStack.RowActivated += HandleRowActivated;
@@ -68,11 +73,13 @@ public ExceptionCaughtWidget (ExceptionInfo exception)
 
 		void HandleRowActivated (object o, RowActivatedArgs args)
 		{
-			Gtk.TreeIter it;
-			if (!stackStore.GetIter (out it, args.Path))
+			TreeIter iter;
+
+			if (!stackStore.GetIter (out iter, args.Path))
 				return;
-			string file = (string) stackStore.GetValue (it, 1);
-			int line = (int) stackStore.GetValue (it, 2);
+
+			string file = (string) stackStore.GetValue (iter, 1);
+			int line = (int) stackStore.GetValue (iter, 2);
 			if (!string.IsNullOrEmpty (file))
 				IdeApp.Workbench.OpenDocument (file, line, 0);
 		}
@@ -103,6 +110,7 @@ void Fill ()
 				valueView.AddValue (exception.Instance);
 				valueView.ExpandRow (new TreePath ("0"), false);
 			}
+
 			if (exception.StackIsEvaluating) {
 				stackStore.AppendValues (GettextCatalog.GetString ("Loading..."), "", 0, 0);
 			}
@@ -110,11 +118,12 @@ void Fill ()
 		
 		void ShowStackTrace (ExceptionInfo exc, bool showExceptionNode)
 		{
-			TreeIter it = TreeIter.Zero;
+			TreeIter iter = TreeIter.Zero;
+
 			if (showExceptionNode) {
 				treeStack.ShowExpanders = true;
 				string tn = exc.Type + ": " + exc.Message;
-				it = stackStore.AppendValues (tn, null, 0, 0);
+				iter = stackStore.AppendValues (tn, null, 0, 0);
 			}
 
 			foreach (ExceptionStackFrame frame in exc.StackTrace) {
@@ -129,8 +138,8 @@ void ShowStackTrace (ExceptionInfo exc, bool showExceptionNode)
 					text += "</small>";
 				}
 
-				if (!it.Equals (TreeIter.Zero))
-					stackStore.AppendValues (it, text, frame.File, frame.Line, frame.Column);
+				if (!iter.Equals (TreeIter.Zero))
+					stackStore.AppendValues (iter, text, frame.File, frame.Line, frame.Column);
 				else
 					stackStore.AppendValues (text, frame.File, frame.Line, frame.Column);
 			}
@@ -150,9 +159,9 @@ protected override void OnDestroyed ()
 
 	class ExceptionCaughtDialog: Gtk.Dialog
 	{
-		ExceptionCaughtWidget widget;
-		ExceptionInfo ex;
-		ExceptionCaughtMessage msg;
+		readonly ExceptionCaughtWidget widget;
+		readonly ExceptionCaughtMessage msg;
+		readonly ExceptionInfo ex;
 
 		public ExceptionCaughtDialog (ExceptionInfo val, ExceptionCaughtMessage msg)
 		{
@@ -393,7 +402,7 @@ void LoadData ()
 
 	class ExceptionCaughtMiniButton: TopLevelWidgetExtension
 	{
-		ExceptionCaughtMessage dlg;
+		readonly ExceptionCaughtMessage dlg;
 
 		public ExceptionCaughtMiniButton (ExceptionCaughtMessage dlg, FilePath file, int line)
 		{

Modified: main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs
===================================================================
@@ -45,7 +45,7 @@
 namespace MonoDevelop.Debugger
 {
 	[System.ComponentModel.ToolboxItem (true)]
-	public class ObjectValueTreeView: TreeView, ICompletionWidget
+	public class ObjectValueTreeView : TreeView, ICompletionWidget
 	{
 		readonly Dictionary<ObjectValue, TreeRowReference> nodes = new Dictionary<ObjectValue, TreeRowReference> ();
 		readonly Dictionary<string, ObjectValue> cachedValues = new Dictionary<string, ObjectValue> ();

Modified: main/src/addins/MonoDevelop.Debugger/gtk-gui/MonoDevelop.Debugger.ExceptionCaughtWidget.cs
===================================================================
@@ -73,8 +73,6 @@ protected virtual void Build ()
 			this.hbox2.Add (this.vboxExceptionInfo);
 			global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.vboxExceptionInfo]));
 			w4.Position = 1;
-			w4.Expand = false;
-			w4.Fill = false;
 			this.vbox2.Add (this.hbox2);
 			global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox2]));
 			w5.Position = 0;

Modified: main/src/addins/MonoDevelop.Debugger/gtk-gui/gui.stetic
===================================================================
@@ -1820,9 +1820,7 @@ Break when the hit count is a multiple of</property>
                   </widget>
                   <packing>
                     <property name="Position">1</property>
-                    <property name="AutoSize">True</property>
-                    <property name="Expand">False</property>
-                    <property name="Fill">False</property>
+                    <property name="AutoSize">False</property>
                   </packing>
                 </child>
               </widget>


_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches