Browse Source

Squashed 'NRefactory/' changes from b374e40..180a690

180a690 Create .pdb file in release build.
f074239 NRefactory 5.0.0.6 release.
11ab30b Added custom event declaration case to code settings.
e0f3421 Add support for type forwarders.
bb27ef5 Fixed completion bug.
86fede3 Fixed anther system.core 3.5 vs. 4.0 type lookup case.
b277e75 Fixed GetClassTypeReference resolving error. Use case: Lib uses System.Core 3.5, Project 4.0 - the 3.5 assembly can't be resolved in the project context.
7dd4c63 Updated formatting tests.
04f8720 Added formatting factory - formatting options should be created with that.
ca289f5 Improved array initializer wrapping options.
3ec1d7b Fixed exception in create method action.
42f6bfb Fixed completion bug.
64ca5a0 Fixed completion bug.
9511d48 Added KeepCommentsAtFirstColumn option.
c882a84 Added space in named argument formatting option.
0326e93 Fixed other enum base type context.
bd20152 Fixed enum base type bug.
bfb4d50 Merge branch 'master' of github.com:icsharpcode/NRefactory
c0b97ae Updated mcs/fixes some unit tests.
d9a88ce Changed the action text of remove backing store action.
629bdce Fixed extract method link bug.
8478cc6 Merge branch 'master' of github.com:icsharpcode/NRefactory
b8dd515 Updated mcs.
eec8403 Added new lines between generated members.
e499b7a Updated mcs.
1576e08 Added some generated code member categories.
0cbca24 Added whitespace and text node. They are needed anyways, now the ast should be theretically round-trip complete.
c7e1236 Added NewLine ast node.
3eff925 Fixed code completion exception.
14ca306 Added function to create a DA object to the refactoring context.
484c142 Added some documentation.
f94402f Made it easier to get the issues out of the gather visitor.
7509ba5 Applied patch by Mansheng Yang to improve the remove braces action.
66a365e Updated mcs.
3761df4 Merge branch 'master' of github.com:icsharpcode/NRefactory
90eadb3 Fixed completion bug.
6669636 Fixed bug in parameter completion.
265a9ec Merge branch 'master' of github.com:icsharpcode/NRefactory
3932a6e Fixed failing completion tests.
374f1cb Fixed parameter completion bug.
53acb15 * ICSharpCode.NRefactory.CSharp.csproj: * SpecializedCodeAction.cs: * ConvertDecToHexAction.cs: * GeneratePropertyAction.cs: * CheckIfParameterIsNullAction.cs:
075ffe3 Fixed completion category bug.
6b3da28 Revert "Changed refactoring context behaviour. It now works on adjacent nodes"
1465739 Changed refactoring context behaviour. It now works on adjacent nodes as well.
1bc751b Added end inclusive GetNodeAt to AstNode.
c114f71 Added unit tests for the open mcs nrefactory related bugs. We should ensure that mcs doesn't regress there.
eb6a774 Fixed some issues in the output visitor. Note that the block statement newline should be done more elegant (new lines should be done in the parent).
6c96156 [NRefactory] Fixed CurrentType check for some actions.
50aa6e0 Fixed a case where extract method returned null.
8111e26 Add issue provider for explicit conversions in foreach loops.
9e1d371 Fixed RedundantUsingIssue to no longer remove "System.Linq" if it is required for a query expression.
f098db8 Fix bugs in RedundantNamespaceUsageIssue and CreatePropertyAction.
0a8825e Fix build of NR.ConsistencyCheck.
656093a [FastSerializer] Added bugfix from Marek Safar.
3ccf18d ResolveAtLocation now uses resolve visitor navigator.
9e622c1 Create class action can now generate interface implementation. Need to think about that feature, maybe just adding the base type is better and letting the user choose implicit/explicit implementation ?
69a7136 Fixed remove brace action tests.
83d4cb2 Fixed link mode in extract method/introduce constant action.
8444dff Startet exctract method action.
b4b3e64 Improved type guessing.
ceef571 Added introduce constant action.
4644a07 Fixed method declaration case.
a627665 Merge branch 'master' of github.com:icsharpcode/NRefactory
bb4cafa Fixed null reference exception in control flow graph builder.
44f8d23 Merge branch 'master' of github.com:icsharpcode/NRefactory
cfe6272 Fixed possible null exception in control flow node.
8bb2301 Fixed tests.
769ea3e Merge branch 'master' of github.com:icsharpcode/NRefactory
a851b1c Fixed indenting behaviour of comments and directives.
444fe4e Make IParsedFile.LastWriteTime nullable.
048a4b9 Updated Fdg rules.
4f47170 Fixed type inference bug introduced in 2e40a34 - array covariance was ignored.
deb6bcd Add CancellationToken to AXmlParser.
b21e85f Updated indent engine.
2ec03c2 Added a text editor options class that contains options for text output.
e5d6452 Code completion name propsoal now uses the word parser to break words.
d85bb0e Fixed completion bug.
acce74e Fixed bug in create method declaration action.
5012f3f Handled static class <--> non static member clash in create field/method/property actions.
c3aea07 Turn off issue marker for var keyword issue (handled by action).
af87519 Removed debug message.
89ee8bc Allow '_' and 'm_' as field prefix name.
256dae8 Fixed create method declaration case.
34b3e18 Adjusted default Fdg rules a bit (private static fields are now camelCase).
62ebfc7 Disabled out name filter for create field,property and method.
b1dfdba Added create delegate action.
718dfe4 Added more cases for create class declaration.
93fb777 Added flag to specify if explict types should be used or not.
9e070b9 Hide not implemented exception issue in the text editor.
c33d15e Fixed bug where code actions could be null.
6b61741 Added create class declaration action.
d4f9318 Added create constructor declaration action/fixed bugs in other creation actions.
2d80884 Fixed failing unit tests.
bcf36de Fixed find type parameter references.
8c55a4e Fixed type parameter rename dialog action.
99270db Fixed type parameter naming.
795e6c8 Improved naming issue checking for some special cases of entities.
98e7a57 Fixed type parameter naming rule.
9ab32dc Fixed inconsistent naming issues.
a14ed3b Fixed inconsistent naming tests.
74e365b DeclareLocal variable action now links the identifiers.
1ca41d1 Added declare local variable action.
b6bdb90 Added inline local variable action.
9ec0d68 Added create indexer action.
627bbb7 Fixed parameter name guessing.
0b6ca98 Handled create method/property in other types.
635af4b Don't show create local/field/property on invocations.
402e112 Fixed create static field/property.
ee71c30 Merge branch 'master' of github.com:icsharpcode/NRefactory
a234f8b Create actions now respect naming convention settings.
ce7bdd7 Added IServiceProvided infrastructure for the refactoring context.
cb60935 Use ImproveDReturnAllResults type inference algorithm in GuessType.
b5bd653 Leave upper bounds empty.
1d3d3df Merge branch 'master' of github.com:icsharpcode/NRefactory
52ebb26 Added create method declaration action/use type inference to guess the correct type.
75b6cc6 Enabled generate getter/property tests.
0c6ea80 Fixed create field, local and property actions.
003b8c9 Added more entities & missing flags.
604011b Fixed check of visibility mask.
fcfbbdb Completed the features of the inconsistent naming issue.
0a55295 Added compiler warnings & errors issue categories.
5e7b449 Set namespace naming rule name.
3e256c4 Added default names for fdg naming rules.
293859f Naming rules now get their rules out of the refactoring context.
fba2d7c ITextSource.MoveOffsetTo: make AnchorMovementType parameter optional.
daa1cff Remove BaseRefactoringContext.StartScript().
439010a Added some inconsistent naming tests.
6b41506 Added missing is null or empty inspector cases.
41d5b50 Worked on inconsistent naming issue.
a179782 Fixed code completion bug.
193a153 Fixed completion bug.
e282837 Fixed parameter completion issue.
9fb443a Improved code issue tests - renamed some issues and actions.
296fc86 Fixed some translation strings/code issues can now offer more actions.
e54b06b Disable the failing unit tests.
6ef14c2 Added documentation for issue severity.
acfcf37 Changed the ContextAction/Inspector API.
3915a4c Add IsEligibleExtensionMethod to public API.
82af219 Added TranslateString method to the context.
ddc74b3 [UnitTests] Track API changes.
615248e Renamed InspectionIssue to CodeIssue.
436eab7 Corrected name token start/end node calls.
974879b Applied sharpdevelop formatting style.
b41059f Added check for links in the context action tests.
16ea65a Started to implement tests for the inspectors.
66dfd28 Fixed context action tests.
8e66275 Fixed unit test.
b6ad6d4 RedundantUsingInspector: visit simple type.
bf71baf Implemented redundant using inspector.
9771b6d Fix icsharpcode/NRefactory#33: Determining if a ThisResolveResult represents this. or base.
a3ced27 Simplified several inspectors. Includes some minor bugfixes.
61d6c02 Fixed loop variable bug.
8d0abbe Fix icsharpcode/NRefactory#30: Target of extension method invocation
d4dd164 Implemented the new options for overridden members in FindReferences.
3336a43 Fixed redundant this inspector.
df285ae Merge branch 'master' of github.com:icsharpcode/NRefactory
efa4b0b Added more inspectors.
ac49370 Simplify ConditionalToNullCoalescingInspector using pattern matching.
c3feace Merge branch 'master' of github.com:icsharpcode/NRefactory
141829a Started inspection API.
eab8372 Fixed resolver crash when resolving the arguments of an ObjectCreateExpression with unresolved type (e.g. due to missing using).
2e40a34 FindReferences: API idea for new options
b3acaaf Added support for specialized members to InheritanceHelper.GetBaseMember().
777be39 Rewrite of the substitution logic in SpecializedMember.
7474cdb Fixed member reference expression bug.
afbf9c9 Fixed for variable initializer name context.
af6c3b2 Updated mcs.
bf42e08 Add support for IReadOnlyList<T>.
e213758 Replace LazyInit.ReadBarrier() with LazyInit.VolatileRead().
1713776 Fixed warnings.
be4e8bb Added function to get the word segment at caret position.
af7cccf Merge branch 'master' of github.com:icsharpcode/NRefactory
54b3bae Fixed possible null reference exception.
f78b052 Fixed bug in override completion.
e2c8922 Fixed formatting filter.
d07356a Fixed ast formatter.
c51a5f6 Fixed stub mechanic.
29da952 Fixed some warnings.
6f4a46c Fixed failing unit test.
837d48d Completion engine now works on freezed compilation units.
40a00e7 GetMemberTextToCaret now gives back the correct member start location.
11b8c3b Removed IRelocatable infrastructure - the start line could now be altered in the lexer directly.
9393ea6 [Refactoring] Refactoring context resolver is now protected.
0907829 Fixed ref/out/params keywords.
d338acc Fix icsharpcode/NRefactory#18: ResolveResult for object creation
ab024b9 Fix icsharpcode/NRefactory#28: Identity of lambda parameters
a798d1a Fixed override completion data bug.
ce2e528 Documentation update.
47d7d5a Fix icsharpcode/NRefactory#29: NullReferenceException when using FindReferencedEntities navigator
08e6a88 AppendMissingClosingBrackets is now reusable.
51bd416 Correctly set OperatorResolveResult.IsLiftedOperator in more cases.
df380b6 Fixed potential cause of CSharpAstResolver.Resolve returning null.
e80f142 Fixed bug in CSharpAstResolver.GetExpectedType().
f74bf90 Make AstNode freezable.
4465839 Fixed error caused by Root role. Ok now I know why it needs to be there :)
2c97bfa Added more location checks / added -verbose command line option for the ast verifier.
6c5b439 Added little command line tool to test the AST roundtrip.
cf134db Fixed potential null reference exception.
da0d25b GtkDemo now uses standard text view.
3c350c1 Merge branch 'master' of github.com:icsharpcode/NRefactory
55f858e Fix icsharpcode/NRefactory#26: Static methods are reported as having "this" as the target
3ac1e56 Fix icsharpcode/NRefactory#22: Event accessors should be called add_X and remove_X
c27f57f Fix icsharpcode/NRefactory#25: OperatorResolveResult.IsLiftedOperator for unary operators
4ea7ebc Moved more roles to the Roles class/Changed TypeDeclaration representation (saves some memory and class type is now always defined).
749a13c formatting visitor now does either place if statement on new line or indent the embedded statement - not both.
cd349d2 Fixed some issues in the formatter.
0b3b290 Fixed case label indentation.
45cab9b Fixed an issue with overlapping segments/fixed failing unit test.
3503318 Track role name changes in nrefactory.c#.
6a0a96c Moved some roles to the Roles class.
90bf204 Moved the roles class out of AstNode.
e93009a Fixed context action unit tests.
5d33b31 Revert "Refactoring context now exposes the document instead of the document"
3d4550c Refactoring context now exposes the document instead of the document like functions.
b44d6c6 Fixed typo.
5e93376 Took out ifdef. (I suppose that patch wont make it upstream)
473f6a7 Added some additional bounds check. As the parser improves they may become required.
ae28762 Fixed destructor identifier.
b491ea8 Rename Conversions to CSharpConversions.
3df0cd3 Make CSharpAstResolver and Conversions thread-safe.
cf331bb Fixed resolving partial method definitions.
24d2d19 Use specialized method for MethodGroupConversion. icsharpcode/NRefactory#21
a731b93 Fix icsharpcode/NRefactory#19: OperatorResolveResult.IsLiftedOperator is false for lifted built-in operators.
3215504 Fix icsharpcode/NRefactory#20: Copy virtual/override/static/etc. modifiers from properties/events to accessor methods.
3fbcf2f Add support for partial methods.
c3d00d1 Add StringBuilderDocument to NR.Editor.
bcad2e1 DocumentScript bugfixes.
8179556 Add DocumentScript that implements Script using a mutable document.
c6ae6c3 Script refactoring.
61c4481 [FindReferences] Added destructor find support.
a76cab2 Merge branch 'master' of github.com:icsharpcode/NRefactory
cfe0d42 Made resolve result == null assertion more verbose.
abe5ca4 Merge branch 'master' of github.com:icsharpcode/NRefactory
fe8e098 Fixed some FxCop warnings.
cbd5a46 Enabled working unit test.
fdfdffb Fixed several query expression locations.
a360992 Fixed type parameter comma locations.
12c0472 Fixed incorrect parser positions in FixedStatement test.
5a9d33f Fixed attribute empty arglist parens.
f1fa0e0 Enabled working unit test.
d6d1f08 Fixed ignored unit test.
1100022 [UnitTests] Track API changes.
b4c1946 Added CancellationToken support for the context actions.
d0618b4 Set version number to 5.0.0.5.
eba0218 FindReferences for IEnumerator.Current now finds foreach statements.
b06160b No longer require a specifil nunit version.
5dfe563 Fixed naming.
96e434e Added GenerateProperty context action.
3e72441 Fix icsharpcode/NRefactory#16: Resolve the GetEnumerator call inside a foreach
fb0dbc9 Fix icsharpcode/NRefactory#17: Resolving "is" and "as" expressions loses the semantics
2ede14a Disabled loction changes by the #line directive.
1503054 TextReplace actions can now depend on each other.
4499d32 Fixed IsInsideDocComment method. TODO: Move the detection of comments & string regions to the IMemberProvider (needs rename) and handle that with a tree on IDE level.
e058867 Fixed interface return type tests.
6eaa0fd Fixed interface return type test.
05fc277 Added interface return types test.
36456b4 Updated mcs & improved try context handling.
fa2db3b Fixed anonymous method brace style formatting.
b13dad1 Resolve visitor change: If the type of an object create expression can't be resolved give back the type resolution failure. This is required to tell why the object creation couldn't be resolved.
11ab326 Readded the 'IsInside' function that checks the position inclusive the end location.
a55cbb4 Semantic change: Contains now excludes the end location.
964b6c0 Fixed unit test.
d284cbb Remove region context action is now more efficient in choosing the subtrees to analyze.
de443b7 Fixed possible exception in create event incocation context action.
a353f23 Combine AttributedNode and MemberDeclaration into EntityDeclaration.
b416f38 CSharpAmbience: allow passing in a custom IOutputFormatter.
d6f3c84 Replace ConversionFlags.UseFullyQualifiedMemberNames with ConversionFlags.ShowDeclaringType.
e8f0928 Add support for calling constructors on COM interfaces.
e436347 * AstFormattingVisitor.cs: Fixed bug in binary operator expression.
7451607 Added "RemoveRegion" context action.
b91ed7e Fixed get current parameter index.
c0deae7 Fixed 2 mcs issues.
3813344 Updated mcs & added unit test.
670975c Parameter data providers now contain the start offset of their expression (makes it easier to count the correct parameter number).
4575266 Filter out members that are not suited for code completion.
c1a777b Applied a similiar handling for field initializers than for the binary operator line breaks.
47c5b9f Improved binary operator line break handling.
e2b3043 Fixed using declaration context.
698164a Merge branch 'master' of github.com:icsharpcode/NRefactory
95ebebc Updated mcs.
008e961 Fixed build under mono.
ab7a24e Removed code duplication. btw. was the worst case of duplication - the methods should do the same but had slightly different semantics.
338bedc Used simpler Identifier.Create calls.
b0de873 Fixed some more attribute completion tests.
e394fb5 Added some more attribute context tests & fixes.
288ab73 Fixed some completion tests.
f49f142 Fixed parameter completion unit test.
47d00e1 Added banner style brace output format.
c22e11d Added banner style brace style.
a993df9 Use simpler IAstVisitor for InsertParenthesesVisitor and TypeSystemConvertVisitor.
2f85914 Use simpler IAstVisitor for ResolveVisitor.
3eee346 CSharpOutputVisitor is now using the IAstVisitor with void return type.
0ffe61e Trim whitespace within XmlDocumentationElements.
a0f7de3 Fixed modifier issues in TypeSystemAstBuilder
5bef6f2 Added some comments for the token classes.
3ae2fe7 The formatting visitor is now using an easier visitor pattern.
47bd60c Removed debug message.
24f5bc9 Fixed bug in operator declaration getrole function.
3ffbaa2 Refactored c# token representation, it's now more consistent with the other nodes and takes up a bit less memory.
73e63dd Added GetText function to AstNode.
196e618 Added some Parse methods to the compilation unit.
72d1381 Provided IAstVisitor and IAstVisitor<T> visitor patterns.
c180304 Fix DocumentationElement.IsTextNode for the root element.
d47cb9d Fix icsharpcode/NRefactory#15
944ba9c Fixed formatting bug.
14bf452 Rename InterfaceImplementations -> ImplementedInterfaceMembers.
274fe41 Add "XmlDocumentationElement", a simplified tree for XML documentation comments that expands "<inheritdoc/>"
18c96e0 Add support for multiline XML documentation comments.
59c9e99 DefaultResolvedTypeDefinition: lazily initialize the list of members.
e52e57e Fixed crash in CSharpAmbience on delegate declarations.
00743d5 Fix project options.
def9943 Add AXmlObject.CreateReader() method.
2c7c1c7 Fixed failing unit test, added a test to document a wrong parser behaviour.
54b6c57 Added some bounds checking.
cb576fb * ICSharpCode.NRefactory.csproj: * IdStringProvider.cs: * IDStringTests.cs: * DocumentationComment.cs: * IdStringMemberReference.cs: * XmlDocumentationProvider.cs: * IDStringConsistencyCheck.cs: * CSharpCrefLookupTests.cs: Renamed IDString -> IdString to follow   .NET naming guidelines.
a21ee06 Added easier string translation for documentation comment class.
d757e48 Fixed possible null reference exception.
c74577a Updated mcs.
d8d65fc Fixed code completion bug.
ca41af4 Add TagMatchingHeuristics.
ea14dc8 Updated parameter data provider interface.
d280684 Put properly nested elements into AXmlElement.
d62f366 Add null node for VariableInitializer.
32626ac Implemented incremental tag soup parser.
06bf2f4 Add consistency check for incremental tag soup parser
191ac7c Use GlobalAssemblyInfo.cs for all projects.
2faf35e Add ICSharpCode.NRefactory.Xml.
29c1b59 Add ICompilation.Assemblies.
2bebee4 C# XML documentation support.
b31e104 Protect against [InternalsVisibleTo] stack overflow and fixed a possible cause for that stack overflow
bd9348d Add documentation about XML documentation.
ec225c1 Fixed bugs related to ID strings.
ee92c68 TypeParameterReference now resolves to a dummy type parameter instead of UnknownType when no ITypeParameter is available in the resolve context.
7a76a80 Add DocumentationComment class that allows looking up 'cref' attributes.
4632c42 Fixed unit test.
de6870b Fixed completion unit test.
d89d25c Added failing unit test.
a6fa72e Fixed constructor initializer parameter completion.
3c3840b Cleaned up code a bit.
789e0cc Cleaned up code a bit.
c3b136b Fixed attribute context cases.
0983e85 Fixed some keyword contexts.
d03d17b Use lazy initialization for C# resolved type definitions.
9df7940 Normalize newlines.
01b538f Fix CSharpToVBConverterVisitor (use Pattern.AnyString).

