Browse Source

Move classes to separate files.

pull/234/merge
Ed Harvey 14 years ago
parent
commit
e32c170ec4
  1. 3
      ILSpy/ILSpy.csproj
  2. 104
      ILSpy/TreeNodes/BaseTypesEntryNode.cs
  3. 82
      ILSpy/TreeNodes/BaseTypesTreeNode.cs
  4. 111
      ILSpy/TreeNodes/DerivedTypesEntryNode.cs
  5. 93
      ILSpy/TreeNodes/DerivedTypesTreeNode.cs
  6. 40
      ILSpy/TreeNodes/FilterResult.cs
  7. 30
      ILSpy/TreeNodes/ILSpyTreeNode.cs

3
ILSpy/ILSpy.csproj

@ -158,6 +158,9 @@ @@ -158,6 +158,9 @@
<Compile Include="TreeNodes\Analyzer\AnalyzedVirtualMethodUsedByTreeNode.cs" />
<Compile Include="TreeNodes\Analyzer\Helpers.cs" />
<Compile Include="TreeNodes\Analyzer\ScopedWhereUsedAnalyzer.cs" />
<Compile Include="TreeNodes\BaseTypesEntryNode.cs" />
<Compile Include="TreeNodes\DerivedTypesEntryNode.cs" />
<Compile Include="TreeNodes\FilterResult.cs" />
<Compile Include="TreeNodes\IMemberTreeNode.cs" />
<Compile Include="TreeNodes\ResourceNodes\CursorResourceEntryNode.cs" />
<Compile Include="TreeNodes\ResourceNodes\ImageResourceEntryNode.cs" />

104
ILSpy/TreeNodes/BaseTypesEntryNode.cs

@ -0,0 +1,104 @@ @@ -0,0 +1,104 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Linq;
using ICSharpCode.Decompiler;
using ICSharpCode.TreeView;
using Mono.Cecil;
namespace ICSharpCode.ILSpy.TreeNodes
{
sealed class BaseTypesEntryNode : ILSpyTreeNode, IMemberTreeNode
{
private TypeReference tr;
private TypeDefinition def;
private bool isInterface;
public BaseTypesEntryNode(TypeReference tr, bool isInterface)
{
if (tr == null)
throw new ArgumentNullException("tr");
this.tr = tr;
this.def = tr.Resolve();
this.isInterface = isInterface;
this.LazyLoading = true;
}
public override bool ShowExpander
{
get { return def != null && (def.BaseType != null || def.HasInterfaces); }
}
public override object Text
{
get { return this.Language.TypeToString(tr, true); }
}
public override object Icon
{
get
{
if (def != null)
return TypeTreeNode.GetIcon(def);
else
return isInterface ? Images.Interface : Images.Class;
}
}
protected override void LoadChildren()
{
if (def != null)
BaseTypesTreeNode.AddBaseTypes(this.Children, def);
}
public override void ActivateItem(System.Windows.RoutedEventArgs e)
{
// on item activation, try to resolve once again (maybe the user loaded the assembly in the meantime)
if (def == null) {
def = tr.Resolve();
if (def != null)
this.LazyLoading = true;
// re-load children
}
e.Handled = ActivateItem(this, def);
}
internal static bool ActivateItem(SharpTreeNode node, TypeDefinition def)
{
if (def != null) {
var assemblyListNode = node.Ancestors().OfType<AssemblyListTreeNode>().FirstOrDefault();
if (assemblyListNode != null) {
assemblyListNode.Select(assemblyListNode.FindTypeNode(def));
return true;
}
}
return false;
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, language.TypeToString(tr, true));
}
MemberReference IMemberTreeNode.Member
{
get { return tr; }
}
}
}

82
ILSpy/TreeNodes/BaseTypesTreeNode.cs

