Browse files

Make "expand automatic property" available in class member bookmark.

  • Loading branch information...
1 parent 7be3020 commit 19c6754f6c5290113161f9d145bba867dcfce726 @dgrunwald dgrunwald committed Sep 9, 2010
View
6 src/AddIns/Misc/SharpRefactoring/Project/SharpRefactoring.addin
@@ -54,7 +54,11 @@
<Class id="toString" class="SharpRefactoring.OverrideToStringMethodRefactoring" />
<Class id="equalsAndGetHashCode" class="SharpRefactoring.OverrideEqualsGetHashCodeMethodsRefactoring" />
</Path>
-
+
+ <Path name = "/SharpDevelop/ViewContent/DefaultTextEditor/ClassMemberContextMenu">
+ <MenuItem id="propertyRefactorings" type="Builder" class="SharpRefactoring.PropertyRefactoringMenuBuilder" />
+ </Path>
+
<Path name="/SharpDevelop/Pads/ClassBrowser/MemberContextMenu">
<MenuItem id="propertyRefactorings" type="Builder" class="SharpRefactoring.PropertyRefactoringMenuBuilder" />
</Path>
View
19 src/AddIns/Misc/SharpRefactoring/Project/Src/PropertyRefactoringMenuBuilder.cs
@@ -12,6 +12,7 @@
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Ast;
using ICSharpCode.SharpDevelop;
+using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.Refactoring;
using ICSharpCode.SharpDevelop.Editor;
@@ -33,10 +34,13 @@ public System.Windows.Forms.ToolStripItem[] BuildSubmenu(ICSharpCode.Core.Codon
List<System.Windows.Forms.ToolStripItem> items = new List<System.Windows.Forms.ToolStripItem>();
MenuCommand cmd;
- if (!(owner is ICSharpCode.SharpDevelop.Gui.ClassBrowser.MemberNode))
- return items.ToArray();
-
- IProperty property = (owner as ICSharpCode.SharpDevelop.Gui.ClassBrowser.MemberNode).Member as IProperty;
+ IProperty property;
+ if (owner is ICSharpCode.SharpDevelop.Gui.ClassBrowser.MemberNode)
+ property = ((ICSharpCode.SharpDevelop.Gui.ClassBrowser.MemberNode)owner).Member as IProperty;
+ else if (owner is ClassMemberBookmark)
+ property = ((ClassMemberBookmark)owner).Member as IProperty;
+ else
+ property = null;
if (property == null)
return items.ToArray();
@@ -64,8 +68,12 @@ public System.Windows.Forms.ToolStripItem[] BuildSubmenu(ICSharpCode.Core.Codon
return items.ToArray();
}
+ #region ExpandAutomaticProperty
internal static bool IsAutomaticProperty(IProperty property)
{
+ if (property.IsAbstract || property.DeclaringType.ClassType == ICSharpCode.SharpDevelop.Dom.ClassType.Interface)
+ return false;
+
string fileName = property.CompilationUnit.FileName;
if (fileName == null)
@@ -153,7 +161,9 @@ void ExpandAutomaticProperty(object sender, EventArgs e)
ParserService.ParseCurrentViewContent();
}
}
+ #endregion
+ #region ConvertToAutomaticProperty
bool IsSimpleProperty(ITextEditor editor, IProperty property, out Ast.PropertyDeclaration astProperty, out string fieldName)
{
astProperty = null;
@@ -299,5 +309,6 @@ void ConvertToAutomaticProperty(ITextEditor editor, IProperty property, IField f
}
}
}
+ #endregion
}
}

0 comments on commit 19c6754

Please sign in to comment.