git-subtree-dir: NRefactory
git-subtree-split: 180a690f373354796520d9468138d95f193f8156
pull/348/head
Daniel Grunwald 13 years ago
parent
commit
a1f08f39d1
  1. 3
      ICSharpCode.NRefactory.CSharp.AstVerifier/.gitignore
  2. 27
      ICSharpCode.NRefactory.CSharp.AstVerifier/AssemblyInfo.cs
  3. 49
      ICSharpCode.NRefactory.CSharp.AstVerifier/ICSharpCode.NRefactory.CSharp.AstVerifier.csproj
  4. 83
      ICSharpCode.NRefactory.CSharp.AstVerifier/Main.cs
  5. 7
      ICSharpCode.NRefactory.CSharp/Analysis/ControlFlow.cs
  6. 73
      ICSharpCode.NRefactory.CSharp/Analysis/DefiniteAssignmentAnalysis.cs
  7. 386
      ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs
  8. 45
      ICSharpCode.NRefactory.CSharp/Ast/AstType.cs
  9. 20
      ICSharpCode.NRefactory.CSharp/Ast/CSharpModifierToken.cs
  10. 56
      ICSharpCode.NRefactory.CSharp/Ast/CSharpTokenNode.cs
  11. 4
      ICSharpCode.NRefactory.CSharp/Ast/CSharpUtil.cs
  12. 84
      ICSharpCode.NRefactory.CSharp/Ast/CompilationUnit.cs
  13. 34
      ICSharpCode.NRefactory.CSharp/Ast/ComposedType.cs
  14. 1215
      ICSharpCode.NRefactory.CSharp/Ast/DepthFirstAstVisitor.cs
  15. 149
      ICSharpCode.NRefactory.CSharp/Ast/DocumentationReference.cs
  16. 11
      ICSharpCode.NRefactory.CSharp/Ast/ErrorNode.cs
  17. 29
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/AnonymousMethodExpression.cs
  18. 16
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/AnonymousTypeCreateExpression.cs
  19. 17
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayCreateExpression.cs
  20. 23
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayInitializerExpression.cs
  21. 16
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/AsExpression.cs
  22. 51
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/AssignmentExpression.cs
  23. 12
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/BaseReferenceExpression.cs
  24. 77
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/BinaryOperatorExpression.cs
  25. 12
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/CastExpression.cs
  26. 16
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/CheckedExpression.cs
  27. 16
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/ConditionalExpression.cs
  28. 16
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/DefaultValueExpression.cs
  29. 17
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/DirectionExpression.cs
  30. 15
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/EmptyExpression.cs
  31. 14
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/ErrorExpression.cs
  32. 23
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/Expression.cs
  33. 14
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/IdentifierExpression.cs
  34. 12
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/IndexerExpression.cs
  35. 12
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/InvocationExpression.cs
  36. 16
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/IsExpression.cs
  37. 23
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/LambdaExpression.cs
  38. 14
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/MemberReferenceExpression.cs
  39. 14
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedArgumentExpression.cs
  40. 14
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedExpression.cs
  41. 12
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/NullReferenceExpression.cs
  42. 15
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/ObjectCreateExpression.cs
  43. 14
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/ParenthesizedExpression.cs
  44. 20
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/PointerReferenceExpression.cs
  45. 35
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/PrimitiveExpression.cs
  46. 183
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/QueryExpression.cs
  47. 16
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/SizeOfExpression.cs
  48. 16
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/StackAllocExpression.cs
  49. 14
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/ThisReferenceExpression.cs
  50. 16
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/TypeOfExpression.cs
  51. 12
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/TypeReferenceExpression.cs
  52. 44
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/UnaryOperatorExpression.cs
  53. 16
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/UncheckedExpression.cs
  54. 32
      ICSharpCode.NRefactory.CSharp/Ast/Expressions/UndocumentedExpression.cs
  55. 17
      ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Attribute.cs
  56. 31
      ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/AttributeSection.cs
  57. 43
      ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Comment.cs
  58. 23
      ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Constraint.cs
  59. 50
      ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/DelegateDeclaration.cs
  60. 20
      ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/ExternAliasDeclaration.cs
  61. 18
      ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NamespaceDeclaration.cs
  62. 132
      ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NewLineNode.cs
  63. 17
      ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/PreProcessorDirective.cs
  64. 94
      ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/TextNode.cs
  65. 70
      ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/TypeDeclaration.cs
  66. 46
      ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/TypeParameterDeclaration.cs
  67. 21
      ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/UsingAliasDeclaration.cs
  68. 15
      ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/UsingDeclaration.cs
  69. 91
      ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/WhitespaceNode.cs
  70. 266
      ICSharpCode.NRefactory.CSharp/Ast/IAstVisitor.cs
  71. 78
      ICSharpCode.NRefactory.CSharp/Ast/Identifier.cs
  72. 2
      ICSharpCode.NRefactory.CSharp/Ast/IdentifierExpressionBackreference.cs
  73. 24
      ICSharpCode.NRefactory.CSharp/Ast/MemberType.cs
  74. 43
      ICSharpCode.NRefactory.CSharp/Ast/ObservableAstVisitor.cs
  75. 38
      ICSharpCode.NRefactory.CSharp/Ast/PrimitiveType.cs
  76. 96
      ICSharpCode.NRefactory.CSharp/Ast/Roles.cs
  77. 25
      ICSharpCode.NRefactory.CSharp/Ast/SimpleType.cs
  78. 35
      ICSharpCode.NRefactory.CSharp/Ast/Statements/BlockStatement.cs
  79. 18
      ICSharpCode.NRefactory.CSharp/Ast/Statements/BreakStatement.cs
  80. 16
      ICSharpCode.NRefactory.CSharp/Ast/Statements/CheckedStatement.cs
  81. 18
      ICSharpCode.NRefactory.CSharp/Ast/Statements/ContinueStatement.cs
  82. 16
      ICSharpCode.NRefactory.CSharp/Ast/Statements/DoWhileStatement.cs
  83. 15
      ICSharpCode.NRefactory.CSharp/Ast/Statements/EmptyStatement.cs
  84. 12
      ICSharpCode.NRefactory.CSharp/Ast/Statements/ExpressionStatement.cs
  85. 16
      ICSharpCode.NRefactory.CSharp/Ast/Statements/FixedStatement.cs
  86. 15
      ICSharpCode.NRefactory.CSharp/Ast/Statements/ForStatement.cs
  87. 21
      ICSharpCode.NRefactory.CSharp/Ast/Statements/ForeachStatement.cs
  88. 52
      ICSharpCode.NRefactory.CSharp/Ast/Statements/GotoStatement.cs
  89. 17
      ICSharpCode.NRefactory.CSharp/Ast/Statements/IfElseStatement.cs
  90. 19
      ICSharpCode.NRefactory.CSharp/Ast/Statements/LabelStatement.cs
  91. 16
      ICSharpCode.NRefactory.CSharp/Ast/Statements/LockStatement.cs
  92. 16
      ICSharpCode.NRefactory.CSharp/Ast/Statements/ReturnStatement.cs
  93. 23
      ICSharpCode.NRefactory.CSharp/Ast/Statements/Statement.cs
  94. 60
      ICSharpCode.NRefactory.CSharp/Ast/Statements/SwitchStatement.cs
  95. 16
      ICSharpCode.NRefactory.CSharp/Ast/Statements/ThrowStatement.cs
  96. 46
      ICSharpCode.NRefactory.CSharp/Ast/Statements/TryCatchStatement.cs
  97. 16
      ICSharpCode.NRefactory.CSharp/Ast/Statements/UncheckedStatement.cs
  98. 16
      ICSharpCode.NRefactory.CSharp/Ast/Statements/UnsafeStatement.cs
  99. 15
      ICSharpCode.NRefactory.CSharp/Ast/Statements/UsingStatement.cs
  100. 20
      ICSharpCode.NRefactory.CSharp/Ast/Statements/VariableDeclarationStatement.cs
  101. Some files were not shown because too many files have changed in this diff Show More

3
ICSharpCode.NRefactory.CSharp.AstVerifier/.gitignore vendored

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
bin/
obj/

27
ICSharpCode.NRefactory.CSharp.AstVerifier/AssemblyInfo.cs

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("ICSharpCode.NRefactory.CSharp.AstVerifier")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("mike")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

49
ICSharpCode.NRefactory.CSharp.AstVerifier/ICSharpCode.NRefactory.CSharp.AstVerifier.csproj

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
<?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>
</Project>

83
ICSharpCode.NRefactory.CSharp.AstVerifier/Main.cs

@ -0,0 +1,83 @@ @@ -0,0 +1,83 @@
using System;
using System.IO;
namespace ICSharpCode.NRefactory.CSharp.AstVerifier
{
class MainClass
{
static bool IsMatch (string src1, string src2, out int i, out int j)
{
i = 0;
j = 0;
while (i < src1.Length && j < src2.Length) {
char c1 = src1 [i];
char c2 = src2 [j];
if (char.IsWhiteSpace (c1)) {
i++;
continue;
}
if (char.IsWhiteSpace (c2)) {
j++;
continue;
}
if (c1 != c2)
return false;
i++;
j++;
}
while (i < src1.Length && char.IsWhiteSpace (src1[i])) {
i++;
}
while (j < src2.Length && char.IsWhiteSpace (src2[j])) {
j++;
}
return i == src1.Length && j == src2.Length;
}
public static void Main (string[] args)
{
if (args.Length == 0) {
Console.WriteLine ("Usage: AstVerifier [-v|-verbose] [Directory]");
return;
}
string directory = args[args.Length - 1];
bool verboseOutput = args.Length > 1 && (args[0] == "-v" || args[0] == "-verbose");
try {
if (!Directory.Exists (directory)) {
Console.WriteLine ("Directory not found.");
return;
}
} catch (IOException) {
Console.WriteLine ("Exception while trying to access the directory.");
return;
}
int failed = 0, passed = 0;
Console.WriteLine ("search in " + directory);
foreach (var file in Directory.GetFileSystemEntries (directory, "*", SearchOption.AllDirectories)) {
if (!file.EndsWith (".cs"))
continue;
string text = File.ReadAllText (file);
var unit = CompilationUnit.Parse (text, file);
if (unit == null)
continue;
string generated = unit.GetText ();
int i, j;
if (!IsMatch (text, generated, out i, out j)) {
if (i > 0 && j > 0 && verboseOutput) {
Console.WriteLine ("fail :" + file + "----original:");
Console.WriteLine (text.Substring (0, Math.Min (text.Length, i + 1)));
Console.WriteLine ("----generated:");
Console.WriteLine (generated.Substring (0, Math.Min (generated.Length, j + 1)));
}
failed++;
} else {
passed++;
}
}
Console.WriteLine ("{0} passed, {1} failed", passed, failed);
}
}
}

7
ICSharpCode.NRefactory.CSharp/Analysis/ControlFlow.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
// Copyright (c) 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
@ -113,7 +113,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis @@ -113,7 +113,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
/// Gets the try-finally statements that this control flow edge is leaving.
/// </summary>
public IEnumerable<TryCatchStatement> TryFinallyStatements {
get { return jumpOutOfTryFinally ?? EmptyList<TryCatchStatement>.Instance; }
get { return jumpOutOfTryFinally ?? Enumerable.Empty<TryCatchStatement>(); }
}
}
@ -420,7 +420,8 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis @@ -420,7 +420,8 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
falseEnd = ifElseStatement.FalseStatement.AcceptVisitor(this, falseBegin);
}
ControlFlowNode end = builder.CreateEndNode(ifElseStatement);
Connect(trueEnd, end);
if (trueEnd != null)
Connect(trueEnd, end);
if (falseEnd != null) {
Connect(falseEnd, end);
} else if (cond != true) {

73
ICSharpCode.NRefactory.CSharp/Analysis/DefiniteAssignmentAnalysis.cs

@ -304,54 +304,53 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis @@ -304,54 +304,53 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
return DefiniteAssignmentStatus.PotentiallyAssigned;
}
void ChangeNodeStatus(DefiniteAssignmentNode node, DefiniteAssignmentStatus inputStatus)
void ChangeNodeStatus (DefiniteAssignmentNode node, DefiniteAssignmentStatus inputStatus)
{
if (node.NodeStatus == inputStatus)
return;
node.NodeStatus = inputStatus;
DefiniteAssignmentStatus outputStatus;
switch (node.Type) {
case ControlFlowNodeType.StartNode:
case ControlFlowNodeType.BetweenStatements:
if (node.NextStatement is IfElseStatement) {
// Handle if-else as a condition node
case ControlFlowNodeType.StartNode:
case ControlFlowNodeType.BetweenStatements:
if (node.NextStatement is IfElseStatement) {
// Handle if-else as a condition node
goto case ControlFlowNodeType.LoopCondition;
}
if (inputStatus == DefiniteAssignmentStatus.DefinitelyAssigned) {
// There isn't any way to un-assign variables, so we don't have to check the expression
// if the status already is definitely assigned.
outputStatus = DefiniteAssignmentStatus.DefinitelyAssigned;
} else {
outputStatus = CleanSpecialValues(node.NextStatement.AcceptVisitor(visitor, inputStatus));
}
break;
case ControlFlowNodeType.EndNode:
outputStatus = inputStatus;
if (node.PreviousStatement.Role == TryCatchStatement.FinallyBlockRole
&& (outputStatus == DefiniteAssignmentStatus.DefinitelyAssigned || outputStatus == DefiniteAssignmentStatus.PotentiallyAssigned))
{
TryCatchStatement tryFinally = (TryCatchStatement)node.PreviousStatement.Parent;
// Changing the status on a finally block potentially changes the status of all edges leaving that finally block:
foreach (ControlFlowEdge edge in allNodes.SelectMany(n => n.Outgoing)) {
if (edge.IsLeavingTryFinally && edge.TryFinallyStatements.Contains(tryFinally)) {
DefiniteAssignmentStatus s = edgeStatus[edge];
if (s == DefiniteAssignmentStatus.PotentiallyAssigned) {
ChangeEdgeStatus(edge, outputStatus);
}
}
if (inputStatus == DefiniteAssignmentStatus.DefinitelyAssigned) {
// There isn't any way to un-assign variables, so we don't have to check the expression
// if the status already is definitely assigned.
outputStatus = DefiniteAssignmentStatus.DefinitelyAssigned;
} else {
outputStatus = CleanSpecialValues (node.NextStatement.AcceptVisitor (visitor, inputStatus));
}
break;
case ControlFlowNodeType.EndNode:
outputStatus = inputStatus;
if (node.PreviousStatement.Role == TryCatchStatement.FinallyBlockRole
&& (outputStatus == DefiniteAssignmentStatus.DefinitelyAssigned || outputStatus == DefiniteAssignmentStatus.PotentiallyAssigned)) {
TryCatchStatement tryFinally = (TryCatchStatement)node.PreviousStatement.Parent;
// Changing the status on a finally block potentially changes the status of all edges leaving that finally block:
foreach (ControlFlowEdge edge in allNodes.SelectMany(n => n.Outgoing)) {
if (edge.IsLeavingTryFinally && edge.TryFinallyStatements.Contains (tryFinally)) {
DefiniteAssignmentStatus s = edgeStatus [edge];
if (s == DefiniteAssignmentStatus.PotentiallyAssigned) {
ChangeEdgeStatus (edge, outputStatus);
}
}
}
}
break;
case ControlFlowNodeType.LoopCondition:
ForeachStatement foreachStmt = node.NextStatement as ForeachStatement;
if (foreachStmt != null) {
outputStatus = CleanSpecialValues (foreachStmt.InExpression.AcceptVisitor (visitor, inputStatus));
if (foreachStmt.VariableName == this.variableName)
outputStatus = DefiniteAssignmentStatus.DefinitelyAssigned;
break;
case ControlFlowNodeType.LoopCondition:
ForeachStatement foreachStmt = node.NextStatement as ForeachStatement;
if (foreachStmt != null) {
outputStatus = CleanSpecialValues(foreachStmt.InExpression.AcceptVisitor(visitor, inputStatus));
if (foreachStmt.VariableName == this.variableName)
outputStatus = DefiniteAssignmentStatus.DefinitelyAssigned;
break;
} else {
Debug.Assert(node.NextStatement is IfElseStatement || node.NextStatement is WhileStatement || node.NextStatement is ForStatement || node.NextStatement is DoWhileStatement);
Expression condition = node.NextStatement.GetChildByRole(AstNode.Roles.Condition);
} else {
Debug.Assert (node.NextStatement is IfElseStatement || node.NextStatement is WhileStatement || node.NextStatement is ForStatement || node.NextStatement is DoWhileStatement);
Expression condition = node.NextStatement.GetChildByRole (Roles.Condition);
if (condition.IsNull)
outputStatus = inputStatus;
else

386
ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// AstNode.cs
//
// Author:
@ -33,8 +33,11 @@ using System.Threading; @@ -33,8 +33,11 @@ using System.Threading;
namespace ICSharpCode.NRefactory.CSharp
{
public abstract class AstNode : AbstractAnnotatable, PatternMatching.INode
public abstract class AstNode : AbstractAnnotatable, ICSharpCode.NRefactory.TypeSystem.IFreezable, PatternMatching.INode
{
// the Root role must be available when creating the null nodes, so we can't put it in the Roles class
internal static readonly Role<AstNode> RootRole = new Role<AstNode> ("Root");
#region Null
public static readonly AstNode Null = new NullAstNode ();
@ -52,7 +55,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -52,7 +55,16 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return default (T);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return default (S);
}
@ -83,7 +95,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -83,7 +95,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return NodeType.Pattern; }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
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);
}
@ -105,7 +127,42 @@ namespace ICSharpCode.NRefactory.CSharp @@ -105,7 +127,42 @@ namespace ICSharpCode.NRefactory.CSharp
AstNode nextSibling;
AstNode firstChild;
AstNode lastChild;
Role role = RootRole;
// Flags, from least significant to most significant bits:
// - Role.RoleIndexBits: role index
// - 1 bit: IsFrozen
protected uint flags = RootRole.Index;
// Derived classes may also use a few bits,
// for example Identifier uses 1 bit for IsVerbatim
const uint roleIndexMask = (1u << Role.RoleIndexBits) - 1;
const uint frozenBit = 1u << Role.RoleIndexBits;
protected const int AstNodeFlagsUsedBits = Role.RoleIndexBits + 1;
protected AstNode()
{
if (IsNull)
Freeze();
}
public bool IsFrozen {
get { return (flags & frozenBit) != 0; }
}
public void Freeze()
{
if (!IsFrozen) {
for (AstNode child = firstChild; child != null; child = child.nextSibling)
child.Freeze();
flags |= frozenBit;
}
}
protected void ThrowIfFrozen()
{
if (IsFrozen)
throw new InvalidOperationException("Cannot mutate frozen " + GetType().Name);
}
public abstract NodeType NodeType {
get;
@ -135,22 +192,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -135,22 +192,6 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
/// <summary>
/// Returns true, if the given coordinates are in the node.
/// </summary>
public bool IsInside (TextLocation location)
{
return StartLocation <= location && location <= EndLocation;
}
/// <summary>
/// Returns true, if the given coordinates (line, column) are in the node.
/// </summary>
public bool IsInside(int line, int column)
{
return IsInside(new TextLocation (line, column));
}
/// <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.
@ -168,7 +209,22 @@ namespace ICSharpCode.NRefactory.CSharp @@ -168,7 +209,22 @@ namespace ICSharpCode.NRefactory.CSharp
}
public Role Role {
get { return role; }
get {
return Role.GetByIndex(flags & roleIndexMask);
}
set {
if (value == null)
throw new ArgumentNullException("value");
if (!value.IsValid(this))
throw new ArgumentException("This node is not valid in the new role.");
ThrowIfFrozen();
SetRole(value);
}
}
void SetRole(Role role)
{
flags = (flags & ~roleIndexMask) | role.Index;
}
public AstNode NextSibling {
@ -187,6 +243,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -187,6 +243,12 @@ namespace ICSharpCode.NRefactory.CSharp
get { return lastChild; }
}
public bool HasChildren {
get {
return firstChild != null;
}
}
public IEnumerable<AstNode> Children {
get {
AstNode next;
@ -211,6 +273,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -211,6 +273,17 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
/// <summary>
/// Gets the ancestors of this node (including this node itself)
/// </summary>
public IEnumerable<AstNode> AncestorsAndSelf {
get {
for (AstNode cur = this; cur != null; cur = cur.parent) {
yield return cur;
}
}
}
/// <summary>
/// Gets all descendants of this node (excluding this node itself).
/// </summary>
@ -233,17 +306,23 @@ namespace ICSharpCode.NRefactory.CSharp @@ -233,17 +306,23 @@ namespace ICSharpCode.NRefactory.CSharp
/// Gets the first child with the specified role.
/// Returns the role's null object if the child is not found.
/// </summary>
public T GetChildByRole<T> (Role<T> role) where T : AstNode
public T GetChildByRole<T>(Role<T> role) where T : AstNode
{
if (role == null)
throw new ArgumentNullException ("role");
uint roleIndex = role.Index;
for (var cur = firstChild; cur != null; cur = cur.nextSibling) {
if (cur.role == role)
if ((cur.flags & roleIndexMask) == roleIndex)
return (T)cur;
}
return role.NullObject;
}
public T GetParent<T>() where T : AstNode
{
return Ancestors.OfType<T>().FirstOrDefault();
}
public AstNodeCollection<T> GetChildrenByRole<T> (Role<T> role) where T : AstNode
{
return new AstNodeCollection<T> (this, role);
@ -264,10 +343,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -264,10 +343,11 @@ namespace ICSharpCode.NRefactory.CSharp
throw new ArgumentNullException ("role");
if (child == null || child.IsNull)
return;
if (this.IsNull)
throw new InvalidOperationException ("Cannot add children to null nodes");
ThrowIfFrozen();
if (child.parent != null)
throw new ArgumentException ("Node is already used in another tree.", "child");
if (child.IsFrozen)
throw new ArgumentException ("Cannot add a frozen node.", "child");
AddChildUnsafe (child, role);
}
@ -277,7 +357,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -277,7 +357,7 @@ namespace ICSharpCode.NRefactory.CSharp
void AddChildUnsafe (AstNode child, Role role)
{
child.parent = this;
child.role = role;
child.SetRole(role);
if (firstChild == null) {
lastChild = firstChild = child;
} else {
@ -286,6 +366,13 @@ namespace ICSharpCode.NRefactory.CSharp @@ -286,6 +366,13 @@ namespace ICSharpCode.NRefactory.CSharp
lastChild = child;
}
}
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
{
@ -298,8 +385,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -298,8 +385,11 @@ namespace ICSharpCode.NRefactory.CSharp
if (child == null || child.IsNull)
return;
ThrowIfFrozen();
if (child.parent != null)
throw new ArgumentException ("Node is already used in another tree.", "child");
if (child.IsFrozen)
throw new ArgumentException ("Cannot add a frozen node.", "child");
if (nextSibling.parent != this)
throw new ArgumentException ("NextSibling is not a child of this node.", "nextSibling");
// No need to test for "Cannot add children to null nodes",
@ -310,7 +400,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -310,7 +400,7 @@ namespace ICSharpCode.NRefactory.CSharp
void InsertChildBeforeUnsafe (AstNode nextSibling, AstNode child, Role role)
{
child.parent = this;
child.role = role;
child.SetRole(role);
child.nextSibling = nextSibling;
child.prevSibling = nextSibling.prevSibling;
@ -335,6 +425,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -335,6 +425,7 @@ namespace ICSharpCode.NRefactory.CSharp
public void Remove ()
{
if (parent != null) {
ThrowIfFrozen();
if (prevSibling != null) {
Debug.Assert (prevSibling.nextSibling == this);
prevSibling.nextSibling = nextSibling;
@ -350,7 +441,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -350,7 +441,6 @@ namespace ICSharpCode.NRefactory.CSharp
parent.lastChild = prevSibling;
}
parent = null;
role = Roles.Root;
prevSibling = null;
nextSibling = null;
}
@ -370,10 +460,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -370,10 +460,11 @@ namespace ICSharpCode.NRefactory.CSharp
if (parent == null) {
throw new InvalidOperationException (this.IsNull ? "Cannot replace the null nodes" : "Cannot replace the root node");
}
ThrowIfFrozen();
// Because this method doesn't statically check the new node's type with the role,
// we perform a runtime test:
if (!role.IsValid (newNode)) {
throw new ArgumentException (string.Format ("The new node '{0}' is not valid in the role {1}", newNode.GetType ().Name, role.ToString ()), "newNode");
if (!this.Role.IsValid (newNode)) {
throw new ArgumentException (string.Format ("The new node '{0}' is not valid in the role {1}", newNode.GetType ().Name, this.Role.ToString ()), "newNode");
}
if (newNode.parent != null) {
// newNode is used within this tree?
@ -385,9 +476,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -385,9 +476,11 @@ namespace ICSharpCode.NRefactory.CSharp
throw new ArgumentException ("Node is already used in another tree.", "newNode");
}
}
if (newNode.IsFrozen)
throw new ArgumentException ("Cannot add a frozen node.", "newNode");
newNode.parent = parent;
newNode.role = role;
newNode.SetRole(this.Role);
newNode.prevSibling = prevSibling;
newNode.nextSibling = nextSibling;
if (parent != null) {
@ -408,7 +501,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -408,7 +501,6 @@ namespace ICSharpCode.NRefactory.CSharp
parent = null;
prevSibling = null;
nextSibling = null;
role = Roles.Root;
}
}
@ -421,7 +513,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -421,7 +513,7 @@ namespace ICSharpCode.NRefactory.CSharp
}
AstNode oldParent = parent;
AstNode oldSuccessor = nextSibling;
Role oldRole = role;
Role oldRole = this.Role;
Remove ();
AstNode replacement = replaceFunction (this);
if (oldSuccessor != null && oldSuccessor.parent != oldParent)
@ -450,26 +542,28 @@ namespace ICSharpCode.NRefactory.CSharp @@ -450,26 +542,28 @@ namespace ICSharpCode.NRefactory.CSharp
AstNode copy = (AstNode)MemberwiseClone ();
// First, reset the shallow pointer copies
copy.parent = null;
copy.role = Roles.Root;
copy.firstChild = null;
copy.lastChild = null;
copy.prevSibling = null;
copy.nextSibling = null;
copy.flags &= ~frozenBit; // unfreeze the copy
// Then perform a deep copy:
for (AstNode cur = firstChild; cur != null; cur = cur.nextSibling) {
copy.AddChildUnsafe (cur.Clone (), cur.role);
copy.AddChildUnsafe (cur.Clone (), cur.Role);
}
// Finally, clone the annotation, if necessary
ICloneable copiedAnnotations = copy.annotations as ICloneable; // read from copy (for thread-safety)
if (copiedAnnotations != null)
copy.annotations = copiedAnnotations.Clone();
copy.CloneAnnotations();
return copy;
}
public abstract S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T));
public abstract void AcceptVisitor (IAstVisitor visitor);
public abstract T AcceptVisitor<T> (IAstVisitor<T> visitor);
public abstract S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data);
#region Pattern Matching
protected static bool MatchString (string pattern, string text)
@ -519,7 +613,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -519,7 +613,6 @@ namespace ICSharpCode.NRefactory.CSharp
return Parent.GetPrevNode ();
return null;
}
// filters all non c# nodes (comments, white spaces or pre processor directives)
public AstNode GetCSharpNodeBefore (AstNode node)
{
@ -532,11 +625,22 @@ namespace ICSharpCode.NRefactory.CSharp @@ -532,11 +625,22 @@ namespace ICSharpCode.NRefactory.CSharp
return null;
}
#region GetNodeAt
/// <summary>
/// Gets the node specified by T at the location line, column. This is useful for getting a specific node from the tree. For example searching
/// the current method declaration.
/// (End exclusive)
/// </summary>
public AstNode GetNodeAt (int line, int column, Predicate<AstNode> pred = null)
{
return GetNodeAt (new TextLocation (line, column), pred);
}
/// <summary>
/// Gets the node specified by pred at location. This is useful for getting a specific node from the tree. For example searching
/// the current method declaration.
/// (End exclusive)
/// </summary>
public AstNode GetNodeAt (TextLocation location, Predicate<AstNode> pred = null)
{
AstNode result = null;
@ -559,6 +663,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -559,6 +663,11 @@ namespace ICSharpCode.NRefactory.CSharp
return result;
}
/// <summary>
/// Gets the node specified by T at the location line, column. This is useful for getting a specific node from the tree. For example searching
/// the current method declaration.
/// (End exclusive)
/// </summary>
public T GetNodeAt<T> (int line, int column) where T : AstNode
{
return GetNodeAt<T> (new TextLocation (line, column));
@ -567,6 +676,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -567,6 +676,7 @@ namespace ICSharpCode.NRefactory.CSharp
/// <summary>
/// Gets the node specified by T at location. This is useful for getting a specific node from the tree. For example searching
/// the current method declaration.
/// (End exclusive)
/// </summary>
public T GetNodeAt<T> (TextLocation location) where T : AstNode
{
@ -589,6 +699,97 @@ namespace ICSharpCode.NRefactory.CSharp @@ -589,6 +699,97 @@ namespace ICSharpCode.NRefactory.CSharp
}
return result;
}
#endregion
#region GetAdjacentNodeAt
/// <summary>
/// Gets the node specified by pred at the location line, column. This is useful for getting a specific node from the tree. For example searching
/// the current method declaration.
/// (End inclusive)
/// </summary>
public AstNode GetAdjacentNodeAt(int line, int column, Predicate<AstNode> pred = null)
{
return GetAdjacentNodeAt (new TextLocation (line, column), pred);
}
/// <summary>
/// Gets the node specified by pred at location. This is useful for getting a specific node from the tree. For example searching
/// the current method declaration.
/// (End inclusive)
/// </summary>
public AstNode GetAdjacentNodeAt (TextLocation location, Predicate<AstNode> pred = null)
{
AstNode result = null;
AstNode node = this;
while (node.FirstChild != null) {
var child = node.FirstChild;
while (child != null) {
if (child.StartLocation <= location && location <= child.EndLocation) {
if (pred == null || pred (child))
result = child;
node = child;
break;
}
child = child.NextSibling;
}
// found no better child node - therefore the parent is the right one.
if (child == null)
break;
}
return result;
}
/// <summary>
/// Gets the node specified by T at the location line, column. This is useful for getting a specific node from the tree. For example searching
/// the current method declaration.
/// (End inclusive)
/// </summary>
public T GetAdjacentNodeAt<T>(int line, int column) where T : AstNode
{
return GetAdjacentNodeAt<T> (new TextLocation (line, column));
}
/// <summary>
/// Gets the node specified by T at location. This is useful for getting a specific node from the tree. For example searching
/// the current method declaration.
/// (End inclusive)
/// </summary>
public T GetAdjacentNodeAt<T> (TextLocation location) where T : AstNode
{
T result = null;
AstNode node = this;
while (node.FirstChild != null) {
var child = node.FirstChild;
while (child != null) {
if (child.StartLocation <= location && location < child.EndLocation) {
if (child is T)
result = (T)child;
node = child;
break;
}
child = child.NextSibling;
}
// found no better child node - therefore the parent is the right one.
if (child == null)
break;
}
return result;
}
#endregion
/// <summary>
/// Gets the node that fully contains the range from startLocation to endLocation.
/// </summary>
public AstNode GetNodeContaining(TextLocation startLocation, TextLocation endLocation)
{
for (AstNode child = firstChild; child != null; child = child.nextSibling) {
if (child.StartLocation <= startLocation && endLocation <= child.EndLocation)
return child.GetNodeContaining(startLocation, endLocation);
}
return this;
}
public IEnumerable<AstNode> GetNodesBetween (int startLine, int startColumn, int endLine, int endColumn)
{
@ -619,16 +820,65 @@ namespace ICSharpCode.NRefactory.CSharp @@ -619,16 +820,65 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
/// <summary>
/// Gets the node as formatted C# output.
/// </summary>
/// <param name='formattingOptions'>
/// Formatting options.
/// </param>
public virtual string GetText (CSharpFormattingOptions formattingOptions = null)
{
if (IsNull)
return "";
var w = new StringWriter ();
AcceptVisitor (new CSharpOutputVisitor (w, formattingOptions ?? FormattingOptionsFactory.CreateMono ()));
return w.ToString ();
}
/// <summary>
/// Returns true, if the given coordinates (line, column) are in the node.
/// </summary>
/// <returns>
/// True, if the given coordinates are between StartLocation and EndLocation (exclusive); otherwise, false.
/// </returns>
public bool Contains (int line, int column)
{
return Contains (new TextLocation (line, column));
}
/// <summary>
/// Returns true, if the given coordinates are in the node.
/// </summary>
/// <returns>
/// True, if location is between StartLocation and EndLocation (exclusive); otherwise, false.
/// </returns>
public bool Contains (TextLocation location)
{
return this.StartLocation <= location && location < this.EndLocation;
}
/// <summary>
/// Returns true, if the given coordinates (line, column) are in the node.
/// </summary>
/// <returns>
/// True, if the given coordinates are between StartLocation and EndLocation (inclusive); otherwise, false.
/// </returns>
public bool IsInside (int line, int column)
{
return IsInside (new TextLocation (line, column));
}
/// <summary>
/// Returns true, if the given coordinates are in the node.
/// </summary>
/// <returns>
/// True, if location is between StartLocation and EndLocation (inclusive); otherwise, false.
/// </returns>
public bool IsInside (TextLocation location)
{
return this.StartLocation <= location && location <= this.EndLocation;
}
public override void AddAnnotation (object annotation)
{
if (this.IsNull)
@ -640,60 +890,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -640,60 +890,12 @@ namespace ICSharpCode.NRefactory.CSharp
{
if (IsNull)
return "Null";
StringWriter w = new StringWriter();
AcceptVisitor(new CSharpOutputVisitor(w, new CSharpFormattingOptions()), null);
string text = w.ToString().TrimEnd().Replace("\t", "").Replace(w.NewLine, " ");
string text = GetText();
text = text.TrimEnd().Replace("\t", "").Replace(Environment.NewLine, " ");
if (text.Length > 100)
return text.Substring(0, 97) + "...";
else
return text;
}
// the Root role must be available when creating the null nodes, so we can't put it in the Roles class
static readonly Role<AstNode> RootRole = new Role<AstNode> ("Root");
public static class Roles
{
/// <summary>
/// Root of an abstract syntax tree.
/// </summary>
public static readonly Role<AstNode> Root = RootRole;
// some pre defined constants for common roles
public static readonly Role<Identifier> Identifier = new Role<Identifier> ("Identifier", CSharp.Identifier.Null);
public static readonly Role<BlockStatement> Body = new Role<BlockStatement> ("Body", CSharp.BlockStatement.Null);
public static readonly Role<ParameterDeclaration> Parameter = new Role<ParameterDeclaration> ("Parameter");
public static readonly Role<Expression> Argument = new Role<Expression> ("Argument", CSharp.Expression.Null);
public static readonly Role<AstType> Type = new Role<AstType> ("Type", CSharp.AstType.Null);
public static readonly Role<Expression> Expression = new Role<Expression> ("Expression", CSharp.Expression.Null);
public static readonly Role<Expression> TargetExpression = new Role<Expression> ("Target", CSharp.Expression.Null);
public readonly static Role<Expression> Condition = new Role<Expression> ("Condition", CSharp.Expression.Null);
public static readonly Role<TypeParameterDeclaration> TypeParameter = new Role<TypeParameterDeclaration> ("TypeParameter");
public static readonly Role<AstType> TypeArgument = new Role<AstType> ("TypeArgument", CSharp.AstType.Null);
public readonly static Role<Constraint> Constraint = new Role<Constraint> ("Constraint");
public static readonly Role<VariableInitializer> Variable = new Role<VariableInitializer> ("Variable");
public static readonly Role<Statement> EmbeddedStatement = new Role<Statement> ("EmbeddedStatement", CSharp.Statement.Null);
public static readonly Role<CSharpTokenNode> Keyword = new Role<CSharpTokenNode> ("Keyword", CSharpTokenNode.Null);
public static readonly Role<CSharpTokenNode> InKeyword = new Role<CSharpTokenNode> ("InKeyword", CSharpTokenNode.Null);
// some pre defined constants for most used punctuation
public static readonly Role<CSharpTokenNode> LPar = new Role<CSharpTokenNode> ("LPar", CSharpTokenNode.Null);
public static readonly Role<CSharpTokenNode> RPar = new Role<CSharpTokenNode> ("RPar", CSharpTokenNode.Null);
public static readonly Role<CSharpTokenNode> LBracket = new Role<CSharpTokenNode> ("LBracket", CSharpTokenNode.Null);
public static readonly Role<CSharpTokenNode> RBracket = new Role<CSharpTokenNode> ("RBracket", CSharpTokenNode.Null);
public static readonly Role<CSharpTokenNode> LBrace = new Role<CSharpTokenNode> ("LBrace", CSharpTokenNode.Null);
public static readonly Role<CSharpTokenNode> RBrace = new Role<CSharpTokenNode> ("RBrace", CSharpTokenNode.Null);
public static readonly Role<CSharpTokenNode> LChevron = new Role<CSharpTokenNode> ("LChevron", CSharpTokenNode.Null);
public static readonly Role<CSharpTokenNode> RChevron = new Role<CSharpTokenNode> ("RChevron", CSharpTokenNode.Null);
public static readonly Role<CSharpTokenNode> Comma = new Role<CSharpTokenNode> ("Comma", CSharpTokenNode.Null);
public static readonly Role<CSharpTokenNode> Dot = new Role<CSharpTokenNode> ("Dot", CSharpTokenNode.Null);
public static readonly Role<CSharpTokenNode> Semicolon = new Role<CSharpTokenNode> ("Semicolon", CSharpTokenNode.Null);
public static readonly Role<CSharpTokenNode> Assign = new Role<CSharpTokenNode> ("Assign", CSharpTokenNode.Null);
public static readonly Role<CSharpTokenNode> Colon = new Role<CSharpTokenNode> ("Colon", CSharpTokenNode.Null);
public static readonly Role<Comment> Comment = new Role<Comment> ("Comment");
public static readonly Role<PreProcessorDirective> PreProcessorDirective = new Role<PreProcessorDirective> ("PreProcessorDirective");
public static readonly Role<ErrorNode> Error = new Role<ErrorNode> ("Error");
}
}
}

45
ICSharpCode.NRefactory.CSharp/Ast/AstType.cs

@ -39,7 +39,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -39,7 +39,16 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return default (T);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return default (S);
}
@ -75,9 +84,19 @@ namespace ICSharpCode.NRefactory.CSharp @@ -75,9 +84,19 @@ namespace ICSharpCode.NRefactory.CSharp
get { return NodeType.Pattern; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data = default(T))
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);
return visitor.VisitPatternPlaceholder (this, child, data);
}
public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode)
@ -153,6 +172,26 @@ namespace ICSharpCode.NRefactory.CSharp @@ -153,6 +172,26 @@ namespace ICSharpCode.NRefactory.CSharp
return new TypeReferenceExpression { Type = this }.Member(memberName);
}
/// <summary>
/// Builds an expression that can be used to access a static member on this type.
/// </summary>
public MemberType MemberType(string memberName, params AstType[] typeArguments)
{
var memberType = new MemberType(this, memberName);
memberType.TypeArguments.AddRange(typeArguments);
return memberType;
}
/// <summary>
/// Builds an expression that can be used to access a static member on this type.
/// </summary>
public MemberType MemberType(string memberName, IEnumerable<AstType> typeArguments)
{
var memberType = new MemberType(this, memberName);
memberType.TypeArguments.AddRange(typeArguments);
return memberType;
}
/// <summary>
/// Builds an invocation expression using this type as target.
/// </summary>