@ -17,9 +17,7 @@ @@ -17,9 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Linq;
using System.Windows.Threading;
using ICSharpCode.Decompiler;
using ICSharpCode.TreeView;
using Mono.Cecil;
@ -39,11 +37,13 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -39,11 +37,13 @@ namespace ICSharpCode.ILSpy.TreeNodes
this.LazyLoading = true;
}
public override object Text {
public override object Text
{
get { return "Base Types"; }
}
public override object Icon {
public override object Icon
{
get { return Images.SuperTypes; }
}
@ -69,78 +69,4 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -69,78 +69,4 @@ namespace ICSharpCode.ILSpy.TreeNodes
}
}
}
sealed class BaseTypesEntryNode : ILSpyTreeNode, IMemberTreeNode
{
TypeReference tr;
TypeDefinition def;
bool isInterface;
public BaseTypesEntryNode(TypeReference tr, bool isInterface)
{
if (tr == null)
throw new ArgumentNullException("tr");
this.tr = tr;
this.def = tr.Resolve();
this.isInterface = isInterface;
this.LazyLoading = true;
}
public override bool ShowExpander {
get {
return def != null && (def.BaseType != null || def.HasInterfaces);
}
}
public override object Text {
get { return this.Language.TypeToString(tr, true); }
}
public override object Icon {
get {
if (def != null)
return TypeTreeNode.GetIcon(def);
else
return isInterface ? Images.Interface : Images.Class;
}
}
protected override void LoadChildren()
{
if (def != null)
BaseTypesTreeNode.AddBaseTypes(this.Children, def);
}
public override void ActivateItem(System.Windows.RoutedEventArgs e)
{
// on item activation, try to resolve once again (maybe the user loaded the assembly in the meantime)
if (def == null) {
def = tr.Resolve();
if (def != null)
this.LazyLoading = true; // re-load children
}
e.Handled = ActivateItem(this, def);
}
internal static bool ActivateItem(SharpTreeNode node, TypeDefinition def)
{
if (def != null) {
var assemblyListNode = node.Ancestors().OfType<AssemblyListTreeNode>().FirstOrDefault();
if (assemblyListNode != null) {
assemblyListNode.Select(assemblyListNode.FindTypeNode(def));
return true;
}
}
return false;
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, language.TypeToString(tr, true));
}
MemberReference IMemberTreeNode.Member {
get { return tr; }
}
}
}

111
ILSpy/TreeNodes/DerivedTypesEntryNode.cs

@ -0,0 +1,111 @@ @@ -0,0 +1,111 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Threading;
using ICSharpCode.Decompiler;
using Mono.Cecil;
namespace ICSharpCode.ILSpy.TreeNodes
{
class DerivedTypesEntryNode : ILSpyTreeNode, IMemberTreeNode
{
private TypeDefinition type;
private AssemblyDefinition[] assemblies;
private ThreadingSupport threading;
public DerivedTypesEntryNode(TypeDefinition type, AssemblyDefinition[] assemblies)
{
this.type = type;
this.assemblies = assemblies;
this.LazyLoading = true;
threading = new ThreadingSupport();
}
public override bool ShowExpander
{
get { return !type.IsSealed && base.ShowExpander; }
}
public override object Text
{
get { return this.Language.TypeToString(type, true); }
}
public override object Icon
{
get { return TypeTreeNode.GetIcon(type); }
}
public override FilterResult Filter(FilterSettings settings)
{
if (!settings.ShowInternalApi && !IsPublicAPI)
return FilterResult.Hidden;
if (settings.SearchTermMatches(type.Name)) {
if (type.IsNested && !settings.Language.ShowMember(type))
return FilterResult.Hidden;
else
return FilterResult.Match;
} else
return FilterResult.Recurse;
}
public bool IsPublicAPI
{
get
{
switch (type.Attributes & TypeAttributes.VisibilityMask) {
case TypeAttributes.Public:
case TypeAttributes.NestedPublic:
case TypeAttributes.NestedFamily:
case TypeAttributes.NestedFamORAssem:
return true;
default:
return false;
}
}
}
protected override void LoadChildren()
{
threading.LoadChildren(this, FetchChildren);
}
IEnumerable<ILSpyTreeNode> FetchChildren(CancellationToken ct)
{
// FetchChildren() runs on the main thread; but the enumerator will be consumed on a background thread
return DerivedTypesTreeNode.FindDerivedTypes(type, assemblies, ct);
}
public override void ActivateItem(System.Windows.RoutedEventArgs e)
{
e.Handled = BaseTypesEntryNode.ActivateItem(this, type);
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, language.TypeToString(type, true));
}
MemberReference IMemberTreeNode.Member
{
get { return type; }
}
}
}

93
ILSpy/TreeNodes/DerivedTypesTreeNode.cs

