Skip to content
Browse files

Merge NRefactory 5.2.0-261-g7a948e7 to ILSpy.

  • Loading branch information...
2 parents f10116f + 349d495 commit 214c1f730dfb65d090c7aff02c52b5e0bedac5dd @dgrunwald dgrunwald committed Aug 23, 2012
Showing with 16,594 additions and 8,496 deletions.
  1. +10 −14 Debugger/Debugger.Core/NRefactory/Visitors/ExpressionEvaluator.cs
  2. +19 −19 ICSharpCode.Decompiler/Ast/AstBuilder.cs
  3. +2 −2 ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs
  4. +5 −5 ICSharpCode.Decompiler/Ast/Transforms/CombineQueryExpressions.cs
  5. +1 −1 ICSharpCode.Decompiler/Ast/Transforms/ExpressionTreeConverter.cs
  6. +1 −1 ICSharpCode.Decompiler/Ast/Transforms/IntroduceUsingDeclarations.cs
  7. +1 −1 ICSharpCode.Decompiler/Tests/DecompilerTestBase.cs
  8. +1 −1 ICSharpCode.Decompiler/Tests/IL/ILTests.cs
  9. +1 −1 ICSharpCode.Decompiler/Tests/TestRunner.cs
  10. +3 −3 ILSpy/Languages/CSharpLanguage.cs
  11. +3 −3 ILSpy/Properties/app.config.template
  12. +1 −1 ILSpy/SearchPane.cs
  13. +1 −1 ILSpy/VB/ILSpyEnvironmentProvider.cs
  14. +2 −2 ILSpy/VB/VBLanguage.cs
  15. +4 −1 NRefactory/.gitignore
  16. +0 −3 NRefactory/ICSharpCode.NRefactory.CSharp.AstVerifier/.gitignore
  17. +68 −48 ...actory/ICSharpCode.NRefactory.CSharp.AstVerifier/ICSharpCode.NRefactory.CSharp.AstVerifier.csproj
  18. +1 −1 NRefactory/ICSharpCode.NRefactory.CSharp.AstVerifier/Main.cs
  19. +0 −3 NRefactory/ICSharpCode.NRefactory.CSharp/.gitignore
  20. +2 −1 NRefactory/ICSharpCode.NRefactory.CSharp/Analysis/ControlFlow.cs
  21. +2 −2 NRefactory/ICSharpCode.NRefactory.CSharp/Analysis/DefiniteAssignmentAnalysis.cs
  22. +42 −35 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs
  23. +16 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/AstNodeCollection.cs
  24. +3 −3 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/AstType.cs
  25. +29 −21 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/CSharpUtil.cs
  26. +1 −1 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/ComposedType.cs
  27. +4 −4 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/DepthFirstAstVisitor.cs
  28. +77 −2 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayInitializerExpression.cs
  29. +10 −1 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/IdentifierExpression.cs
  30. +10 −2 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/MemberReferenceExpression.cs
  31. +5 −5 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedArgumentExpression.cs
  32. +5 −5 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedExpression.cs
  33. +12 −3 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/PointerReferenceExpression.cs
  34. +1 −1 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NamespaceDeclaration.cs
  35. +8 −2 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/PreProcessorDirective.cs
  36. +3 −3 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/IAstVisitor.cs
  37. +2 −2 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/MemberType.cs
  38. +474 −818 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/ObservableAstVisitor.cs
  39. +1 −1 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/PrimitiveType.cs
  40. +2 −2 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/SimpleType.cs
  41. +33 −1 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/Statements/TryCatchStatement.cs
  42. +49 −36 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/{CompilationUnit.cs → SyntaxTree.cs}
  43. +12 −1 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/IndexerDeclaration.cs
  44. +1,201 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/old_ObservableAstVisitor.cs
  45. +118 −16 NRefactory/ICSharpCode.NRefactory.CSharp/CSharpProjectContent.cs
  46. +1,129 −642 NRefactory/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs
  47. +166 −253 NRefactory/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs
  48. +16 −168 NRefactory/ICSharpCode.NRefactory.CSharp/Completion/CSharpParameterCompletionEngine.cs
  49. +84 −74 NRefactory/ICSharpCode.NRefactory.CSharp/Completion/CompletionDataWrapper.cs
  50. +213 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Completion/ICompletionContextProvider.cs
  51. +3 −6 NRefactory/ICSharpCode.NRefactory.CSharp/Completion/ICompletionDataFactory.cs
  52. +339 −54 NRefactory/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs
  53. +76 −5 NRefactory/ICSharpCode.NRefactory.CSharp/Formatter/CSharpFormattingOptions.cs
  54. +116 −22 NRefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingOptionsFactory.cs
  55. +4 −2 NRefactory/ICSharpCode.NRefactory.CSharp/Formatter/GeneratedCodeSettings.cs
  56. +13 −1 NRefactory/ICSharpCode.NRefactory.CSharp/Formatter/Indent.cs
  57. +10 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Formatter/TextEditorOptions.cs
  58. +145 −14 NRefactory/ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj
  59. +1 −1 NRefactory/ICSharpCode.NRefactory.CSharp/{SimpleNameLookupMode.cs → NameLookupMode.cs}
  60. +13 −4 NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpOutputVisitor.cs
  61. +109 −34 NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs
  62. +609 −354 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
  63. +151 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/CompilerSettings.cs
  64. +103 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/SeekableStreamReader.cs
  65. +1 −1 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolFile.cs
  66. +49 −32 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolTable.cs
  67. +2 −2 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/SourceMethodBuilder.cs
  68. +53 −29 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs
  69. +8 −8 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/argument.cs
  70. +10 −3 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs
  71. +8 −8 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/assign.cs
  72. +5 −9 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/async.cs
  73. +44 −1 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/attribute.cs
  74. +20 −20 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/cfold.cs
  75. +35 −17 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs
  76. +14 −2 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/codegen.cs
  77. +1 −1 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/const.cs
  78. +25 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/context.cs
  79. +1 −2 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/convert.cs
  80. +4,766 −4,728 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs
  81. +128 −102 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay
  82. +163 −121 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs
  83. +10 −1 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs
  84. +4 −1 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/delegate.cs
  85. +11 −3 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/doc.cs
  86. +63 −12 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/driver.cs
  87. +1 −1 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/dynamic.cs
  88. +292 −173 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs
  89. +7 −4 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs
  90. +56 −18 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs
  91. +2 −3 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/field.cs
  92. +34 −50 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs
  93. +56 −15 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs
  94. +3 −1 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs
  95. +32 −22 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/location.cs
  96. +5 −2 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/membercache.cs
  97. +67 −23 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs
  98. +1 −1 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/module.cs
  99. +114 −47 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs
  100. +6 −6 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/nullable.cs
  101. +22 −18 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/outline.cs
  102. +21 −7 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs
  103. +8 −8 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs
  104. +36 −57 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs
  105. +54 −45 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs
  106. +8 −6 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/support.cs
  107. +26 −12 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/typemanager.cs
  108. +40 −6 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs
  109. +4 −3 NRefactory/ICSharpCode.NRefactory.CSharp/Parser/mcs/visit.cs
  110. +357 −0 NRefactory/ICSharpCode.NRefactory.CSharp/QueryExpressionExpander.cs
  111. +28 −2 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/BaseRefactoringContext.cs
  112. +2 −2 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/AddAnotherAccessorAction.cs
  113. +59 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/AddCatchTypeAction.cs
  114. +10 −4 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CheckIfParameterIsNullAction.cs
  115. +61 −0 ...y/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertAnonymousDelegateToLambdaAction.cs
  116. +44 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertAsToCastAction.cs
  117. +52 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertCastToAsAction.cs
  118. +146 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertConditionalToIfAction.cs
  119. +69 −0 ...rpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertExplicitToImplicitImplementationAction.cs
  120. +20 −12 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertForeachToForAction.cs
  121. +138 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertIfToConditionalAction.cs
  122. +193 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertIfToSwitchAction.cs
  123. +60 −0 ...rpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertImplicitToExplicitImplementationAction.cs
  124. +61 −0 ...arpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertLambdaBodyExpressionToStatementAction.cs
  125. +57 −0 ...arpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertLambdaBodyStatementToExpressionAction.cs
  126. +80 −0 ...y/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertLambdaToAnonymousDelegateAction.cs
  127. +147 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertSwitchToIfAction.cs
  128. +208 −0 ...Refactoring/CodeActions/ConvertToInitializer/ConvertInitializerToExplicitInitializationsAction.cs
  129. +109 −0 ...Code.NRefactory.CSharp/Refactoring/CodeActions/ConvertToInitializer/ConvertToInitializerAction.cs
  130. +180 −0 ...ory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertToInitializer/InitializerPath.cs
  131. +428 −0 ...Refactory.CSharp/Refactoring/CodeActions/ConvertToInitializer/StatementsToInitializerConverter.cs
  132. +2 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateBackingStoreAction.cs
  133. +5 −1 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateClassDeclarationAction.cs
  134. +6 −2 ...ctory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateConstructorDeclarationAction.cs
  135. +66 −0 ...ry/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateCustomEventImplementationAction.cs
  136. +15 −11 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateEventInvocatorAction.cs
  137. +57 −15 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateFieldAction.cs
  138. +4 −4 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateIndexerAction.cs
  139. +8 −7 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateMethodDeclarationAction.cs
  140. +140 −0 ...ory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateOverloadWithoutParameterAction.cs
  141. +12 −5 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreatePropertyAction.cs
  142. +69 −0 ...factory.CSharp/Refactoring/CodeActions/ExtensionMethodInvocationToStaticMethodInvocationAction.cs
  143. +117 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractAnonymousMethodAction.cs
  144. +93 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractFieldAction.cs
  145. +83 −62 ...actory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractMethod/ExtractMethodAction.cs
  146. +14 −9 ...tory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractMethod/VariableLookupVisitor.cs
  147. +146 −0 ...y/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractMethod/VariableUsageAnalyzation.cs
  148. +5 −2 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/GenerateGetterAction.cs
  149. +17 −7 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/GeneratePropertyAction.cs
  150. +116 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ImplementAbstractMembersAction.cs
  151. +179 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ImplementInterfaceAction.cs
  152. +68 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ImplementInterfaceExplicitAction.cs
  153. +3 −3 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/InlineLocalVariableAction.cs
  154. +3 −3 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/IntroduceConstantAction.cs
  155. +168 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/IterateViaForeachAction.cs
  156. +63 −0 ...ctory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/JoinDeclarationAndAssignmentAction.cs
  157. +62 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/JoinStringAction.cs
  158. +106 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/MergeNestedIfAction.cs
  159. +154 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/MoveToOuterScopeAction.cs
  160. +48 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/NegateRelationalExpressionAction.cs
  161. +147 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/PutInsideUsingAction.cs
  162. +5 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/RemoveBracesAction.cs
  163. +80 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/RemoveRedundantCatchTypeAction.cs
  164. +93 −0 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/SplitDeclarationListAction.cs
  165. +68 −0 ...factory.CSharp/Refactoring/CodeActions/StaticMethodInvocationToExtensionMethodInvocationAction.cs
  166. +1 −1 NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/UseExplicitTypeAction.cs