20
ICSharpCode.NRefactory.CSharp/Ast/CSharpModifierToken.cs

@ -29,19 +29,29 @@ using System.Linq; @@ -29,19 +29,29 @@ using System.Linq;
namespace ICSharpCode.NRefactory.CSharp
{
public class CSharpModifierToken : CSharpTokenNode
{
Modifiers modifier;
public Modifiers Modifier {
get { return modifier; }
set {
this.tokenLength = GetModifierName(value).Length;
this.modifier = value;
set {
ThrowIfFrozen();
this.modifier = value;
}
}
protected override int TokenLength {
get {
return GetModifierName (modifier).Length;
}
}
public override string GetText (CSharpFormattingOptions formattingOptions = null)
{
return GetModifierName (Modifier);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
CSharpModifierToken o = other as CSharpModifierToken;
@ -65,7 +75,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -65,7 +75,7 @@ namespace ICSharpCode.NRefactory.CSharp
get { return allModifiers; }
}
public CSharpModifierToken (TextLocation location, Modifiers modifier) : base (location, 0)
public CSharpModifierToken (TextLocation location, Modifiers modifier) : base (location)
{
this.Modifier = modifier;
}

56
ICSharpCode.NRefactory.CSharp/Ast/CSharpTokenNode.cs

@ -27,7 +27,13 @@ using System; @@ -27,7 +27,13 @@ using System;
namespace ICSharpCode.NRefactory.CSharp
{
public class CSharpTokenNode : AstNode, IRelocatable
/// <summary>
/// Represents a token in C#. Note that the type of the token is defined through the TokenRole.
/// </summary>
/// <remarks>
/// In all non null c# token nodes the Role of a CSharpToken must be a TokenRole.
/// </remarks>
public class CSharpTokenNode : AstNode
{
public static new readonly CSharpTokenNode Null = new NullCSharpTokenNode ();
class NullCSharpTokenNode : CSharpTokenNode
@ -38,11 +44,20 @@ namespace ICSharpCode.NRefactory.CSharp @@ -38,11 +44,20 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public NullCSharpTokenNode () : base (TextLocation.Empty, 0)
public NullCSharpTokenNode () : base (TextLocation.Empty)
{
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return default (T);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return default (S);
}
@ -53,7 +68,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -53,7 +68,6 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public override NodeType NodeType {
get {
return NodeType.Token;
@ -67,27 +81,43 @@ namespace ICSharpCode.NRefactory.CSharp @@ -67,27 +81,43 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
protected int tokenLength;
protected virtual int TokenLength {
get {
if (!(Role is TokenRole))
return 0;
return ((TokenRole)Role).Length;
}
}
public override TextLocation EndLocation {
get {
return new TextLocation (StartLocation.Line, StartLocation.Column + tokenLength);
return new TextLocation (StartLocation.Line, StartLocation.Column + TokenLength);
}
}
public CSharpTokenNode (TextLocation location, int tokenLength)
public CSharpTokenNode (TextLocation location)
{
this.startLocation = location;
this.tokenLength = tokenLength;
}
#region IRelocationable implementation
void IRelocatable.SetStartLocation (TextLocation startLocation)
public override string GetText (CSharpFormattingOptions formattingOptions = null)
{
if (!(Role is TokenRole))
return null;
return ((TokenRole)Role).Token;
}
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitCSharpTokenNode (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
this.startLocation = startLocation;
return visitor.VisitCSharpTokenNode (this);
}
#endregion
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitCSharpTokenNode (this, data);
}

4
ICSharpCode.NRefactory.CSharp/Ast/CSharpUtil.cs

@ -74,7 +74,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -74,7 +74,6 @@ namespace ICSharpCode.NRefactory.CSharp
return new UnaryOperatorExpression (UnaryOperatorType.Not, new ParenthesizedExpression (condition));
}
}
if (condition is ConditionalExpression) {
var cEx = condition as ConditionalExpression;
cEx.Condition = InvertCondition (cEx.Condition);
@ -83,8 +82,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -83,8 +82,7 @@ namespace ICSharpCode.NRefactory.CSharp
if (condition is PrimitiveExpression) {
var pex = condition as PrimitiveExpression;
if (pex.Value is bool) {
pex.Value = !((bool)pex.Value);
return pex;
return new PrimitiveExpression (!((bool)pex.Value));
}
}

84
ICSharpCode.NRefactory.CSharp/Ast/CompilationUnit.cs

@ -28,6 +28,10 @@ using System.Collections.Generic; @@ -28,6 +28,10 @@ using System.Collections.Generic;
using ICSharpCode.NRefactory.CSharp.Resolver;
using ICSharpCode.NRefactory.CSharp.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem;
using System.Threading;
using Mono.CSharp;
using System.IO;
using ICSharpCode.NRefactory.Editor;
namespace ICSharpCode.NRefactory.CSharp
{
@ -41,10 +45,22 @@ namespace ICSharpCode.NRefactory.CSharp @@ -41,10 +45,22 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
string fileName;
/// <summary>
/// Gets/Sets the file name of this compilation unit.
/// </summary>
public string FileName { get; set; }
public string FileName {
get { return fileName; }
set {
ThrowIfFrozen();
fileName = value;
}
}
public AstNodeCollection<AstNode> Members {
get { return GetChildrenByRole(MemberRole); }
}
List<Error> errors = new List<Error> ();
@ -68,17 +84,18 @@ namespace ICSharpCode.NRefactory.CSharp @@ -68,17 +84,18 @@ namespace ICSharpCode.NRefactory.CSharp
{
}
public IEnumerable<TypeDeclaration> GetTypes (bool includeInnerTypes = false)
public IEnumerable<TypeDeclaration> GetTypes(bool includeInnerTypes = false)
{
Stack<AstNode> nodeStack = new Stack<AstNode> ();
nodeStack.Push (this);
nodeStack.Push(this);
while (nodeStack.Count > 0) {
var curNode = nodeStack.Pop ();
if (curNode is TypeDeclaration)
var curNode = nodeStack.Pop();
if (curNode is TypeDeclaration) {
yield return (TypeDeclaration)curNode;
}
foreach (var child in curNode.Children) {
if (!(child is Statement || child is Expression) &&
(child.Role != TypeDeclaration.MemberRole || (child is TypeDeclaration && includeInnerTypes)))
(child.Role != Roles.TypeMemberRole || (child is TypeDeclaration && includeInnerTypes)))
nodeStack.Push (child);
}
}
@ -90,7 +107,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -90,7 +107,17 @@ namespace ICSharpCode.NRefactory.CSharp
return o != null && GetChildrenByRole(MemberRole).DoMatch(o.GetChildrenByRole(MemberRole), match);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitCompilationUnit (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitCompilationUnit (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitCompilationUnit (this, data);
}
@ -98,14 +125,45 @@ namespace ICSharpCode.NRefactory.CSharp @@ -98,14 +125,45 @@ namespace ICSharpCode.NRefactory.CSharp
/// <summary>
/// Converts this compilation unit into a parsed file that can be stored in the type system.
/// </summary>
public CSharpParsedFile ToTypeSystem()
public CSharpParsedFile ToTypeSystem ()
{
if (string.IsNullOrEmpty(this.FileName))
throw new InvalidOperationException("Cannot use ToTypeSystem() on a compilation unit without file name.");
var v = new TypeSystemConvertVisitor(this.FileName);
v.VisitCompilationUnit(this, null);
if (string.IsNullOrEmpty (this.FileName))
throw new InvalidOperationException ("Cannot use ToTypeSystem() on a compilation unit without file name.");
var v = new TypeSystemConvertVisitor (this.FileName);
v.VisitCompilationUnit (this);
return v.ParsedFile;
}
public static CompilationUnit Parse (string text, string fileName = "", CompilerSettings settings = null, CancellationToken cancellationToken = default (CancellationToken))
{
var parser = new CSharpParser ();
if (settings != null)
parser.CompilerSettings = settings;
return parser.Parse (text, fileName);
}
public static CompilationUnit Parse (TextReader reader, string fileName = "", CompilerSettings settings = null, CancellationToken cancellationToken = default (CancellationToken))
{
var parser = new CSharpParser ();
if (settings != null)
parser.CompilerSettings = settings;
return parser.Parse (reader, fileName, 0);
}
public static CompilationUnit Parse (Stream stream, string fileName = "", CompilerSettings settings = null, CancellationToken cancellationToken = default (CancellationToken))
{
var parser = new CSharpParser ();
if (settings != null)
parser.CompilerSettings = settings;
return parser.Parse (stream, fileName, 0);
}
public static CompilationUnit Parse (ITextSource textSource, string fileName = "", CompilerSettings settings = null, CancellationToken cancellationToken = default (CancellationToken))
{
var parser = new CSharpParser ();
if (settings != null)
parser.CompilerSettings = settings;
return parser.Parse (textSource, fileName, 0);
}
}
}

34
ICSharpCode.NRefactory.CSharp/Ast/ComposedType.cs

@ -33,8 +33,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -33,8 +33,8 @@ namespace ICSharpCode.NRefactory.CSharp
{
public class ComposedType : AstType
{
public static readonly Role<CSharpTokenNode> NullableRole = new Role<CSharpTokenNode>("Nullable", CSharpTokenNode.Null);
public static readonly Role<CSharpTokenNode> PointerRole = new Role<CSharpTokenNode>("Pointer", CSharpTokenNode.Null);
public static readonly TokenRole NullableRole = new TokenRole("?");
public static readonly TokenRole PointerRole = new TokenRole("*");
public static readonly Role<ArraySpecifier> ArraySpecifierRole = new Role<ArraySpecifier>("ArraySpecifier");
public AstType BaseType {
@ -47,7 +47,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -47,7 +47,7 @@ namespace ICSharpCode.NRefactory.CSharp
return !GetChildByRole(NullableRole).IsNull;
}
set {
SetChildByRole(NullableRole, value ? new CSharpTokenNode(TextLocation.Empty, 1) : null);
SetChildByRole(NullableRole, value ? new CSharpTokenNode(TextLocation.Empty) : null);
}
}
@ -64,7 +64,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -64,7 +64,7 @@ namespace ICSharpCode.NRefactory.CSharp
d--;
}
while (d < value) {
InsertChildBefore(GetChildByRole(PointerRole), new CSharpTokenNode(TextLocation.Empty, 1), PointerRole);
InsertChildBefore(GetChildByRole(PointerRole), new CSharpTokenNode(TextLocation.Empty), PointerRole);
d++;
}
}
@ -74,7 +74,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -74,7 +74,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildrenByRole (ArraySpecifierRole); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitComposedType (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitComposedType (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitComposedType (this, data);
}
@ -166,7 +176,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -166,7 +176,7 @@ namespace ICSharpCode.NRefactory.CSharp
d--;
}
while (d < value) {
InsertChildBefore(GetChildByRole(Roles.Comma), new CSharpTokenNode(TextLocation.Empty, 1), Roles.Comma);
InsertChildBefore(GetChildByRole(Roles.Comma), new CSharpTokenNode(TextLocation.Empty), Roles.Comma);
d++;
}
}
@ -176,7 +186,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -176,7 +186,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RBracket); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitArraySpecifier (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitArraySpecifier (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitArraySpecifier(this, data);
}

1215
ICSharpCode.NRefactory.CSharp/Ast/DepthFirstAstVisitor.cs

File diff suppressed because it is too large Load Diff

149
ICSharpCode.NRefactory.CSharp/Ast/DocumentationReference.cs

@ -0,0 +1,149 @@ @@ -0,0 +1,149 @@
// Copyright (c) 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 ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.NRefactory.CSharp
{
/// <summary>
/// Represents a 'cref' reference in XML documentation.
/// </summary>
public class DocumentationReference : AstNode
{
public static readonly Role<AstType> DeclaringTypeRole = new Role<AstType>("DeclaringType", AstType.Null);
public static readonly Role<AstType> ConversionOperatorReturnTypeRole = new Role<AstType>("ConversionOperatorReturnType", AstType.Null);
EntityType entityType;
OperatorType operatorType;
bool hasParameterList;
/// <summary>
/// Gets/Sets the entity type.
/// Possible values are:
/// <c>EntityType.Operator</c> for operators,
/// <c>EntityType.Indexer</c> for indexers,
/// <c>EntityType.TypeDefinition</c> for references to primitive types,
/// and <c>EntityType.None</c> for everything else.
/// </summary>
public EntityType EntityType {
get { return entityType; }
set {
ThrowIfFrozen();
entityType = value;
}
}
/// <summary>
/// Gets/Sets the operator type.
/// This property is only used when EntityType==Operator.
/// </summary>
public OperatorType OperatorType {
get { return operatorType; }
set {
ThrowIfFrozen();
operatorType = value;
}
}
/// <summary>
/// Gets/Sets whether a parameter list was provided.
/// </summary>
public bool HasParameterList {
get { return hasParameterList; }
set {
ThrowIfFrozen();
hasParameterList = value;
}
}
public override NodeType NodeType {
get { return NodeType.Unknown; }
}
/// <summary>
/// Gets/Sets the declaring type.
/// </summary>
public AstType DeclaringType {
get { return GetChildByRole(DeclaringTypeRole); }
set { SetChildByRole(DeclaringTypeRole, value); }
}
/// <summary>
/// Gets/sets the member name.
/// This property is only used when EntityType==None.
/// </summary>
public string MemberName {
get { return GetChildByRole(Roles.Identifier).Name; }
set { SetChildByRole(Roles.Identifier, Identifier.Create(value)); }
}
/// <summary>
/// Gets/Sets the return type of conversion operators.
/// This property is only used when EntityType==Operator and OperatorType is explicit or implicit.
/// </summary>
public AstType ConversionOperatorReturnType {
get { return GetChildByRole(ConversionOperatorReturnTypeRole); }
set { SetChildByRole(ConversionOperatorReturnTypeRole, value); }
}
public AstNodeCollection<AstType> TypeArguments {
get { return GetChildrenByRole (Roles.TypeArgument); }
}
public AstNodeCollection<ParameterDeclaration> Parameters {
get { return GetChildrenByRole (Roles.Parameter); }
}
protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match)
{
DocumentationReference o = other as DocumentationReference;
if (!(o != null && this.EntityType == o.EntityType && this.HasParameterList == o.HasParameterList))
return false;
if (this.EntityType == EntityType.Operator) {
if (this.OperatorType != o.OperatorType)
return false;
if (this.OperatorType == OperatorType.Implicit || this.OperatorType == OperatorType.Explicit) {
if (!this.ConversionOperatorReturnType.DoMatch(o.ConversionOperatorReturnType, match))
return false;
}
} else if (this.EntityType == EntityType.None) {
if (!MatchString(this.MemberName, o.MemberName))
return false;
if (!this.TypeArguments.DoMatch(o.TypeArguments, match))
return false;
}
return this.Parameters.DoMatch(o.Parameters, match);
}
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitDocumentationReference (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitDocumentationReference (this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitDocumentationReference (this, data);
}
}
}

11
ICSharpCode.NRefactory.CSharp/Ast/ErrorNode.cs

@ -58,7 +58,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -58,7 +58,16 @@ namespace ICSharpCode.NRefactory.CSharp
{
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return default (T);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
// nothing
return default (S);

29
ICSharpCode.NRefactory.CSharp/Ast/Expressions/AnonymousMethodExpression.cs

@ -34,17 +34,26 @@ namespace ICSharpCode.NRefactory.CSharp @@ -34,17 +34,26 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class AnonymousMethodExpression : Expression
{
public readonly static Role<CSharpTokenNode> AsyncModifierRole = LambdaExpression.AsyncModifierRole;
public readonly static TokenRole DelegateKeywordRole = new TokenRole ("delegate");
public readonly static TokenRole AsyncModifierRole = LambdaExpression.AsyncModifierRole;
public bool IsAsync { get; set; }
bool isAsync;
public bool IsAsync {
get { return isAsync; }
set { ThrowIfFrozen(); isAsync = value; }
}
// used to tell the difference between delegate {} and delegate () {}
bool hasParameterList;
public bool HasParameterList {
get; set;
get { return hasParameterList; }
set { ThrowIfFrozen(); hasParameterList = value; }
}
public CSharpTokenNode DelegateToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (DelegateKeywordRole); }
}
public CSharpTokenNode LParToken {
@ -82,7 +91,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -82,7 +91,17 @@ namespace ICSharpCode.NRefactory.CSharp
{
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitAnonymousMethodExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitAnonymousMethodExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitAnonymousMethodExpression (this, data);
}

16
ICSharpCode.NRefactory.CSharp/Ast/Expressions/AnonymousTypeCreateExpression.cs

@ -33,8 +33,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -33,8 +33,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class AnonymousTypeCreateExpression : Expression
{
public readonly static TokenRole NewKeywordRole = new TokenRole ("new");
public CSharpTokenNode NewToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (NewKeywordRole); }
}
public CSharpTokenNode LParToken {
@ -64,7 +66,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -64,7 +66,17 @@ namespace ICSharpCode.NRefactory.CSharp
{
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitAnonymousTypeCreateExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitAnonymousTypeCreateExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitAnonymousTypeCreateExpression (this, data);
}

17
ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayCreateExpression.cs

@ -26,9 +26,14 @@ namespace ICSharpCode.NRefactory.CSharp @@ -26,9 +26,14 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class ArrayCreateExpression : Expression
{
public readonly static TokenRole NewKeywordRole = new TokenRole ("new");
public readonly static Role<ArraySpecifier> AdditionalArraySpecifierRole = new Role<ArraySpecifier>("AdditionalArraySpecifier");
public readonly static Role<ArrayInitializerExpression> InitializerRole = new Role<ArrayInitializerExpression>("Initializer", ArrayInitializerExpression.Null);
public CSharpTokenNode NewToken {
get { return GetChildByRole (NewKeywordRole); }
}
public AstType Type {
get { return GetChildByRole (Roles.Type); }
set { SetChildByRole (Roles.Type, value); }
@ -51,7 +56,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -51,7 +56,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (InitializerRole, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitArrayCreateExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitArrayCreateExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitArrayCreateExpression (this, data);
}

23
ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayInitializerExpression.cs

@ -58,7 +58,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -58,7 +58,16 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return default (T);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return default (S);
}
@ -82,7 +91,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -82,7 +91,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RBrace); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitArrayInitializerExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitArrayInitializerExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitArrayInitializerExpression (this, data);
}

16
ICSharpCode.NRefactory.CSharp/Ast/Expressions/AsExpression.cs

@ -31,13 +31,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,13 +31,15 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class AsExpression : Expression
{
public readonly static TokenRole AsKeywordRole = new TokenRole ("as");
public Expression Expression {
get { return GetChildByRole (Roles.Expression); }
set { SetChildByRole(Roles.Expression, value); }
}
public CSharpTokenNode AsToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (AsKeywordRole); }
}
public AstType Type {
@ -55,7 +57,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -55,7 +57,17 @@ namespace ICSharpCode.NRefactory.CSharp
AddChild (type, Roles.Type);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitAsExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitAsExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitAsExpression (this, data);
}

51
ICSharpCode.NRefactory.CSharp/Ast/Expressions/AssignmentExpression.cs

@ -36,9 +36,20 @@ namespace ICSharpCode.NRefactory.CSharp @@ -36,9 +36,20 @@ namespace ICSharpCode.NRefactory.CSharp
{
// reuse roles from BinaryOperatorExpression
public readonly static Role<Expression> LeftRole = BinaryOperatorExpression.LeftRole;
public readonly static Role<CSharpTokenNode> OperatorRole = BinaryOperatorExpression.OperatorRole;
public readonly static Role<Expression> RightRole = BinaryOperatorExpression.RightRole;
public readonly static TokenRole AssignRole = new TokenRole ("=");
public readonly static TokenRole AddRole = new TokenRole ("+=");
public readonly static TokenRole SubtractRole = new TokenRole ("-=");
public readonly static TokenRole MultiplyRole = new TokenRole ("*=");
public readonly static TokenRole DivideRole = new TokenRole ("/=");
public readonly static TokenRole ModulusRole = new TokenRole ("%=");
public readonly static TokenRole ShiftLeftRole = new TokenRole ("<<=");
public readonly static TokenRole ShiftRightRole = new TokenRole (">>=");
public readonly static TokenRole BitwiseAndRole = new TokenRole ("&=");
public readonly static TokenRole BitwiseOrRole = new TokenRole ("|=");
public readonly static TokenRole ExclusiveOrRole = new TokenRole ("^=");
public AssignmentExpression()
{
}
@ -67,7 +78,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -67,7 +78,7 @@ namespace ICSharpCode.NRefactory.CSharp
}
public CSharpTokenNode OperatorToken {
get { return GetChildByRole (OperatorRole); }
get { return GetChildByRole (GetOperatorRole(Operator)); }
}
public Expression Right {
@ -75,7 +86,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -75,7 +86,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole(RightRole, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitAssignmentExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitAssignmentExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitAssignmentExpression (this, data);
}
@ -87,31 +108,31 @@ namespace ICSharpCode.NRefactory.CSharp @@ -87,31 +108,31 @@ namespace ICSharpCode.NRefactory.CSharp
&& this.Left.DoMatch(o.Left, match) && this.Right.DoMatch(o.Right, match);
}
public static string GetOperatorSymbol(AssignmentOperatorType op)
public static TokenRole GetOperatorRole(AssignmentOperatorType op)
{
switch (op) {
case AssignmentOperatorType.Assign:
return "=";
return AssignRole;
case AssignmentOperatorType.Add:
return "+=";
return AddRole;
case AssignmentOperatorType.Subtract:
return "-=";
return SubtractRole;
case AssignmentOperatorType.Multiply:
return "*=";
return MultiplyRole;
case AssignmentOperatorType.Divide:
return "/=";
return DivideRole;
case AssignmentOperatorType.Modulus:
return "%=";
return ModulusRole;
case AssignmentOperatorType.ShiftLeft:
return "<<=";
return ShiftLeftRole;
case AssignmentOperatorType.ShiftRight:
return ">>=";
return ShiftRightRole;
case AssignmentOperatorType.BitwiseAnd:
return "&=";
return BitwiseAndRole;
case AssignmentOperatorType.BitwiseOr:
return "|=";
return BitwiseOrRole;
case AssignmentOperatorType.ExclusiveOr:
return "^=";
return ExclusiveOrRole;
default:
throw new NotSupportedException("Invalid value for AssignmentOperatorType");
}

12
ICSharpCode.NRefactory.CSharp/Ast/Expressions/BaseReferenceExpression.cs

@ -47,7 +47,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -47,7 +47,17 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitBaseReferenceExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitBaseReferenceExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitBaseReferenceExpression (this, data);
}

77
ICSharpCode.NRefactory.CSharp/Ast/Expressions/BinaryOperatorExpression.cs

@ -34,8 +34,27 @@ namespace ICSharpCode.NRefactory.CSharp @@ -34,8 +34,27 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class BinaryOperatorExpression : Expression
{
public readonly static TokenRole BitwiseAndRole = new TokenRole ("&");
public readonly static TokenRole BitwiseOrRole = new TokenRole ("|");
public readonly static TokenRole ConditionalAndRole = new TokenRole ("&&");
public readonly static TokenRole ConditionalOrRole = new TokenRole ("||");
public readonly static TokenRole ExclusiveOrRole = new TokenRole ("^");
public readonly static TokenRole GreaterThanRole = new TokenRole (">");
public readonly static TokenRole GreaterThanOrEqualRole = new TokenRole (">=");
public readonly static TokenRole EqualityRole = new TokenRole ("==");
public readonly static TokenRole InEqualityRole = new TokenRole ("!=");
public readonly static TokenRole LessThanRole = new TokenRole ("<");
public readonly static TokenRole LessThanOrEqualRole = new TokenRole ("<=");
public readonly static TokenRole AddRole = new TokenRole ("+");
public readonly static TokenRole SubtractRole = new TokenRole ("-");
public readonly static TokenRole MultiplyRole = new TokenRole ("*");
public readonly static TokenRole DivideRole = new TokenRole ("/");
public readonly static TokenRole ModulusRole = new TokenRole ("%");
public readonly static TokenRole ShiftLeftRole = new TokenRole ("<<");
public readonly static TokenRole ShiftRightRole = new TokenRole (">>");
public readonly static TokenRole NullCoalescingRole = new TokenRole ("??");
public readonly static Role<Expression> LeftRole = new Role<Expression>("Left", Expression.Null);
public readonly static Role<CSharpTokenNode> OperatorRole = new Role<CSharpTokenNode>("Operator", CSharpTokenNode.Null);
public readonly static Role<Expression> RightRole = new Role<Expression>("Right", Expression.Null);
public BinaryOperatorExpression()
@ -60,15 +79,25 @@ namespace ICSharpCode.NRefactory.CSharp @@ -60,15 +79,25 @@ namespace ICSharpCode.NRefactory.CSharp
}
public CSharpTokenNode OperatorToken {
get { return GetChildByRole (OperatorRole); }
get { return GetChildByRole (GetOperatorRole (Operator)); }
}
public Expression Right {
get { return GetChildByRole (RightRole); }
set { SetChildByRole(RightRole, value); }
set { SetChildByRole (RightRole, value); }
}
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitBinaryOperatorExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitBinaryOperatorExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitBinaryOperatorExpression (this, data);
}
@ -80,47 +109,47 @@ namespace ICSharpCode.NRefactory.CSharp @@ -80,47 +109,47 @@ namespace ICSharpCode.NRefactory.CSharp
&& this.Left.DoMatch(o.Left, match) && this.Right.DoMatch(o.Right, match);
}
public static string GetOperatorSymbol(BinaryOperatorType op)
public static TokenRole GetOperatorRole (BinaryOperatorType op)
{
switch (op) {
case BinaryOperatorType.BitwiseAnd:
return "&";
return BitwiseAndRole;
case BinaryOperatorType.BitwiseOr:
return "|";
return BitwiseOrRole;
case BinaryOperatorType.ConditionalAnd:
return "&&";
return ConditionalAndRole;
case BinaryOperatorType.ConditionalOr:
return "||";
return ConditionalOrRole;
case BinaryOperatorType.ExclusiveOr:
return "^";
return ExclusiveOrRole;
case BinaryOperatorType.GreaterThan:
return ">";
return GreaterThanRole;
case BinaryOperatorType.GreaterThanOrEqual:
return ">=";
return GreaterThanOrEqualRole;
case BinaryOperatorType.Equality:
return "==";
return EqualityRole;
case BinaryOperatorType.InEquality:
return "!=";
return InEqualityRole;
case BinaryOperatorType.LessThan:
return "<";
return LessThanRole;
case BinaryOperatorType.LessThanOrEqual:
return "<=";
return LessThanOrEqualRole;
case BinaryOperatorType.Add:
return "+";
return AddRole;
case BinaryOperatorType.Subtract:
return "-";
return SubtractRole;
case BinaryOperatorType.Multiply:
return "*";
return MultiplyRole;
case BinaryOperatorType.Divide:
return "/";
return DivideRole;
case BinaryOperatorType.Modulus:
return "%";
return ModulusRole;
case BinaryOperatorType.ShiftLeft:
return "<<";
return ShiftLeftRole;
case BinaryOperatorType.ShiftRight:
return ">>";
return ShiftRightRole;
case BinaryOperatorType.NullCoalescing:
return "??";
return NullCoalescingRole;
default:
throw new NotSupportedException("Invalid value for BinaryOperatorType");
}

12
ICSharpCode.NRefactory.CSharp/Ast/Expressions/CastExpression.cs

@ -59,7 +59,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -59,7 +59,17 @@ namespace ICSharpCode.NRefactory.CSharp
AddChild (expression, Roles.Expression);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitCastExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitCastExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitCastExpression (this, data);
}

