Browse Source

Fixed SD2-755: Partial classes in class browser

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1297 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
c6688222c1
  1. 2
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/AbstractDesignerGenerator.cs
  2. 2
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/NRefactoryDesignerLoader.cs
  3. 6
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/SecondaryDisplayBinding.cs
  4. 6
      src/Main/Base/Project/Src/Dom/IClass.cs
  5. 5
      src/Main/Base/Project/Src/Dom/Implementations/DefaultClass.cs
  6. 4
      src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/ClassBrowser.cs
  7. 25
      src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ProjectNode.cs
  8. 12
      src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs
  9. 2
      src/Main/Base/Project/Src/TextEditor/Commands/ClassBookmarkMenuBuilder.cs
  10. 2
      src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/CodeGenerator.cs
  11. 2
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/QuickClassBrowserPanel.cs

2
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/AbstractDesignerGenerator.cs

@ -303,7 +303,7 @@ namespace ICSharpCode.FormsDesigner @@ -303,7 +303,7 @@ namespace ICSharpCode.FormsDesigner
tabs = line.Substring(0, line.Length - line.TrimStart().Length);
}
this.c = c;
this.completeClass = c.DefaultReturnType.GetUnderlyingClass();
this.completeClass = c.GetCompoundClass();
this.formClass = initializeComponents.DeclaringType;
break;
}

2
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/NRefactoryDesignerLoader.cs