Sorry, we could not display the entire diff because too many files (584) changed.
View
24 Debugger/Debugger.Core/NRefactory/Visitors/ExpressionEvaluator.cs
@@ -73,14 +73,12 @@ public static AstNode Parse(string code, SupportedLanguage language)
switch (language) {
case SupportedLanguage.CSharp:
var parser = new CSharpParser();
- using (var textReader = new StringReader(code)) {
- AstNode astRoot = parser.ParseExpression(textReader);
- if (parser.HasErrors) {
- throw new GetValueException("Parser errors");
- }
-
- return astRoot;
+ AstNode astRoot = parser.ParseExpression(code);
+ if (parser.HasErrors) {
+ throw new GetValueException("Parser errors");
}
+
+ return astRoot;
default:
throw new ArgumentException("Unsuported language");
@@ -125,14 +123,12 @@ public static Expression ParseExpression(string code, SupportedLanguage language
switch (language) {
case SupportedLanguage.CSharp:
var parser = new CSharpParser();
- using (var textReader = new StringReader(code)) {
- AstNode astRoot = parser.ParseExpression(textReader);
- if (parser.HasErrors) {
- throw new GetValueException("Parser errors");
- }
-
- return astRoot as Expression;
+ AstNode astRoot = parser.ParseExpression(code);
+ if (parser.HasErrors) {
+ throw new GetValueException("Parser errors");
}
+
+ return astRoot as Expression;
default:
throw new ArgumentException("Unsuported language");
}
View
38 ICSharpCode.Decompiler/Ast/AstBuilder.cs
@@ -52,7 +52,7 @@ public enum ConvertTypeOptions
public class AstBuilder
{
DecompilerContext context;
- CompilationUnit astCompileUnit = new CompilationUnit();
+ SyntaxTree syntaxTree = new SyntaxTree();
Dictionary<string, NamespaceDeclaration> astNamespaces = new Dictionary<string, NamespaceDeclaration>();
bool transformationsHaveRun;
@@ -139,15 +139,15 @@ public void RunTransformations()
public void RunTransformations(Predicate<IAstTransform> transformAbortCondition)
{
- TransformationPipeline.RunTransformationsUntil(astCompileUnit, transformAbortCondition, context);
+ TransformationPipeline.RunTransformationsUntil(syntaxTree, transformAbortCondition, context);
transformationsHaveRun = true;
}
/// <summary>
/// Gets the abstract source tree.
/// </summary>
- public CompilationUnit CompilationUnit {
- get { return astCompileUnit; }
+ public SyntaxTree SyntaxTree {
+ get { return syntaxTree; }
}
/// <summary>
@@ -159,16 +159,16 @@ public void GenerateCode(ITextOutput output)
if (!transformationsHaveRun)
RunTransformations();
- astCompileUnit.AcceptVisitor(new InsertParenthesesVisitor { InsertParenthesesForReadability = true });
+ syntaxTree.AcceptVisitor(new InsertParenthesesVisitor { InsertParenthesesForReadability = true });
var outputFormatter = new TextOutputFormatter(output) { FoldBraces = context.Settings.FoldBraces };
var formattingPolicy = context.Settings.CSharpFormattingOptions;
- astCompileUnit.AcceptVisitor(new CSharpOutputVisitor(outputFormatter, formattingPolicy));
+ syntaxTree.AcceptVisitor(new CSharpOutputVisitor(outputFormatter, formattingPolicy));
}
public void AddAssembly(AssemblyDefinition assemblyDefinition, bool onlyAssemblyLevel = false)
{
if (assemblyDefinition.Name.Version != null) {
- astCompileUnit.AddChild(
+ syntaxTree.AddChild(
new AttributeSection {
AttributeTarget = "assembly",
Attributes = {
@@ -185,10 +185,10 @@ public void AddAssembly(AssemblyDefinition assemblyDefinition, bool onlyAssembly
}, EntityDeclaration.AttributeRole);
}
- ConvertCustomAttributes(astCompileUnit, assemblyDefinition, "assembly");
- ConvertSecurityAttributes(astCompileUnit, assemblyDefinition, "assembly");
- ConvertCustomAttributes(astCompileUnit, assemblyDefinition.MainModule, "module");
- AddTypeForwarderAttributes(astCompileUnit, assemblyDefinition.MainModule, "assembly");
+ ConvertCustomAttributes(syntaxTree, assemblyDefinition, "assembly");
+ ConvertSecurityAttributes(syntaxTree, assemblyDefinition, "assembly");
+ ConvertCustomAttributes(syntaxTree, assemblyDefinition.MainModule, "module");
+ AddTypeForwarderAttributes(syntaxTree, assemblyDefinition.MainModule, "assembly");
if (!onlyAssemblyLevel) {
foreach (TypeDefinition typeDef in assemblyDefinition.MainModule.Types) {
@@ -203,7 +203,7 @@ public void AddAssembly(AssemblyDefinition assemblyDefinition, bool onlyAssembly
}
}
- void AddTypeForwarderAttributes(CompilationUnit astCompileUnit, ModuleDefinition module, string target)
+ void AddTypeForwarderAttributes(SyntaxTree astCompileUnit, ModuleDefinition module, string target)
{
if (!module.HasExportedTypes)
return;
@@ -237,7 +237,7 @@ NamespaceDeclaration GetCodeNamespace(string name)
} else {
// Create the namespace
NamespaceDeclaration astNamespace = new NamespaceDeclaration { Name = name };
- astCompileUnit.AddChild(astNamespace, CompilationUnit.MemberRole);
+ syntaxTree.Members.Add(astNamespace);
astNamespaces[name] = astNamespace;
return astNamespace;
}
@@ -248,31 +248,31 @@ public void AddType(TypeDefinition typeDef)
var astType = CreateType(typeDef);
NamespaceDeclaration astNS = GetCodeNamespace(typeDef.Namespace);
if (astNS != null) {
- astNS.AddChild(astType, NamespaceDeclaration.MemberRole);
+ astNS.Members.Add(astType);
} else {
- astCompileUnit.AddChild(astType, CompilationUnit.MemberRole);
+ syntaxTree.Members.Add(astType);
}
}
public void AddMethod(MethodDefinition method)
{
AstNode node = method.IsConstructor ? (AstNode)CreateConstructor(method) : CreateMethod(method);
- astCompileUnit.AddChild(node, CompilationUnit.MemberRole);
+ syntaxTree.Members.Add(node);
}
public void AddProperty(PropertyDefinition property)
{
- astCompileUnit.AddChild(CreateProperty(property), CompilationUnit.MemberRole);
+ syntaxTree.Members.Add(CreateProperty(property));
}
public void AddField(FieldDefinition field)
{
- astCompileUnit.AddChild(CreateField(field), CompilationUnit.MemberRole);
+ syntaxTree.Members.Add(CreateField(field));
}
public void AddEvent(EventDefinition ev)
{
- astCompileUnit.AddChild(CreateEvent(ev), CompilationUnit.MemberRole);
+ syntaxTree.Members.Add(CreateEvent(ev));
}
/// <summary>
View
4 ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs
@@ -755,7 +755,7 @@ AstNode TransformByteCode(ILExpression byteCode)
for (int i = 0; i < args.Count; i++) {
atce.Initializers.Add(
new NamedExpression {
- Identifier = ctor.Parameters[i].Name,
+ Name = ctor.Parameters[i].Name,
Expression = args[i]
});
}
@@ -805,7 +805,7 @@ AstNode TransformByteCode(ILExpression byteCode)
MemberReferenceExpression mre = m.Get<MemberReferenceExpression>("left").Single();
initializer.Elements.Add(
new NamedExpression {
- Identifier = mre.MemberName,
+ Name = mre.MemberName,
Expression = m.Get<Expression>("right").Single().Detach()
}.CopyAnnotationsFrom(mre));
} else {
View
10 ICSharpCode.Decompiler/Ast/Transforms/CombineQueryExpressions.cs
@@ -82,11 +82,11 @@ void CombineQueries(AstNode node)
new AnonymousTypeCreateExpression {
Initializers = {
new NamedExpression {
- Identifier = Pattern.AnyString,
+ Name = Pattern.AnyString,
Expression = new IdentifierExpression(Pattern.AnyString)
}.WithName("nae1"),
new NamedExpression {
- Identifier = Pattern.AnyString,
+ Name = Pattern.AnyString,
Expression = new AnyNode("nae2Expr")
}.WithName("nae2")
}
@@ -114,11 +114,11 @@ bool TryRemoveTransparentIdentifier(QueryExpression query, QueryFromClause fromC
QuerySelectClause selectClause = (QuerySelectClause)innerQuery.Clauses.Last();
NamedExpression nae1 = match.Get<NamedExpression>("nae1").SingleOrDefault();
NamedExpression nae2 = match.Get<NamedExpression>("nae2").SingleOrDefault();
- if (nae1 != null && nae1.Identifier != ((IdentifierExpression)nae1.Expression).Identifier)
+ if (nae1 != null && nae1.Name != ((IdentifierExpression)nae1.Expression).Identifier)
return false;
Expression nae2Expr = match.Get<Expression>("nae2Expr").Single();
IdentifierExpression nae2IdentExpr = nae2Expr as IdentifierExpression;
- if (nae2IdentExpr != null && (nae2 == null || nae2.Identifier == nae2IdentExpr.Identifier)) {
+ if (nae2IdentExpr != null && (nae2 == null || nae2.Name == nae2IdentExpr.Identifier)) {
// from * in (from x in ... select new { x = x, y = y }) ...
// =>
// from x in ... ...
@@ -142,7 +142,7 @@ bool TryRemoveTransparentIdentifier(QueryExpression query, QueryFromClause fromC
}
string ident;
if (nae2 != null)
- ident = nae2.Identifier;
+ ident = nae2.Name;
else if (nae2Expr is IdentifierExpression)
ident = ((IdentifierExpression)nae2Expr).Identifier;
else if (nae2Expr is MemberReferenceExpression)
View
2 ICSharpCode.Decompiler/Ast/Transforms/ExpressionTreeConverter.cs
@@ -567,7 +567,7 @@ Expression ConvertNewObject(InvocationExpression invocation)
for (int i = 0; i < resolvedCtor.Parameters.Count; i++) {
atce.Initializers.Add(
new NamedExpression {
- Identifier = resolvedCtor.Parameters[i].Name,
+ Name = resolvedCtor.Parameters[i].Name,
Expression = arguments[i].Detach()
});
}
View
2 ICSharpCode.Decompiler/Ast/Transforms/IntroduceUsingDeclarations.cs
@@ -55,7 +55,7 @@ public void Run(AstNode compilationUnit)
for (int i = 1; i < parts.Length; i++) {
nsType = new MemberType { Target = nsType, MemberName = parts[i] };
}
- compilationUnit.InsertChildAfter(null, new UsingDeclaration { Import = nsType }, CompilationUnit.MemberRole);
+ compilationUnit.InsertChildAfter(null, new UsingDeclaration { Import = nsType }, SyntaxTree.MemberRole);
}
if (!context.Settings.FullyQualifyAmbiguousTypeNames)
View
2 ICSharpCode.Decompiler/Tests/DecompilerTestBase.cs
@@ -58,7 +58,7 @@ static string RoundtripCode(string code)
AssemblyDefinition assembly = Compile(code);
AstBuilder decompiler = new AstBuilder(new DecompilerContext(assembly.MainModule) { Settings = settings });
decompiler.AddAssembly(assembly);
- new Helpers.RemoveCompilerAttribute().Run(decompiler.CompilationUnit);
+ new Helpers.RemoveCompilerAttribute().Run(decompiler.SyntaxTree);
StringWriter output = new StringWriter();
decompiler.GenerateCode(new PlainTextOutput(output));
return output.ToString();
View
2 ICSharpCode.Decompiler/Tests/IL/ILTests.cs
@@ -42,7 +42,7 @@ void Run(string compiledFile, string expectedOutputFile)
var assembly = AssemblyDefinition.ReadAssembly(Path.Combine(path, compiledFile));
AstBuilder decompiler = new AstBuilder(new DecompilerContext(assembly.MainModule));
decompiler.AddAssembly(assembly);
- new Helpers.RemoveCompilerAttribute().Run(decompiler.CompilationUnit);
+ new Helpers.RemoveCompilerAttribute().Run(decompiler.SyntaxTree);
StringWriter output = new StringWriter();
decompiler.GenerateCode(new PlainTextOutput(output));
CodeAssert.AreEqual(expectedOutput, output.ToString());
View
2 ICSharpCode.Decompiler/Tests/TestRunner.cs
@@ -184,7 +184,7 @@ static void TestFile(string fileName, bool optimize, bool useDebug = false)
AssemblyDefinition assembly = Compile(code, optimize, useDebug);
AstBuilder decompiler = new AstBuilder(new DecompilerContext(assembly.MainModule));
decompiler.AddAssembly(assembly);
- new Helpers.RemoveCompilerAttribute().Run(decompiler.CompilationUnit);
+ new Helpers.RemoveCompilerAttribute().Run(decompiler.SyntaxTree);
StringWriter output = new StringWriter();
decompiler.GenerateCode(new PlainTextOutput(output));
CodeAssert.AreEqual(code, output.ToString());
View
6 ILSpy/Languages/CSharpLanguage.cs
@@ -212,10 +212,10 @@ void RunTransformsAndGenerateCode(AstBuilder astBuilder, ITextOutput output, Dec
{
astBuilder.RunTransformations(transformAbortCondition);
if (additionalTransform != null) {
- additionalTransform.Run(astBuilder.CompilationUnit);
+ additionalTransform.Run(astBuilder.SyntaxTree);
}
if (options.DecompilerSettings.ShowXmlDocumentation) {
- AddXmlDocTransform.Run(astBuilder.CompilationUnit);
+ AddXmlDocTransform.Run(astBuilder.SyntaxTree);
}
astBuilder.GenerateCode(output);
}
@@ -650,7 +650,7 @@ public override string GetTooltip(MemberReference member)
else
b.AddField(fd);
b.RunTransformations();
- foreach (var attribute in b.CompilationUnit.Descendants.OfType<AttributeSection>())
+ foreach (var attribute in b.SyntaxTree.Descendants.OfType<AttributeSection>())
attribute.Remove();
StringWriter w = new StringWriter();
View
6 ILSpy/Properties/app.config.template
@@ -17,15 +17,15 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ICSharpCode.NRefactory" publicKeyToken="d4bfe873e7598c49" culture="neutral"/>
- <bindingRedirect oldVersion="5.0.0.0-99.9.9.9" newVersion="5.0.0.6"/>
+ <bindingRedirect oldVersion="5.0.0.0-99.9.9.9" newVersion="5.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ICSharpCode.NRefactory.CSharp" publicKeyToken="d4bfe873e7598c49" culture="neutral"/>
- <bindingRedirect oldVersion="5.0.0.0-99.9.9.9" newVersion="5.0.0.6"/>
+ <bindingRedirect oldVersion="5.0.0.0-99.9.9.9" newVersion="5.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ICSharpCode.NRefactory.VB" publicKeyToken="d4bfe873e7598c49" culture="neutral"/>
- <bindingRedirect oldVersion="5.0.0.0-99.9.9.9" newVersion="5.0.0.6"/>
+ <bindingRedirect oldVersion="5.0.0.0-99.9.9.9" newVersion="5.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ICSharpCode.Decompiler" publicKeyToken="d4bfe873e7598c49" culture="neutral"/>
View
2 ILSpy/SearchPane.cs
@@ -217,7 +217,7 @@ public void Run()
if (1 == searchTerm.Length)
{
CSharpParser parser = new CSharpParser();
- PrimitiveExpression pe = parser.ParseExpression(new StringReader(searchTerm[0])) as PrimitiveExpression;
+ PrimitiveExpression pe = parser.ParseExpression(searchTerm[0]) as PrimitiveExpression;
if (pe != null && pe.Value != null) {
TypeCode peValueType = Type.GetTypeCode(pe.Value.GetType());
switch (peValueType) {
View
2 ILSpy/VB/ILSpyEnvironmentProvider.cs
@@ -36,7 +36,7 @@ public class ILSpyEnvironmentProvider : IEnvironmentProvider
}
}
- readonly CecilLoader loader = new CecilLoader(false);
+ readonly CecilLoader loader = new CecilLoader();
public string GetTypeNameForAttribute(ICSharpCode.NRefactory.CSharp.Attribute attribute)
{
View
4 ILSpy/VB/VBLanguage.cs
@@ -406,8 +406,8 @@ void RunTransformsAndGenerateCode(AstBuilder astBuilder, ITextOutput output, Dec
{
astBuilder.RunTransformations(transformAbortCondition);
if (options.DecompilerSettings.ShowXmlDocumentation)
- AddXmlDocTransform.Run(astBuilder.CompilationUnit);
- var csharpUnit = astBuilder.CompilationUnit;
+ AddXmlDocTransform.Run(astBuilder.SyntaxTree);
+ var csharpUnit = astBuilder.SyntaxTree;
csharpUnit.AcceptVisitor(new NRefactory.CSharp.InsertParenthesesVisitor() { InsertParenthesesForReadability = true });
var unit = csharpUnit.AcceptVisitor(new CSharpToVBConverterVisitor(new ILSpyEnvironmentProvider()), null);
var outputFormatter = new VBTextOutputFormatter(output);
View
5 NRefactory/.gitignore
@@ -1,2 +1,5 @@
+bin
+obj
/lib/*.dll
-/ICSharpCode.NRefactory.Tests/PartCover/*
+/ICSharpCode.NRefactory.Tests/PartCover/*
+_ReSharper*/*
View
3 NRefactory/ICSharpCode.NRefactory.CSharp.AstVerifier/.gitignore
@@ -1,3 +0,0 @@
-
-bin/
-obj/
View
116 ...CSharpCode.NRefactory.CSharp.AstVerifier/ICSharpCode.NRefactory.CSharp.AstVerifier.csproj
@@ -1,49 +1,69 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>10.0.0</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{961DADFA-7CE6-429F-BC22-47630D6DB826}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <RootNamespace>ICSharpCode.NRefactory.CSharp.AstVerifier</RootNamespace>
- <AssemblyName>AstVerifier</AssemblyName>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug</OutputPath>
- <DefineConstants>DEBUG;</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <Externalconsole>true</Externalconsole>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>none</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Release</OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <Externalconsole>true</Externalconsole>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Main.cs" />
- <Compile Include="AssemblyInfo.cs" />
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <ItemGroup>
- <ProjectReference Include="..\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj">
- <Project>{53DCA265-3C3C-42F9-B647-F72BA678122B}</Project>
- <Name>ICSharpCode.NRefactory.CSharp</Name>
- </ProjectReference>
- <ProjectReference Include="..\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
- <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
- <Name>ICSharpCode.NRefactory</Name>
- </ProjectReference>
- </ItemGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>10.0.0</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{961DADFA-7CE6-429F-BC22-47630D6DB826}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>ICSharpCode.NRefactory.CSharp.AstVerifier</RootNamespace>
+ <AssemblyName>AstVerifier</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Externalconsole>true</Externalconsole>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Externalconsole>true</Externalconsole>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_4_5_Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Externalconsole>true</Externalconsole>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_4_5_Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Externalconsole>true</Externalconsole>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Main.cs" />
+ <Compile Include="AssemblyInfo.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <ItemGroup>
+ <ProjectReference Include="..\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj">
+ <Project>{53DCA265-3C3C-42F9-B647-F72BA678122B}</Project>
+ <Name>ICSharpCode.NRefactory.CSharp</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
+ <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
+ <Name>ICSharpCode.NRefactory</Name>
+ </ProjectReference>
+ </ItemGroup>
</Project>
View
2 NRefactory/ICSharpCode.NRefactory.CSharp.AstVerifier/Main.cs
@@ -59,7 +59,7 @@ public static void Main (string[] args)
if (!file.EndsWith (".cs"))
continue;
string text = File.ReadAllText (file);
- var unit = CompilationUnit.Parse (text, file);
+ var unit = SyntaxTree.Parse (text, file);
if (unit == null)
continue;
string generated = unit.GetText ();
View
3 NRefactory/ICSharpCode.NRefactory.CSharp/.gitignore
@@ -1,3 +0,0 @@
-
-bin/
-obj/
View
3 NRefactory/ICSharpCode.NRefactory.CSharp/Analysis/ControlFlow.cs
@@ -599,7 +599,8 @@ public override ControlFlowNode VisitForStatement(ForStatement forStatement, Con
ControlFlowNode bodyStart = builder.CreateStartNode(forStatement.EmbeddedStatement);
ControlFlowNode bodyEnd = forStatement.EmbeddedStatement.AcceptVisitor(this, bodyStart);
- Connect(bodyEnd, iteratorStart);
+ if (bodyEnd != null)
+ Connect(bodyEnd, iteratorStart);
breakTargets.Pop();
continueTargets.Pop();
View
4 NRefactory/ICSharpCode.NRefactory.CSharp/Analysis/DefiniteAssignmentAnalysis.cs
@@ -443,7 +443,7 @@ protected override DefiniteAssignmentStatus VisitChildren(AstNode node, Definite
// the special values are valid as output only, not as input
Debug.Assert(data == CleanSpecialValues(data));
DefiniteAssignmentStatus status = data;
- foreach (AstNode child in node.Children) {
+ for (AstNode child = node.FirstChild; child != null; child = child.NextSibling) {
analysis.analysisCancellationToken.ThrowIfCancellationRequested();
Debug.Assert(!(child is Statement)); // statements are visited with the CFG, not with the visitor pattern
@@ -721,7 +721,7 @@ public override DefiniteAssignmentStatus VisitConditionalExpression(ConditionalE
}
DefiniteAssignmentStatus afterTrue = conditionalExpression.TrueExpression.AcceptVisitor(this, beforeTrue);
- DefiniteAssignmentStatus afterFalse = conditionalExpression.TrueExpression.AcceptVisitor(this, beforeFalse);
+ DefiniteAssignmentStatus afterFalse = conditionalExpression.FalseExpression.AcceptVisitor(this, beforeFalse);
return MergeStatus(CleanSpecialValues(afterTrue), CleanSpecialValues(afterFalse));
}
}
View
77 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs
@@ -1,4 +1,4 @@
-//
+//
// AstNode.cs
//
// Author:
@@ -23,6 +23,7 @@
// 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;
using System.Collections.Generic;
@@ -194,13 +195,13 @@ protected void ThrowIfFrozen()
/// <summary>
/// Gets the region from StartLocation to EndLocation for this node.
- /// The file name of the region is set based on the parent CompilationUnit's file name.
+ /// The file name of the region is set based on the parent SyntaxTree's file name.
/// If this node is not connected to a whole compilation, the file name will be null.
/// </summary>
public ICSharpCode.NRefactory.TypeSystem.DomRegion GetRegion()
{
- var cu = (this.Ancestors.LastOrDefault() ?? this) as CompilationUnit;
- string fileName = (cu != null ? cu.FileName : null);
+ var syntaxTree = (this.Ancestors.LastOrDefault() ?? this) as SyntaxTree;
+ string fileName = (syntaxTree != null ? syntaxTree.FileName : null);
return new ICSharpCode.NRefactory.TypeSystem.DomRegion(fileName, this.StartLocation, this.EndLocation);
}
@@ -288,17 +289,31 @@ void SetRole(Role role)
/// Gets all descendants of this node (excluding this node itself).
/// </summary>
public IEnumerable<AstNode> Descendants {
- get {
- return Utils.TreeTraversal.PreOrder (this.Children, n => n.Children);
- }
+ get { return GetDescendants(false); }
}
/// <summary>
/// Gets all descendants of this node (including this node itself).
/// </summary>
public IEnumerable<AstNode> DescendantsAndSelf {
- get {
- return Utils.TreeTraversal.PreOrder (this, n => n.Children);
+ get { return GetDescendants(true); }
+ }
+
+ IEnumerable<AstNode> GetDescendants(bool includeSelf)
+ {
+ if (includeSelf)
+ yield return this;
+ Stack<AstNode> nextStack = new Stack<AstNode>();
+ nextStack.Push(null);
+ AstNode pos = firstChild;
+ while (pos != null) {
+ if (pos.nextSibling != null)
+ nextStack.Push(pos.nextSibling);
+ yield return pos;
+ if (pos.firstChild != null)
+ pos = pos.firstChild;
+ else
+ pos = nextStack.Pop();
}
}
@@ -322,7 +337,7 @@ void SetRole(Role role)
{
return Ancestors.OfType<T>().FirstOrDefault();
}
-
+
public AstNodeCollection<T> GetChildrenByRole<T> (Role<T> role) where T : AstNode
{
return new AstNodeCollection<T> (this, role);
@@ -367,13 +382,6 @@ void AddChildUnsafe (AstNode child, Role role)
}
}
- public void InsertChildsBefore<T>(AstNode nextSibling, Role<T> role, params T[] child) where T : AstNode
- {
- foreach (var cur in child) {
- InsertChildBefore(nextSibling, cur, role);
- }
- }
-
public void InsertChildBefore<T> (AstNode nextSibling, T child, Role<T> role) where T : AstNode
{
if (role == null)
@@ -483,25 +491,24 @@ public void ReplaceWith (AstNode newNode)
newNode.SetRole(this.Role);
newNode.prevSibling = prevSibling;
newNode.nextSibling = nextSibling;
- if (parent != null) {
- if (prevSibling != null) {
- Debug.Assert (prevSibling.nextSibling == this);
- prevSibling.nextSibling = newNode;
- } else {
- Debug.Assert (parent.firstChild == this);
- parent.firstChild = newNode;
- }
- if (nextSibling != null) {
- Debug.Assert (nextSibling.prevSibling == this);
- nextSibling.prevSibling = newNode;
- } else {
- Debug.Assert (parent.lastChild == this);
- parent.lastChild = newNode;
- }
- parent = null;
- prevSibling = null;
- nextSibling = null;
+
+ if (prevSibling != null) {
+ Debug.Assert (prevSibling.nextSibling == this);
+ prevSibling.nextSibling = newNode;
+ } else {
+ Debug.Assert (parent.firstChild == this);
+ parent.firstChild = newNode;
+ }
+ if (nextSibling != null) {
+ Debug.Assert (nextSibling.prevSibling == this);
+ nextSibling.prevSibling = newNode;
+ } else {
+ Debug.Assert (parent.lastChild == this);
+ parent.lastChild = newNode;
}
+ parent = null;
+ prevSibling = null;
+ nextSibling = null;
}
public AstNode ReplaceWith (Func<AstNode, AstNode> replaceFunction)
View
16 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/AstNodeCollection.cs
@@ -204,5 +204,21 @@ public void InsertBefore(T existingItem, T newItem)
{
node.InsertChildBefore(existingItem, newItem, role);
}
+
+ /// <summary>
+ /// Applies the <paramref name="visitor"/> to all nodes in this collection.
+ /// </summary>
+ public void AcceptVisitor(IAstVisitor visitor)
+ {
+ AstNode next;
+ for (AstNode cur = node.FirstChild; cur != null; cur = next) {
+ Debug.Assert(cur.Parent == node);
+ // Remember next before yielding cur.
+ // This allows removing/replacing nodes while iterating through the list.
+ next = cur.NextSibling;
+ if (cur.Role == role)
+ cur.AcceptVisitor(visitor);
+ }
+ }
}
}
View
6 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/AstType.cs
@@ -58,7 +58,7 @@ protected internal override bool DoMatch(AstNode other, PatternMatching.Match ma
return other == null || other.IsNull;
}
- public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode)
+ public override ITypeReference ToTypeReference(NameLookupMode lookupMode)
{
return SpecialType.UnknownType;
}
@@ -99,7 +99,7 @@ public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
return visitor.VisitPatternPlaceholder (this, child, data);
}
- public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode)
+ public override ITypeReference ToTypeReference(NameLookupMode lookupMode)
{
throw new NotSupportedException();
}
@@ -135,7 +135,7 @@ public new AstType Clone()
/// For resolving simple names, the current namespace and usings from the CurrentUsingScope
/// (on CSharpTypeResolveContext only) is used.
/// </remarks>
- public abstract ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode = SimpleNameLookupMode.Type);
+ public abstract ITypeReference ToTypeReference(NameLookupMode lookupMode = NameLookupMode.Type);
/// <summary>
/// Creates a pointer type from this type by nesting it in a <see cref="ComposedType"/>.
View
50 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/CSharpUtil.cs
@@ -51,28 +51,11 @@ static Expression InvertConditionInternal (Expression condition)
if (condition is BinaryOperatorExpression) {
var bOp = (BinaryOperatorExpression)condition;
- switch (bOp.Operator) {
- case BinaryOperatorType.GreaterThan:
- bOp.Operator = BinaryOperatorType.LessThanOrEqual;
- return bOp;
- case BinaryOperatorType.GreaterThanOrEqual:
- bOp.Operator = BinaryOperatorType.LessThan;
- return bOp;
- case BinaryOperatorType.Equality:
- bOp.Operator = BinaryOperatorType.InEquality;
- return bOp;
- case BinaryOperatorType.InEquality:
- bOp.Operator = BinaryOperatorType.Equality;
- return bOp;
- case BinaryOperatorType.LessThan:
- bOp.Operator = BinaryOperatorType.GreaterThanOrEqual;
- return bOp;
- case BinaryOperatorType.LessThanOrEqual:
- bOp.Operator = BinaryOperatorType.GreaterThan;
- return bOp;
- default:
+ var negatedOp = NegateRelationalOperator (bOp.Operator);
+ if (negatedOp == BinaryOperatorType.Any)
return new UnaryOperatorExpression (UnaryOperatorType.Not, new ParenthesizedExpression (condition));
- }
+ bOp.Operator = negatedOp;
+ return bOp;
}
if (condition is ConditionalExpression) {
var cEx = condition as ConditionalExpression;
@@ -88,6 +71,31 @@ static Expression InvertConditionInternal (Expression condition)
return new UnaryOperatorExpression (UnaryOperatorType.Not, condition);
}
+
+ /// <summary>
+ /// Get negation of the specified relational operator
+ /// </summary>
+ /// <returns>
+ /// negation of the specified relational operator, or BinaryOperatorType.Any if it's not a relational operator
+ /// </returns>
+ public static BinaryOperatorType NegateRelationalOperator (BinaryOperatorType op)
+ {
+ switch (op) {
+ case BinaryOperatorType.GreaterThan:
+ return BinaryOperatorType.LessThanOrEqual;
+ case BinaryOperatorType.GreaterThanOrEqual:
+ return BinaryOperatorType.LessThan;
+ case BinaryOperatorType.Equality:
+ return BinaryOperatorType.InEquality;
+ case BinaryOperatorType.InEquality:
+ return BinaryOperatorType.Equality;
+ case BinaryOperatorType.LessThan:
+ return BinaryOperatorType.GreaterThanOrEqual;
+ case BinaryOperatorType.LessThanOrEqual:
+ return BinaryOperatorType.GreaterThan;
+ }
+ return BinaryOperatorType.Any;
+ }
}
}
View
2 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/ComposedType.cs
@@ -126,7 +126,7 @@ public override AstType MakeArrayType(int dimensions)
return this;
}
- public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode = SimpleNameLookupMode.Type)
+ public override ITypeReference ToTypeReference(NameLookupMode lookupMode = NameLookupMode.Type)
{
ITypeReference t = this.BaseType.ToTypeReference(lookupMode);
if (this.HasNullableSpecifier) {
View
8 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/DepthFirstAstVisitor.cs
@@ -44,9 +44,9 @@ protected virtual void VisitChildren (AstNode node)
}
}
- public virtual void VisitCompilationUnit (CompilationUnit unit)
+ public virtual void VisitSyntaxTree (SyntaxTree syntaxTree)
{
- VisitChildren (unit);
+ VisitChildren (syntaxTree);
}
public virtual void VisitComment(Comment comment)
@@ -642,7 +642,7 @@ protected virtual T VisitChildren (AstNode node)
return default (T);
}
- public virtual T VisitCompilationUnit (CompilationUnit unit)
+ public virtual T VisitSyntaxTree (SyntaxTree unit)
{
return VisitChildren (unit);
}
@@ -1240,7 +1240,7 @@ protected virtual S VisitChildren (AstNode node, T data)
return default (S);
}
- public virtual S VisitCompilationUnit (CompilationUnit unit, T data)
+ public virtual S VisitSyntaxTree (SyntaxTree unit, T data)
{
return VisitChildren (unit, data);
}
View
79 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayInitializerExpression.cs
@@ -33,6 +33,18 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class ArrayInitializerExpression : Expression
{
+ /// <summary>
+ /// For ease of use purposes in the resolver the ast representation
+ /// of { a, b, c } is { {a}, {b}, {c} }.
+ /// If IsSingleElement is true then this array initializer expression is a generated one.
+ /// That has no meaning in the source code (and contains no brace tokens).
+ /// </summary>
+ public virtual bool IsSingleElement {
+ get {
+ return false;
+ }
+ }
+
public ArrayInitializerExpression()
{
}
@@ -61,7 +73,7 @@ sealed class NullArrayInitializerExpression : ArrayInitializerExpression
public override void AcceptVisitor (IAstVisitor visitor)
{
}
-
+
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return default (T);
@@ -95,7 +107,7 @@ public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitArrayInitializerExpression (this);
}
-
+
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitArrayInitializerExpression (this);
@@ -111,6 +123,69 @@ protected internal override bool DoMatch(AstNode other, PatternMatching.Match ma
ArrayInitializerExpression o = other as ArrayInitializerExpression;
return o != null && this.Elements.DoMatch(o.Elements, match);
}
+
+ public static ArrayInitializerExpression CreateSingleElementInitializer ()
+ {
+ return new SingleArrayInitializerExpression();
+ }
+ /// <summary>
+ /// Single elements in array initializers are represented with this special class.
+ /// </summary>
+ class SingleArrayInitializerExpression : ArrayInitializerExpression
+ {
+ public override bool IsSingleElement {
+ get {
+ return true;
+ }
+ }
+
+ }
+
+ #region PatternPlaceholder
+ public static implicit operator ArrayInitializerExpression(PatternMatching.Pattern pattern)
+ {
+ return pattern != null ? new PatternPlaceholder(pattern) : null;
+ }
+
+ sealed class PatternPlaceholder : ArrayInitializerExpression, PatternMatching.INode
+ {
+ readonly PatternMatching.Pattern child;
+
+ public PatternPlaceholder(PatternMatching.Pattern child)
+ {
+ this.child = child;
+ }
+
+ public override NodeType NodeType {
+ get { return NodeType.Pattern; }
+ }
+
+ public override void AcceptVisitor (IAstVisitor visitor)
+ {
+ visitor.VisitPatternPlaceholder(this, child);
+ }
+
+ public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
+ {
+ return visitor.VisitPatternPlaceholder(this, child);
+ }
+
+ public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
+ {
+ return visitor.VisitPatternPlaceholder(this, child, data);
+ }
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ return child.DoMatch(other, match);
+ }
+
+ bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
+ {
+ return child.DoMatchCollection(role, pos, match, backtrackingInfo);
+ }
+ }
+ #endregion
}
}
View
11 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/IdentifierExpression.cs
@@ -55,7 +55,16 @@ public IdentifierExpression(string identifier, TextLocation location)
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value));
}
}
-
+
+ public Identifier IdentifierToken {
+ get {
+ return GetChildByRole (Roles.Identifier);
+ }
+ set {
+ SetChildByRole (Roles.Identifier, value);
+ }
+ }
+
public AstNodeCollection<AstType> TypeArguments {
get { return GetChildrenByRole (Roles.TypeArgument); }
}
View
12 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/MemberReferenceExpression.cs
@@ -34,8 +34,16 @@ namespace ICSharpCode.NRefactory.CSharp
public class MemberReferenceExpression : Expression
{
public Expression Target {
- get { return GetChildByRole (Roles.TargetExpression); }
- set { SetChildByRole(Roles.TargetExpression, value); }
+ get {
+ return GetChildByRole(Roles.TargetExpression);
+ }
+ set {
+ SetChildByRole(Roles.TargetExpression, value);
+ }
+ }
+
+ public CSharpTokenNode DotToken {
+ get { return GetChildByRole (Roles.Dot); }
}
public string MemberName {
View
10 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedArgumentExpression.cs
@@ -30,13 +30,13 @@ public NamedArgumentExpression()
{
}
- public NamedArgumentExpression(string identifier, Expression expression)
+ public NamedArgumentExpression(string name, Expression expression)
{
- this.Identifier = identifier;
+ this.Name = name;
this.Expression = expression;
}
- public string Identifier {
+ public string Name {
get {
return GetChildByRole (Roles.Identifier).Name;
}
@@ -45,7 +45,7 @@ public NamedArgumentExpression(string identifier, Expression expression)
}
}
- public Identifier IdentifierToken {
+ public Identifier NameToken {
get {
return GetChildByRole (Roles.Identifier);
}
@@ -81,7 +81,7 @@ public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
NamedArgumentExpression o = other as NamedArgumentExpression;
- return o != null && MatchString(this.Identifier, o.Identifier) && this.Expression.DoMatch(o.Expression, match);
+ return o != null && MatchString(this.Name, o.Name) && this.Expression.DoMatch(o.Expression, match);
}
}
}
View
10 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedExpression.cs
@@ -40,13 +40,13 @@ public NamedExpression()
{
}
- public NamedExpression (string identifier, Expression expression)
+ public NamedExpression (string name, Expression expression)
{
- this.Identifier = identifier;
+ this.Name = name;
this.Expression = expression;
}
- public string Identifier {
+ public string Name {
get {
return GetChildByRole (Roles.Identifier).Name;
}
@@ -55,7 +55,7 @@ public NamedExpression (string identifier, Expression expression)
}
}
- public Identifier IdentifierToken {
+ public Identifier NameToken {
get {
return GetChildByRole (Roles.Identifier);
}
@@ -91,7 +91,7 @@ public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
var o = other as NamedExpression;
- return o != null && MatchString(this.Identifier, o.Identifier) && this.Expression.DoMatch(o.Expression, match);
+ return o != null && MatchString(this.Name, o.Name) && this.Expression.DoMatch(o.Expression, match);
}
}
}
View
15 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/PointerReferenceExpression.cs
@@ -43,13 +43,22 @@ public class PointerReferenceExpression : Expression
public CSharpTokenNode ArrowToken {
get { return GetChildByRole (ArrowRole); }
}
-
+
public string MemberName {
get {
return GetChildByRole (Roles.Identifier).Name;
}
set {
- SetChildByRole(Roles.Identifier, Identifier.Create (value));
+ SetChildByRole(Roles.Identifier, Identifier.Create (value));
+ }
+ }
+
+ public Identifier MemberNameToken {
+ get {
+ return GetChildByRole (Roles.Identifier);
+ }
+ set {
+ SetChildByRole (Roles.Identifier, value);
}
}
@@ -61,7 +70,7 @@ public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitPointerReferenceExpression (this);
}
-
+
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitPointerReferenceExpression (this);
View
2 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NamespaceDeclaration.cs
@@ -35,7 +35,7 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class NamespaceDeclaration : AstNode
{
- public static readonly Role<AstNode> MemberRole = CompilationUnit.MemberRole;
+ public static readonly Role<AstNode> MemberRole = SyntaxTree.MemberRole;
public override NodeType NodeType {
get {
View
10 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/PreProcessorDirective.cs
@@ -86,13 +86,19 @@ public class PreProcessorDirective : AstNode
}
}
- public PreProcessorDirective (PreProcessorDirectiveType type, TextLocation startLocation, TextLocation endLocation)
+ public PreProcessorDirective(PreProcessorDirectiveType type, TextLocation startLocation, TextLocation endLocation)
{
this.Type = type;
this.startLocation = startLocation;
this.endLocation = endLocation;
}
-
+
+ public PreProcessorDirective(PreProcessorDirectiveType type, string argument = null)
+ {
+ this.Type = type;
+ this.Argument = argument;
+ }
+
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitPreProcessorDirective (this);
View
6 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/IAstVisitor.cs
@@ -129,7 +129,7 @@ public interface IAstVisitor
void VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration);
void VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer);
- void VisitCompilationUnit(CompilationUnit compilationUnit);
+ void VisitSyntaxTree(SyntaxTree syntaxTree);
void VisitSimpleType(SimpleType simpleType);
void VisitMemberType(MemberType memberType);
void VisitComposedType(ComposedType composedType);
@@ -260,7 +260,7 @@ public interface IAstVisitor<out S>
S VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration);
S VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer);
- S VisitCompilationUnit(CompilationUnit compilationUnit);
+ S VisitSyntaxTree(SyntaxTree syntaxTree);
S VisitSimpleType(SimpleType simpleType);
S VisitMemberType(MemberType memberType);
S VisitComposedType(ComposedType composedType);
@@ -391,7 +391,7 @@ public interface IAstVisitor<in T, out S>
S VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration, T data);
S VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer, T data);
- S VisitCompilationUnit(CompilationUnit compilationUnit, T data);
+ S VisitSyntaxTree(SyntaxTree syntaxTree, T data);
S VisitSimpleType(SimpleType simpleType, T data);
S VisitMemberType(MemberType memberType, T data);
S VisitComposedType(ComposedType composedType, T data);
View
4 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/MemberType.cs
@@ -135,7 +135,7 @@ public override string ToString()
return b.ToString();
}
- public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode = SimpleNameLookupMode.Type)
+ public override ITypeReference ToTypeReference(NameLookupMode lookupMode = NameLookupMode.Type)
{
TypeOrNamespaceReference t;
if (this.IsDoubleColon) {
@@ -154,7 +154,7 @@ public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode =
foreach (var ta in this.TypeArguments) {
typeArguments.Add(ta.ToTypeReference(lookupMode));
}
- return new MemberTypeOrNamespaceReference(t, this.MemberName, typeArguments);
+ return new MemberTypeOrNamespaceReference(t, this.MemberName, typeArguments, lookupMode);
}
}
}
View
1,292 NRefactory/ICSharpCode.NRefactory.CSharp/Ast/ObservableAstVisitor.cs
@@ -1,6 +1,6 @@
//
// ObservableAstVisitor.cs
-//
+//
// Author:
// Mike Krüger <mkrueger@novell.com>
//
@@ -23,1178 +23,834 @@
// 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;
namespace ICSharpCode.NRefactory.CSharp
{
- public class ObservableAstVisitor<T, S>: IAstVisitor<T, S>
+ public class ObservableAstVisitor : IAstVisitor
{
- S VisitChildren (AstNode node, T data)
+ void Visit<T>(Action<T> enter, Action<T> leave, T node) where T : AstNode
{
+ if (enter != null)
+ enter(node);
AstNode next;
for (var child = node.FirstChild; child != null; child = next) {
// Store next to allow the loop to continue
- // if the visitor removes/replaces child.
+ // if the visitor removes/replaces children.
next = child.NextSibling;
- child.AcceptVisitor (this, data);
+ child.AcceptVisitor (this);
}
- return default (S);
+ if (leave != null)
+ leave(node);
}
- public event Action<CompilationUnit, T> CompilationUnitVisited;
-
- S IAstVisitor<T, S>.VisitCompilationUnit (CompilationUnit unit, T data)
+ public event Action<SyntaxTree> EnterSyntaxTree, LeaveSyntaxTree;
+
+ void IAstVisitor.VisitSyntaxTree(SyntaxTree unit)
{
- var handler = CompilationUnitVisited;
- if (handler != null)
- handler (unit, data);
- return VisitChildren (unit, data);
+ Visit(EnterSyntaxTree, LeaveSyntaxTree, unit);
}
- public event Action<Comment, T> CommentVisited;
-
- S IAstVisitor<T, S>.VisitComment (Comment comment, T data)
+ public event Action<Comment> EnterComment, LeaveComment;
+
+ void IAstVisitor.VisitComment(Comment comment)
{
- var handler = CommentVisited;
- if (handler != null)
- handler (comment, data);
- return VisitChildren (comment, data);
+ Visit(EnterComment, LeaveComment, comment);
}
-
- public event Action<NewLineNode, T> NewLineVisited;
-
- S IAstVisitor<T, S>.VisitNewLine(NewLineNode newLineNode, T data)
+
+ public event Action<NewLineNode> EnterNewLine, LeaveNewLine;
+
+ void IAstVisitor.VisitNewLine(NewLineNode newLineNode)
{
- var handler = NewLineVisited;
- if (handler != null)
- handler(newLineNode, data);
- return VisitChildren(newLineNode, data);
+ Visit(EnterNewLine, LeaveNewLine, newLineNode);
}
-
- public event Action<WhitespaceNode, T> WhitespaceVisited;
-
- S IAstVisitor<T, S>.VisitWhitespace(WhitespaceNode whitespace, T data)
+
+ public event Action<WhitespaceNode> EnterWhitespace, LeaveWhitespace;
+
+ void IAstVisitor.VisitWhitespace(WhitespaceNode whitespace)
{
- var handler = WhitespaceVisited;
- if (handler != null)
- handler(whitespace, data);
- return VisitChildren(whitespace, data);
+ Visit(EnterWhitespace, LeaveWhitespace, whitespace);
}
-
- public event Action<TextNode, T> TextVisited;
-
- S IAstVisitor<T, S>.VisitText(TextNode textNode, T data)
+
+ public event Action<TextNode> EnterText, LeaveText;
+
+ void IAstVisitor.VisitText(TextNode textNode)
{
- var handler = TextVisited;
- if (handler != null)
- handler(textNode, data);
- return VisitChildren(textNode, data);
+ Visit(EnterText, LeaveText, textNode);
}
-
- public event Action<PreProcessorDirective, T> PreProcessorDirectiveVisited;
- S IAstVisitor<T, S>.VisitPreProcessorDirective (PreProcessorDirective preProcessorDirective, T data)
+
+ public event Action<PreProcessorDirective> EnterPreProcessorDirective, LeavePreProcessorDirective;
+ void IAstVisitor.VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective)
{
- var handler = PreProcessorDirectiveVisited;
- if (handler != null)
- handler (preProcessorDirective, data);
- return VisitChildren (preProcessorDirective, data);
+ Visit(EnterPreProcessorDirective, LeavePreProcessorDirective, preProcessorDirective);
}
- public event Action<DocumentationReference, T> DocumentationReferenceVisited;
-
- S IAstVisitor<T, S>.VisitDocumentationReference (DocumentationReference documentationReference, T data)
+ public event Action<DocumentationReference> EnterDocumentationReference, LeaveDocumentationReference;
+
+ void IAstVisitor.VisitDocumentationReference(DocumentationReference documentationReference)
{
- var handler = DocumentationReferenceVisited;
- if (handler != null)
- handler (documentationReference, data);
- return VisitChildren (documentationReference, data);
+ Visit(EnterDocumentationReference, LeaveDocumentationReference, documentationReference);
}
- public event Action<Identifier, T> IdentifierVisited;
-
- S IAstVisitor<T, S>.VisitIdentifier (Identifier identifier, T data)
+ public event Action<Identifier> EnterIdentifier, LeaveIdentifier;
+
+ void IAstVisitor.VisitIdentifier(Identifier identifier)
{
- var handler = IdentifierVisited;
- if (handler != null)
- handler (identifier, data);
- return VisitChildren (identifier, data);
+ Visit(EnterIdentifier, LeaveIdentifier, identifier);
}
- public event Action<CSharpTokenNode, T> CSharpTokenNodeVisited;
-
- S IAstVisitor<T, S>.VisitCSharpTokenNode (CSharpTokenNode token, T data)
+ public event Action<CSharpTokenNode> EnterCSharpTokenNode, LeaveCSharpTokenNode;
+
+ void IAstVisitor.VisitCSharpTokenNode(CSharpTokenNode token)
{
- var handler = CSharpTokenNodeVisited;
- if (handler != null)
- handler (token, data);
- return VisitChildren (token, data);
+ Visit(EnterCSharpTokenNode, LeaveCSharpTokenNode, token);
}
- public event Action<PrimitiveType, T> PrimitiveTypeVisited;
-
- S IAstVisitor<T, S>.VisitPrimitiveType (PrimitiveType primitiveType, T data)
+ public event Action<PrimitiveType> EnterPrimitiveType, LeavePrimitiveType;
+
+ void IAstVisitor.VisitPrimitiveType(PrimitiveType primitiveType)
{
- var handler = PrimitiveTypeVisited;
- if (handler != null)
- handler (primitiveType, data);
- return VisitChildren (primitiveType, data);
+ Visit(EnterPrimitiveType, LeavePrimitiveType, primitiveType);
}
- public event Action<ComposedType, T> ComposedTypeVisited;
-
- S IAstVisitor<T, S>.VisitComposedType (ComposedType composedType, T data)
+ public event Action<ComposedType> EnterComposedType, LeaveComposedType;
+
+ void IAstVisitor.VisitComposedType(ComposedType composedType)
{
- var handler = ComposedTypeVisited;
- if (handler != null)
- handler (composedType, data);
- return VisitChildren (composedType, data);
+ Visit(EnterComposedType, LeaveComposedType, composedType);
}
- public event Action<SimpleType, T> SimpleTypeVisited;
-
- S IAstVisitor<T, S>.VisitSimpleType (SimpleType simpleType, T data)
+ public event Action<SimpleType> EnterSimpleType, LeaveSimpleType;
+
+ void IAstVisitor.VisitSimpleType(SimpleType simpleType)
{
- var handler = SimpleTypeVisited;
- if (handler != null)
- handler (simpleType, data);
- return VisitChildren (simpleType, data);
+ Visit(EnterSimpleType, LeaveSimpleType, simpleType);
}
- public event Action<MemberType, T> MemberTypeVisited;
-
- S IAstVisitor<T, S>.VisitMemberType (MemberType memberType, T data)
+ public event Action<MemberType> EnterMemberType, LeaveMemberType;
+
+ void IAstVisitor.VisitMemberType(MemberType memberType)
{
- var handler = MemberTypeVisited;
- if (handler != null)
- handler (memberType, data);
- return VisitChildren (memberType, data);
+ Visit(EnterMemberType, LeaveMemberType, memberType);
}
- public event Action<Attribute, T> AttributeVisited;
-
- S IAstVisitor<T, S>.VisitAttribute (Attribute attribute, T data)
+ public event Action<Attribute> EnterAttribute, LeaveAttribute;
+
+ void IAstVisitor.VisitAttribute(Attribute attribute)
{
- var handler = AttributeVisited;
- if (handler != null)
- handler (attribute, data);
- return VisitChildren (attribute, data);
+ Visit(EnterAttribute, LeaveAttribute, attribute);
}
- public event Action<AttributeSection, T> AttributeSectionVisited;
-
- S IAstVisitor<T, S>.VisitAttributeSection (AttributeSection attributeSection, T data)
+ public event Action<AttributeSection> EnterAttributeSection, LeaveAttributeSection;
+
+ void IAstVisitor.VisitAttributeSection(AttributeSection attributeSection)
{
- var handler = AttributeSectionVisited;
- if (handler != null)
- handler (attributeSection, data);
- return VisitChildren (attributeSection, data);
+ Visit(EnterAttributeSection, LeaveAttributeSection, attributeSection);
}
- public event Action<DelegateDeclaration, T> DelegateDeclarationVisited;
-
- S IAstVisitor<T, S>.VisitDelegateDeclaration (DelegateDeclaration delegateDeclaration, T data)
+ public event Action<DelegateDeclaration> EnterDelegateDeclaration, LeaveDelegateDeclaration;
+
+ void IAstVisitor.VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration)
{
- var handler = DelegateDeclarationVisited;
- if (handler != null)
- handler (delegateDeclaration, data);
- return VisitChildren (delegateDeclaration, data);
+ Visit(EnterDelegateDeclaration, LeaveDelegateDeclaration, delegateDeclaration);
}
- public event Action<NamespaceDeclaration, T> NamespaceDeclarationVisited;
-
- S IAstVisitor<T, S>.VisitNamespaceDeclaration (NamespaceDeclaration namespaceDeclaration, T data)
+ public event Action<NamespaceDeclaration> EnterNamespaceDeclaration, LeaveNamespaceDeclaration;
+
+ void IAstVisitor.VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration)
{
- var handler = NamespaceDeclarationVisited;
- if (handler != null)
- handler (namespaceDeclaration, data);
- return VisitChildren (namespaceDeclaration, data);
+ Visit(EnterNamespaceDeclaration, LeaveNamespaceDeclaration, namespaceDeclaration);
}
- public event Action<TypeDeclaration, T> TypeDeclarationVisited;
-
- S IAstVisitor<T, S>.VisitTypeDeclaration (TypeDeclaration typeDeclaration, T data)
+ public event Action<TypeDeclaration> EnterTypeDeclaration, LeaveTypeDeclaration;
+
+ void IAstVisitor.VisitTypeDeclaration(TypeDeclaration typeDeclaration)
{
- var handler = TypeDeclarationVisited;
- if (handler != null)
- handler (typeDeclaration, data);
- return VisitChildren (typeDeclaration, data);
+ Visit(EnterTypeDeclaration, LeaveTypeDeclaration, typeDeclaration);
}
- public event Action<TypeParameterDeclaration, T> TypeParameterDeclarationVisited;
-
- S IAstVisitor<T, S>.VisitTypeParameterDeclaration (TypeParameterDeclaration typeParameterDeclaration, T data)
+ public event Action<TypeParameterDeclaration> EnterTypeParameterDeclaration, LeaveTypeParameterDeclaration;
+
+ void IAstVisitor.VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration)
{
- var handler = TypeParameterDeclarationVisited;
- if (handler != null)
- handler (typeParameterDeclaration, data);
- return VisitChildren (typeParameterDeclaration, data);
+ Visit(EnterTypeParameterDeclaration, LeaveTypeParameterDeclaration, typeParameterDeclaration);
}
- public event Action<EnumMemberDeclaration, T> EnumMemberDeclarationVisited;
-
- S IAstVisitor<T, S>.VisitEnumMemberDeclaration (EnumMemberDeclaration enumMemberDeclaration, T data)
+ public event Action<EnumMemberDeclaration> EnterEnumMemberDeclaration, LeaveEnumMemberDeclaration;
+
+ void IAstVisitor.VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration)
{
- var handler = EnumMemberDeclarationVisited;
- if (handler != null)
- handler (enumMemberDeclaration, data);
- return VisitChildren (enumMemberDeclaration, data);
+ Visit(EnterEnumMemberDeclaration, LeaveEnumMemberDeclaration, enumMemberDeclaration);
}
- public event Action<UsingDeclaration, T> UsingDeclarationVisited;
-
- S IAstVisitor<T, S>.VisitUsingDeclaration (UsingDeclaration usingDeclaration, T data)
+ public event Action<UsingDeclaration> EnterUsingDeclaration, LeaveUsingDeclaration;
+
+ void IAstVisitor.VisitUsingDeclaration(UsingDeclaration usingDeclaration)
{
- var handler = UsingDeclarationVisited;
- if (handler != null)
- handler (usingDeclaration, data);
- return VisitChildren (usingDeclaration, data);
+ Visit(EnterUsingDeclaration, LeaveUsingDeclaration, usingDeclaration);
}
- public event Action<UsingAliasDeclaration, T> UsingAliasDeclarationVisited;
-
- S IAstVisitor<T, S>.VisitUsingAliasDeclaration (UsingAliasDeclaration usingDeclaration, T data)
+ public event Action<UsingAliasDeclaration> EnterUsingAliasDeclaration, LeaveUsingAliasDeclaration;
+
+ void IAstVisitor.VisitUsingAliasDeclaration(UsingAliasDeclaration usingDeclaration)
{
- var handler = UsingAliasDeclarationVisited;
- if (handler != null)
- handler (usingDeclaration, data);
- return VisitChildren (usingDeclaration, data);
+ Visit(EnterUsingAliasDeclaration, LeaveUsingAliasDeclaration, usingDeclaration);
}
- public event Action<ExternAliasDeclaration, T> ExternAliasDeclarationVisited;
-
- S IAstVisitor<T, S>.VisitExternAliasDeclaration (ExternAliasDeclaration externAliasDeclaration, T data)
+ public event Action<ExternAliasDeclaration> EnterExternAliasDeclaration, LeaveExternAliasDeclaration;
+
+ void IAstVisitor.VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration)
{
- var handler = ExternAliasDeclarationVisited;
- if (handler != null)
- handler (externAliasDeclaration, data);
- return VisitChildren (externAliasDeclaration, data);
+ Visit(EnterExternAliasDeclaration, LeaveExternAliasDeclaration, externAliasDeclaration);
}
- public event Action<ConstructorDeclaration, T> ConstructorDeclarationVisited;
-
- S IAstVisitor<T, S>.VisitConstructorDeclaration (ConstructorDeclaration constructorDeclaration, T data)
+ public event Action<ConstructorDeclaration> EnterConstructorDeclaration, LeaveConstructorDeclaration;
+
+ void IAstVisitor.VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration)
{
- var handler = ConstructorDeclarationVisited;
- if (handler != null)
- handler (constructorDeclaration, data);
- return VisitChildren (constructorDeclaration, data);
+ Visit(EnterConstructorDeclaration, LeaveConstructorDeclaration, constructorDeclaration);
}
- public event Action<ConstructorInitializer, T> ConstructorInitializerVisited;
-
- S IAstVisitor<T, S>.VisitConstructorInitializer (ConstructorInitializer constructorInitializer, T data)
+ public event Action<ConstructorInitializer> EnterConstructorInitializer, LeaveConstructorInitializer;
+
+ void IAstVisitor.VisitConstructorInitializer(ConstructorInitializer constructorInitializer)
{
- var handler = ConstructorInitializerVisited;
- if (handler != null)
- handler (constructorInitializer, data);
- return VisitChildren (constructorInitializer, data);
+ Visit(EnterConstructorInitializer, LeaveConstructorInitializer, constructorInitializer);
}
- public event Action<DestructorDeclaration, T> DestructorDeclarationVisited;
-
- S IAstVisitor<T, S>.VisitDestructorDeclaration (DestructorDeclaration destructorDeclaration, T data)
+ public event Action<DestructorDeclaration> EnterDestructorDeclaration, LeaveDestructorDeclaration;
+
+ void IAstVisitor.VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration)
{
- var handler = DestructorDeclarationVisited;
- if (handler != null)
- handler (destructorDeclaration, data);
- return VisitChildren (destructorDeclaration, data);
+ Visit(EnterDestructorDeclaration, LeaveDestructorDeclaration, destructorDeclaration);
}
- public event Action<EventDeclaration, T> EventDeclarationVisited;
-
- S IAstVisitor<T, S>.VisitEventDeclaration (EventDeclaration eventDeclaration, T data)
+ public event Action<EventDeclaration> EnterEventDeclaration, LeaveEventDeclaration;
+
+ void IAstVisitor.VisitEventDeclaration(EventDeclaration eventDeclaration)
{
- var handler = EventDeclarationVisited;
- if (handler != null)
- handler (eventDeclaration, data);
- return VisitChildren (eventDeclaration, data);
+ Visit(EnterEventDeclaration, LeaveEventDeclaration, eventDeclaration);
}
- public event Action<CustomEventDeclaration, T> CustomEventDeclarationVisited;
-
- S IAstVisitor<T, S>.VisitCustomEventDeclaration (CustomEventDeclaration eventDeclaration, T data)
+ public event Action<CustomEventDeclaration> EnterCustomEventDeclaration, LeaveCustomEventDeclaration;
+
+ void IAstVisitor.VisitCustomEventDeclaration(CustomEventDeclaration eventDeclaration)
{
- var handler = CustomEventDeclarationVisited;
- if (handler != null)
- handler (eventDeclaration, data);
- return VisitChildren (eventDeclaration, data);
+ Visit(EnterCustomEventDeclaration, LeaveCustomEventDeclaration, eventDeclaration);
}
- public event Action<FieldDeclaration, T> FieldDeclarationVisited;
-
- S IAstVisitor<T, S>.VisitFieldDeclaration (FieldDeclaration fieldDeclaration, T data)
+ public event Action<FieldDeclaration> EnterFieldDeclaration, LeaveFieldDeclaration;
+
+ void IAstVisitor.VisitFieldDeclaration(FieldDeclaration fieldDeclaration)
{
- var handler = FieldDeclarationVisited;
- if (handler != null)
- handler (fieldDeclaration, data);
- return VisitChildren (fieldDeclaration, data);
+ Visit(EnterFieldDeclaration, LeaveFieldDeclaration, fieldDeclaration);
}
- public event Action<FixedFieldDeclaration, T> FixedFieldDeclarationVisited;
-
- S IAstVisitor<T, S>.VisitFixedFieldDeclaration (FixedFieldDeclaration fixedFieldDeclaration, T data)
+ public event Action<FixedFieldDeclaration> EnterFixedFieldDeclaration, LeaveFixedFieldDeclaration;
+
+ void IAstVisitor.VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration)
{
- var handler = FixedFieldDeclarationVisited;
- if (handler != null)
- handler (fixedFieldDeclaration, data);
- return VisitChildren (fixedFieldDeclaration, data);
+ Visit(EnterFixedFieldDeclaration, LeaveFixedFieldDeclaration, fixedFieldDeclaration);
}
- public event Action<FixedVariableInitializer, T> FixedVariableInitializerVisited;
-
- S IAstVisitor<T, S>.VisitFixedVariableInitializer (FixedVariableInitializer fixedVariableInitializer, T data)
+ public event Action<FixedVariableInitializer> EnterFixedVariableInitializer, LeaveFixedVariableInitializer;
+
+ void IAstVisitor.VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer)
{
- var handler = FixedVariableInitializerVisited;
- if (handler != null)
- handler (fixedVariableInitializer, data);
- return VisitChildren (fixedVariableInitializer, data);
+ Visit(EnterFixedVariableInitializer, LeaveFixedVariableInitializer, fixedVariableInitializer);
}
- public event Action<IndexerDeclaration, T> IndexerDeclarationVisited;
-
- S IAstVisitor<T, S>.VisitIndexerDeclaration (IndexerDeclaration indexerDeclaration, T data)
+ public event Action<IndexerDeclaration> EnterIndexerDeclaration, LeaveIndexerDeclaration;
+
+ void IAstVisitor.VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration)
{
- var handler = IndexerDeclarationVisited;
- if (handler != null)
- handler (indexerDeclaration, data);
- return VisitChildren (indexerDeclaration, data);
+ Visit(EnterIndexerDeclaration, LeaveIndexerDeclaration, indexerDeclaration);
}