16
ICSharpCode.NRefactory.CSharp/Ast/Expressions/CheckedExpression.cs

@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class CheckedExpression : Expression
{
public readonly static TokenRole CheckedKeywordRole = new TokenRole ("checked");
public CSharpTokenNode CheckedToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (CheckedKeywordRole); }
}
public CSharpTokenNode LParToken {
@ -57,7 +59,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -57,7 +59,17 @@ namespace ICSharpCode.NRefactory.CSharp
AddChild (expression, Roles.Expression);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitCheckedExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitCheckedExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitCheckedExpression (this, data);
}

16
ICSharpCode.NRefactory.CSharp/Ast/Expressions/ConditionalExpression.cs

@ -32,9 +32,9 @@ namespace ICSharpCode.NRefactory.CSharp @@ -32,9 +32,9 @@ namespace ICSharpCode.NRefactory.CSharp
public class ConditionalExpression : Expression
{
public readonly static Role<Expression> ConditionRole = Roles.Condition;
public readonly static Role<CSharpTokenNode> QuestionMarkRole = new Role<CSharpTokenNode>("QuestionMark", CSharpTokenNode.Null);
public readonly static TokenRole QuestionMarkRole = new TokenRole("?");
public readonly static Role<Expression> TrueRole = new Role<Expression>("True", Expression.Null);
public readonly static Role<CSharpTokenNode> ColonRole = Roles.Colon;
public readonly static TokenRole ColonRole = Roles.Colon;
public readonly static Role<Expression> FalseRole = new Role<Expression>("False", Expression.Null);
public Expression Condition {
@ -71,7 +71,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -71,7 +71,17 @@ namespace ICSharpCode.NRefactory.CSharp
AddChild (falseExpression, FalseRole);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitConditionalExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitConditionalExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitConditionalExpression (this, data);
}

16
ICSharpCode.NRefactory.CSharp/Ast/Expressions/DefaultValueExpression.cs

@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class DefaultValueExpression : Expression
{
public readonly static TokenRole DefaultKeywordRole = new TokenRole ("default");
public CSharpTokenNode DefaultToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (DefaultKeywordRole); }
}
public CSharpTokenNode LParToken {
@ -57,7 +59,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -57,7 +59,17 @@ namespace ICSharpCode.NRefactory.CSharp
AddChild (type, Roles.Type);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitDefaultValueExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitDefaultValueExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitDefaultValueExpression (this, data);
}

17
ICSharpCode.NRefactory.CSharp/Ast/Expressions/DirectionExpression.cs

@ -38,13 +38,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -38,13 +38,16 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class DirectionExpression : Expression
{
public readonly static TokenRole RefKeywordRole = new TokenRole ("ref");
public readonly static TokenRole OutKeywordRole = new TokenRole ("out");
public FieldDirection FieldDirection {
get;
set;
}
public CSharpTokenNode FieldDirectionToken {
get { return GetChildByRole (Roles.Keyword); }
get { return FieldDirection == ICSharpCode.NRefactory.CSharp.FieldDirection.Ref ? GetChildByRole (RefKeywordRole) : GetChildByRole (OutKeywordRole); }
}
public Expression Expression {
@ -62,7 +65,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -62,7 +65,17 @@ namespace ICSharpCode.NRefactory.CSharp
AddChild (expression, Roles.Expression);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitDirectionExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitDirectionExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitDirectionExpression (this, data);
}

15
ICSharpCode.NRefactory.CSharp/Ast/Expressions/EmptyExpression.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -30,7 +30,7 @@ namespace ICSharpCode.NRefactory.CSharp
/// <summary>
/// Type&lt;[EMPTY]&gt;
/// </summary>
public class EmptyExpression : Expression, IRelocatable
public class EmptyExpression : Expression
{
TextLocation location;
@ -55,14 +55,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -55,14 +55,17 @@ namespace ICSharpCode.NRefactory.CSharp
this.location = location;
}
#region IRelocationable implementation
void IRelocatable.SetStartLocation (TextLocation startLocation)
public override void AcceptVisitor (IAstVisitor visitor)
{
this.location = startLocation;
visitor.VisitEmptyExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitEmptyExpression (this);
}
#endregion
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitEmptyExpression (this, data);
}

14
ICSharpCode.NRefactory.CSharp/Ast/Expressions/ErrorExpression.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// ErrorExpression.cs
//
// Author:
@ -52,8 +52,18 @@ namespace ICSharpCode.NRefactory.CSharp @@ -52,8 +52,18 @@ namespace ICSharpCode.NRefactory.CSharp
this.location = location;
}
public override void AcceptVisitor (IAstVisitor visitor)
{
// nothing
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
// nothing
return default (T);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
// nothing
return default(S);

23
ICSharpCode.NRefactory.CSharp/Ast/Expressions/Expression.cs

@ -41,7 +41,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -41,7 +41,16 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return default (T);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return default (S);
}
@ -72,7 +81,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -72,7 +81,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return NodeType.Pattern; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data = default(T))
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);
}

14
ICSharpCode.NRefactory.CSharp/Ast/Expressions/IdentifierExpression.cs

@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp
return GetChildByRole (Roles.Identifier).Name;
}
set {
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, TextLocation.Empty));
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value));
}
}
@ -60,7 +60,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -60,7 +60,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildrenByRole (Roles.TypeArgument); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitIdentifierExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitIdentifierExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitIdentifierExpression (this, data);
}

12
ICSharpCode.NRefactory.CSharp/Ast/Expressions/IndexerExpression.cs

@ -68,7 +68,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -68,7 +68,17 @@ namespace ICSharpCode.NRefactory.CSharp
{
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitIndexerExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitIndexerExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitIndexerExpression (this, data);
}

12
ICSharpCode.NRefactory.CSharp/Ast/Expressions/InvocationExpression.cs

@ -50,7 +50,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -50,7 +50,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RPar); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitInvocationExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitInvocationExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitInvocationExpression (this, data);
}

16
ICSharpCode.NRefactory.CSharp/Ast/Expressions/IsExpression.cs