@ -150,7 +150,7 @@ namespace ICSharpCode.FormsDesigner @@ -150,7 +150,7 @@ namespace ICSharpCode.FormsDesigner
throw new FormsDesignerLoadException("No class derived from Form or UserControl was found.");
// Initialize designer for formClass
formClass = formClass.DefaultReturnType.GetUnderlyingClass();
formClass = formClass.GetCompoundClass();
List<IClass> parts;
if (formClass is CompoundClass) {
parts = (formClass as CompoundClass).Parts;

6
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/SecondaryDisplayBinding.cs

@ -37,9 +37,7 @@ namespace ICSharpCode.FormsDesigner @@ -37,9 +37,7 @@ namespace ICSharpCode.FormsDesigner
public static IMethod GetInitializeComponents(IClass c)
{
c = c.DefaultReturnType.GetUnderlyingClass();
if (c == null)
return null;
c = c.GetCompoundClass();
foreach (IMethod method in c.Methods) {
if (IsInitializeComponentsMethodName(method.Name) && method.Parameters.Count == 0) {
return method;
@ -51,7 +49,7 @@ namespace ICSharpCode.FormsDesigner @@ -51,7 +49,7 @@ namespace ICSharpCode.FormsDesigner
public static bool BaseClassIsFormOrControl(IClass c)
{
// Simple test for fully qualified name
c = c.DefaultReturnType.GetUnderlyingClass();
c = c.GetCompoundClass();
foreach (IReturnType baseType in c.BaseTypes) {
if (baseType.FullyQualifiedName == "System.Windows.Forms.Form"
|| baseType.FullyQualifiedName == "System.Windows.Forms.UserControl"

6
src/Main/Base/Project/Src/Dom/IClass.cs

@ -102,6 +102,12 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -102,6 +102,12 @@ namespace ICSharpCode.SharpDevelop.Dom
get;
}
/// <summary>
/// If this is a partial class, gets the compound class containing information from all parts.
/// If this is not a partial class, a reference to this class is returned.
/// </summary>
IClass GetCompoundClass();
IClass GetInnermostClass(int caretLine, int caretColumn);
List<IClass> GetAccessibleTypes(IClass callingClass);

5
src/Main/Base/Project/Src/Dom/Implementations/DefaultClass.cs

@ -126,6 +126,11 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -126,6 +126,11 @@ namespace ICSharpCode.SharpDevelop.Dom
}
}
public IClass GetCompoundClass()
{
return this.DefaultReturnType.GetUnderlyingClass() ?? this;
}
protected override void OnFullyQualifiedNameChanged(EventArgs e)
{
base.OnFullyQualifiedNameChanged(e);

4
src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/ClassBrowser.cs

@ -107,12 +107,11 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -107,12 +107,11 @@ namespace ICSharpCode.SharpDevelop.Gui
if (ProjectService.OpenSolution != null) {
ProjectServiceSolutionLoaded(null, null);
}
Application.Idle += new EventHandler(UpdateThread);
UpdateToolbars();
}
List<ICompilationUnit[]> pending = new List<ICompilationUnit[]> ();
void UpdateThread(object sender, EventArgs ea)
void UpdateThread()
{
lock (pending) {
foreach (ICompilationUnit[] units in pending) {
@ -134,6 +133,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -134,6 +133,7 @@ namespace ICSharpCode.SharpDevelop.Gui
lock (pending) {
pending.Add(new ICompilationUnit[] { e.ParseInformation.BestCompilationUnit as ICompilationUnit, e.CompilationUnit});
}
WorkbenchSingleton.SafeThreadAsyncCall(new MethodInvoker(UpdateThread));
}
#region Navigation

25
src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ProjectNode.cs

@ -53,7 +53,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -53,7 +53,7 @@ namespace ICSharpCode.SharpDevelop.Gui
if (oldUnit != null) {
foreach (IClass c in oldUnit.Classes) {
classDictionary[c.FullyQualifiedName] = c;
classDictionary[c.FullyQualifiedName] = c.GetCompoundClass();
wasUpdatedDictionary[c.FullyQualifiedName] = false;
}
}
@ -62,9 +62,9 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -62,9 +62,9 @@ namespace ICSharpCode.SharpDevelop.Gui
TreeNode path = GetNodeByPath(c.Namespace, true);
ClassNode node = GetNodeByName(path.Nodes, c.Name) as ClassNode;
if (node != null) {
node.Class = c;
node.Class = c.GetCompoundClass();
} else {
new ClassNode(project, c).AddTo(path);
new ClassNode(project, c.GetCompoundClass()).AddTo(path);
}
wasUpdatedDictionary[c.FullyQualifiedName] = true;
}
@ -74,10 +74,16 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -74,10 +74,16 @@ namespace ICSharpCode.SharpDevelop.Gui
IClass c = classDictionary[entry.Key];
TreeNode path = GetNodeByPath(c.Namespace, true);
TreeNode node = GetNodeByName(path.Nodes, c.Name);
ClassNode node = GetNodeByName(path.Nodes, c.Name) as ClassNode;
if (node != null) {
path.Nodes.Remove(node);
RemoveEmptyNamespace(path);
CompoundClass cc = c as CompoundClass;
if (cc != null && cc.Parts.Count > 0) {
node.Class = cc; // update members after part has been removed
} else {
path.Nodes.Remove(node);
RemoveEmptyNamespace(path);
}
}
}
}
@ -120,8 +126,11 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -120,8 +126,11 @@ namespace ICSharpCode.SharpDevelop.Gui
void InsertParseInformation(ICompilationUnit unit)
{
foreach (IClass c in unit.Classes) {
TreeNode node = GetNodeByPath(c.Namespace, true);
new ClassNode(project, c).AddTo(node);
TreeNode path = GetNodeByPath(c.Namespace, true);
TreeNode node = GetNodeByName(path.Nodes, c.Name);
if (node == null) {
new ClassNode(project, c.GetCompoundClass()).AddTo(path);
}
}
}

12
src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs

@ -27,7 +27,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -27,7 +27,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring
/// <param name="directDerivationOnly">If true, gets only the classes that derive directly from <paramref name="baseClass"/>.</param>
public static List<IClass> FindDerivedClasses(IClass baseClass, IEnumerable<IProjectContent> projectContents, bool directDerivationOnly)
{
baseClass = FixClass(baseClass);
baseClass = baseClass.GetCompoundClass();
string baseClassName = baseClass.Name;
string baseClassFullName = baseClass.FullyQualifiedName;
List<IClass> list = new List<IClass>();
@ -109,7 +109,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -109,7 +109,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring
files = new List<ProjectItem>();
files.Add(FindItem(ownerClass.CompilationUnit.FileName));
} else {
ownerClass = FixClass(ownerClass);
ownerClass = ownerClass.GetCompoundClass();
files = GetPossibleFiles(ownerClass, member);
}
ParseableFileContentEnumerator enumerator = new ParseableFileContentEnumerator(files.ToArray());
@ -236,14 +236,6 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -236,14 +236,6 @@ namespace ICSharpCode.SharpDevelop.Refactoring
return new Point(column, line);
}
/// <summary>
/// Gets the compound class if the class was partial.
/// </summary>
static IClass FixClass(IClass c)
{
return c.DefaultReturnType.GetUnderlyingClass();
}
public static List<string> GetFileNames(IClass c)
{
List<string> list = new List<string>();

2
src/Main/Base/Project/Src/TextEditor/Commands/ClassBookmarkMenuBuilder.cs

@ -146,7 +146,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -146,7 +146,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
public static void RenameClass(IClass c, string newName)
{
c = c.DefaultReturnType.GetUnderlyingClass(); // get compound class if class is partial
c = c.GetCompoundClass(); // get compound class if class is partial
List<Reference> list = RefactoringService.FindReferences(c, null);
if (list == null) return;

2
src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/CodeGenerator.cs

@ -27,7 +27,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -27,7 +27,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
public void Initialize(IClass currentClass)
{
this.currentClass = currentClass.DefaultReturnType.GetUnderlyingClass();
this.currentClass = currentClass.GetCompoundClass();
this.codeGen = currentClass.ProjectContent.Language.CodeGenerator;
this.classFinderContext = new ClassFinder(currentClass, currentClass.Region.BeginLine + 1, 0);
this.InitContent();

2
src/Main/Base/Project/Src/TextEditor/Gui/Editor/QuickClassBrowserPanel.cs

@ -338,7 +338,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -338,7 +338,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
bool partialMode = false;
IClass currentPart = c;
if (c.IsPartial) {
CompoundClass cc = c.DefaultReturnType.GetUnderlyingClass() as CompoundClass;
CompoundClass cc = c.GetCompoundClass() as CompoundClass;
if (cc != null && cc.Parts.Count > 0) {
partialMode = true;
c = cc;

Loading…
Cancel
Save