|
|
@ -38,14 +38,12 @@ namespace ICSharpCode.Decompiler.Ast.Transforms |
|
|
|
|
|
|
|
|
|
|
|
public void Run(AstNode compilationUnit) |
|
|
|
public void Run(AstNode compilationUnit) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!context.Settings.UsingDeclarations) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// First determine all the namespaces that need to be imported:
|
|
|
|
// First determine all the namespaces that need to be imported:
|
|
|
|
compilationUnit.AcceptVisitor(new FindRequiredImports(this), null); |
|
|
|
compilationUnit.AcceptVisitor(new FindRequiredImports(this), null); |
|
|
|
|
|
|
|
|
|
|
|
importedNamespaces.Add("System"); // always import System, even when not necessary
|
|
|
|
importedNamespaces.Add("System"); // always import System, even when not necessary
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (context.Settings.UsingDeclarations) { |
|
|
|
// Now add using declarations for those namespaces:
|
|
|
|
// Now add using declarations for those namespaces:
|
|
|
|
foreach (string ns in importedNamespaces.OrderByDescending(n => n)) { |
|
|
|
foreach (string ns in importedNamespaces.OrderByDescending(n => n)) { |
|
|
|
// we go backwards (OrderByDescending) through the list of namespaces because we insert them backwards
|
|
|
|
// we go backwards (OrderByDescending) through the list of namespaces because we insert them backwards
|
|
|
@ -57,6 +55,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms |
|
|
|
} |
|
|
|
} |
|
|
|
compilationUnit.InsertChildAfter(null, new UsingDeclaration { Import = nsType }, SyntaxTree.MemberRole); |
|
|
|
compilationUnit.InsertChildAfter(null, new UsingDeclaration { Import = nsType }, SyntaxTree.MemberRole); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!context.Settings.FullyQualifyAmbiguousTypeNames) |
|
|
|
if (!context.Settings.FullyQualifyAmbiguousTypeNames) |
|
|
|
return; |
|
|
|
return; |
|
|
|