@ -31,13 +31,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,13 +31,15 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class IsExpression : Expression
{
public readonly static TokenRole IsKeywordRole = new TokenRole ("is");
public Expression Expression {
get { return GetChildByRole(Roles.Expression); }
set { SetChildByRole(Roles.Expression, value); }
}
public CSharpTokenNode IsToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (IsKeywordRole); }
}
public AstType Type {
@ -45,7 +47,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -45,7 +47,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole(Roles.Type, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitIsExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitIsExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitIsExpression (this, data);
}

23
ICSharpCode.NRefactory.CSharp/Ast/Expressions/LambdaExpression.cs

@ -33,11 +33,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -33,11 +33,16 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class LambdaExpression : Expression
{
public readonly static Role<CSharpTokenNode> AsyncModifierRole = new Role<CSharpTokenNode>("AsyncModifier", CSharpTokenNode.Null);
public readonly static Role<CSharpTokenNode> ArrowRole = new Role<CSharpTokenNode>("Arrow", CSharpTokenNode.Null);
public readonly static TokenRole AsyncModifierRole = new TokenRole ("async");
public readonly static TokenRole ArrowRole = new TokenRole ("=>");
public static readonly Role<AstNode> BodyRole = new Role<AstNode>("Body", AstNode.Null);
public bool IsAsync { get; set; }
bool isAsync;
public bool IsAsync {
get { return isAsync; }
set { ThrowIfFrozen(); isAsync = value; }
}
public AstNodeCollection<ParameterDeclaration> Parameters {
get { return GetChildrenByRole (Roles.Parameter); }
@ -52,7 +57,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -52,7 +57,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (BodyRole, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitLambdaExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitLambdaExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitLambdaExpression (this, data);
}

14
ICSharpCode.NRefactory.CSharp/Ast/Expressions/MemberReferenceExpression.cs

@ -43,7 +43,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -43,7 +43,7 @@ namespace ICSharpCode.NRefactory.CSharp
return GetChildByRole (Roles.Identifier).Name;
}
set {
SetChildByRole (Roles.Identifier, Identifier.Create (value, TextLocation.Empty));
SetChildByRole (Roles.Identifier, Identifier.Create (value));
}
}
@ -87,7 +87,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -87,7 +87,17 @@ namespace ICSharpCode.NRefactory.CSharp
{
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitMemberReferenceExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitMemberReferenceExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitMemberReferenceExpression (this, data);
}

14
ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedArgumentExpression.cs

@ -41,7 +41,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -41,7 +41,7 @@ namespace ICSharpCode.NRefactory.CSharp
return GetChildByRole (Roles.Identifier).Name;
}
set {
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, TextLocation.Empty));
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value));
}
}
@ -63,7 +63,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -63,7 +63,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.Expression, value); }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitNamedArgumentExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitNamedArgumentExpression (this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNamedArgumentExpression(this, data);
}

14
ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedExpression.cs

@ -51,7 +51,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -51,7 +51,7 @@ namespace ICSharpCode.NRefactory.CSharp
return GetChildByRole (Roles.Identifier).Name;
}
set {
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, TextLocation.Empty));
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value));
}
}
@ -73,7 +73,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -73,7 +73,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.Expression, value); }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitNamedExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitNamedExpression (this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNamedExpression(this, data);
}

12
ICSharpCode.NRefactory.CSharp/Ast/Expressions/NullReferenceExpression.cs

@ -53,7 +53,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -53,7 +53,17 @@ namespace ICSharpCode.NRefactory.CSharp
this.location = location;
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitNullReferenceExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitNullReferenceExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNullReferenceExpression (this, data);
}

15
ICSharpCode.NRefactory.CSharp/Ast/Expressions/ObjectCreateExpression.cs

@ -33,10 +33,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -33,10 +33,11 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class ObjectCreateExpression : Expression
{
public readonly static TokenRole NewKeywordRole = new TokenRole ("new");
public readonly static Role<ArrayInitializerExpression> InitializerRole = ArrayCreateExpression.InitializerRole;
public CSharpTokenNode NewToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (NewKeywordRole); }
}
public AstType Type {
@ -79,7 +80,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -79,7 +80,17 @@ namespace ICSharpCode.NRefactory.CSharp
{
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitObjectCreateExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitObjectCreateExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitObjectCreateExpression (this, data);
}

14
ICSharpCode.NRefactory.CSharp/Ast/Expressions/ParenthesizedExpression.cs

@ -53,7 +53,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -53,7 +53,17 @@ namespace ICSharpCode.NRefactory.CSharp
Expression = expr;
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitParenthesizedExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitParenthesizedExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitParenthesizedExpression (this, data);
}
@ -81,7 +91,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -81,7 +91,7 @@ namespace ICSharpCode.NRefactory.CSharp
public static Expression UnpackParenthesizedExpression(Expression expr)
{
while (ActsAsParenthesizedExpression(expr))
expr = expr.GetChildByRole(ParenthesizedExpression.Roles.Expression);
expr = expr.GetChildByRole(Roles.Expression);
return expr;
}
}

20
ICSharpCode.NRefactory.CSharp/Ast/Expressions/PointerReferenceExpression.cs

@ -33,19 +33,23 @@ namespace ICSharpCode.NRefactory.CSharp @@ -33,19 +33,23 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class PointerReferenceExpression : Expression
{
public readonly static Role<CSharpTokenNode> ArrowRole = new Role<CSharpTokenNode>("Arrow", CSharpTokenNode.Null);
public readonly static TokenRole ArrowRole = new TokenRole ("->");
public Expression Target {
get { return GetChildByRole (Roles.TargetExpression); }
set { SetChildByRole(Roles.TargetExpression, value); }
}
public CSharpTokenNode ArrowToken {
get { return GetChildByRole (ArrowRole); }
}
public string MemberName {
get {
return GetChildByRole (Roles.Identifier).Name;
}
set {
SetChildByRole(Roles.Identifier, Identifier.Create (value, TextLocation.Empty));
SetChildByRole(Roles.Identifier, Identifier.Create (value));
}
}
@ -53,7 +57,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -53,7 +57,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildrenByRole (Roles.TypeArgument); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitPointerReferenceExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitPointerReferenceExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPointerReferenceExpression (this, data);
}

35
ICSharpCode.NRefactory.CSharp/Ast/Expressions/PrimitiveExpression.cs