@ -20,7 +20,6 @@ using System; @@ -20,7 +20,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using ICSharpCode.Decompiler;
using ICSharpCode.NRefactory.Utils;
using Mono.Cecil;
@ -44,11 +43,13 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -44,11 +43,13 @@ namespace ICSharpCode.ILSpy.TreeNodes
this.threading = new ThreadingSupport();
}
public override object Text {
public override object Text
{
get { return "Derived Types"; }
}
public override object Icon {
public override object Icon
{
get { return Images.SubTypes; }
}
@ -102,90 +103,4 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -102,90 +103,4 @@ namespace ICSharpCode.ILSpy.TreeNodes
threading.Decompile(language, output, options, EnsureLazyChildren);
}
}
class DerivedTypesEntryNode : ILSpyTreeNode, IMemberTreeNode
{
TypeDefinition type;
AssemblyDefinition[] assemblies;
ThreadingSupport threading;
public DerivedTypesEntryNode(TypeDefinition type, AssemblyDefinition[] assemblies)
{
this.type = type;
this.assemblies = assemblies;
this.LazyLoading = true;
threading = new ThreadingSupport();
}
public override bool ShowExpander {
get {
return !type.IsSealed && base.ShowExpander;
}
}
public override object Text {
get { return this.Language.TypeToString(type, true); }
}
public override object Icon {
get {
return TypeTreeNode.GetIcon(type);
}
}
public override FilterResult Filter(FilterSettings settings)
{
if (!settings.ShowInternalApi && !IsPublicAPI)
return FilterResult.Hidden;
if (settings.SearchTermMatches(type.Name)) {
if (type.IsNested && !settings.Language.ShowMember(type))
return FilterResult.Hidden;
else
return FilterResult.Match;
} else {
return FilterResult.Recurse;
}
}
public bool IsPublicAPI
{
get
{
switch (type.Attributes & TypeAttributes.VisibilityMask) {
case TypeAttributes.Public:
case TypeAttributes.NestedPublic:
case TypeAttributes.NestedFamily:
case TypeAttributes.NestedFamORAssem:
return true;
default:
return false;
}
}
}
protected override void LoadChildren()
{
threading.LoadChildren(this, FetchChildren);
}
IEnumerable<ILSpyTreeNode> FetchChildren(CancellationToken ct)
{
// FetchChildren() runs on the main thread; but the enumerator will be consumed on a background thread
return DerivedTypesTreeNode.FindDerivedTypes(type, assemblies, ct);
}
public override void ActivateItem(System.Windows.RoutedEventArgs e)
{
e.Handled = BaseTypesEntryNode.ActivateItem(this, type);
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, language.TypeToString(type, true));
}
MemberReference IMemberTreeNode.Member {
get { return type; }
}
}
}

40
ILSpy/TreeNodes/FilterResult.cs

@ -0,0 +1,40 @@ @@ -0,0 +1,40 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
namespace ICSharpCode.ILSpy.TreeNodes
{
public enum FilterResult
{
/// <summary>
/// Hides the node.
/// </summary>
Hidden,
/// <summary>
/// Shows the node (and resets the search term for child nodes).
/// </summary>
Match,
/// <summary>
/// Hides the node only if all children are hidden (and resets the search term for child nodes).
/// </summary>
MatchAndRecurse,
/// <summary>
/// Hides the node only if all children are hidden (doesn't reset the search term for child nodes).
/// </summary>
Recurse
}
}

30
ILSpy/TreeNodes/ILSpyTreeNode.cs

@ -17,7 +17,6 @@ @@ -17,7 +17,6 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
@ -34,9 +33,11 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -34,9 +33,11 @@ namespace ICSharpCode.ILSpy.TreeNodes
FilterSettings filterSettings;
bool childrenNeedFiltering;
public FilterSettings FilterSettings {
public FilterSettings FilterSettings
{
get { return filterSettings; }
set {
set
{
if (filterSettings != value) {
filterSettings = value;
OnFilterSettingsChanged();
@ -44,7 +45,8 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -44,7 +45,8 @@ namespace ICSharpCode.ILSpy.TreeNodes
}
}
public Language Language {
public Language Language
{
get { return filterSettings != null ? filterSettings.Language : Languages.AllLanguages[0]; }
}
@ -165,24 +167,4 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -165,24 +167,4 @@ namespace ICSharpCode.ILSpy.TreeNodes
}
}
}
public enum FilterResult
{
/// <summary>
/// Hides the node.
/// </summary>
Hidden,
/// <summary>
/// Shows the node (and resets the search term for child nodes).
/// </summary>
Match,
/// <summary>
/// Hides the node only if all children are hidden (and resets the search term for child nodes).
/// </summary>
MatchAndRecurse,
/// <summary>
/// Hides the node only if all children are hidden (doesn't reset the search term for child nodes).
/// </summary>
Recurse
}
}
Loading…
Cancel
Save