diff --git a/ILSpy/Language.cs b/ILSpy/Language.cs index 9bdb4fc62..4cb85722f 100644 --- a/ILSpy/Language.cs +++ b/ILSpy/Language.cs @@ -28,6 +28,7 @@ using ICSharpCode.Decompiler.Ast; using ICSharpCode.Decompiler.Disassembler; using ICSharpCode.Decompiler.ILAst; using ICSharpCode.NRefactory.CSharp; +using ICSharpCode.NRefactory.Utils; using Mono.Cecil; namespace ICSharpCode.ILSpy @@ -40,17 +41,17 @@ namespace ICSharpCode.ILSpy /// /// Gets ot sets the code mappings /// - public Dictionary> CodeMappings { get; set; } + public Dictionary> CodeMappings { get; internal set; } /// /// Gets or sets the local variables. /// - public ConcurrentDictionary> LocalVariables { get; set; } + public ConcurrentDictionary> LocalVariables { get; internal set; } /// /// Gets the list of MembeReferences that are decompiled (TypeDefinitions, MethodDefinitions, etc) /// - public Dictionary DecompiledMemberReferences { get; set; } + public Dictionary DecompiledMemberReferences { get; internal set; } /// /// Gets (or internal sets) the AST nodes. @@ -187,11 +188,16 @@ namespace ICSharpCode.ILSpy { if (b is AstBuilder) { var builder = b as AstBuilder; + + var nodes = TreeTraversal + .PreOrder((AstNode)builder.CompilationUnit, n => n.Children) + .Where(n => n is AttributedNode && n.Annotation>() != null); + OnDecompilationFinished(new DecompileEventArgs { CodeMappings = builder.CodeMappings, LocalVariables = builder.LocalVariables, DecompiledMemberReferences = builder.DecompiledMemberReferences, - AstNodes = builder.CompilationUnit.GetNodesWithLineNumbers(n => n is AttributedNode) + AstNodes = nodes }); } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/CompilationUnit.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/CompilationUnit.cs index 94e168140..6053d6848 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/CompilationUnit.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/CompilationUnit.cs @@ -104,21 +104,6 @@ namespace ICSharpCode.NRefactory.CSharp } } - /// - /// Gets all nodes in that are satisfing a predicate. - /// - /// Predicate to filter the nodes. - /// - public IEnumerable GetNodesWithLineNumbers(Predicate predicate) - { - if (predicate == null) - throw new ArgumentNullException("predicate"); - - return TreeTraversal - .PreOrder((AstNode)this, n => n.Children) - .Where(n => predicate(n) && n.Annotation>() != null); - } - public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitCompilationUnit (this, data);