@ -24,12 +24,14 @@ @@ -24,12 +24,14 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace ICSharpCode.NRefactory.CSharp
{
/// <summary>
/// Represents a literal value.
/// </summary>
public class PrimitiveExpression : Expression, IRelocatable
public class PrimitiveExpression : Expression
{
public static readonly object AnyValue = new object();
@ -47,20 +49,30 @@ namespace ICSharpCode.NRefactory.CSharp @@ -47,20 +49,30 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
object value;
public object Value {
get;
set;
get { return this.value; }
set {
ThrowIfFrozen();
this.value = value;
}
}
public string LiteralValue {
get {
return literalValue;
get { return literalValue; }
set {
if (value == null)
throw new ArgumentNullException();
ThrowIfFrozen();
literalValue = value;
}
}
public PrimitiveExpression (object value)
{
this.Value = value;
this.literalValue = "";
}
public PrimitiveExpression (object value, string literalValue)
@ -76,14 +88,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -76,14 +88,17 @@ namespace ICSharpCode.NRefactory.CSharp
this.literalValue = literalValue ?? "";
}
#region IRelocationable implementation
void IRelocatable.SetStartLocation (TextLocation startLocation)
public override void AcceptVisitor (IAstVisitor visitor)
{
this.startLocation = startLocation;
visitor.VisitPrimitiveExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitPrimitiveExpression (this);
}
#endregion
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPrimitiveExpression (this, data);
}

183
ICSharpCode.NRefactory.CSharp/Ast/Expressions/QueryExpression.cs

@ -36,7 +36,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -36,7 +36,16 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return default (T);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return default (S);
}
@ -52,7 +61,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -52,7 +61,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildrenByRole(ClauseRole); }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitQueryExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitQueryExpression (this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQueryExpression (this, data);
}
@ -92,7 +111,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -92,7 +111,7 @@ namespace ICSharpCode.NRefactory.CSharp
public class QueryContinuationClause : QueryClause
{
public static readonly Role<QueryExpression> PrecedingQueryRole = new Role<QueryExpression>("PrecedingQuery", QueryExpression.Null);
public static readonly Role<CSharpTokenNode> IntoKeywordRole = Roles.Keyword;
public static readonly TokenRole IntoKeywordRole = new TokenRole ("into");
public QueryExpression PrecedingQuery {
get { return GetChildByRole(PrecedingQueryRole); }
@ -104,7 +123,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -104,7 +123,7 @@ namespace ICSharpCode.NRefactory.CSharp
return GetChildByRole (Roles.Identifier).Name;
}
set {
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, TextLocation.Empty));
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value));
}
}
@ -112,7 +131,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -112,7 +131,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.Identifier); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitQueryContinuationClause (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitQueryContinuationClause (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQueryContinuationClause (this, data);
}
@ -126,8 +155,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -126,8 +155,8 @@ namespace ICSharpCode.NRefactory.CSharp
public class QueryFromClause : QueryClause
{
public static readonly Role<CSharpTokenNode> FromKeywordRole = Roles.Keyword;
public static readonly Role<CSharpTokenNode> InKeywordRole = Roles.InKeyword;
public static readonly TokenRole FromKeywordRole = new TokenRole ("from");
public static readonly TokenRole InKeywordRole = new TokenRole ("in");
public AstType Type {
get { return GetChildByRole (Roles.Type); }
@ -139,7 +168,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -139,7 +168,7 @@ namespace ICSharpCode.NRefactory.CSharp
return GetChildByRole (Roles.Identifier).Name;
}
set {
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, TextLocation.Empty));
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value));
}
}
@ -152,7 +181,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -152,7 +181,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.Expression, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitQueryFromClause (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitQueryFromClause (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQueryFromClause (this, data);
}
@ -167,8 +206,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -167,8 +206,10 @@ namespace ICSharpCode.NRefactory.CSharp
public class QueryLetClause : QueryClause
{
public readonly static TokenRole LetKeywordRole = new TokenRole ("let");
public CSharpTokenNode LetKeyword {
get { return GetChildByRole(Roles.Keyword); }
get { return GetChildByRole(LetKeywordRole); }
}
public string Identifier {
@ -176,7 +217,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -176,7 +217,7 @@ namespace ICSharpCode.NRefactory.CSharp
return GetChildByRole(Roles.Identifier).Name;
}
set {
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, TextLocation.Empty));
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value));
}
}
@ -193,7 +234,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -193,7 +234,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole(Roles.Expression, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitQueryLetClause (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitQueryLetClause (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQueryLetClause (this, data);
}
@ -208,8 +259,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -208,8 +259,10 @@ namespace ICSharpCode.NRefactory.CSharp
public class QueryWhereClause : QueryClause
{
public readonly static TokenRole WhereKeywordRole = new TokenRole ("where");
public CSharpTokenNode WhereKeyword {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (WhereKeywordRole); }
}
public Expression Condition {
@ -217,7 +270,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -217,7 +270,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.Condition, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitQueryWhereClause (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitQueryWhereClause (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQueryWhereClause (this, data);
}
@ -234,16 +297,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -234,16 +297,16 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class QueryJoinClause : QueryClause
{
public static readonly Role<CSharpTokenNode> JoinKeywordRole = Roles.Keyword;
public static readonly TokenRole JoinKeywordRole = new TokenRole ("join");
public static readonly Role<AstType> TypeRole = Roles.Type;
public static readonly Role<Identifier> JoinIdentifierRole = Roles.Identifier;
public static readonly Role<CSharpTokenNode> InKeywordRole = Roles.InKeyword;
public static readonly TokenRole InKeywordRole = new TokenRole ("in");
public static readonly Role<Expression> InExpressionRole = Roles.Expression;
public static readonly Role<CSharpTokenNode> OnKeywordRole = new Role<CSharpTokenNode>("OnKeyword", CSharpTokenNode.Null);
public static readonly TokenRole OnKeywordRole = new TokenRole ("on");
public static readonly Role<Expression> OnExpressionRole = new Role<Expression>("OnExpression", Expression.Null);
public static readonly Role<CSharpTokenNode> EqualsKeywordRole = new Role<CSharpTokenNode>("EqualsKeyword", CSharpTokenNode.Null);
public static readonly TokenRole EqualsKeywordRole = new TokenRole ("equals");
public static readonly Role<Expression> EqualsExpressionRole = new Role<Expression>("EqualsExpression", Expression.Null);
public static readonly Role<CSharpTokenNode> IntoKeywordRole = new Role<CSharpTokenNode>("IntoKeyword", CSharpTokenNode.Null);
public static readonly TokenRole IntoKeywordRole = new TokenRole ("into");
public static readonly Role<Identifier> IntoIdentifierRole = new Role<Identifier>("IntoIdentifier", Identifier.Null);
public bool IsGroupJoin {
@ -264,7 +327,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -264,7 +327,7 @@ namespace ICSharpCode.NRefactory.CSharp
return GetChildByRole(JoinIdentifierRole).Name;
}
set {
SetChildByRole(JoinIdentifierRole, Identifier.Create (value, TextLocation.Empty));
SetChildByRole(JoinIdentifierRole, Identifier.Create (value));
}
}
@ -308,7 +371,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -308,7 +371,7 @@ namespace ICSharpCode.NRefactory.CSharp
return GetChildByRole (IntoIdentifierRole).Name;
}
set {
SetChildByRole(IntoIdentifierRole, Identifier.Create (value, TextLocation.Empty));
SetChildByRole(IntoIdentifierRole, Identifier.Create (value));
}
}
@ -316,7 +379,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -316,7 +379,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole(IntoIdentifierRole); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitQueryJoinClause (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitQueryJoinClause (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQueryJoinClause (this, data);
}
@ -334,17 +407,28 @@ namespace ICSharpCode.NRefactory.CSharp @@ -334,17 +407,28 @@ namespace ICSharpCode.NRefactory.CSharp
public class QueryOrderClause : QueryClause
{
public static readonly TokenRole OrderbyKeywordRole = new TokenRole ("orderby");
public static readonly Role<QueryOrdering> OrderingRole = new Role<QueryOrdering>("Ordering");
public CSharpTokenNode Keyword {
get { return GetChildByRole (Roles.Keyword); }
public CSharpTokenNode OrderbyToken {
get { return GetChildByRole (OrderbyKeywordRole); }
}
public AstNodeCollection<QueryOrdering> Orderings {
get { return GetChildrenByRole (OrderingRole); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitQueryOrderClause (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitQueryOrderClause (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQueryOrderClause (this, data);
}
@ -358,6 +442,9 @@ namespace ICSharpCode.NRefactory.CSharp @@ -358,6 +442,9 @@ namespace ICSharpCode.NRefactory.CSharp
public class QueryOrdering : AstNode
{
public readonly static TokenRole AscendingKeywordRole = new TokenRole ("ascending");
public readonly static TokenRole DescendingKeywordRole = new TokenRole ("descending");
public override NodeType NodeType {
get { return NodeType.Unknown; }
}
@ -373,10 +460,20 @@ namespace ICSharpCode.NRefactory.CSharp @@ -373,10 +460,20 @@ namespace ICSharpCode.NRefactory.CSharp
}
public CSharpTokenNode DirectionToken {
get { return GetChildByRole (Roles.Keyword); }
get { return Direction == QueryOrderingDirection.Ascending ? GetChildByRole (AscendingKeywordRole) : GetChildByRole (DescendingKeywordRole); }
}
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitQueryOrdering (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitQueryOrdering (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQueryOrdering (this, data);
}
@ -397,8 +494,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -397,8 +494,10 @@ namespace ICSharpCode.NRefactory.CSharp
public class QuerySelectClause : QueryClause
{
public readonly static TokenRole SelectKeywordRole = new TokenRole ("select");
public CSharpTokenNode SelectKeyword {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (SelectKeywordRole); }
}
public Expression Expression {
@ -406,7 +505,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -406,7 +505,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.Expression, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitQuerySelectClause (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitQuerySelectClause (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQuerySelectClause (this, data);
}
@ -420,9 +529,9 @@ namespace ICSharpCode.NRefactory.CSharp @@ -420,9 +529,9 @@ namespace ICSharpCode.NRefactory.CSharp
public class QueryGroupClause : QueryClause
{
public static readonly Role<CSharpTokenNode> GroupKeywordRole = Roles.Keyword;
public static readonly TokenRole GroupKeywordRole = new TokenRole ("group");
public static readonly Role<Expression> ProjectionRole = new Role<Expression>("Projection", Expression.Null);
public static readonly Role<CSharpTokenNode> ByKeywordRole = new Role<CSharpTokenNode>("ByKeyword", CSharpTokenNode.Null);
public static readonly TokenRole ByKeywordRole = new TokenRole ("by");
public static readonly Role<Expression> KeyRole = new Role<Expression>("Key", Expression.Null);
public CSharpTokenNode GroupKeyword {
@ -443,7 +552,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -443,7 +552,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (KeyRole, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitQueryGroupClause (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitQueryGroupClause (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitQueryGroupClause (this, data);
}

16
ICSharpCode.NRefactory.CSharp/Ast/Expressions/SizeOfExpression.cs

@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class SizeOfExpression : Expression
{
public readonly static TokenRole SizeofKeywordRole = new TokenRole ("sizeof");
public CSharpTokenNode SizeOfToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (SizeofKeywordRole); }
}
public CSharpTokenNode LParToken {
@ -57,7 +59,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -57,7 +59,17 @@ namespace ICSharpCode.NRefactory.CSharp
AddChild (type, Roles.Type);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitSizeOfExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitSizeOfExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitSizeOfExpression (this, data);
}

16
ICSharpCode.NRefactory.CSharp/Ast/Expressions/StackAllocExpression.cs

@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class StackAllocExpression : Expression
{
public readonly static TokenRole StackallocKeywordRole = new TokenRole ("stackalloc");
public CSharpTokenNode StackAllocToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (StackallocKeywordRole); }
}
public AstType Type {
@ -53,7 +55,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -53,7 +55,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RBracket); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitStackAllocExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitStackAllocExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitStackAllocExpression (this, data);
}

14
ICSharpCode.NRefactory.CSharp/Ast/Expressions/ThisReferenceExpression.cs

@ -46,8 +46,18 @@ namespace ICSharpCode.NRefactory.CSharp @@ -46,8 +46,18 @@ namespace ICSharpCode.NRefactory.CSharp
return new TextLocation (Location.Line, Location.Column + "this".Length);
}
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitThisReferenceExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitThisReferenceExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitThisReferenceExpression (this, data);
}

16
ICSharpCode.NRefactory.CSharp/Ast/Expressions/TypeOfExpression.cs

@ -32,8 +32,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -32,8 +32,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class TypeOfExpression : Expression
{
public readonly static TokenRole TypeofKeywordRole = new TokenRole ("typeof");
public CSharpTokenNode TypeOfToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (TypeofKeywordRole); }
}
public CSharpTokenNode LParToken {
@ -58,7 +60,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -58,7 +60,17 @@ namespace ICSharpCode.NRefactory.CSharp
AddChild (type, Roles.Type);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitTypeOfExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitTypeOfExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitTypeOfExpression (this, data);
}

12
ICSharpCode.NRefactory.CSharp/Ast/Expressions/TypeReferenceExpression.cs

@ -31,7 +31,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,7 +31,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole(Roles.Type, value); }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitTypeReferenceExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitTypeReferenceExpression (this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitTypeReferenceExpression(this, data);
}

44
ICSharpCode.NRefactory.CSharp/Ast/Expressions/UnaryOperatorExpression.cs

@ -34,7 +34,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -34,7 +34,15 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class UnaryOperatorExpression : Expression
{
public readonly static Role<CSharpTokenNode> OperatorRole = BinaryOperatorExpression.OperatorRole;
public readonly static TokenRole NotRole = new TokenRole ("!");
public readonly static TokenRole BitNotRole = new TokenRole ("~");
public readonly static TokenRole MinusRole = new TokenRole ("-");
public readonly static TokenRole PlusRole = new TokenRole ("+");
public readonly static TokenRole IncrementRole = new TokenRole ("++");
public readonly static TokenRole DecrementRole = new TokenRole ("--");
public readonly static TokenRole DereferenceRole = new TokenRole ("*");
public readonly static TokenRole AddressOfRole = new TokenRole ("&");
public readonly static TokenRole AwaitRole = new TokenRole ("await");
public UnaryOperatorExpression()
{
@ -52,7 +60,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -52,7 +60,7 @@ namespace ICSharpCode.NRefactory.CSharp
}
public CSharpTokenNode OperatorToken {
get { return GetChildByRole (OperatorRole); }
get { return GetChildByRole (GetOperatorRole (Operator)); }
}
public Expression Expression {
@ -60,7 +68,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -60,7 +68,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.Expression, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitUnaryOperatorExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitUnaryOperatorExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitUnaryOperatorExpression (this, data);
}
@ -72,29 +90,29 @@ namespace ICSharpCode.NRefactory.CSharp @@ -72,29 +90,29 @@ namespace ICSharpCode.NRefactory.CSharp
&& this.Expression.DoMatch(o.Expression, match);
}
public static string GetOperatorSymbol(UnaryOperatorType op)
public static TokenRole GetOperatorRole(UnaryOperatorType op)
{
switch (op) {
case UnaryOperatorType.Not:
return "!";
return NotRole;
case UnaryOperatorType.BitNot:
return "~";
return BitNotRole;
case UnaryOperatorType.Minus:
return "-";
return MinusRole;
case UnaryOperatorType.Plus:
return "+";
return PlusRole;
case UnaryOperatorType.Increment:
case UnaryOperatorType.PostIncrement:
return "++";
return IncrementRole;
case UnaryOperatorType.PostDecrement:
case UnaryOperatorType.Decrement:
return "--";
return DecrementRole;
case UnaryOperatorType.Dereference:
return "*";
return DereferenceRole;
case UnaryOperatorType.AddressOf:
return "&";
return AddressOfRole;
case UnaryOperatorType.Await:
return "await";
return AwaitRole;
default:
throw new NotSupportedException("Invalid value for UnaryOperatorType");
}

16
ICSharpCode.NRefactory.CSharp/Ast/Expressions/UncheckedExpression.cs

@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class UncheckedExpression : Expression
{
public readonly static TokenRole UncheckedKeywordRole = new TokenRole ("unchecked");
public CSharpTokenNode UncheckedToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (UncheckedKeywordRole); }
}
public CSharpTokenNode LParToken {
@ -57,7 +59,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -57,7 +59,17 @@ namespace ICSharpCode.NRefactory.CSharp
AddChild (expression, Roles.Expression);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitUncheckedExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitUncheckedExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitUncheckedExpression (this, data);
}

32
ICSharpCode.NRefactory.CSharp/Ast/Expressions/UndocumentedExpression.cs

@ -42,12 +42,30 @@ namespace ICSharpCode.NRefactory.CSharp @@ -42,12 +42,30 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class UndocumentedExpression : Expression
{
public readonly static TokenRole ArglistKeywordRole = new TokenRole ("__arglist");
public readonly static TokenRole RefvalueKeywordRole = new TokenRole ("__refvalue");
public readonly static TokenRole ReftypeKeywordRole = new TokenRole ("__reftype");
public readonly static TokenRole MakerefKeywordRole = new TokenRole ("__makeref");
public UndocumentedExpressionType UndocumentedExpressionType {
get; set;
}
public CSharpTokenNode UndocumentedToken {
get { return GetChildByRole (Roles.Keyword); }
get {
switch (UndocumentedExpressionType) {
case ICSharpCode.NRefactory.CSharp.UndocumentedExpressionType.ArgListAccess:
case ICSharpCode.NRefactory.CSharp.UndocumentedExpressionType.ArgList:
return GetChildByRole (ArglistKeywordRole);
case ICSharpCode.NRefactory.CSharp.UndocumentedExpressionType.RefValue:
return GetChildByRole (RefvalueKeywordRole);
case ICSharpCode.NRefactory.CSharp.UndocumentedExpressionType.RefType:
return GetChildByRole (ReftypeKeywordRole);
case ICSharpCode.NRefactory.CSharp.UndocumentedExpressionType.MakeRef:
return GetChildByRole (MakerefKeywordRole);
}
return CSharpTokenNode.Null;
}
}
public CSharpTokenNode LParToken {
@ -62,7 +80,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -62,7 +80,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RPar); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitUndocumentedExpression (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitUndocumentedExpression (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitUndocumentedExpression (this, data);
}

17
ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Attribute.cs

@ -54,7 +54,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -54,7 +54,17 @@ namespace ICSharpCode.NRefactory.CSharp
set;
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitAttribute (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitAttribute (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitAttribute (this, data);
}
@ -69,9 +79,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -69,9 +79,8 @@ namespace ICSharpCode.NRefactory.CSharp
{
if (IsNull)
return "Null";
var w = new System.IO.StringWriter ();
AcceptVisitor (new CSharpOutputVisitor (w, new CSharpFormattingOptions ()), null);
return w.ToString ();
else
return GetText();
}
}
}

31
ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/AttributeSection.cs

@ -54,7 +54,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -54,7 +54,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return NodeType.Pattern; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data = default(T))
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);
}
@ -71,9 +81,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -71,9 +81,6 @@ namespace ICSharpCode.NRefactory.CSharp
}
#endregion
public static readonly Role<Attribute> AttributeRole = new Role<Attribute>("Attribute");
public static readonly Role<CSharpTokenNode> TargetRole = new Role<CSharpTokenNode>("Target", CSharpTokenNode.Null);
public override NodeType NodeType {
get {
return NodeType.Unknown;
@ -89,7 +96,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -89,7 +96,7 @@ namespace ICSharpCode.NRefactory.CSharp
return GetChildByRole (Roles.Identifier).Name;
}
set {
SetChildByRole (Roles.Identifier, CSharp.Identifier.Create (value, TextLocation.Empty));
SetChildByRole (Roles.Identifier, CSharp.Identifier.Create (value));
}
}
@ -103,14 +110,24 @@ namespace ICSharpCode.NRefactory.CSharp @@ -103,14 +110,24 @@ namespace ICSharpCode.NRefactory.CSharp
}
public AstNodeCollection<Attribute> Attributes {
get { return base.GetChildrenByRole (AttributeRole); }
get { return base.GetChildrenByRole (Roles.Attribute); }
}
public CSharpTokenNode RBracketToken {
get { return GetChildByRole (Roles.RBracket); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitAttributeSection (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitAttributeSection (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitAttributeSection (this, data);
}

43
ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Comment.cs

@ -43,10 +43,14 @@ namespace ICSharpCode.NRefactory.CSharp @@ -43,10 +43,14 @@ namespace ICSharpCode.NRefactory.CSharp
/// <summary>
/// Inactive code (code in non-taken "#if")
/// </summary>
InactiveCode
InactiveCode,
/// <summary>
/// "/** */" comment
/// </summary>
MultiLineDocumentation
}
public class Comment : AstNode, IRelocatable
public class Comment : AstNode
{
public override NodeType NodeType {
get {
@ -54,19 +58,25 @@ namespace ICSharpCode.NRefactory.CSharp @@ -54,19 +58,25 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
CommentType commentType;
public CommentType CommentType {
get;
set;
get { return commentType; }
set { ThrowIfFrozen(); commentType = value; }
}
bool startsLine;
public bool StartsLine {
get;
set;
get { return startsLine; }
set { ThrowIfFrozen(); startsLine = value; }
}
string content;
public string Content {
get;
set;
get { return content; }
set { ThrowIfFrozen(); content = value; }
}
TextLocation startLocation;
@ -96,16 +106,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -96,16 +106,17 @@ namespace ICSharpCode.NRefactory.CSharp
this.endLocation = endLocation;
}
#region IRelocationable implementation
void IRelocatable.SetStartLocation (TextLocation startLocation)
public override void AcceptVisitor (IAstVisitor visitor)
{
int lineDelta = startLocation.Line - this.startLocation.Line;
endLocation = new TextLocation (endLocation.Line + lineDelta, lineDelta != 0 ? endLocation.Column : endLocation.Column + startLocation.Column - this.startLocation.Column);
this.startLocation = startLocation;
visitor.VisitComment (this);
}
#endregion
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitComment (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitComment (this, data);
}

23
ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Constraint.cs

@ -36,10 +36,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -36,10 +36,6 @@ namespace ICSharpCode.NRefactory.CSharp
/// </remarks>
public class Constraint : AstNode
{
public readonly static Role<CSharpTokenNode> ColonRole = TypeDeclaration.ColonRole;
public readonly static Role<AstType> BaseTypeRole = TypeDeclaration.BaseTypeRole;
public readonly static Role<SimpleType> TypeParameterRole = new Role<SimpleType> ("TypeParameter", SimpleType.Null);
public override NodeType NodeType {
get {
return NodeType.Unknown;
@ -48,18 +44,29 @@ namespace ICSharpCode.NRefactory.CSharp @@ -48,18 +44,29 @@ namespace ICSharpCode.NRefactory.CSharp
public SimpleType TypeParameter {
get {
return GetChildByRole (TypeParameterRole);
return GetChildByRole (Roles.ConstraintTypeParameter);
}
set {
SetChildByRole(TypeParameterRole, value);
SetChildByRole(Roles.ConstraintTypeParameter, value);
}
}
public AstNodeCollection<AstType> BaseTypes {
get { return GetChildrenByRole (BaseTypeRole); }
get {
return GetChildrenByRole(Roles.BaseType); }
}
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitConstraint (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitConstraint (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitConstraint (this, data);
}

50
ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/DelegateDeclaration.cs

@ -24,45 +24,27 @@ @@ -24,45 +24,27 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System.Collections.Generic;
using System.Linq;
using ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.NRefactory.CSharp
{
/// <summary>
/// delegate ReturnType Name&lt;TypeParameters&gt;(Parameters) where Constraints;
/// </summary>
public class DelegateDeclaration : AttributedNode
public class DelegateDeclaration : EntityDeclaration
{
public override NodeType NodeType {
get {
return NodeType.TypeDeclaration;
}
get { return NodeType.TypeDeclaration; }
}
public AstType ReturnType {
get { return GetChildByRole (Roles.Type); }
set { SetChildByRole (Roles.Type, value); }
public override EntityType EntityType {
get { return EntityType.TypeDefinition; }
}
public string Name {
get {
return GetChildByRole (Roles.Identifier).Name;
}
set {
SetChildByRole (Roles.Identifier, Identifier.Create (value, TextLocation.Empty));
}
public CSharpTokenNode DelegateToken {
get { return GetChildByRole(Roles.DelegateKeyword); }
}
public Identifier NameToken {
get {
return GetChildByRole (Roles.Identifier);
}
set {
SetChildByRole (Roles.Identifier, value);
}
}
public AstNodeCollection<TypeParameterDeclaration> TypeParameters {
get { return GetChildrenByRole (Roles.TypeParameter); }
}
@ -83,7 +65,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -83,7 +65,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildrenByRole (Roles.Constraint); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitDelegateDeclaration (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitDelegateDeclaration (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitDelegateDeclaration (this, data);
}
@ -91,8 +83,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -91,8 +83,8 @@ namespace ICSharpCode.NRefactory.CSharp
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
DelegateDeclaration o = other as DelegateDeclaration;
return o != null && this.MatchAttributesAndModifiers(o, match)
&& this.ReturnType.DoMatch(o.ReturnType, match) && MatchString(this.Name, o.Name)
return o != null && MatchString(this.Name, o.Name)
&& this.MatchAttributesAndModifiers(o, match) && this.ReturnType.DoMatch(o.ReturnType, match)
&& this.TypeParameters.DoMatch(o.TypeParameters, match) && this.Parameters.DoMatch(o.Parameters, match)
&& this.Constraints.DoMatch(o.Constraints, match);
}

20
ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/ExternAliasDeclaration.cs

@ -31,8 +31,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,8 +31,6 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class ExternAliasDeclaration : AstNode
{
public static readonly Role<CSharpTokenNode> AliasRole = new Role<CSharpTokenNode> ("Alias", CSharpTokenNode.Null);
public override NodeType NodeType {
get {
return NodeType.Unknown;
@ -40,11 +38,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -40,11 +38,11 @@ namespace ICSharpCode.NRefactory.CSharp
}
public CSharpTokenNode ExternToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (Roles.ExternKeyword); }
}
public CSharpTokenNode AliasToken {
get { return GetChildByRole (AliasRole); }
get { return GetChildByRole (Roles.AliasKeyword); }
}
public string Name {
@ -52,7 +50,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -52,7 +50,7 @@ namespace ICSharpCode.NRefactory.CSharp
return GetChildByRole (Roles.Identifier).Name;
}
set {
SetChildByRole (Roles.Identifier, Identifier.Create (value, TextLocation.Empty));
SetChildByRole (Roles.Identifier, Identifier.Create (value));
}
}
@ -69,7 +67,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -69,7 +67,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.Semicolon); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitExternAliasDeclaration (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitExternAliasDeclaration (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitExternAliasDeclaration (this, data);
}

18
ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NamespaceDeclaration.cs

@ -43,6 +43,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -43,6 +43,10 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public CSharpTokenNode NamespaceToken {
get { return GetChildByRole (Roles.NamespaceKeyword); }
}
public string Name {
get {
StringBuilder builder = new StringBuilder ();
@ -54,7 +58,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -54,7 +58,7 @@ namespace ICSharpCode.NRefactory.CSharp
return builder.ToString ();
}
set {
GetChildrenByRole(Roles.Identifier).ReplaceWith(value.Split('.').Select(ident => Identifier.Create (ident, TextLocation.Empty)));
GetChildrenByRole(Roles.Identifier).ReplaceWith(value.Split('.').Select(ident => Identifier.Create (ident)));
}
}
@ -109,7 +113,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -109,7 +113,17 @@ namespace ICSharpCode.NRefactory.CSharp
AddChild (child, MemberRole);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitNamespaceDeclaration (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitNamespaceDeclaration (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNamespaceDeclaration (this, data);
}

132
ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NewLineNode.cs

@ -0,0 +1,132 @@ @@ -0,0 +1,132 @@
using System;
namespace ICSharpCode.NRefactory.CSharp
{
public enum NewLineType {
Unix,
Windows,
Mac
}
/// <summary>
/// A New line node represents a line break in the text.
/// </summary>
public abstract class NewLineNode : AstNode
{
public override NodeType NodeType {
get {
return NodeType.Whitespace;
}
}
public abstract NewLineType NewLineType {
get;
}
TextLocation startLocation;
public override TextLocation StartLocation {
get {
return startLocation;
}
}
public override TextLocation EndLocation {
get {
return new TextLocation (startLocation.Line + 1, 1);
}
}
public NewLineNode() : this (TextLocation.Empty)
{
}
public NewLineNode(TextLocation startLocation)
{
this.startLocation = startLocation;
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitNewLine (this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitNewLine (this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNewLine (this, data);
}
}
public class UnixNewLine : NewLineNode
{
public override NewLineType NewLineType {
get {
return NewLineType.Unix;
}
}
public UnixNewLine()
{
}
public UnixNewLine(TextLocation startLocation) : base (startLocation)
{
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
var o = other as UnixNewLine;
return o != null;
}
}
public class WindowsNewLine : NewLineNode
{
public override NewLineType NewLineType {
get {
return NewLineType.Windows;
}
}
public WindowsNewLine()
{
}
public WindowsNewLine(TextLocation startLocation) : base (startLocation)
{
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
var o = other as WindowsNewLine;
return o != null;
}
}
public class MacNewLine : NewLineNode
{
public override NewLineType NewLineType {
get {
return NewLineType.Mac;
}
}
public MacNewLine()
{
}
public MacNewLine(TextLocation startLocation) : base (startLocation)
{
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
var o = other as MacNewLine;
return o != null;
}
}
}

17
ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/PreProcessorDirective.cs

@ -46,7 +46,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -46,7 +46,7 @@ namespace ICSharpCode.NRefactory.CSharp
Line = 12
}
public class PreProcessorDirective : AstNode, IRelocatable
public class PreProcessorDirective : AstNode
{
public override NodeType NodeType {
get {
@ -93,16 +93,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -93,16 +93,17 @@ namespace ICSharpCode.NRefactory.CSharp
this.endLocation = endLocation;
}
#region IRelocationable implementation
void IRelocatable.SetStartLocation (TextLocation startLocation)
public override void AcceptVisitor (IAstVisitor visitor)
{
int lineDelta = startLocation.Line - this.startLocation.Line;
endLocation = new TextLocation (endLocation.Line + lineDelta, lineDelta != 0 ? endLocation.Column : endLocation.Column + startLocation.Column - this.startLocation.Column);
this.startLocation = startLocation;
visitor.VisitPreProcessorDirective (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitPreProcessorDirective (this);
}
#endregion
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPreProcessorDirective (this, data);
}

94
ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/TextNode.cs

@ -0,0 +1,94 @@ @@ -0,0 +1,94 @@
//
// TextNode.cs
//
// Author:
// Mike Krüger <mkrueger@xamarin.com>
//
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
//
// 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;
namespace ICSharpCode.NRefactory.CSharp
{
/// <summary>
/// A text node contains text without syntactic or semantic information.
/// (non parseable part of a text)
/// </summary>
public class TextNode : AstNode
{
public override NodeType NodeType {
get {
return NodeType.Whitespace;
}
}
public string Text {
get;
set;
}
TextLocation startLocation;
public override TextLocation StartLocation {
get {
return startLocation;
}
}
TextLocation endLocation;
public override TextLocation EndLocation {
get {
return endLocation;
}
}
public TextNode(string text) : this (text, TextLocation.Empty, TextLocation.Empty)
{
}
public TextNode(string text, TextLocation startLocation, TextLocation endLocation)
{
this.Text = text;
this.startLocation = startLocation;
this.endLocation = endLocation;
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitText (this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitText (this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitText (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
var o = other as TextNode;
return o != null && o.Text == Text;
}
}
}

70
ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/TypeDeclaration.cs

@ -41,66 +41,78 @@ namespace ICSharpCode.NRefactory.CSharp @@ -41,66 +41,78 @@ namespace ICSharpCode.NRefactory.CSharp
/// <summary>
/// class Name&lt;TypeParameters&gt; : BaseTypes where Constraints;
/// </summary>
public class TypeDeclaration : AttributedNode
public class TypeDeclaration : EntityDeclaration
{
public readonly static Role<CSharpTokenNode> ColonRole = Roles.Colon;
public readonly static Role<AstType> BaseTypeRole = new Role<AstType>("BaseType", AstType.Null);
public readonly static Role<AttributedNode> MemberRole = new Role<AttributedNode>("Member");
public override NodeType NodeType {
get {
return NodeType.TypeDeclaration;
}
get { return NodeType.TypeDeclaration; }
}
public ClassType ClassType {
get;
set;
public override EntityType EntityType {
get { return EntityType.TypeDefinition; }
}
public string Name {
ClassType classType;
public CSharpTokenNode TypeKeyword {
get {
return GetChildByRole (Roles.Identifier).Name;
}
set {
SetChildByRole (Roles.Identifier, Identifier.Create (value, TextLocation.Empty));
switch (classType) {
case ClassType.Class:
return GetChildByRole(Roles.ClassKeyword);
case ClassType.Struct:
return GetChildByRole(Roles.StructKeyword);
case ClassType.Interface:
return GetChildByRole(Roles.InterfaceKeyword);
case ClassType.Enum:
return GetChildByRole(Roles.EnumKeyword);
default:
return CSharpTokenNode.Null;
}
}
}
public Identifier NameToken {
get {
return GetChildByRole (Roles.Identifier);
}
public ClassType ClassType {
get { return classType; }
set {
SetChildByRole (Roles.Identifier, value);
ThrowIfFrozen();
classType = value;
}
}
public AstNodeCollection<TypeParameterDeclaration> TypeParameters {
get { return GetChildrenByRole (Roles.TypeParameter); }
}
public AstNodeCollection<AstType> BaseTypes {
get { return GetChildrenByRole (BaseTypeRole); }
get { return GetChildrenByRole(Roles.BaseType); }
}
public AstNodeCollection<Constraint> Constraints {
get { return GetChildrenByRole (Roles.Constraint); }
get { return GetChildrenByRole(Roles.Constraint); }
}
public CSharpTokenNode LBraceToken {
get { return GetChildByRole (Roles.LBrace); }
}
public AstNodeCollection<AttributedNode> Members {
get { return GetChildrenByRole (MemberRole); }
public AstNodeCollection<EntityDeclaration> Members {
get { return GetChildrenByRole (Roles.TypeMemberRole); }
}
public CSharpTokenNode RBraceToken {
get { return GetChildByRole (Roles.RBrace); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitTypeDeclaration (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitTypeDeclaration (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitTypeDeclaration (this, data);
}
@ -108,8 +120,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -108,8 +120,8 @@ namespace ICSharpCode.NRefactory.CSharp
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
TypeDeclaration o = other as TypeDeclaration;
return o != null && this.ClassType == o.ClassType && this.MatchAttributesAndModifiers(o, match)
&& MatchString(this.Name, o.Name) && this.TypeParameters.DoMatch(o.TypeParameters, match)
return o != null && this.ClassType == o.ClassType && MatchString(this.Name, o.Name)
&& this.MatchAttributesAndModifiers(o, match) && this.TypeParameters.DoMatch(o.TypeParameters, match)
&& this.BaseTypes.DoMatch(o.BaseTypes, match) && this.Constraints.DoMatch(o.Constraints, match)
&& this.Members.DoMatch(o.Members, match);
}

46
ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/TypeParameterDeclaration.cs

@ -30,8 +30,9 @@ namespace ICSharpCode.NRefactory.CSharp @@ -30,8 +30,9 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class TypeParameterDeclaration : AstNode
{
public static readonly Role<AttributeSection> AttributeRole = AttributedNode.AttributeRole;
public static readonly Role<CSharpTokenNode> VarianceRole = new Role<CSharpTokenNode>("Variance", CSharpTokenNode.Null);
public static readonly Role<AttributeSection> AttributeRole = EntityDeclaration.AttributeRole;
public static readonly TokenRole OutVarianceKeywordRole = new TokenRole ("out");
public static readonly TokenRole InVarianceKeywordRole = new TokenRole ("in");
public override NodeType NodeType {
get { return NodeType.Unknown; }
@ -41,8 +42,24 @@ namespace ICSharpCode.NRefactory.CSharp @@ -41,8 +42,24 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildrenByRole (AttributeRole); }
}
VarianceModifier variance;
public VarianceModifier Variance {
get; set;
get { return variance; }
set { ThrowIfFrozen(); variance = value; }
}
public CSharpTokenNode VarianceToken {
get {
switch (Variance) {
case VarianceModifier.Covariant:
return GetChildByRole(OutVarianceKeywordRole);
case VarianceModifier.Contravariant:
return GetChildByRole(InVarianceKeywordRole);
default:
return CSharpTokenNode.Null;
}
}
}
public string Name {
@ -50,7 +67,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -50,7 +67,7 @@ namespace ICSharpCode.NRefactory.CSharp
return GetChildByRole (Roles.Identifier).Name;
}
set {
SetChildByRole(Roles.Identifier, Identifier.Create (value, TextLocation.Empty));
SetChildByRole(Roles.Identifier, Identifier.Create (value));
}
}
@ -62,8 +79,27 @@ namespace ICSharpCode.NRefactory.CSharp @@ -62,8 +79,27 @@ namespace ICSharpCode.NRefactory.CSharp
SetChildByRole (Roles.Identifier, value);
}
}
public TypeParameterDeclaration ()
{
}
public TypeParameterDeclaration (string name)
{
Name = name;
}
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitTypeParameterDeclaration (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitTypeParameterDeclaration (this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data = default(T))
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitTypeParameterDeclaration(this, data);
}

21
ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/UsingAliasDeclaration.cs

@ -31,6 +31,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,6 +31,7 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class UsingAliasDeclaration : AstNode
{
public static readonly TokenRole UsingKeywordRole = new TokenRole ("using");
public static readonly Role<Identifier> AliasRole = new Role<Identifier>("Alias", Identifier.Null);
public static readonly Role<AstType> ImportRole = UsingDeclaration.ImportRole;
@ -41,7 +42,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -41,7 +42,7 @@ namespace ICSharpCode.NRefactory.CSharp
}
public CSharpTokenNode UsingToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (UsingKeywordRole); }
}
public string Alias {
@ -49,7 +50,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -49,7 +50,7 @@ namespace ICSharpCode.NRefactory.CSharp
return GetChildByRole (AliasRole).Name;
}
set {
SetChildByRole(AliasRole, Identifier.Create (value, TextLocation.Empty));
SetChildByRole(AliasRole, Identifier.Create (value));
}
}
@ -72,17 +73,27 @@ namespace ICSharpCode.NRefactory.CSharp @@ -72,17 +73,27 @@ namespace ICSharpCode.NRefactory.CSharp
public UsingAliasDeclaration (string alias, string nameSpace)
{
AddChild (Identifier.Create (alias, TextLocation.Empty), AliasRole);
AddChild (Identifier.Create (alias), AliasRole);
AddChild (new SimpleType (nameSpace), ImportRole);
}
public UsingAliasDeclaration (string alias, AstType import)
{
AddChild (Identifier.Create (alias, TextLocation.Empty), AliasRole);
AddChild (Identifier.Create (alias), AliasRole);
AddChild (import, ImportRole);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitUsingAliasDeclaration (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitUsingAliasDeclaration (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitUsingAliasDeclaration (this, data);
}

15
ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/UsingDeclaration.cs

@ -35,6 +35,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -35,6 +35,7 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class UsingDeclaration : AstNode
{
public static readonly TokenRole UsingKeywordRole = new TokenRole ("using");
public static readonly Role<AstType> ImportRole = new Role<AstType>("Import", AstType.Null);
public override NodeType NodeType {
@ -44,7 +45,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -44,7 +45,7 @@ namespace ICSharpCode.NRefactory.CSharp
}
public CSharpTokenNode UsingToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (UsingKeywordRole); }
}
public AstType Import {
@ -74,7 +75,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -74,7 +75,17 @@ namespace ICSharpCode.NRefactory.CSharp
AddChild (import, ImportRole);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitUsingDeclaration (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitUsingDeclaration (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitUsingDeclaration (this, data);
}

91
ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/WhitespaceNode.cs

@ -0,0 +1,91 @@ @@ -0,0 +1,91 @@
//
// WhitespaceNode.cs
//
// Author:
// Mike Krüger <mkrueger@xamarin.com>
//
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
//
// 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;
namespace ICSharpCode.NRefactory.CSharp
{
/// <summary>
/// A Whitespace node contains only whitespaces.
/// </summary>
public class WhitespaceNode : AstNode
{
public override NodeType NodeType {
get {
return NodeType.Whitespace;
}
}
public string WhiteSpaceText {
get;
set;
}
TextLocation startLocation;
public override TextLocation StartLocation {
get {
return startLocation;
}
}
public override TextLocation EndLocation {
get {
return new TextLocation (startLocation.Line, startLocation.Column + WhiteSpaceText.Length);
}
}
public WhitespaceNode(string whiteSpaceText) : this (whiteSpaceText, TextLocation.Empty)
{
}
public WhitespaceNode(string whiteSpaceText, TextLocation startLocation)
{
this.WhiteSpaceText = WhiteSpaceText;
this.startLocation = startLocation;
}
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitWhitespace (this);
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return visitor.VisitWhitespace (this);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitWhitespace (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
var o = other as WhitespaceNode;
return o != null && o.WhiteSpaceText == WhiteSpaceText;
}
}
}

266
ICSharpCode.NRefactory.CSharp/Ast/IAstVisitor.cs

@ -20,6 +20,268 @@ using System; @@ -20,6 +20,268 @@ using System;
namespace ICSharpCode.NRefactory.CSharp
{
/// <summary>
/// AST visitor.
/// </summary>
public interface IAstVisitor
{
void VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression);
void VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression);
void VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression);
void VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression);
void VisitAsExpression(AsExpression asExpression);
void VisitAssignmentExpression(AssignmentExpression assignmentExpression);
void VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression);
void VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression);
void VisitCastExpression(CastExpression castExpression);
void VisitCheckedExpression(CheckedExpression checkedExpression);
void VisitConditionalExpression(ConditionalExpression conditionalExpression);
void VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression);
void VisitDirectionExpression(DirectionExpression directionExpression);
void VisitIdentifierExpression(IdentifierExpression identifierExpression);
void VisitIndexerExpression(IndexerExpression indexerExpression);
void VisitInvocationExpression(InvocationExpression invocationExpression);
void VisitIsExpression(IsExpression isExpression);
void VisitLambdaExpression(LambdaExpression lambdaExpression);
void VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression);
void VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression);
void VisitNamedExpression(NamedExpression namedExpression);
void VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression);
void VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression);
void VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression);
void VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression);
void VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression);
void VisitPrimitiveExpression(PrimitiveExpression primitiveExpression);
void VisitSizeOfExpression(SizeOfExpression sizeOfExpression);
void VisitStackAllocExpression(StackAllocExpression stackAllocExpression);
void VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression);
void VisitTypeOfExpression(TypeOfExpression typeOfExpression);
void VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression);
void VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression);
void VisitUncheckedExpression(UncheckedExpression uncheckedExpression);
void VisitEmptyExpression (EmptyExpression emptyExpression);
void VisitQueryExpression(QueryExpression queryExpression);
void VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause);
void VisitQueryFromClause(QueryFromClause queryFromClause);
void VisitQueryLetClause(QueryLetClause queryLetClause);
void VisitQueryWhereClause(QueryWhereClause queryWhereClause);
void VisitQueryJoinClause(QueryJoinClause queryJoinClause);
void VisitQueryOrderClause(QueryOrderClause queryOrderClause);
void VisitQueryOrdering(QueryOrdering queryOrdering);
void VisitQuerySelectClause(QuerySelectClause querySelectClause);
void VisitQueryGroupClause(QueryGroupClause queryGroupClause);
void VisitAttribute(Attribute attribute);
void VisitAttributeSection(AttributeSection attributeSection);
void VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration);
void VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration);
void VisitTypeDeclaration(TypeDeclaration typeDeclaration);
void VisitUsingAliasDeclaration(UsingAliasDeclaration usingAliasDeclaration);
void VisitUsingDeclaration(UsingDeclaration usingDeclaration);
void VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration);
void VisitBlockStatement(BlockStatement blockStatement);
void VisitBreakStatement(BreakStatement breakStatement);
void VisitCheckedStatement(CheckedStatement checkedStatement);
void VisitContinueStatement(ContinueStatement continueStatement);
void VisitDoWhileStatement(DoWhileStatement doWhileStatement);
void VisitEmptyStatement(EmptyStatement emptyStatement);
void VisitExpressionStatement(ExpressionStatement expressionStatement);
void VisitFixedStatement(FixedStatement fixedStatement);
void VisitForeachStatement(ForeachStatement foreachStatement);
void VisitForStatement(ForStatement forStatement);
void VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement);
void VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement);
void VisitGotoStatement(GotoStatement gotoStatement);
void VisitIfElseStatement(IfElseStatement ifElseStatement);
void VisitLabelStatement(LabelStatement labelStatement);
void VisitLockStatement(LockStatement lockStatement);
void VisitReturnStatement(ReturnStatement returnStatement);
void VisitSwitchStatement(SwitchStatement switchStatement);
void VisitSwitchSection(SwitchSection switchSection);
void VisitCaseLabel(CaseLabel caseLabel);
void VisitThrowStatement(ThrowStatement throwStatement);
void VisitTryCatchStatement(TryCatchStatement tryCatchStatement);
void VisitCatchClause(CatchClause catchClause);
void VisitUncheckedStatement(UncheckedStatement uncheckedStatement);
void VisitUnsafeStatement(UnsafeStatement unsafeStatement);
void VisitUsingStatement(UsingStatement usingStatement);
void VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement);
void VisitWhileStatement(WhileStatement whileStatement);
void VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement);
void VisitYieldReturnStatement(YieldReturnStatement yieldReturnStatement);
void VisitAccessor(Accessor accessor);
void VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration);
void VisitConstructorInitializer(ConstructorInitializer constructorInitializer);
void VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration);
void VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration);
void VisitEventDeclaration(EventDeclaration eventDeclaration);
void VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration);
void VisitFieldDeclaration(FieldDeclaration fieldDeclaration);
void VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration);
void VisitMethodDeclaration(MethodDeclaration methodDeclaration);
void VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration);
void VisitParameterDeclaration(ParameterDeclaration parameterDeclaration);
void VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration);
void VisitVariableInitializer(VariableInitializer variableInitializer);
void VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration);
void VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer);
void VisitCompilationUnit(CompilationUnit compilationUnit);
void VisitSimpleType(SimpleType simpleType);
void VisitMemberType(MemberType memberType);
void VisitComposedType(ComposedType composedType);
void VisitArraySpecifier(ArraySpecifier arraySpecifier);
void VisitPrimitiveType(PrimitiveType primitiveType);
void VisitComment(Comment comment);
void VisitNewLine(NewLineNode newLineNode);
void VisitWhitespace(WhitespaceNode whitespaceNode);
void VisitText(TextNode textNode);
void VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective);
void VisitDocumentationReference(DocumentationReference documentationReference);
void VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration);
void VisitConstraint(Constraint constraint);
void VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode);
void VisitIdentifier(Identifier identifier);
void VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern);
}
/// <summary>
/// AST visitor.
/// </summary>
public interface IAstVisitor<out S>
{
S VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression);
S VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression);
S VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression);
S VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression);
S VisitAsExpression(AsExpression asExpression);
S VisitAssignmentExpression(AssignmentExpression assignmentExpression);
S VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression);
S VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression);
S VisitCastExpression(CastExpression castExpression);
S VisitCheckedExpression(CheckedExpression checkedExpression);
S VisitConditionalExpression(ConditionalExpression conditionalExpression);
S VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression);
S VisitDirectionExpression(DirectionExpression directionExpression);
S VisitIdentifierExpression(IdentifierExpression identifierExpression);
S VisitIndexerExpression(IndexerExpression indexerExpression);
S VisitInvocationExpression(InvocationExpression invocationExpression);
S VisitIsExpression(IsExpression isExpression);
S VisitLambdaExpression(LambdaExpression lambdaExpression);
S VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression);
S VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression);
S VisitNamedExpression(NamedExpression namedExpression);
S VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression);
S VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression);
S VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression);
S VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression);
S VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression);
S VisitPrimitiveExpression(PrimitiveExpression primitiveExpression);
S VisitSizeOfExpression(SizeOfExpression sizeOfExpression);
S VisitStackAllocExpression(StackAllocExpression stackAllocExpression);
S VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression);
S VisitTypeOfExpression(TypeOfExpression typeOfExpression);
S VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression);
S VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression);
S VisitUncheckedExpression(UncheckedExpression uncheckedExpression);
S VisitEmptyExpression (EmptyExpression emptyExpression);
S VisitQueryExpression(QueryExpression queryExpression);
S VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause);
S VisitQueryFromClause(QueryFromClause queryFromClause);
S VisitQueryLetClause(QueryLetClause queryLetClause);
S VisitQueryWhereClause(QueryWhereClause queryWhereClause);
S VisitQueryJoinClause(QueryJoinClause queryJoinClause);
S VisitQueryOrderClause(QueryOrderClause queryOrderClause);
S VisitQueryOrdering(QueryOrdering queryOrdering);
S VisitQuerySelectClause(QuerySelectClause querySelectClause);
S VisitQueryGroupClause(QueryGroupClause queryGroupClause);
S VisitAttribute(Attribute attribute);
S VisitAttributeSection(AttributeSection attributeSection);
S VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration);
S VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration);
S VisitTypeDeclaration(TypeDeclaration typeDeclaration);
S VisitUsingAliasDeclaration(UsingAliasDeclaration usingAliasDeclaration);
S VisitUsingDeclaration(UsingDeclaration usingDeclaration);
S VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration);
S VisitBlockStatement(BlockStatement blockStatement);
S VisitBreakStatement(BreakStatement breakStatement);
S VisitCheckedStatement(CheckedStatement checkedStatement);
S VisitContinueStatement(ContinueStatement continueStatement);
S VisitDoWhileStatement(DoWhileStatement doWhileStatement);
S VisitEmptyStatement(EmptyStatement emptyStatement);
S VisitExpressionStatement(ExpressionStatement expressionStatement);
S VisitFixedStatement(FixedStatement fixedStatement);
S VisitForeachStatement(ForeachStatement foreachStatement);
S VisitForStatement(ForStatement forStatement);
S VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement);
S VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement);
S VisitGotoStatement(GotoStatement gotoStatement);
S VisitIfElseStatement(IfElseStatement ifElseStatement);
S VisitLabelStatement(LabelStatement labelStatement);
S VisitLockStatement(LockStatement lockStatement);
S VisitReturnStatement(ReturnStatement returnStatement);
S VisitSwitchStatement(SwitchStatement switchStatement);
S VisitSwitchSection(SwitchSection switchSection);
S VisitCaseLabel(CaseLabel caseLabel);
S VisitThrowStatement(ThrowStatement throwStatement);
S VisitTryCatchStatement(TryCatchStatement tryCatchStatement);
S VisitCatchClause(CatchClause catchClause);
S VisitUncheckedStatement(UncheckedStatement uncheckedStatement);
S VisitUnsafeStatement(UnsafeStatement unsafeStatement);
S VisitUsingStatement(UsingStatement usingStatement);
S VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement);
S VisitWhileStatement(WhileStatement whileStatement);
S VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement);
S VisitYieldReturnStatement(YieldReturnStatement yieldReturnStatement);
S VisitAccessor(Accessor accessor);
S VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration);
S VisitConstructorInitializer(ConstructorInitializer constructorInitializer);
S VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration);
S VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration);
S VisitEventDeclaration(EventDeclaration eventDeclaration);
S VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration);
S VisitFieldDeclaration(FieldDeclaration fieldDeclaration);
S VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration);
S VisitMethodDeclaration(MethodDeclaration methodDeclaration);
S VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration);
S VisitParameterDeclaration(ParameterDeclaration parameterDeclaration);
S VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration);
S VisitVariableInitializer(VariableInitializer variableInitializer);
S VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration);
S VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer);
S VisitCompilationUnit(CompilationUnit compilationUnit);
S VisitSimpleType(SimpleType simpleType);
S VisitMemberType(MemberType memberType);
S VisitComposedType(ComposedType composedType);
S VisitArraySpecifier(ArraySpecifier arraySpecifier);
S VisitPrimitiveType(PrimitiveType primitiveType);
S VisitComment(Comment comment);
S VisitWhitespace(WhitespaceNode whitespaceNode);
S VisitText(TextNode textNode);
S VisitNewLine(NewLineNode newLineNode);
S VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective);
S VisitDocumentationReference(DocumentationReference documentationReference);
S VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration);
S VisitConstraint(Constraint constraint);
S VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode);
S VisitIdentifier(Identifier identifier);
S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern);
}
/// <summary>
/// AST visitor.
/// </summary>
@ -137,7 +399,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -137,7 +399,11 @@ namespace ICSharpCode.NRefactory.CSharp
S VisitPrimitiveType(PrimitiveType primitiveType, T data);
S VisitComment(Comment comment, T data);
S VisitNewLine(NewLineNode newLineNode, T data);
S VisitWhitespace(WhitespaceNode whitespaceNode, T data);
S VisitText(TextNode textNode, T data);
S VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective, T data);
S VisitDocumentationReference(DocumentationReference documentationReference, T data);
S VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration, T data);
S VisitConstraint(Constraint constraint, T data);

78
ICSharpCode.NRefactory.CSharp/Ast/Identifier.cs

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
//
// Identifier.cs
//
//
// Author:
// Mike Krüger <mkrueger@novell.com>
//
@ -28,7 +28,7 @@ using System; @@ -28,7 +28,7 @@ using System;
namespace ICSharpCode.NRefactory.CSharp
{
public class Identifier : AstNode, IRelocatable
public class Identifier : AstNode
{
public new static readonly Identifier Null = new NullIdentifier ();
sealed class NullIdentifier : Identifier
@ -39,7 +39,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -39,7 +39,16 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return default (T);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return default (S);
}
@ -59,9 +68,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -59,9 +68,10 @@ namespace ICSharpCode.NRefactory.CSharp
string name;
public string Name {
get { return this.name; }
set {
set {
if (value == null)
throw new ArgumentNullException("value");
ThrowIfFrozen();
this.name = value;
}
}
@ -71,25 +81,26 @@ namespace ICSharpCode.NRefactory.CSharp @@ -71,25 +81,26 @@ namespace ICSharpCode.NRefactory.CSharp
get {
return startLocation;
}
}
public virtual bool IsVerbatim {
const uint verbatimBit = 1u << AstNodeFlagsUsedBits;
public bool IsVerbatim {
get {
return false;
return (flags & verbatimBit) != 0;
}
set {
ThrowIfFrozen();
if (value)
flags |= verbatimBit;
else
flags &= ~verbatimBit;
}
}
#region IRelocationable implementation
void IRelocatable.SetStartLocation (TextLocation startLocation)
{
this.startLocation = startLocation;
}
#endregion
public override TextLocation EndLocation {
get {
return new TextLocation (StartLocation.Line, StartLocation.Column + (Name ?? "").Length);
return new TextLocation (StartLocation.Line, StartLocation.Column + (Name ?? "").Length + (IsVerbatim ? 1 : 0));
}
}
@ -116,22 +127,32 @@ namespace ICSharpCode.NRefactory.CSharp @@ -116,22 +127,32 @@ namespace ICSharpCode.NRefactory.CSharp
if (string.IsNullOrEmpty(name))
return Identifier.Null;
if (name[0] == '@')
return new VerbatimIdentifier(name.Substring (1), location);
return new Identifier (name.Substring (1), location) { IsVerbatim = true };
else
return new Identifier (name, location);
}
public static Identifier Create (string name, TextLocation location, bool isVerbatim)
{
if (string.IsNullOrEmpty(name))
if (string.IsNullOrEmpty (name))
return Identifier.Null;
if (isVerbatim)
return new VerbatimIdentifier(name, location);
return new Identifier (name, location) { IsVerbatim = true };
return new Identifier (name, location);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitIdentifier (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitIdentifier (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitIdentifier (this, data);
}
@ -141,24 +162,5 @@ namespace ICSharpCode.NRefactory.CSharp @@ -141,24 +162,5 @@ namespace ICSharpCode.NRefactory.CSharp
Identifier o = other as Identifier;
return o != null && !o.IsNull && MatchString(this.Name, o.Name);
}
class VerbatimIdentifier : Identifier
{
public override TextLocation EndLocation {
get {
return new TextLocation (StartLocation.Line, StartLocation.Column + (Name ?? "").Length + 1); // @"..."
}
}
public override bool IsVerbatim {
get {
return true;
}
}
public VerbatimIdentifier(string name, TextLocation location) : base (name, location)
{
}
}
}
}

2
ICSharpCode.NRefactory.CSharp/Ast/IdentifierExpressionBackreference.cs

@ -48,7 +48,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -48,7 +48,7 @@ namespace ICSharpCode.NRefactory.CSharp
CSharp.AstNode referenced = (CSharp.AstNode)match.Get(referencedGroupName).Last();
if (referenced == null)
return false;
return ident.Identifier == referenced.GetChildByRole(CSharp.AstNode.Roles.Identifier).Name;
return ident.Identifier == referenced.GetChildByRole(CSharp.Roles.Identifier).Name;
}
}
}

24
ICSharpCode.NRefactory.CSharp/Ast/MemberType.cs

@ -37,7 +37,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -37,7 +37,15 @@ namespace ICSharpCode.NRefactory.CSharp
{
public static readonly Role<AstType> TargetRole = new Role<AstType>("Target", AstType.Null);
public bool IsDoubleColon { get; set; }
bool isDoubleColon;
public bool IsDoubleColon {
get { return isDoubleColon; }
set {
ThrowIfFrozen();
isDoubleColon = value;
}
}
public AstType Target {
get { return GetChildByRole(TargetRole); }
@ -49,7 +57,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -49,7 +57,7 @@ namespace ICSharpCode.NRefactory.CSharp
return GetChildByRole (Roles.Identifier).Name;
}
set {
SetChildByRole (Roles.Identifier, Identifier.Create (value, TextLocation.Empty));
SetChildByRole (Roles.Identifier, Identifier.Create (value));
}
}
@ -89,7 +97,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -89,7 +97,17 @@ namespace ICSharpCode.NRefactory.CSharp
{
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitMemberType (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitMemberType (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitMemberType (this, data);
}

43
ICSharpCode.NRefactory.CSharp/Ast/ObservableAstVisitor.cs

@ -60,9 +60,38 @@ namespace ICSharpCode.NRefactory.CSharp @@ -60,9 +60,38 @@ namespace ICSharpCode.NRefactory.CSharp
handler (comment, data);
return VisitChildren (comment, data);
}
public event Action<PreProcessorDirective, T> PreProcessorDirectiveVisited;
public event Action<NewLineNode, T> NewLineVisited;
S IAstVisitor<T, S>.VisitNewLine(NewLineNode newLineNode, T data)
{
var handler = NewLineVisited;
if (handler != null)
handler(newLineNode, data);
return VisitChildren(newLineNode, data);
}
public event Action<WhitespaceNode, T> WhitespaceVisited;
S IAstVisitor<T, S>.VisitWhitespace(WhitespaceNode whitespace, T data)
{
var handler = WhitespaceVisited;
if (handler != null)
handler(whitespace, data);
return VisitChildren(whitespace, data);
}
public event Action<TextNode, T> TextVisited;
S IAstVisitor<T, S>.VisitText(TextNode textNode, T data)
{
var handler = TextVisited;
if (handler != null)
handler(textNode, data);
return VisitChildren(textNode, data);
}
public event Action<PreProcessorDirective, T> PreProcessorDirectiveVisited;
S IAstVisitor<T, S>.VisitPreProcessorDirective (PreProcessorDirective preProcessorDirective, T data)
{
var handler = PreProcessorDirectiveVisited;
@ -71,6 +100,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -71,6 +100,16 @@ namespace ICSharpCode.NRefactory.CSharp
return VisitChildren (preProcessorDirective, data);
}
public event Action<DocumentationReference, T> DocumentationReferenceVisited;
S IAstVisitor<T, S>.VisitDocumentationReference (DocumentationReference documentationReference, T data)
{
var handler = DocumentationReferenceVisited;
if (handler != null)
handler (documentationReference, data);
return VisitChildren (documentationReference, data);
}
public event Action<Identifier, T> IdentifierVisited;
S IAstVisitor<T, S>.VisitIdentifier (Identifier identifier, T data)

38
ICSharpCode.NRefactory.CSharp/Ast/PrimitiveType.cs

@ -32,10 +32,20 @@ using ICSharpCode.NRefactory.TypeSystem.Implementation; @@ -32,10 +32,20 @@ using ICSharpCode.NRefactory.TypeSystem.Implementation;
namespace ICSharpCode.NRefactory.CSharp
{
public class PrimitiveType : AstType, IRelocatable
public class PrimitiveType : AstType
{
public string Keyword { get; set; }
public TextLocation Location { get; set; }
TextLocation location;
string keyword = string.Empty;
public string Keyword {
get { return keyword; }
set {
if (value == null)
throw new ArgumentNullException();
ThrowIfFrozen();
keyword = value;
}
}
public KnownTypeCode KnownTypeCode {
get { return GetTypeCodeForPrimitiveType(this.Keyword); }
@ -53,29 +63,31 @@ namespace ICSharpCode.NRefactory.CSharp @@ -53,29 +63,31 @@ namespace ICSharpCode.NRefactory.CSharp
public PrimitiveType(string keyword, TextLocation location)
{
this.Keyword = keyword;
this.Location = location;
this.location = location;
}
public override TextLocation StartLocation {
get {
return Location;
return location;
}
}
public override TextLocation EndLocation {
get {
return new TextLocation (Location.Line, Location.Column + (Keyword != null ? Keyword.Length : 0));
return new TextLocation (location.Line, location.Column + keyword.Length);
}
}
#region IRelocationable implementation
void IRelocatable.SetStartLocation (TextLocation startLocation)
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitPrimitiveType (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
this.Location = startLocation;
return visitor.VisitPrimitiveType (this);
}
#endregion
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPrimitiveType (this, data);
}
@ -88,7 +100,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -88,7 +100,7 @@ namespace ICSharpCode.NRefactory.CSharp
public override string ToString()
{
return Keyword ?? base.ToString();
return Keyword;
}
public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode = SimpleNameLookupMode.Type)

96
ICSharpCode.NRefactory.CSharp/Ast/Roles.cs

@ -0,0 +1,96 @@ @@ -0,0 +1,96 @@
//
// Roles.cs
//
// Author:
// Mike Krüger <mkrueger@xamarin.com>
//
// Copyright (c) 2012 Xamarin <http://xamarin.com>
//
// 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;
namespace ICSharpCode.NRefactory.CSharp
{
public static class Roles
{
public static readonly Role<AstNode> Root = AstNode.RootRole;
// some pre defined constants for common roles
public static readonly Role<Identifier> Identifier = new Role<Identifier> ("Identifier", CSharp.Identifier.Null);
public static readonly Role<BlockStatement> Body = new Role<BlockStatement> ("Body", CSharp.BlockStatement.Null);
public static readonly Role<ParameterDeclaration> Parameter = new Role<ParameterDeclaration> ("Parameter");
public static readonly Role<Expression> Argument = new Role<Expression> ("Argument", CSharp.Expression.Null);
public static readonly Role<AstType> Type = new Role<AstType> ("Type", CSharp.AstType.Null);
public static readonly Role<Expression> Expression = new Role<Expression> ("Expression", CSharp.Expression.Null);
public static readonly Role<Expression> TargetExpression = new Role<Expression> ("Target", CSharp.Expression.Null);
public readonly static Role<Expression> Condition = new Role<Expression> ("Condition", CSharp.Expression.Null);
public static readonly Role<TypeParameterDeclaration> TypeParameter = new Role<TypeParameterDeclaration> ("TypeParameter");
public static readonly Role<AstType> TypeArgument = new Role<AstType> ("TypeArgument", CSharp.AstType.Null);
public readonly static Role<Constraint> Constraint = new Role<Constraint> ("Constraint");
public static readonly Role<VariableInitializer> Variable = new Role<VariableInitializer> ("Variable", VariableInitializer.Null);
public static readonly Role<Statement> EmbeddedStatement = new Role<Statement> ("EmbeddedStatement", CSharp.Statement.Null);
public readonly static Role<EntityDeclaration> TypeMemberRole = new Role<EntityDeclaration> ("TypeMember");
// public static readonly TokenRole Keyword = new TokenRole ("Keyword", CSharpTokenNode.Null);
// public static readonly TokenRole InKeyword = new TokenRole ("InKeyword", CSharpTokenNode.Null);
// some pre defined constants for most used punctuation
public static readonly TokenRole LPar = new TokenRole ("(");
public static readonly TokenRole RPar = new TokenRole (")");
public static readonly TokenRole LBracket = new TokenRole ("[");
public static readonly TokenRole RBracket = new TokenRole ("]");
public static readonly TokenRole LBrace = new TokenRole ("{");
public static readonly TokenRole RBrace = new TokenRole ("}");
public static readonly TokenRole LChevron = new TokenRole ("<");
public static readonly TokenRole RChevron = new TokenRole (">");
public static readonly TokenRole Comma = new TokenRole (",");
public static readonly TokenRole Dot = new TokenRole (".");
public static readonly TokenRole Semicolon = new TokenRole (";");
public static readonly TokenRole Assign = new TokenRole ("=");
public static readonly TokenRole Colon = new TokenRole (":");
public static readonly TokenRole DoubleColon = new TokenRole ("::");
public static readonly Role<Comment> Comment = new Role<Comment> ("Comment");
public static readonly Role<NewLineNode> NewLine = new Role<NewLineNode> ("NewLine");
public static readonly Role<WhitespaceNode> Whitespace = new Role<WhitespaceNode> ("Whitespace");
public static readonly Role<TextNode> Text = new Role<TextNode> ("Text");
public static readonly Role<PreProcessorDirective> PreProcessorDirective = new Role<PreProcessorDirective> ("PreProcessorDirective");
public static readonly Role<ErrorNode> Error = new Role<ErrorNode> ("Error");
public readonly static Role<AstType> BaseType = new Role<AstType> ("BaseType", AstType.Null);
public static readonly Role<Attribute> Attribute = new Role<Attribute> ("Attribute");
public static readonly Role<CSharpTokenNode> AttributeTargetRole = new Role<CSharpTokenNode> ("AttributeTarget", CSharpTokenNode.Null);
public readonly static TokenRole WhereKeyword = new TokenRole ("where");
public readonly static Role<SimpleType> ConstraintTypeParameter = new Role<SimpleType> ("TypeParameter", SimpleType.Null);
public readonly static TokenRole DelegateKeyword = new TokenRole ("delegate");
public static readonly TokenRole ExternKeyword = new TokenRole ("extern");
public static readonly TokenRole AliasKeyword = new TokenRole ("alias");
public static readonly TokenRole NamespaceKeyword = new TokenRole ("namespace");
public static readonly TokenRole EnumKeyword = new TokenRole ("enum");
public static readonly TokenRole InterfaceKeyword = new TokenRole ("interface");
public static readonly TokenRole StructKeyword = new TokenRole ("struct");
public static readonly TokenRole ClassKeyword = new TokenRole ("class");
}
}

25
ICSharpCode.NRefactory.CSharp/Ast/SimpleType.cs

@ -47,7 +47,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -47,7 +47,16 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return default (T);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return default (S);
}
@ -100,7 +109,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -100,7 +109,7 @@ namespace ICSharpCode.NRefactory.CSharp
return GetChildByRole (Roles.Identifier).Name;
}
set {
SetChildByRole (Roles.Identifier, CSharp.Identifier.Create (value, TextLocation.Empty));
SetChildByRole (Roles.Identifier, CSharp.Identifier.Create (value));
}
}
@ -117,7 +126,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -117,7 +126,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildrenByRole (Roles.TypeArgument); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitSimpleType (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitSimpleType (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitSimpleType (this, data);
}

35
ICSharpCode.NRefactory.CSharp/Ast/Statements/BlockStatement.cs

@ -45,7 +45,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -45,7 +45,16 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return default (T);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return default (S);
}
@ -76,7 +85,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -76,7 +85,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return NodeType.Pattern; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data = default(T))
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);
}
@ -105,7 +124,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -105,7 +124,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RBrace); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitBlockStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitBlockStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitBlockStatement (this, data);
}

18
ICSharpCode.NRefactory.CSharp/Ast/Statements/BreakStatement.cs

@ -31,11 +31,27 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,11 +31,27 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class BreakStatement : Statement
{
public static readonly TokenRole BreakKeywordRole = new TokenRole ("break");
public CSharpTokenNode BreakToken {
get { return GetChildByRole (BreakKeywordRole); }
}
public CSharpTokenNode SemicolonToken {
get { return GetChildByRole (Roles.Semicolon); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitBreakStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitBreakStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitBreakStatement (this, data);
}

16
ICSharpCode.NRefactory.CSharp/Ast/Statements/CheckedStatement.cs

@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class CheckedStatement : Statement
{
public static readonly TokenRole CheckedKeywordRole = new TokenRole ("checked");
public CSharpTokenNode CheckedToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (CheckedKeywordRole); }
}
public BlockStatement Body {
@ -49,7 +51,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -49,7 +51,17 @@ namespace ICSharpCode.NRefactory.CSharp
AddChild (body, Roles.Body);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitCheckedStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitCheckedStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitCheckedStatement (this, data);
}

18
ICSharpCode.NRefactory.CSharp/Ast/Statements/ContinueStatement.cs

@ -31,11 +31,27 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,11 +31,27 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class ContinueStatement : Statement
{
public static readonly TokenRole ContinueKeywordRole = new TokenRole ("continue");
public CSharpTokenNode ContinueToken {
get { return GetChildByRole (ContinueKeywordRole); }
}
public CSharpTokenNode SemicolonToken {
get { return GetChildByRole (Roles.Semicolon); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitContinueStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitContinueStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitContinueStatement (this, data);
}

16
ICSharpCode.NRefactory.CSharp/Ast/Statements/DoWhileStatement.cs

@ -31,8 +31,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,8 +31,8 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class DoWhileStatement : Statement
{
public static readonly Role<CSharpTokenNode> DoKeywordRole = new Role<CSharpTokenNode>("DoKeyword", CSharpTokenNode.Null);
public static readonly Role<CSharpTokenNode> WhileKeywordRole = new Role<CSharpTokenNode>("WhileKeyword", CSharpTokenNode.Null);
public static readonly TokenRole DoKeywordRole = new TokenRole ("do");
public static readonly TokenRole WhileKeywordRole = new TokenRole ("while");
public CSharpTokenNode DoToken {
get { return GetChildByRole (DoKeywordRole); }
@ -64,7 +64,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -64,7 +64,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.Semicolon); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitDoWhileStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitDoWhileStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitDoWhileStatement (this, data);
}

15
ICSharpCode.NRefactory.CSharp/Ast/Statements/EmptyStatement.cs

@ -29,7 +29,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -29,7 +29,7 @@ namespace ICSharpCode.NRefactory.CSharp
/// <summary>
/// ;
/// </summary>
public class EmptyStatement : Statement, IRelocatable
public class EmptyStatement : Statement
{
public TextLocation Location {
get;
@ -48,14 +48,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -48,14 +48,17 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
#region IRelocationable implementation
void IRelocatable.SetStartLocation (TextLocation startLocation)
public override void AcceptVisitor (IAstVisitor visitor)
{
this.Location = startLocation;
visitor.VisitEmptyStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitEmptyStatement (this);
}
#endregion
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitEmptyStatement (this, data);
}

12
ICSharpCode.NRefactory.CSharp/Ast/Statements/ExpressionStatement.cs

@ -40,7 +40,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -40,7 +40,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.Semicolon); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitExpressionStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitExpressionStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitExpressionStatement (this, data);
}

16
ICSharpCode.NRefactory.CSharp/Ast/Statements/FixedStatement.cs

@ -33,8 +33,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -33,8 +33,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class FixedStatement : Statement
{
public static readonly TokenRole FixedKeywordRole = new TokenRole ("fixed");
public CSharpTokenNode FixedToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (FixedKeywordRole); }
}
public CSharpTokenNode LParToken {
@ -59,7 +61,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -59,7 +61,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.EmbeddedStatement, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitFixedStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitFixedStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitFixedStatement (this, data);
}

15
ICSharpCode.NRefactory.CSharp/Ast/Statements/ForStatement.cs

@ -33,11 +33,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -33,11 +33,12 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class ForStatement : Statement
{
public static readonly TokenRole ForKeywordRole = new TokenRole ("for");
public readonly static Role<Statement> InitializerRole = new Role<Statement>("Initializer", Statement.Null);
public readonly static Role<Statement> IteratorRole = new Role<Statement>("Iterator", Statement.Null);
public CSharpTokenNode ForToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (ForKeywordRole); }
}
public CSharpTokenNode LParToken {
@ -71,7 +72,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -71,7 +72,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.EmbeddedStatement, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitForStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitForStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitForStatement (this, data);
}

21
ICSharpCode.NRefactory.CSharp/Ast/Statements/ForeachStatement.cs

@ -31,8 +31,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,8 +31,11 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class ForeachStatement : Statement
{
public static readonly TokenRole ForeachKeywordRole = new TokenRole ("foreach");
public static readonly TokenRole InKeywordRole = new TokenRole ("in");
public CSharpTokenNode ForeachToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (ForeachKeywordRole); }
}
public CSharpTokenNode LParToken {
@ -49,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -49,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp
return GetChildByRole (Roles.Identifier).Name;
}
set {
SetChildByRole(Roles.Identifier, Identifier.Create (value, TextLocation.Empty));
SetChildByRole(Roles.Identifier, Identifier.Create (value));
}
}
@ -63,7 +66,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -63,7 +66,7 @@ namespace ICSharpCode.NRefactory.CSharp
}
public CSharpTokenNode InToken {
get { return GetChildByRole (Roles.InKeyword); }
get { return GetChildByRole (InKeywordRole); }
}
public Expression InExpression {
@ -80,7 +83,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -80,7 +83,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.EmbeddedStatement, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitForeachStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitForeachStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitForeachStatement (this, data);
}

52
ICSharpCode.NRefactory.CSharp/Ast/Statements/GotoStatement.cs

@ -31,6 +31,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,6 +31,8 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class GotoStatement : Statement
{
public static readonly TokenRole GotoKeywordRole = new TokenRole ("goto");
public GotoStatement ()
{
}
@ -41,7 +43,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -41,7 +43,7 @@ namespace ICSharpCode.NRefactory.CSharp
}
public CSharpTokenNode GotoToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (GotoKeywordRole); }
}
public string Label {
@ -52,7 +54,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -52,7 +54,7 @@ namespace ICSharpCode.NRefactory.CSharp
if (string.IsNullOrEmpty(value))
SetChildByRole(Roles.Identifier, null);
else
SetChildByRole(Roles.Identifier, Identifier.Create (value, TextLocation.Empty));
SetChildByRole(Roles.Identifier, Identifier.Create (value));
}
}
@ -60,7 +62,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -60,7 +62,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.Semicolon); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitGotoStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitGotoStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitGotoStatement (this, data);
}
@ -77,10 +89,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -77,10 +89,11 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class GotoCaseStatement : Statement
{
public static readonly Role<CSharpTokenNode> CaseKeywordRole = new Role<CSharpTokenNode>("CaseKeyword", CSharpTokenNode.Null);
public static readonly TokenRole GotoKeywordRole = new TokenRole ("goto");
public static readonly TokenRole CaseKeywordRole = new TokenRole ("case");
public CSharpTokenNode GotoToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (GotoKeywordRole); }
}
public CSharpTokenNode CaseToken {
@ -99,7 +112,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -99,7 +112,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.Semicolon); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitGotoCaseStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitGotoCaseStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitGotoCaseStatement (this, data);
}
@ -116,10 +139,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -116,10 +139,11 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class GotoDefaultStatement : Statement
{
public static readonly Role<CSharpTokenNode> DefaultKeywordRole = new Role<CSharpTokenNode>("DefaultKeyword", CSharpTokenNode.Null);
public static readonly TokenRole GotoKeywordRole = new TokenRole ("goto");
public static readonly TokenRole DefaultKeywordRole = new TokenRole ("default");
public CSharpTokenNode GotoToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (GotoKeywordRole); }
}
public CSharpTokenNode DefaultToken {
@ -130,7 +154,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -130,7 +154,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.Semicolon); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitGotoDefaultStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitGotoDefaultStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitGotoDefaultStatement (this, data);
}

17
ICSharpCode.NRefactory.CSharp/Ast/Statements/IfElseStatement.cs

@ -31,11 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,11 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class IfElseStatement : Statement
{
public readonly static Role<CSharpTokenNode> IfKeywordRole = Roles.Keyword;
public readonly static TokenRole IfKeywordRole = new TokenRole ("if");
public readonly static Role<Expression> ConditionRole = Roles.Condition;
public readonly static Role<CSharpTokenNode> QuestionMarkRole = new Role<CSharpTokenNode>("QuestionMark", CSharpTokenNode.Null);
public readonly static Role<Statement> TrueRole = new Role<Statement>("True", Statement.Null);
public readonly static Role<CSharpTokenNode> ElseKeywordRole = new Role<CSharpTokenNode>("ElseKeyword", CSharpTokenNode.Null);
public readonly static TokenRole ElseKeywordRole = new TokenRole ("else");
public readonly static Role<Statement> FalseRole = new Role<Statement>("False", Statement.Null);
public CSharpTokenNode IfToken {
@ -69,7 +68,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -69,7 +68,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (FalseRole, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitIfElseStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitIfElseStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitIfElseStatement (this, data);
}

19
ICSharpCode.NRefactory.CSharp/Ast/Statements/LabelStatement.cs

@ -36,15 +36,30 @@ namespace ICSharpCode.NRefactory.CSharp @@ -36,15 +36,30 @@ namespace ICSharpCode.NRefactory.CSharp
return GetChildByRole (Roles.Identifier).Name;
}
set {
SetChildByRole(Roles.Identifier, Identifier.Create (value, TextLocation.Empty));
SetChildByRole(Roles.Identifier, Identifier.Create (value));
}
}
public Identifier LabelToken {
get { return GetChildByRole (Roles.Identifier); }
set { SetChildByRole (Roles.Identifier, value); }
}
public CSharpTokenNode Colon {
get { return GetChildByRole (Roles.Colon); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitLabelStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitLabelStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitLabelStatement (this, data);
}

16
ICSharpCode.NRefactory.CSharp/Ast/Statements/LockStatement.cs

@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class LockStatement : Statement
{
public static readonly TokenRole LockKeywordRole = new TokenRole ("lock");
public CSharpTokenNode LockToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (LockKeywordRole); }
}
public CSharpTokenNode LParToken {
@ -53,7 +55,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -53,7 +55,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.EmbeddedStatement, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitLockStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitLockStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitLockStatement (this, data);
}

16
ICSharpCode.NRefactory.CSharp/Ast/Statements/ReturnStatement.cs

@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class ReturnStatement : Statement
{
public static readonly TokenRole ReturnKeywordRole = new TokenRole ("return");
public CSharpTokenNode ReturnToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (ReturnKeywordRole); }
}
public Expression Expression {
@ -53,7 +55,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -53,7 +55,17 @@ namespace ICSharpCode.NRefactory.CSharp
AddChild (returnExpression, Roles.Expression);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitReturnStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitReturnStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitReturnStatement (this, data);
}

23
ICSharpCode.NRefactory.CSharp/Ast/Statements/Statement.cs

@ -25,7 +25,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -25,7 +25,16 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return default (T);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return default (S);
}
@ -56,7 +65,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -56,7 +65,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return NodeType.Pattern; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data = default(T))
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);
}

60
ICSharpCode.NRefactory.CSharp/Ast/Statements/SwitchStatement.cs

@ -34,10 +34,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -34,10 +34,11 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class SwitchStatement : Statement
{
public static readonly TokenRole SwitchKeywordRole = new TokenRole ("switch");
public static readonly Role<SwitchSection> SwitchSectionRole = new Role<SwitchSection>("SwitchSection");
public CSharpTokenNode SwitchToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (SwitchKeywordRole); }
}
public CSharpTokenNode LParToken {
@ -65,7 +66,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -65,7 +66,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RBrace); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitSwitchStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitSwitchStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitSwitchStatement (this, data);
}
@ -98,7 +109,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -98,7 +109,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return NodeType.Pattern; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data = default(T))
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);
}
@ -131,7 +152,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -131,7 +152,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildrenByRole (Roles.EmbeddedStatement); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitSwitchSection (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitSwitchSection (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitSwitchSection (this, data);
}
@ -145,6 +176,9 @@ namespace ICSharpCode.NRefactory.CSharp @@ -145,6 +176,9 @@ namespace ICSharpCode.NRefactory.CSharp
public class CaseLabel : AstNode
{
public static readonly TokenRole CaseKeywordRole = new TokenRole ("case");
public static readonly TokenRole DefaultKeywordRole = new TokenRole ("default");
public override NodeType NodeType {
get {
return NodeType.Unknown;
@ -158,7 +192,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -158,7 +192,11 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.Expression); }
set { SetChildByRole (Roles.Expression, value); }
}
public CSharpTokenNode ColonToken {
get { return GetChildByRole (Roles.Colon); }
}
public CaseLabel ()
{
}
@ -168,7 +206,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -168,7 +206,17 @@ namespace ICSharpCode.NRefactory.CSharp
this.Expression = expression;
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitCaseLabel (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitCaseLabel (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitCaseLabel (this, data);
}

16
ICSharpCode.NRefactory.CSharp/Ast/Statements/ThrowStatement.cs

@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class ThrowStatement : Statement
{
public static readonly TokenRole ThrowKeywordRole = new TokenRole ("throw");
public CSharpTokenNode ThrowToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (ThrowKeywordRole); }
}
public Expression Expression {
@ -53,7 +55,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -53,7 +55,17 @@ namespace ICSharpCode.NRefactory.CSharp
AddChild (expression, Roles.Expression);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitThrowStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitThrowStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitThrowStatement (this, data);
}

46
ICSharpCode.NRefactory.CSharp/Ast/Statements/TryCatchStatement.cs

@ -34,10 +34,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -34,10 +34,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class TryCatchStatement : Statement
{
public static readonly Role<CSharpTokenNode> TryKeywordRole = new Role<CSharpTokenNode>("TryKeyword", CSharpTokenNode.Null);
public static readonly TokenRole TryKeywordRole = new TokenRole ("try");
public static readonly Role<BlockStatement> TryBlockRole = new Role<BlockStatement>("TryBlock", BlockStatement.Null);
public static readonly Role<CatchClause> CatchClauseRole = new Role<CatchClause>("CatchClause");
public static readonly Role<CSharpTokenNode> FinallyKeywordRole = new Role<CSharpTokenNode>("FinallyKeyword", CSharpTokenNode.Null);
public static readonly TokenRole FinallyKeywordRole = new TokenRole ("finally");
public static readonly Role<BlockStatement> FinallyBlockRole = new Role<BlockStatement>("FinallyBlock", BlockStatement.Null);
public CSharpTokenNode TryToken {
@ -62,7 +62,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -62,7 +62,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (FinallyBlockRole, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitTryCatchStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitTryCatchStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitTryCatchStatement (this, data);
}
@ -79,6 +89,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -79,6 +89,8 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class CatchClause : AstNode
{
public static readonly TokenRole CatchKeywordRole = new TokenRole ("catch");
#region PatternPlaceholder
public static implicit operator CatchClause(PatternMatching.Pattern pattern)
{
@ -98,7 +110,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -98,7 +110,17 @@ namespace ICSharpCode.NRefactory.CSharp
get { return NodeType.Pattern; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data = default(T))
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);
}
@ -122,7 +144,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -122,7 +144,7 @@ namespace ICSharpCode.NRefactory.CSharp
}
public CSharpTokenNode CatchToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (CatchKeywordRole); }
}
public CSharpTokenNode LParToken {
@ -140,7 +162,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -140,7 +162,7 @@ namespace ICSharpCode.NRefactory.CSharp
if (string.IsNullOrEmpty(value))
SetChildByRole (Roles.Identifier, null);
else
SetChildByRole (Roles.Identifier, Identifier.Create (value, TextLocation.Empty));
SetChildByRole (Roles.Identifier, Identifier.Create (value));
}
}
@ -162,7 +184,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -162,7 +184,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.Body, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitCatchClause (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitCatchClause (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitCatchClause (this, data);
}

16
ICSharpCode.NRefactory.CSharp/Ast/Statements/UncheckedStatement.cs

@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class UncheckedStatement : Statement
{
public static readonly TokenRole UncheckedKeywordRole = new TokenRole ("unchecked");
public CSharpTokenNode UncheckedToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (UncheckedKeywordRole); }
}
public BlockStatement Body {
@ -49,7 +51,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -49,7 +51,17 @@ namespace ICSharpCode.NRefactory.CSharp
AddChild (body, Roles.Body);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitUncheckedStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitUncheckedStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitUncheckedStatement (this, data);
}

16
ICSharpCode.NRefactory.CSharp/Ast/Statements/UnsafeStatement.cs

@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class UnsafeStatement : Statement
{
public static readonly TokenRole UnsafeKeywordRole = new TokenRole ("unsafe");
public CSharpTokenNode UnsafeToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (UnsafeKeywordRole); }
}
public BlockStatement Body {
@ -40,7 +42,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -40,7 +42,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.Body, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitUnsafeStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitUnsafeStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitUnsafeStatement (this, data);
}

15
ICSharpCode.NRefactory.CSharp/Ast/Statements/UsingStatement.cs

@ -31,10 +31,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,10 +31,11 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class UsingStatement : Statement
{
public static readonly TokenRole UsingKeywordRole = new TokenRole ("using");
public static readonly Role<AstNode> ResourceAcquisitionRole = new Role<AstNode>("ResourceAcquisition", AstNode.Null);
public CSharpTokenNode UsingToken {
get { return GetChildByRole (Roles.Keyword); }
get { return GetChildByRole (UsingKeywordRole); }
}
public CSharpTokenNode LParToken {
@ -58,7 +59,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -58,7 +59,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.EmbeddedStatement, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitUsingStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitUsingStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitUsingStatement (this, data);
}

20
ICSharpCode.NRefactory.CSharp/Ast/Statements/VariableDeclarationStatement.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,7 +31,7 @@ namespace ICSharpCode.NRefactory.CSharp
{
public class VariableDeclarationStatement : Statement
{
public static readonly Role<CSharpModifierToken> ModifierRole = AttributedNode.ModifierRole;
public static readonly Role<CSharpModifierToken> ModifierRole = EntityDeclaration.ModifierRole;
public VariableDeclarationStatement()
{
@ -44,8 +44,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -44,8 +44,8 @@ namespace ICSharpCode.NRefactory.CSharp
}
public Modifiers Modifiers {
get { return AttributedNode.GetModifiers(this); }
set { AttributedNode.SetModifiers(this, value); }
get { return EntityDeclaration.GetModifiers(this); }
set { EntityDeclaration.SetModifiers(this, value); }
}
public AstType Type {
@ -63,10 +63,20 @@ namespace ICSharpCode.NRefactory.CSharp @@ -63,10 +63,20 @@ namespace ICSharpCode.NRefactory.CSharp
public VariableInitializer GetVariable (string name)
{
return Variables.FirstOrDefault (vi => vi.Name == name);
return Variables.FirstOrNullObject (vi => vi.Name == name);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
public override void AcceptVisitor (IAstVisitor visitor)
{
visitor.VisitVariableDeclarationStatement (this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
return visitor.VisitVariableDeclarationStatement (this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitVariableDeclarationStatement (this, data);
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save