diff --git a/ICSharpCode.NRefactory/CSharp/Dom/AbstractNode.cs b/ICSharpCode.NRefactory/CSharp/Dom/AbstractNode.cs new file mode 100644 index 0000000000..2d27ec4fad --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/AbstractNode.cs @@ -0,0 +1,200 @@ +// +// AbstractNode.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public abstract class AbstractNode : INode + { + public static class Roles + { + // some pre defined constants for common roles + public const int Identifier = 1; + public const int Keyword = 2; + public const int Argument = 3; + public const int Attribute = 4; + public const int ReturnType = 5; + public const int Modifier = 6; + public const int Body = 7; + public const int Initializer = 8; + public const int Condition = 9; + public const int EmbeddedStatement = 10; + public const int Iterator = 11; + public const int Expression = 12; + public const int Statement = 13; + public const int TargetExpression = 14; + public const int Member = 15; + + // some pre defined constants for most used punctuation + + public const int LPar = 50; // ( + public const int RPar = 51; // ) + + public const int LBrace = 52; // { + public const int RBrace = 53; // } + + public const int LBracket = 54; // [ + public const int RBracket = 55; // ] + + public const int LChevron = 56; // < + public const int RChevron = 57; // > + + public const int Dot = 58; // , + public const int Comma = 59; // , + public const int Colon = 60; // : + public const int Semicolon = 61; // ; + public const int QuestionMark = 62; // ? + + public const int Assign = 63; // = + + public const int TypeArgument = 64; + public const int Constraint = 65; + } + + public virtual DomLocation StartLocation { + get { + INode child = (INode)FirstChild; + if (child == null) + return DomLocation.Empty; + return child.StartLocation; + } + } + + public virtual DomLocation EndLocation { + get { + INode child = (INode)LastChild; + if (child == null) + return DomLocation.Empty; + return child.EndLocation; + } + } + + public INode Parent { + get; + set; + } + + public int Role { + get; + set; + } + + public INode NextSibling { + get; + set; + } + + public INode PrevSibling { + get; + set; + } + + public INode FirstChild { + get; + set; + } + + public INode LastChild { + get; + set; + } + + public IEnumerable Children { + get { + INode cur = FirstChild; + while (cur != null) { + yield return cur; + cur = cur.NextSibling; + } + } + } + + public INode GetChildByRole (int role) + { + AbstractNode cur = (AbstractNode)FirstChild; + while (cur != null) { + if (cur.Role == role) + return cur; + cur = (AbstractNode)cur.NextSibling; + } + return null; + } + + public IEnumerable GetChildrenByRole (int role) + { + AbstractNode cur = (AbstractNode)FirstChild; + while (cur != null) { + if (cur.Role == role) + yield return cur; + cur = (AbstractNode)cur.NextSibling; + } + } + + public void AddChild (INode child) + { + child.Parent = this; + if (FirstChild == null) { + LastChild = FirstChild = child; + } else { + LastChild.NextSibling = child; + child.PrevSibling = LastChild; + LastChild = child; + } + } + + public void AddChild (INode child, int role) + { + child.Role = role; + AddChild (child); + } + + public void InsertChildBefore (INode nextSibling, INode child, int role) + { + if (FirstChild == null || nextSibling == null) { + AddChild (child, role); + return; + } + child.Parent = this; + child.Role = role; + + child.NextSibling = nextSibling; + + if (nextSibling.PrevSibling != null) { + child.PrevSibling = nextSibling.PrevSibling; + nextSibling.PrevSibling.NextSibling = child; + } + nextSibling.PrevSibling = child; + } + + public virtual S AcceptVisitor (IDomVisitor visitor, T data) + { + return default(S); + } + + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/AbtractDomVisitor.cs b/ICSharpCode.NRefactory/CSharp/Dom/AbtractDomVisitor.cs new file mode 100644 index 0000000000..58b4b42e66 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/AbtractDomVisitor.cs @@ -0,0 +1,481 @@ +// +// IDomVisitor.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.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 abstract class AbtractDomVisitor : IDomVisitor + { + protected S VisitChildren (INode node, T data) + { + INode child = node.FirstChild as INode; + while (child != null) { + child.AcceptVisitor (this, data); + child = child.NextSibling as INode; + } + return default (S); + } + + public virtual S VisitCompilationUnit (CompilationUnit unit, T data) + { + return VisitChildren (unit, data); + } + + public virtual S VisitFullTypeName (FullTypeName fullTypeName, T data) + { + return default (S); + } + + public virtual S VisitIdentifier (Identifier identifier, T data) + { + return default (S); + } + + public virtual S VisitAttribute (Attribute attribute, T data) + { + return VisitChildren (attribute, data); + } + + public virtual S VisitAttributeSection (AttributeSection attributeSection, T data) + { + return VisitChildren (attributeSection, data); + } + + public virtual S VisitDelegateDeclaration (DelegateDeclaration delegateDeclaration, T data) + { + return VisitChildren (delegateDeclaration, data); + } + + public virtual S VisitNamespaceDeclaration (NamespaceDeclaration namespaceDeclaration, T data) + { + return VisitChildren (namespaceDeclaration, data); + } + + public virtual S VisitTypeDeclaration (TypeDeclaration typeDeclaration, T data) + { + foreach (INode node in typeDeclaration.GetChildrenByRole (TypeDeclaration.Roles.Member)) { + node.AcceptVisitor (this, data); + } + return default (S); + } + + public virtual S VisitEnumDeclaration (EnumDeclaration enumDeclaration, T data) + { + return VisitChildren (enumDeclaration, data); + } + + public virtual S VisitEnumMemberDeclaration (EnumMemberDeclaration enumMemberDeclaration, T data) + { + return VisitChildren (enumMemberDeclaration, data); + } + + public virtual S VisitUsingDeclaration (UsingDeclaration usingDeclaration, T data) + { + return VisitChildren (usingDeclaration, data); + } + + public virtual S VisitUsingAliasDeclaration (UsingAliasDeclaration usingDeclaration, T data) + { + return VisitChildren (usingDeclaration, data); + } + + public virtual S VisitConstructorDeclaration (ConstructorDeclaration constructorDeclaration, T data) + { + return VisitChildren (constructorDeclaration, data); + } + + public virtual S VisitConstructorInitializer (ConstructorInitializer constructorInitializer, T data) + { + return VisitChildren (constructorInitializer, data); + } + + public virtual S VisitDestructorDeclaration (DestructorDeclaration destructorDeclaration, T data) + { + return VisitChildren (destructorDeclaration, data); + } + + public virtual S VisitEventDeclaration (EventDeclaration eventDeclaration, T data) + { + return VisitChildren (eventDeclaration, data); + } + + public virtual S VisitFieldDeclaration (FieldDeclaration fieldDeclaration, T data) + { + return VisitChildren (fieldDeclaration, data); + } + + public virtual S VisitIndexerDeclaration (IndexerDeclaration indexerDeclaration, T data) + { + return VisitChildren (indexerDeclaration, data); + } + + public virtual S VisitMethodDeclaration (MethodDeclaration methodDeclaration, T data) + { + return VisitChildren (methodDeclaration, data); + } + + public virtual S VisitOperatorDeclaration (OperatorDeclaration operatorDeclaration, T data) + { + return VisitChildren (operatorDeclaration, data); + } + + public virtual S VisitPropertyDeclaration (PropertyDeclaration propertyDeclaration, T data) + { + return VisitChildren (propertyDeclaration, data); + } + + public virtual S VisitAccessorDeclaration (Accessor accessorDeclaration, T data) + { + return VisitChildren (accessorDeclaration, data); + } + + public virtual S VisitVariableInitializer (VariableInitializer variableInitializer, T data) + { + return VisitChildren (variableInitializer, data); + } + + public virtual S VisitParameterDeclarationExpression (ParameterDeclarationExpression parameterDeclarationExpression, T data) + { + return VisitChildren (parameterDeclarationExpression, data); + } + + public virtual S VisitConstraint (Constraint constraint, T data) + { + return VisitChildren (constraint, data); + } + + public virtual S VisitBlockStatement (BlockStatement blockStatement, T data) + { + return VisitChildren (blockStatement, data); + } + + public virtual S VisitExpressionStatement (ExpressionStatement expressionStatement, T data) + { + return VisitChildren (expressionStatement, data); + } + + public virtual S VisitBreakStatement (BreakStatement breakStatement, T data) + { + return VisitChildren (breakStatement, data); + } + + public virtual S VisitCheckedStatement (CheckedStatement checkedStatement, T data) + { + return VisitChildren (checkedStatement, data); + } + + public virtual S VisitContinueStatement (ContinueStatement continueStatement, T data) + { + return VisitChildren (continueStatement, data); + } + + public virtual S VisitEmptyStatement (EmptyStatement emptyStatement, T data) + { + return VisitChildren (emptyStatement, data); + } + + public virtual S VisitFixedStatement (FixedStatement fixedStatement, T data) + { + return VisitChildren (fixedStatement, data); + } + + public virtual S VisitForeachStatement (ForeachStatement foreachStatement, T data) + { + return VisitChildren (foreachStatement, data); + } + + public virtual S VisitForStatement (ForStatement forStatement, T data) + { + return VisitChildren (forStatement, data); + } + + public virtual S VisitGotoStatement (GotoStatement gotoStatement, T data) + { + return VisitChildren (gotoStatement, data); + } + + public virtual S VisitIfElseStatement (IfElseStatement ifElseStatement, T data) + { + return VisitChildren (ifElseStatement, data); + } + + public virtual S VisitLabelStatement (LabelStatement labelStatement, T data) + { + return VisitChildren (labelStatement, data); + } + + public virtual S VisitLockStatement (LockStatement lockStatement, T data) + { + return VisitChildren (lockStatement, data); + } + + public virtual S VisitReturnStatement (ReturnStatement returnStatement, T data) + { + return VisitChildren (returnStatement, data); + } + + public virtual S VisitSwitchStatement (SwitchStatement switchStatement, T data) + { + return VisitChildren (switchStatement, data); + } + + public virtual S VisitSwitchSection (SwitchSection switchSection, T data) + { + return VisitChildren (switchSection, data); + } + + public virtual S VisitCaseLabel (CaseLabel caseLabel, T data) + { + return VisitChildren (caseLabel, data); + } + + public virtual S VisitThrowStatement (ThrowStatement throwStatement, T data) + { + return VisitChildren (throwStatement, data); + } + + public virtual S VisitTryCatchStatement (TryCatchStatement tryCatchStatement, T data) + { + return VisitChildren (tryCatchStatement, data); + } + + public virtual S VisitCatchClause (CatchClause catchClause, T data) + { + return VisitChildren (catchClause, data); + } + + public virtual S VisitUncheckedStatement (UncheckedStatement uncheckedStatement, T data) + { + return VisitChildren (uncheckedStatement, data); + } + + public virtual S VisitUnsafeStatement (UnsafeStatement unsafeStatement, T data) + { + return VisitChildren (unsafeStatement, data); + } + + public virtual S VisitUsingStatement (UsingStatement usingStatement, T data) + { + return VisitChildren (usingStatement, data); + } + + public virtual S VisitVariableDeclarationStatement (VariableDeclarationStatement variableDeclarationStatement, T data) + { + return VisitChildren (variableDeclarationStatement, data); + } + + public virtual S VisitWhileStatement (WhileStatement whileStatement, T data) + { + return VisitChildren (whileStatement, data); + } + + public virtual S VisitYieldStatement (YieldStatement yieldStatement, T data) + { + return VisitChildren (yieldStatement, data); + } + + public virtual S VisitAnonymousMethodExpression (AnonymousMethodExpression anonymousMethodExpression, T data) + { + return VisitChildren (anonymousMethodExpression, data); + } + + public virtual S VisitLambdaExpression (LambdaExpression lambdaExpression, T data) + { + return VisitChildren (lambdaExpression, data); + } + + public virtual S VisitAssignmentExpression (AssignmentExpression assignmentExpression, T data) + { + return VisitChildren (assignmentExpression, data); + } + + public virtual S VisitBaseReferenceExpression (BaseReferenceExpression baseReferenceExpression, T data) + { + return VisitChildren (baseReferenceExpression, data); + } + + public virtual S VisitBinaryOperatorExpression (BinaryOperatorExpression binaryOperatorExpression, T data) + { + return VisitChildren (binaryOperatorExpression, data); + } + + public virtual S VisitCastExpression (CastExpression castExpression, T data) + { + return VisitChildren (castExpression, data); + } + + public virtual S VisitCheckedExpression (CheckedExpression checkedExpression, T data) + { + return VisitChildren (checkedExpression, data); + } + + public virtual S VisitConditionalExpression (ConditionalExpression conditionalExpression, T data) + { + return VisitChildren (conditionalExpression, data); + } + + public virtual S VisitIdentifierExpression (IdentifierExpression identifierExpression, T data) + { + return VisitChildren (identifierExpression, data); + } + + public virtual S VisitIndexerExpression (IndexerExpression indexerExpression, T data) + { + return VisitChildren (indexerExpression, data); + } + + public virtual S VisitInvocationExpression (InvocationExpression invocationExpression, T data) + { + return VisitChildren (invocationExpression, data); + } + + public virtual S VisitMemberReferenceExpression (MemberReferenceExpression memberReferenceExpression, T data) + { + return VisitChildren (memberReferenceExpression, data); + } + + public virtual S VisitNullReferenceExpression (NullReferenceExpression nullReferenceExpression, T data) + { + return VisitChildren (nullReferenceExpression, data); + } + + public virtual S VisitObjectCreateExpression (ObjectCreateExpression objectCreateExpression, T data) + { + return VisitChildren (objectCreateExpression, data); + } + + public virtual S VisitArrayObjectCreateExpression (ArrayObjectCreateExpression arrayObjectCreateExpression, T data) + { + return VisitChildren (arrayObjectCreateExpression, data); + } + + public virtual S VisitParenthesizedExpression (ParenthesizedExpression parenthesizedExpression, T data) + { + return VisitChildren (parenthesizedExpression, data); + } + + public virtual S VisitPointerReferenceExpression (PointerReferenceExpression pointerReferenceExpression, T data) + { + return VisitChildren (pointerReferenceExpression, data); + } + + public virtual S VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, T data) + { + return VisitChildren (primitiveExpression, data); + } + + public virtual S VisitSizeOfExpression (SizeOfExpression sizeOfExpression, T data) + { + return VisitChildren (sizeOfExpression, data); + } + + public virtual S VisitStackAllocExpression (StackAllocExpression stackAllocExpression, T data) + { + return VisitChildren (stackAllocExpression, data); + } + + public virtual S VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, T data) + { + return VisitChildren (thisReferenceExpression, data); + } + + public virtual S VisitTypeOfExpression (TypeOfExpression typeOfExpression, T data) + { + return VisitChildren (typeOfExpression, data); + } + + public virtual S VisitUnaryOperatorExpression (UnaryOperatorExpression unaryOperatorExpression, T data) + { + return VisitChildren (unaryOperatorExpression, data); + } + + public virtual S VisitUncheckedExpression (UncheckedExpression uncheckedExpression, T data) + { + return VisitChildren (uncheckedExpression, data); + } + + public virtual S VisitQueryExpressionFromClause (QueryExpressionFromClause queryExpressionFromClause, T data) + { + return VisitChildren (queryExpressionFromClause, data); + } + + public virtual S VisitQueryExpressionWhereClause (QueryExpressionWhereClause queryExpressionWhereClause, T data) + { + return VisitChildren (queryExpressionWhereClause, data); + } + + public virtual S VisitQueryExpressionJoinClause (QueryExpressionJoinClause queryExpressionJoinClause, T data) + { + return VisitChildren (queryExpressionJoinClause, data); + } + + public virtual S VisitQueryExpressionGroupClause (QueryExpressionGroupClause queryExpressionGroupClause, T data) + { + return VisitChildren (queryExpressionGroupClause, data); + } + + public virtual S VisitQueryExpressionLetClause (QueryExpressionLetClause queryExpressionLetClause, T data) + { + return VisitChildren (queryExpressionLetClause, data); + } + + public virtual S VisitQueryExpressionOrderClause (QueryExpressionOrderClause queryExpressionOrderClause, T data) + { + return VisitChildren (queryExpressionOrderClause, data); + } + + public virtual S VisitQueryExpressionOrdering (QueryExpressionOrdering queryExpressionOrdering, T data) + { + return VisitChildren (queryExpressionOrdering, data); + } + + public virtual S VisitQueryExpressionSelectClause (QueryExpressionSelectClause queryExpressionSelectClause, T data) + { + return VisitChildren (queryExpressionSelectClause, data); + } + + public virtual S VisitAsExpression (AsExpression asExpression, T data) + { + return VisitChildren (asExpression, data); + } + + public virtual S VisitIsExpression (IsExpression isExpression, T data) + { + return VisitChildren (isExpression, data); + } + + public virtual S VisitDefaultValueExpression (DefaultValueExpression defaultValueExpression, T data) + { + return VisitChildren (defaultValueExpression, data); + } + + public virtual S VisitArgListExpression (ArgListExpression argListExpression, T data) + { + return VisitChildren (argListExpression, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/CSharpModifierToken.cs b/ICSharpCode.NRefactory/CSharp/Dom/CSharpModifierToken.cs new file mode 100644 index 0000000000..64103c4fd1 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/CSharpModifierToken.cs @@ -0,0 +1,72 @@ +// +// CSharpModifierToken.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.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; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + + public class CSharpModifierToken : CSharpTokenNode + { + Modifiers modifier; + + public Modifiers Modifier { + get { return modifier; } + set { + modifier = value; + if (!lengthTable.TryGetValue (modifier, out tokenLength)) + throw new InvalidOperationException ("Modifier " + modifier + " is invalid."); + } + } + + static Dictionary lengthTable = new Dictionary (); + static CSharpModifierToken () + { + lengthTable[Modifiers.New] = "new".Length; + lengthTable[Modifiers.Public] = "new".Length; + lengthTable[Modifiers.Protected] = "protected".Length; + lengthTable[Modifiers.Private] = "private".Length; + lengthTable[Modifiers.Internal] = "internal".Length; + lengthTable[Modifiers.Abstract] = "abstract".Length; + lengthTable[Modifiers.Virtual] = "virtual".Length; + lengthTable[Modifiers.Sealed] = "sealed".Length; + lengthTable[Modifiers.Static] = "static".Length; + lengthTable[Modifiers.Override] = "override".Length; + lengthTable[Modifiers.Readonly] = "readonly".Length; + lengthTable[Modifiers.Const] = "const".Length; + lengthTable[Modifiers.Partial] = "partial".Length; + lengthTable[Modifiers.Extern] = "extern".Length; + lengthTable[Modifiers.Volatile] = "volatile".Length; + lengthTable[Modifiers.Unsafe] = "unsafe".Length; + lengthTable[Modifiers.Overloads] = "override".Length; + } + + public CSharpModifierToken (DomLocation location, Modifiers modifier) : base (location, 0) + { + this.Modifier = modifier; + } + } +} \ No newline at end of file diff --git a/ICSharpCode.NRefactory/CSharp/Dom/CSharpTokenNode.cs b/ICSharpCode.NRefactory/CSharp/Dom/CSharpTokenNode.cs new file mode 100644 index 0000000000..e21e7352c4 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/CSharpTokenNode.cs @@ -0,0 +1,63 @@ +// +// TokenNode.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; +namespace ICSharpCode.NRefactory.CSharp +{ + public class CSharpTokenNode : AbstractNode + { + DomLocation startLocation; + public override DomLocation StartLocation { + get { + return startLocation; + } + } + + protected int tokenLength; + public override DomLocation EndLocation { + get { + return new DomLocation (StartLocation.Line, StartLocation.Column + tokenLength); + } + } + + public CSharpTokenNode (DomLocation location, int tokenLength) + { + this.startLocation = location; + this.tokenLength = tokenLength; + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return default (S); + } + + public override string ToString () + { + return string.Format ("[CSharpTokenNode: StartLocation={0}, EndLocation={1}, Role={2}]", StartLocation, EndLocation, Role); + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Dom/CompilationUnit.cs b/ICSharpCode.NRefactory/CSharp/Dom/CompilationUnit.cs new file mode 100644 index 0000000000..8c69080ce0 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/CompilationUnit.cs @@ -0,0 +1,43 @@ +// +// CompilationUnit.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.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 class CompilationUnit : AbstractNode + { + public CompilationUnit () + { + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitCompilationUnit (this, data); + } + + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Dom/DomLocation.cs b/ICSharpCode.NRefactory/CSharp/Dom/DomLocation.cs new file mode 100644 index 0000000000..7c20308de5 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/DomLocation.cs @@ -0,0 +1,139 @@ +// +// DomLocation.cs +// +// Author: +// Mike Krüger +// +// Copyright (C) 2008 Novell, Inc (http://www.novell.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 +{ + [Serializable] + public struct DomLocation : IComparable, IEquatable + { + public bool IsEmpty { + get { + return Line < 0; + } + } + + public int Line { + get; + set; + } + + public int Column { + get; + set; + } + + public static DomLocation Empty { + get { + return new DomLocation (-1, -1); + } + } + + public DomLocation (int line, int column) : this () + { + this.Line = line; + this.Column = column; + } + + public override bool Equals (object other) + { + if (!(other is DomLocation)) + return false; + return (DomLocation)other == this; + } + + public override int GetHashCode () + { + return Line + Column * 5000; + } + + public bool Equals (DomLocation other) + { + return other == this; + } + + public int CompareTo (DomLocation other) + { + if (this == other) + return 0; + if (this < other) + return -1; + return 1; + } + + public override string ToString () + { + return String.Format ("[DomLocation: Line={0}, Column={1}]", Line, Column); + } + + public static DomLocation FromInvariantString (string invariantString) + { + if (invariantString.ToUpper () == "EMPTY") + return DomLocation.Empty; + string[] splits = invariantString.Split (',', '/'); + if (splits.Length == 2) + return new DomLocation (Int32.Parse (splits[0]), Int32.Parse (splits[1])); + return DomLocation.Empty; + } + + public string ToInvariantString () + { + if (IsEmpty) + return "Empty"; + return String.Format ("{0}/{1}", Line, Column); + } + + public static bool operator==(DomLocation left, DomLocation right) + { + return left.Line == right.Line && left.Column == right.Column; + } + + public static bool operator!=(DomLocation left, DomLocation right) + { + return left.Line != right.Line || left.Column != right.Column; + } + + public static bool operator<(DomLocation left, DomLocation right) + { + return left.Line < right.Line || left.Line == right.Line && left.Column < right.Column; + } + public static bool operator>(DomLocation left, DomLocation right) + { + return left.Line > right.Line || left.Line == right.Line && left.Column > right.Column; + } + public static bool operator<=(DomLocation left, DomLocation right) + { + return !(left > right); + } + public static bool operator>=(DomLocation left, DomLocation right) + { + return !(left < right); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/AnonymousMethodExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/AnonymousMethodExpression.cs new file mode 100644 index 0000000000..043fbc59b3 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/AnonymousMethodExpression.cs @@ -0,0 +1,52 @@ +// +// AnonymousMethodExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class AnonymousMethodExpression : AbstractNode + { + public IEnumerable Arguments { + get { + return base.GetChildrenByRole (Roles.Argument).Cast (); + } + } + + public BlockStatement Body { + get { + return (BlockStatement)GetChildByRole (Roles.Body); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitAnonymousMethodExpression (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/ArgListExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/ArgListExpression.cs new file mode 100644 index 0000000000..aa165fc952 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/ArgListExpression.cs @@ -0,0 +1,66 @@ +// +// ArgListExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.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 ICSharpCode.NRefactory.TypeSystem; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace ICSharpCode.NRefactory.CSharp +{ + /// + /// Represents the undocumented __arglist keyword. + /// + public class ArgListExpression : AbstractNode + { + public bool IsAccess { // access is __arglist, otherwise it's __arlist (a1, a2, ..., an) + get; + set; + } + + public CSharpTokenNode Keyword { + get { return (CSharpTokenNode)GetChildByRole (Roles.Keyword); } + } + + public CSharpTokenNode LPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.LPar); } + } + + public CSharpTokenNode RPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + + public IEnumerable Arguments { + get { return GetChildrenByRole (Roles.Argument).Cast (); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitArgListExpression (this, data); + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/ArrayObjectCreateExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/ArrayObjectCreateExpression.cs new file mode 100644 index 0000000000..4c16491d27 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/ArrayObjectCreateExpression.cs @@ -0,0 +1,43 @@ +// +// ObjectCreateExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; +namespace ICSharpCode.NRefactory.CSharp +{ + public class ArrayObjectCreateExpression : ObjectCreateExpression + { + public CSharpTokenNode Rank { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitArrayObjectCreateExpression (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/AsExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/AsExpression.cs new file mode 100644 index 0000000000..1d23a7614e --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/AsExpression.cs @@ -0,0 +1,47 @@ +// +// AsExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class AsExpression : AbstractNode + { + public FullTypeName TypeReference { + get { return (FullTypeName)GetChildByRole (Roles.ReturnType); } + } + + public INode Expression { + get { return GetChildByRole (Roles.Expression); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitAsExpression (this, data); + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/AssignmentExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/AssignmentExpression.cs new file mode 100644 index 0000000000..de94a0692e --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/AssignmentExpression.cs @@ -0,0 +1,90 @@ +// +// AssignmentExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class AssignmentExpression : AbstractNode + { + public const int LeftExpressionRole = 100; + public const int RightExpressionRole = 101; + public const int OperatorRole = 102; + + public AssignmentOperatorType AssignmentOperatorType { + get; + set; + } + + public INode Left { + get { return GetChildByRole (LeftExpressionRole); } + } + + public INode Right { + get { return GetChildByRole (RightExpressionRole); } + } + + public CSharpTokenNode Operator { + get { return (CSharpTokenNode)GetChildByRole (OperatorRole); } + } + + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitAssignmentExpression (this, data); + } + } + + public enum AssignmentOperatorType + { + /// left = right + Assign, + + /// left += right + Add, + /// left -= right + Subtract, + /// left *= right + Multiply, + /// left /= right + Divide, + /// left %= right + Modulus, + + /// left <<= right + ShiftLeft, + /// left >>= right + ShiftRight, + + /// left &= right + BitwiseAnd, + /// left |= right + BitwiseOr, + /// left ^= right + ExclusiveOr, + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/BaseReferenceExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/BaseReferenceExpression.cs new file mode 100644 index 0000000000..d3eb0a7643 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/BaseReferenceExpression.cs @@ -0,0 +1,55 @@ +// +// BaseReferenceExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class BaseReferenceExpression : AbstractNode + { + public DomLocation Location { + get; + set; + } + + public override DomLocation StartLocation { + get { + return Location; + } + } + public override DomLocation EndLocation { + get { + return new DomLocation (Location.Line, Location.Column + "base".Length); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitBaseReferenceExpression (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/BinaryOperatorExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/BinaryOperatorExpression.cs new file mode 100644 index 0000000000..feb4c7acf3 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/BinaryOperatorExpression.cs @@ -0,0 +1,106 @@ +// +// BinaryOperatorExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class BinaryOperatorExpression : AbstractNode + { + public const int LeftExpressionRole = 100; + public const int RightExpressionRole = 101; + public const int OperatorRole = 102; + + public BinaryOperatorType BinaryOperatorType { + get; + set; + } + + public CSharpTokenNode Operator { + get { return (CSharpTokenNode)GetChildByRole (OperatorRole); } + } + + public INode Left { + get { return GetChildByRole (LeftExpressionRole); } + } + + public INode Right { + get { return GetChildByRole (RightExpressionRole); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitBinaryOperatorExpression (this, data); + } + } + + public enum BinaryOperatorType + { + /// left & right + BitwiseAnd, + /// left | right + BitwiseOr, + /// left && right + LogicalAnd, + /// left || right + LogicalOr, + /// left ^ right + ExclusiveOr, + + /// left > right + GreaterThan, + /// left >= right + GreaterThanOrEqual, + /// left == right + Equality, + /// left != right + InEquality, + /// left < right + LessThan, + /// left <= right + LessThanOrEqual, + + /// left + right + Add, + /// left - right + Subtract, + /// left * right + Multiply, + /// left / right + Divide, + /// left % right + Modulus, + + /// left << right + ShiftLeft, + /// left >> right + ShiftRight, + + /// left ?? right + NullCoalescing + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/CastExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/CastExpression.cs new file mode 100644 index 0000000000..5c9eb5c5a1 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/CastExpression.cs @@ -0,0 +1,56 @@ +// +// CastExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class CastExpression : AbstractNode + { + public INode CastTo { + get { return (INode)GetChildByRole (Roles.ReturnType); } + } + + public INode Expression { + get { return GetChildByRole (Roles.Expression); } + } + + public CSharpTokenNode LPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.LPar); } + } + + public CSharpTokenNode RPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitCastExpression (this, data); + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/CheckedExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/CheckedExpression.cs new file mode 100644 index 0000000000..760ba640a2 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/CheckedExpression.cs @@ -0,0 +1,51 @@ +// +// CheckedExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class CheckedExpression : AbstractNode + { + public INode Expression { + get { return GetChildByRole (Roles.Expression); } + } + + public CSharpTokenNode LPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.LPar); } + } + + public CSharpTokenNode RPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitCheckedExpression (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/ConditionalExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/ConditionalExpression.cs new file mode 100644 index 0000000000..1e3bef655a --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/ConditionalExpression.cs @@ -0,0 +1,65 @@ +// +// ConditionalExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + /// + /// cond ? true : false + /// + public class ConditionalExpression : AbstractNode + { + public const int TrueExpressionRole = 100; + public const int FalseExpressionRole = 101; + + public INode TrueExpression { + get { return GetChildByRole (TrueExpressionRole); } + } + + public INode FalseExpression { + get { return GetChildByRole (FalseExpressionRole); } + } + + public INode Condition { + get { return GetChildByRole (Roles.Condition); } + } + + public CSharpTokenNode QuestionMark { + get { return (CSharpTokenNode)GetChildByRole (Roles.QuestionMark); } + } + + public CSharpTokenNode Colon { + get { return (CSharpTokenNode)GetChildByRole (Roles.Colon); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitConditionalExpression (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/DefaultValueExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/DefaultValueExpression.cs new file mode 100644 index 0000000000..80d4f19ada --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/DefaultValueExpression.cs @@ -0,0 +1,42 @@ +// +// DefaultValueExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.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 class DefaultValueExpression : AbstractNode + { + public FullTypeName TypeReference { + get { return (FullTypeName)GetChildByRole (Roles.ReturnType); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitDefaultValueExpression (this, data); + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/IdentifierExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/IdentifierExpression.cs new file mode 100644 index 0000000000..04b9c09ccf --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/IdentifierExpression.cs @@ -0,0 +1,45 @@ +// +// IdentifierExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class IdentifierExpression : AbstractNode + { + public Identifier Identifier { + get { + return (Identifier)GetChildByRole (Roles.Identifier); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitIdentifierExpression (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/IndexerExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/IndexerExpression.cs new file mode 100644 index 0000000000..bead020634 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/IndexerExpression.cs @@ -0,0 +1,61 @@ +// +// IndexerExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class IndexerExpression : AbstractNode + { + public INode Target { + get { return (INode)GetChildByRole (Roles.TargetExpression); } + } + + public CSharpTokenNode LBracket { + get { + return (CSharpTokenNode)GetChildByRole (Roles.LBracket); + } + } + + public CSharpTokenNode RBracket { + get { + return (CSharpTokenNode)GetChildByRole (Roles.RBracket); + } + } + + public IEnumerable Arguments { + get { return GetChildrenByRole (Roles.Argument); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitIndexerExpression (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/InvocationExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/InvocationExpression.cs new file mode 100644 index 0000000000..d40d3790e6 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/InvocationExpression.cs @@ -0,0 +1,57 @@ +// +// InvocationExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class InvocationExpression : AbstractNode + { + public INode Target { + get { return GetChildByRole (Roles.TargetExpression); } + } + + public IEnumerable Arguments { + get { return GetChildrenByRole (Roles.Argument).Cast (); } + } + + public CSharpTokenNode LPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.LPar); } + } + + public CSharpTokenNode RPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitInvocationExpression (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/IsExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/IsExpression.cs new file mode 100644 index 0000000000..4fe79a9e27 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/IsExpression.cs @@ -0,0 +1,47 @@ +// +// TypeOfIsExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class IsExpression : AbstractNode + { + public FullTypeName TypeReference { + get { return (FullTypeName)GetChildByRole (Roles.ReturnType); } + } + + public INode Expression { + get { return GetChildByRole (Roles.Expression); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitIsExpression (this, data); + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/LambdaExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/LambdaExpression.cs new file mode 100644 index 0000000000..a16be734c4 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/LambdaExpression.cs @@ -0,0 +1,63 @@ +// +// LambdaExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.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; +using System.Linq; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class LambdaExpression : AbstractNode + { + public IEnumerable Arguments { + get { + return base.GetChildrenByRole (Roles.Argument).Cast (); + } + } + + public BlockStatement Body { + get { + return (BlockStatement)GetChildByRole (Roles.Body); + } + } + + public CSharpTokenNode Arrow { + get { return (CSharpTokenNode)GetChildByRole (Roles.Assign); } + } + + public CSharpTokenNode LPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.LPar); } + } + + public CSharpTokenNode RPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitLambdaExpression (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/MemberReferenceExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/MemberReferenceExpression.cs new file mode 100644 index 0000000000..fc56e2dd47 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/MemberReferenceExpression.cs @@ -0,0 +1,55 @@ +// +// MemberReferenceExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class MemberReferenceExpression : AbstractNode + { + public INode Target { + get { return GetChildByRole (Roles.TargetExpression); } + } + + public INode Identifier { + get { + return (INode)GetChildByRole (Roles.Identifier); + } + } + + public IEnumerable TypeArguments { + get { return GetChildrenByRole (Roles.TypeArgument).Cast (); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitMemberReferenceExpression (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/NullReferenceExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/NullReferenceExpression.cs new file mode 100644 index 0000000000..fb5962b1ef --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/NullReferenceExpression.cs @@ -0,0 +1,39 @@ +// +// NullReferenceExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class NullReferenceExpression : AbstractNode + { + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitNullReferenceExpression (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/ObjectCreateExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/ObjectCreateExpression.cs new file mode 100644 index 0000000000..edb012cced --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/ObjectCreateExpression.cs @@ -0,0 +1,57 @@ +// +// ObjectCreateExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class ObjectCreateExpression : AbstractNode + { + public INode Type { + get { return (INode)GetChildByRole (Roles.ReturnType); } + } + + public CSharpTokenNode LPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.LPar); } + } + + public CSharpTokenNode RPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + + public IEnumerable Arguments { + get { return GetChildrenByRole (Roles.Argument); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitObjectCreateExpression (this, data); + } + } + +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/ParenthesizedExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/ParenthesizedExpression.cs new file mode 100644 index 0000000000..d41d0618be --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/ParenthesizedExpression.cs @@ -0,0 +1,51 @@ +// +// ParenthesizedExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class ParenthesizedExpression : AbstractNode + { + public INode Expression { + get { return GetChildByRole (Roles.Expression); } + } + + public CSharpTokenNode LPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.LPar); } + } + + public CSharpTokenNode RPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitParenthesizedExpression (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/PointerReferenceExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/PointerReferenceExpression.cs new file mode 100644 index 0000000000..e910dfa9b4 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/PointerReferenceExpression.cs @@ -0,0 +1,53 @@ +// +// PointerReferenceExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + /// + /// Same as member reference, only with pointer as base (a->b) + /// + public class PointerReferenceExpression : MemberReferenceExpression + { + public INode Expression { + get { return GetChildByRole (Roles.TargetExpression); } + } + + public string Dim { + get; + set; + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitPointerReferenceExpression (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/PrimitiveExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/PrimitiveExpression.cs new file mode 100644 index 0000000000..35f2c2a120 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/PrimitiveExpression.cs @@ -0,0 +1,66 @@ +// +// PrimitiveExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class PrimitiveExpression : AbstractNode + { + DomLocation startLocation; + public override DomLocation StartLocation { + get { + return startLocation; + } + } + + int length; + public override DomLocation EndLocation { + get { + return new DomLocation (StartLocation.Line, StartLocation.Column + length); + } + } + + public object Value { + get; + private set; + } + + public PrimitiveExpression (object value, DomLocation startLocation, int length) + { + this.Value = value; + this.startLocation = startLocation; + this.length = length; + } + + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitPrimitiveExpression (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/QueryExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/QueryExpression.cs new file mode 100644 index 0000000000..3d985118d3 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/QueryExpression.cs @@ -0,0 +1,291 @@ +// +// QueryExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using System.Collections.Generic; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class QueryExpressionFromClause : AbstractNode + { + public const int FromKeywordRole = 100; + public const int InKeywordRole = 101; + + public INode Type { + get { + return (INode)GetChildByRole (Roles.ReturnType); + } + } + + public string Identifier { + get { + return QueryIdentifier.Name; + } + } + + public Identifier QueryIdentifier { + get { + return (Identifier)GetChildByRole (Roles.Identifier); + } + } + + public INode Expression { + get { return GetChildByRole (Roles.Expression); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitQueryExpressionFromClause (this, data); + } + } + + public class QueryExpressionJoinClause : QueryExpressionFromClause + { + public const int OnExpressionRole = 100; + public const int EqualsExpressionRole = 101; + public const int IntoIdentifierRole = 102; + + public const int JoinKeywordRole = 110; + public new const int InKeywordRole = 111; + public const int OnKeywordRole = 112; + public const int EqualsKeywordRole = 113; + public const int IntoKeywordRole = 114; + + public CSharpTokenNode JoinKeyword { + get { return (CSharpTokenNode)GetChildByRole (JoinKeywordRole); } + } + public CSharpTokenNode InKeyword { + get { return (CSharpTokenNode)GetChildByRole (InKeywordRole); } + } + public CSharpTokenNode OnKeyword { + get { return (CSharpTokenNode)GetChildByRole (OnKeywordRole); } + } + public CSharpTokenNode EqualsKeyword { + get { return (CSharpTokenNode)GetChildByRole (EqualsKeywordRole); } + } + public CSharpTokenNode IntoKeyword { + get { return (CSharpTokenNode)GetChildByRole (IntoKeywordRole); } + } + + + public INode OnExpression { + get { + return GetChildByRole (OnExpressionRole); + } + } + + public INode EqualsExpression { + get { + return GetChildByRole (EqualsExpressionRole); + } + } + + public string IntoIdentifier { + get { + return IntoIdentifierIdentifier.Name; + } + } + + public Identifier IntoIdentifierIdentifier { + get { + return (Identifier)GetChildByRole (IntoIdentifierRole); + } + } + + public INode InExpression { + get { + return (INode)GetChildByRole (Roles.Expression); + } + } + + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitQueryExpressionJoinClause (this, data); + } + } + + public class QueryExpressionGroupClause : AbstractNode + { + public const int ProjectionExpressionRole = 100; + public const int GroupByExpressionRole = 101; + + public const int GroupKeywordRole = 102; + public const int ByKeywordRole = 103; + + public CSharpTokenNode GroupKeyword { + get { return (CSharpTokenNode)GetChildByRole (GroupKeywordRole); } + } + + public CSharpTokenNode ByKeyword { + get { return (CSharpTokenNode)GetChildByRole (ByKeywordRole); } + } + + public INode Projection { + get { + return GetChildByRole (ProjectionExpressionRole); + } + } + + public INode GroupBy { + get { + return GetChildByRole (GroupByExpressionRole); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitQueryExpressionGroupClause (this, data); + } + } + + public class QueryExpressionLetClause : AbstractNode + { + public string Identifier { + get { + return QueryIdentifier.Name; + } + } + + public Identifier QueryIdentifier { + get { + return (Identifier)GetChildByRole (Roles.Identifier); + } + } + + public INode Expression { + get { + return GetChildByRole (Roles.Expression); + } + } + + public CSharpTokenNode LetKeyword { + get { return (CSharpTokenNode)GetChildByRole (Roles.Keyword); } + } + + public INode Assign { + get { + return (INode)GetChildByRole (Roles.Assign); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitQueryExpressionLetClause (this, data); + } + } + + public class QueryExpressionOrderClause : AbstractNode + { + public const int OrderingRole = 100; + + public bool OrderAscending { + get; + set; + } + + public INode Expression { + get { + return GetChildByRole (Roles.Expression); + } + } + + public CSharpTokenNode Keyword { + get { return (CSharpTokenNode)GetChildByRole (Roles.Keyword); } + } + + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitQueryExpressionOrderClause (this, data); + } + } + + public class QueryExpressionOrdering : AbstractNode + { + public QueryExpressionOrderingDirection Direction { + get; + set; + } + + public INode Criteria { + get { + return GetChildByRole (Roles.Expression); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitQueryExpressionOrdering (this, data); + } + } + + public enum QueryExpressionOrderingDirection + { + Unknown, + Ascending, + Descending + } + + public class QueryExpressionSelectClause : AbstractNode + { + public CSharpTokenNode SelectKeyword { + get { return (CSharpTokenNode)GetChildByRole (Roles.Keyword); } + } + + public INode Projection { + get { + return (INode)GetChildByRole (Roles.Expression); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitQueryExpressionSelectClause (this, data); + } + } + + public class QueryExpressionWhereClause : AbstractNode + { + public CSharpTokenNode WhereKeyword { + get { return (CSharpTokenNode)GetChildByRole (Roles.Keyword); } + } + + public INode Condition { + get { + return (INode)GetChildByRole (Roles.Condition); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitQueryExpressionWhereClause (this, data); + } + } + +} \ No newline at end of file diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/SizeOfExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/SizeOfExpression.cs new file mode 100644 index 0000000000..7b4ab73708 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/SizeOfExpression.cs @@ -0,0 +1,52 @@ +// +// SizeOfExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class SizeOfExpression : AbstractNode + { + public FullTypeName Type { + get { + return (FullTypeName)GetChildByRole (Roles.ReturnType); + } + } + + public CSharpTokenNode LPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.LPar); } + } + + public CSharpTokenNode RPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitSizeOfExpression (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/StackAllocExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/StackAllocExpression.cs new file mode 100644 index 0000000000..07fc9875d5 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/StackAllocExpression.cs @@ -0,0 +1,69 @@ +// +// StackAllocExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class StackAllocExpression : AbstractNode + { + public const int StackAllocKeywordRole = 100; + + public FullTypeName Type { + get { + return (FullTypeName)GetChildByRole (Roles.ReturnType); + } + } + + public INode CountExpression { + get { return (INode)GetChildByRole (Roles.Expression); } + } + + public CSharpTokenNode StackAllocKeyword { + get { + return (CSharpTokenNode)GetChildByRole (StackAllocKeywordRole); + } + } + + public CSharpTokenNode LBracket { + get { + return (CSharpTokenNode)GetChildByRole (Roles.LBracket); + } + } + + public CSharpTokenNode RBracket { + get { + return (CSharpTokenNode)GetChildByRole (Roles.RBracket); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitStackAllocExpression (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/ThisReferenceExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/ThisReferenceExpression.cs new file mode 100644 index 0000000000..ff6d04d93f --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/ThisReferenceExpression.cs @@ -0,0 +1,56 @@ +// +// ThisReferenceExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class ThisReferenceExpression : AbstractNode + { + public DomLocation Location { + get; + set; + } + + public override DomLocation StartLocation { + get { + return Location; + } + } + public override DomLocation EndLocation { + get { + return new DomLocation (Location.Line, Location.Column + "this".Length); + } + } + + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitThisReferenceExpression (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/TypeOfExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/TypeOfExpression.cs new file mode 100644 index 0000000000..23cb140471 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/TypeOfExpression.cs @@ -0,0 +1,53 @@ +// +// TypeOfExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class TypeOfExpression : AbstractNode + { + public FullTypeName Type { + get { + return (FullTypeName)GetChildByRole (Roles.ReturnType); + } + } + + public CSharpTokenNode LPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.LPar); } + } + + public CSharpTokenNode RPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitTypeOfExpression (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/UnaryOperatorExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/UnaryOperatorExpression.cs new file mode 100644 index 0000000000..6476192dc5 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/UnaryOperatorExpression.cs @@ -0,0 +1,75 @@ +// +// UnaryOperatorExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class UnaryOperatorExpression : AbstractNode + { + public const int Operator = 100; + + public UnaryOperatorType UnaryOperatorType { + get; + set; + } + + public INode Expression { + get { return GetChildByRole (Roles.Expression); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitUnaryOperatorExpression (this, data); + } + } + + public enum UnaryOperatorType + { + /// Logical not (!a) + Not, + /// Bitwise not (~a) + BitNot, + /// Unary minus (-a) + Minus, + /// Unary plus (+a) + Plus, + /// Pre increment (++a) + Increment, + /// Pre decrement (--a) + Decrement, + /// Post increment (a++) + PostIncrement, + /// Post decrement (a--) + PostDecrement, + /// Dereferencing (*a) + Dereference, + /// Get address (&a) + AddressOf + } + +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Expressions/UncheckedExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/UncheckedExpression.cs new file mode 100644 index 0000000000..7c892077be --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Expressions/UncheckedExpression.cs @@ -0,0 +1,50 @@ +// +// UncheckedExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class UncheckedExpression : AbstractNode + { + public INode Expression { + get { return GetChildByRole (Roles.Expression); } + } + + public CSharpTokenNode LPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.LPar); } + } + + public CSharpTokenNode RPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitUncheckedExpression (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/FullTypeName.cs b/ICSharpCode.NRefactory/CSharp/Dom/FullTypeName.cs new file mode 100644 index 0000000000..315f1cd349 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/FullTypeName.cs @@ -0,0 +1,52 @@ +// +// FullTypeName.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; +using System.Linq; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class FullTypeName : AbstractNode + { + public Identifier Identifier { + get { + return (Identifier)GetChildByRole (Roles.Identifier); + } + } + + public IEnumerable TypeArguments { + get { return GetChildrenByRole (Roles.TypeArgument).Cast (); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitFullTypeName (this, data); + } + + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/Attribute.cs b/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/Attribute.cs new file mode 100644 index 0000000000..14d4f6c6b0 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/Attribute.cs @@ -0,0 +1,60 @@ +// +// Attribute.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class Attribute : AbstractNode + { + public string Name { + get { + return NameIdentifier.QualifiedName; + } + } + + public QualifiedIdentifier NameIdentifier { + get { + return (QualifiedIdentifier)GetChildByRole (Roles.Identifier); + } + } + + // Todo: Arguments should not be nodes, instead it should be expressions, change when it's implemented. + public IEnumerable Arguments { + get { + return base.GetChildrenByRole (Roles.Argument).Cast (); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitAttribute (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/AttributeSection.cs b/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/AttributeSection.cs new file mode 100644 index 0000000000..a6897390de --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/AttributeSection.cs @@ -0,0 +1,69 @@ +// +// AttributeSection.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class AttributeSection : AbstractNode + { + const int TargetRole = 101; + + public AttributeTarget AttributeTarget { + get; + set; + } + + public Identifier TargetIdentifier { + get { return (Identifier)GetChildByRole (TargetRole); } + } + + public IEnumerable Attributes { + get { return base.GetChildrenByRole (Roles.Attribute).Cast (); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitAttributeSection (this, data); + } + } + + public enum AttributeTarget { + None, + Assembly, + Module, + + Type, + Param, + Field, + Return, + Method, + Unknown + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/Constraint.cs b/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/Constraint.cs new file mode 100644 index 0000000000..29a79b1ad5 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/Constraint.cs @@ -0,0 +1,58 @@ +// +// Constraint.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.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; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class Constraint : AbstractNode + { + public CSharpTokenNode WhereKeyword { + get { return (CSharpTokenNode)GetChildByRole (Roles.Keyword); } + } + + public Identifier TypeParameter { + get { return (Identifier)GetChildByRole (Roles.Identifier); } + } + + public CSharpTokenNode Colon { + get { return (CSharpTokenNode)GetChildByRole (Roles.Colon); } + } + + public IEnumerable TypeArguments { + get { return GetChildrenByRole (Roles.TypeArgument).Cast (); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitConstraint (this, data); + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/DelegateDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/DelegateDeclaration.cs new file mode 100644 index 0000000000..fb3e6b606d --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/DelegateDeclaration.cs @@ -0,0 +1,78 @@ +// +// DelegateDeclaration.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class DelegateDeclaration : AbstractNode + { + public string Name { + get { + return NameIdentifier.Name; + } + } + + public Identifier NameIdentifier { + get { + return (Identifier)GetChildByRole (Roles.Identifier); + } + } + + public INode ReturnType { + get { + return (INode)GetChildByRole (Roles.ReturnType); + } + } + + // Todo: Arguments should not be nodes, instead it should be expressions, change when it's implemented. + public IEnumerable Arguments { + get { + return base.GetChildrenByRole (Roles.Argument).Cast (); + } + } + + public IEnumerable Attributes { + get { + return base.GetChildrenByRole (Roles.Attribute).Cast (); + } + } + + public IEnumerable Modifiers { + get { + return base.GetChildrenByRole (Roles.Modifier); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitDelegateDeclaration (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/EnumDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/EnumDeclaration.cs new file mode 100644 index 0000000000..3b02d58d07 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/EnumDeclaration.cs @@ -0,0 +1,87 @@ +// +// EnumDeclaration.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class EnumDeclaration : TypeDeclaration + { + const int EnumMemberDeclarationRole = 100; + + public IEnumerable Members { + get { + return base.GetChildrenByRole (EnumMemberDeclarationRole).Cast (); + } + } + + public override ClassType ClassType { + get { + return ClassType.Enum; + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitEnumDeclaration (this, data); + } + } + + public class EnumMemberDeclaration : AbstractNode + { + public IEnumerable Attributes { + get { + return base.GetChildrenByRole (Roles.Attribute).Cast (); + } + } + + public string Name { + get { + return NameIdentifier.Name; + } + } + + public Identifier NameIdentifier { + get { + return (Identifier)GetChildByRole (Roles.Identifier); + } + } + + public INode Initializer { + get { + return GetChildByRole (Roles.Initializer); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitEnumMemberDeclaration (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/NamespaceDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/NamespaceDeclaration.cs new file mode 100644 index 0000000000..7fab7749a0 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/NamespaceDeclaration.cs @@ -0,0 +1,69 @@ +// +// NamespaceDeclaration.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class NamespaceDeclaration : AbstractNode + { + public string Name { + get { + return NameIdentifier.QualifiedName; + } + } + + public string QualifiedName { + get { + NamespaceDeclaration parentNamespace = Parent as NamespaceDeclaration; + if (parentNamespace != null) + return BuildQualifiedName (parentNamespace.QualifiedName, Name); + return Name; + } + } + + public QualifiedIdentifier NameIdentifier { + get { + return (QualifiedIdentifier)GetChildByRole (Roles.Identifier); + } + } + + public static string BuildQualifiedName (string name1, string name2) + { + if (string.IsNullOrEmpty (name1)) + return name1; + if (string.IsNullOrEmpty (name2)) + return name2; + return name1 + "." + name2; + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitNamespaceDeclaration (this, data); + } + } +}; diff --git a/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/TypeDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/TypeDeclaration.cs new file mode 100644 index 0000000000..a7ef60ed91 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/TypeDeclaration.cs @@ -0,0 +1,84 @@ +// +// TypeDeclaration.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class TypeDeclaration : AbstractMemberBase + { + public const int TypeKeyword = 100; + + public Identifier NameIdentifier { + get { + return (Identifier)GetChildByRole (Roles.Identifier); + } + } + + public string Name { + get { + return NameIdentifier.Name; + } + } + + public IEnumerable TypeArguments { + get { + return GetChildrenByRole (Roles.TypeArgument).Cast (); + } + } + + public IEnumerable Constraints { + get { + return base.GetChildrenByRole (Roles.Constraint).Cast (); + } + } + + public CSharpTokenNode LBrace { + get { + return (CSharpTokenNode)GetChildByRole (Roles.LBrace); + } + } + + public CSharpTokenNode RBrace { + get { + return (CSharpTokenNode)GetChildByRole (Roles.RBrace); + } + } + + public virtual ClassType ClassType { + get; + set; + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitTypeDeclaration (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/UsingAliasDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/UsingAliasDeclaration.cs new file mode 100644 index 0000000000..2f2f918487 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/UsingAliasDeclaration.cs @@ -0,0 +1,53 @@ +// +// UsingAliasDeclaration.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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 class UsingAliasDeclaration : UsingDeclaration + { + public const int Assignment = 103; + public const int AliasRole = 104; + + public string Alias { + get { + return AliasIdentifier.QualifiedName; + } + } + + public QualifiedIdentifier AliasIdentifier { + get { + return (QualifiedIdentifier)GetChildByRole (AliasRole); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitUsingAliasDeclaration (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/UsingDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/UsingDeclaration.cs new file mode 100644 index 0000000000..a82abb9c63 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/GeneralScope/UsingDeclaration.cs @@ -0,0 +1,51 @@ +// +// UsingDeclaration.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class UsingDeclaration : AbstractNode + { + public string Namespace { + get { + return NameIdentifier.QualifiedName; + } + } + + public QualifiedIdentifier NameIdentifier { + get { + return (QualifiedIdentifier)GetChildByRole (Roles.Identifier); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitUsingDeclaration (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/IDomVisitor.cs b/ICSharpCode.NRefactory/CSharp/Dom/IDomVisitor.cs new file mode 100644 index 0000000000..aa51ed3a3e --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/IDomVisitor.cs @@ -0,0 +1,139 @@ +// +// IDomVisitor.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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 interface IDomVisitor + { + S VisitCompilationUnit (CompilationUnit unit, T data); + + #region General scope + S VisitAttribute (Attribute attribute, T data); + S VisitAttributeSection (AttributeSection attributeSection, T data); + S VisitDelegateDeclaration (DelegateDeclaration delegateDeclaration, T data); + S VisitNamespaceDeclaration (NamespaceDeclaration namespaceDeclaration, T data); + S VisitTypeDeclaration (TypeDeclaration typeDeclaration, T data); + S VisitEnumDeclaration (EnumDeclaration enumDeclaration, T data); + S VisitEnumMemberDeclaration (EnumMemberDeclaration enumMemberDeclaration, T data); + S VisitUsingDeclaration (UsingDeclaration usingDeclaration, T data); + S VisitUsingAliasDeclaration (UsingAliasDeclaration usingDeclaration, T data); + S VisitFullTypeName (FullTypeName fullTypeName, T data); + S VisitIdentifier (Identifier identifier, T data); + S VisitParameterDeclarationExpression (ParameterDeclarationExpression parameterDeclarationExpression, T data); + S VisitConstraint (Constraint constraint, T data); + #endregion + + #region Type members + S VisitConstructorDeclaration (ConstructorDeclaration constructorDeclaration, T data); + S VisitConstructorInitializer (ConstructorInitializer constructorInitializer, T data); + S VisitDestructorDeclaration (DestructorDeclaration destructorDeclaration, T data); + S VisitEventDeclaration (EventDeclaration eventDeclaration, T data); + S VisitFieldDeclaration (FieldDeclaration fieldDeclaration, T data); + S VisitIndexerDeclaration (IndexerDeclaration indexerDeclaration, T data); + S VisitMethodDeclaration (MethodDeclaration methodDeclaration, T data); + S VisitOperatorDeclaration (OperatorDeclaration operatorDeclaration, T data); + S VisitPropertyDeclaration (PropertyDeclaration propertyDeclaration, T data); + S VisitAccessorDeclaration (Accessor accessorDeclaration, T data); + S VisitVariableInitializer (VariableInitializer variableInitializer, T data); + #endregion + + #region Statements + S VisitBlockStatement (BlockStatement blockStatement, T data); + S VisitExpressionStatement (ExpressionStatement expressionStatement, T data); + S VisitBreakStatement (BreakStatement breakStatement, T data); + S VisitCheckedStatement (CheckedStatement checkedStatement, T data); + S VisitContinueStatement (ContinueStatement continueStatement, T data); + S VisitEmptyStatement (EmptyStatement emptyStatement, T data); + S VisitFixedStatement (FixedStatement fixedStatement, T data); + S VisitForeachStatement (ForeachStatement foreachStatement, T data); + S VisitForStatement (ForStatement forStatement, T data); + S VisitGotoStatement (GotoStatement gotoStatement, T data); + S VisitIfElseStatement (IfElseStatement ifElseStatement, T data); + S VisitLabelStatement (LabelStatement labelStatement, T data); + S VisitLockStatement (LockStatement lockStatement, T data); + S VisitReturnStatement (ReturnStatement returnStatement, T data); + S VisitSwitchStatement (SwitchStatement switchStatement, T data); + S VisitSwitchSection (SwitchSection switchSection, T data); + S VisitCaseLabel (CaseLabel caseLabel, T data); + + S VisitThrowStatement (ThrowStatement throwStatement, T data); + S VisitTryCatchStatement (TryCatchStatement tryCatchStatement, T data); + S VisitCatchClause (CatchClause catchClause, T data); + + S VisitUncheckedStatement (UncheckedStatement uncheckedStatement, T data); + S VisitUnsafeStatement (UnsafeStatement unsafeStatement, T data); + S VisitUsingStatement (UsingStatement usingStatement, T data); + S VisitVariableDeclarationStatement (VariableDeclarationStatement variableDeclarationStatement, T data); + S VisitWhileStatement (WhileStatement whileStatement, T data); + S VisitYieldStatement (YieldStatement yieldStatement, T data); + #endregion + + #region Expressions + S VisitAnonymousMethodExpression (AnonymousMethodExpression anonymousMethodExpression, T data); + S VisitLambdaExpression (LambdaExpression lambdaExpression, T data); + S VisitAssignmentExpression (AssignmentExpression assignmentExpression, T data); + S VisitBaseReferenceExpression (BaseReferenceExpression baseReferenceExpression, T data); + S VisitBinaryOperatorExpression (BinaryOperatorExpression binaryOperatorExpression, T data); + S VisitCastExpression (CastExpression castExpression, T data); + S VisitCheckedExpression (CheckedExpression checkedExpression, T data); + S VisitConditionalExpression (ConditionalExpression conditionalExpression, T data); + S VisitIdentifierExpression (IdentifierExpression identifierExpression, T data); + S VisitIndexerExpression (IndexerExpression indexerExpression, T data); + S VisitInvocationExpression (InvocationExpression invocationExpression, T data); + S VisitMemberReferenceExpression (MemberReferenceExpression memberReferenceExpression, T data); + S VisitNullReferenceExpression (NullReferenceExpression nullReferenceExpression, T data); + S VisitObjectCreateExpression (ObjectCreateExpression objectCreateExpression, T data); + S VisitArrayObjectCreateExpression (ArrayObjectCreateExpression arrayObjectCreateExpression, T data); + + S VisitParenthesizedExpression (ParenthesizedExpression parenthesizedExpression, T data); + S VisitPointerReferenceExpression (PointerReferenceExpression pointerReferenceExpression, T data); + S VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, T data); + S VisitSizeOfExpression (SizeOfExpression sizeOfExpression, T data); + S VisitStackAllocExpression (StackAllocExpression stackAllocExpression, T data); + S VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, T data); + S VisitTypeOfExpression (TypeOfExpression typeOfExpression, T data); + S VisitUnaryOperatorExpression (UnaryOperatorExpression unaryOperatorExpression, T data); + S VisitUncheckedExpression (UncheckedExpression uncheckedExpression, T data); + S VisitAsExpression (AsExpression asExpression, T data); + S VisitIsExpression (IsExpression isExpression, T data); + S VisitDefaultValueExpression (DefaultValueExpression defaultValueExpression, T data); + S VisitArgListExpression (ArgListExpression argListExpression, T data); + #endregion + + #region Query Expressions + S VisitQueryExpressionFromClause (QueryExpressionFromClause queryExpressionFromClause, T data); + S VisitQueryExpressionWhereClause (QueryExpressionWhereClause queryExpressionWhereClause, T data); + S VisitQueryExpressionJoinClause (QueryExpressionJoinClause queryExpressionJoinClause, T data); + S VisitQueryExpressionGroupClause (QueryExpressionGroupClause queryExpressionGroupClause, T data); + S VisitQueryExpressionLetClause (QueryExpressionLetClause queryExpressionLetClause, T data); + S VisitQueryExpressionOrderClause (QueryExpressionOrderClause queryExpressionOrderClause, T data); + S VisitQueryExpressionOrdering (QueryExpressionOrdering queryExpressionOrdering, T data); + S VisitQueryExpressionSelectClause (QueryExpressionSelectClause queryExpressionSelectClause, T data); + #endregion + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/INode.cs b/ICSharpCode.NRefactory/CSharp/Dom/INode.cs new file mode 100644 index 0000000000..36199e61b3 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/INode.cs @@ -0,0 +1,75 @@ +// +// INode.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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 interface INode + { + INode Parent { + get; + set; + } + + int Role { + get; + set; + } + + + INode NextSibling { + get; + set; + } + + INode PrevSibling { + get; + set; + } + + INode FirstChild { + get; + set; + } + + INode LastChild { + get; + set; + } + + DomLocation StartLocation { + get; + } + + DomLocation EndLocation { + get; + } + + + S AcceptVisitor (IDomVisitor visitor, T data); + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Identifier.cs b/ICSharpCode.NRefactory/CSharp/Dom/Identifier.cs new file mode 100644 index 0000000000..2caff2d498 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Identifier.cs @@ -0,0 +1,73 @@ +// +// Identifier.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class Identifier : AbstractNode + { + public string Name { + get; + set; + } + + DomLocation startLocation; + public override DomLocation StartLocation { + get { + return startLocation; + } + } + + public override DomLocation EndLocation { + get { + return new DomLocation (StartLocation.Line, StartLocation.Column + (Name ?? "").Length); + } + } + + /* + public ISegment Segment { + get { + return new Segment (Offset, Name != null ? Name.Length : 0); + } + }*/ + + public Identifier () + { + } + public Identifier (string name, DomLocation location) + { + this.Name = name; + this.startLocation = location; + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitIdentifier (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Modifiers.cs b/ICSharpCode.NRefactory/CSharp/Dom/Modifiers.cs new file mode 100644 index 0000000000..d49faa992a --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Modifiers.cs @@ -0,0 +1,68 @@ +// +// Modifiers.cs +// +// Author: +// Mike Krüger +// +// Copyright (C) 2008 Novell, Inc (http://www.novell.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 +{ + // For compatibility with nrefactory - same flags. + [Flags] + public enum Modifiers : uint { + None = 0, + + Private = 0x0001, + Internal = 0x0002, + Protected = 0x0004, + Public = 0x0008, + + Abstract = 0x0010, + Virtual = 0x0020, + Sealed = 0x0040, + Static = 0x0080, + Override = 0x0100, + Readonly = 0x0200, + Const = 0X0400, + New = 0x0800, + Partial = 0x1000, + + Extern = 0x2000, + Volatile = 0x4000, + Unsafe = 0x8000, + + Overloads = 0x10000, + WithEvents = 0x20000, + Default = 0x40000, + Fixed = 0x80000, + + ProtectedOrInternal = Internal | Protected, + ProtectedAndInternal = 0x100000, + SpecialName = 0x200000, + Final = 0x400000, + Literal = 0x800000, + VisibilityMask = Private | Internal | Protected | Public, + }} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/QualifiedIdentifier.cs b/ICSharpCode.NRefactory/CSharp/Dom/QualifiedIdentifier.cs new file mode 100644 index 0000000000..acd33e2903 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/QualifiedIdentifier.cs @@ -0,0 +1,50 @@ +// +// QualifiedIdentifier.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Text; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class QualifiedIdentifier : AbstractNode + { + public string QualifiedName { + get { + StringBuilder builder = new StringBuilder (); + foreach (Identifier identifier in GetChildrenByRole (Roles.Identifier)) { + if (builder.Length > 0) + builder.Append ('.'); + builder.Append (identifier.Name); + } + return builder.ToString (); + } + } + + public QualifiedIdentifier () + { + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/BlockStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/BlockStatement.cs new file mode 100644 index 0000000000..4c00b57491 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/BlockStatement.cs @@ -0,0 +1,58 @@ +// +// BlockStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class BlockStatement : AbstractNode + { + public CSharpTokenNode LBrace { + get { + return (CSharpTokenNode)GetChildByRole (Roles.LBrace); + } + } + + public CSharpTokenNode RBrace { + get { + return (CSharpTokenNode)GetChildByRole (Roles.RBrace); + } + } + + public IEnumerable Statements { + get { + return GetChildrenByRole (Roles.Statement); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitBlockStatement (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/BreakStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/BreakStatement.cs new file mode 100644 index 0000000000..1f7877253f --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/BreakStatement.cs @@ -0,0 +1,45 @@ +// +// BreakStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class BreakStatement : AbstractNode + { + public INode BreakKeyword { + get { + return GetChildByRole (Roles.Keyword); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitBreakStatement (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/CheckedStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/CheckedStatement.cs new file mode 100644 index 0000000000..2d912d684d --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/CheckedStatement.cs @@ -0,0 +1,43 @@ +// +// CheckedStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class CheckedStatement : AbstractNode + { + public INode EmbeddedStatement { + get { return (INode)GetChildByRole (Roles.EmbeddedStatement); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitCheckedStatement (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/ContinueStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/ContinueStatement.cs new file mode 100644 index 0000000000..ce43314442 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/ContinueStatement.cs @@ -0,0 +1,43 @@ +// +// ContinueStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class ContinueStatement : AbstractNode + { + public INode ContinueKeyword { + get { return GetChildByRole (Roles.Keyword); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitContinueStatement (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/EmptyStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/EmptyStatement.cs new file mode 100644 index 0000000000..d05a2b6a90 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/EmptyStatement.cs @@ -0,0 +1,55 @@ +// +// EmptyStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class EmptyStatement : AbstractNode + { + public DomLocation Location { + get; + set; + } + + public override DomLocation StartLocation { + get { + return Location; + } + } + public override DomLocation EndLocation { + get { + return new DomLocation (Location.Line, Location.Column + 1); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitEmptyStatement (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/ExpressionStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/ExpressionStatement.cs new file mode 100644 index 0000000000..953377513d --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/ExpressionStatement.cs @@ -0,0 +1,39 @@ +// +// ExpressionStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class ExpressionStatement : AbstractNode + { + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitExpressionStatement (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/FixedStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/FixedStatement.cs new file mode 100644 index 0000000000..25b3ce8efd --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/FixedStatement.cs @@ -0,0 +1,51 @@ +// +// FixedStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class FixedStatement : AbstractNode + { + public const int PointerDeclarationRole = 100; + public const int FixedKeywordRole = 101; + public const int DeclaratorRole = 102; + + public INode EmbeddedStatement { + get { return (INode)GetChildByRole (Roles.EmbeddedStatement); } + } + + public INode PointerDeclaration { + get { return GetChildByRole (PointerDeclarationRole); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitFixedStatement (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/ForStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/ForStatement.cs new file mode 100644 index 0000000000..9823a240ad --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/ForStatement.cs @@ -0,0 +1,64 @@ +// +// ForStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class ForStatement : AbstractNode + { + public INode EmbeddedStatement { + get { return (INode)GetChildByRole (Roles.EmbeddedStatement); } + } + + public INode Condition { + get { return GetChildByRole (Roles.Condition); } + } + + public IEnumerable Initializers { + get { return GetChildrenByRole (Roles.Initializer); } + } + + public IEnumerable Iterators { + get { return GetChildrenByRole (Roles.Iterator); } + } + + public CSharpTokenNode LPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.LPar); } + } + + public CSharpTokenNode RPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitForStatement (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/ForeachStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/ForeachStatement.cs new file mode 100644 index 0000000000..52c46b46c0 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/ForeachStatement.cs @@ -0,0 +1,74 @@ +// +// ForeachStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class ForeachStatement : AbstractNode + { + public const int ForEachKeywordRole = 100; + public const int InKeywordRole = 101; + + public INode EmbeddedStatement { + get { return (INode)GetChildByRole (Roles.EmbeddedStatement); } + } + + public INode Expression { + get { return GetChildByRole (Roles.Initializer); } + } + + public INode VariableType { + get { return (INode)GetChildByRole (Roles.ReturnType); } + } + + public CSharpTokenNode LPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.LPar); } + } + + public CSharpTokenNode RPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + + public string VariableName { + get { + return VariableNameIdentifier.Name; + } + } + + public Identifier VariableNameIdentifier { + get { + return (Identifier)GetChildByRole (Roles.Identifier); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitForeachStatement (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/GotoStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/GotoStatement.cs new file mode 100644 index 0000000000..7f2c0c95a6 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/GotoStatement.cs @@ -0,0 +1,68 @@ +// +// GotoStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class GotoStatement : AbstractNode + { + public const int DefaultKeywordRole = 100; + public const int CaseKeywordRole = 101; + + public GotoType GotoType { + get; + set; + } + + public string Label { + get { return ((Identifier)LabelExpression).Name; } + } + + public INode LabelExpression { + get { return GetChildByRole (Roles.Expression); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitGotoStatement (this, data); + } + + public GotoStatement (GotoType gotoType) + { + this.GotoType = gotoType; + } + + + } + + public enum GotoType { + Label, + Case, + CaseDefault + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/IfElseStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/IfElseStatement.cs new file mode 100644 index 0000000000..7ff41692ab --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/IfElseStatement.cs @@ -0,0 +1,72 @@ +// +// IfElseStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class IfElseStatement : AbstractNode + { + public const int TrueEmbeddedStatementRole = 100; + public const int FalseEmbeddedStatementRole = 101; + public const int IfKeywordRole = 102; + public const int ElseKeywordRole = 103; + + public INode TrueEmbeddedStatement { + get { return (INode)GetChildByRole (TrueEmbeddedStatementRole); } + } + + public INode FalseEmbeddedStatement { + get { return (INode)GetChildByRole (FalseEmbeddedStatementRole); } + } + + public INode Condition { + get { return (INode)GetChildByRole (Roles.Condition); } + } + + public CSharpTokenNode LPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.LPar); } + } + + public CSharpTokenNode RPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + + public CSharpTokenNode IfKeyword { + get { return (CSharpTokenNode)GetChildByRole (IfKeywordRole); } + } + + public CSharpTokenNode ElseKeyword { + get { return (CSharpTokenNode)GetChildByRole (ElseKeywordRole); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitIfElseStatement (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/LabelStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/LabelStatement.cs new file mode 100644 index 0000000000..ba5cb62224 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/LabelStatement.cs @@ -0,0 +1,47 @@ +// +// LabelStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class LabelStatement : AbstractNode + { + public string Label { + get { return LabelIdentifier.Name; } + } + + public Identifier LabelIdentifier { + get { return (Identifier)GetChildByRole (Roles.Identifier); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitLabelStatement (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/LockStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/LockStatement.cs new file mode 100644 index 0000000000..d4e04701e6 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/LockStatement.cs @@ -0,0 +1,55 @@ +// +// LockStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class LockStatement : AbstractNode + { + public INode Expression { + get { return GetChildByRole (Roles.Expression); } + } + + public INode EmbeddedStatement { + get { return (INode)GetChildByRole (Roles.EmbeddedStatement); } + } + + public CSharpTokenNode LPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.LPar); } + } + + public CSharpTokenNode RPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitLockStatement (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/ReturnStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/ReturnStatement.cs new file mode 100644 index 0000000000..786f70ab46 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/ReturnStatement.cs @@ -0,0 +1,43 @@ +// +// ReturnStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class ReturnStatement : AbstractNode + { + public INode Expression { + get { return GetChildByRole (Roles.Expression); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitReturnStatement (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/SwitchStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/SwitchStatement.cs new file mode 100644 index 0000000000..812b61481a --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/SwitchStatement.cs @@ -0,0 +1,99 @@ +// +// SwitchStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class SwitchStatement : AbstractNode + { + public const int SwitchSectionRole = 100; + + public INode Expression { + get { return GetChildByRole (Roles.Expression); } + } + + public IEnumerable SwitchSections { + get { return GetChildrenByRole (SwitchSectionRole).Cast (); } + } + + public CSharpTokenNode LPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.LPar); } + } + + public CSharpTokenNode RPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + public CSharpTokenNode LBrace { + get { return (CSharpTokenNode)GetChildByRole (Roles.LBrace); } + } + + public CSharpTokenNode RBrace { + get { return (CSharpTokenNode)GetChildByRole (Roles.RBrace); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitSwitchStatement (this, data); + } + } + + public class SwitchSection : AbstractNode + { + public const int CaseLabelRole = 100; + + public IEnumerable CaseLabels { + get { return GetChildrenByRole (CaseLabelRole).Cast (); } + } + + public IEnumerable Statements { + get { + BlockStatement block = (BlockStatement)GetChildByRole (Roles.Body); + return block.Statements; + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitSwitchSection (this, data); + } + } + + public class CaseLabel : AbstractNode + { + public INode Expression { + get { return GetChildByRole (Roles.Expression); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitCaseLabel (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/ThrowStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/ThrowStatement.cs new file mode 100644 index 0000000000..c16a68b90c --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/ThrowStatement.cs @@ -0,0 +1,43 @@ +// +// ThrowStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class ThrowStatement : AbstractNode + { + public INode Expression { + get { return GetChildByRole (Roles.Expression); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitThrowStatement (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/TryCatchStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/TryCatchStatement.cs new file mode 100644 index 0000000000..ab10861fdc --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/TryCatchStatement.cs @@ -0,0 +1,103 @@ +// +// TryCatchStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class TryCatchStatement : AbstractNode + { + public const int TryKeywordRole = 100; + public const int FinallyKeywordRole = 101; + public const int TryBlockRole = 102; + public const int FinallyBlockRole = 103; + public const int CatchClauseRole = 104; + + public CSharpTokenNode TryKeyword { + get { return (CSharpTokenNode)GetChildByRole (TryKeywordRole); } + } + + public CSharpTokenNode FinallyKeyword { + get { return (CSharpTokenNode)GetChildByRole (FinallyKeywordRole); } + } + + public BlockStatement TryBlock { + get { return (BlockStatement)GetChildByRole (TryBlockRole); } + } + + public BlockStatement FinallyBlock { + get { return (BlockStatement)GetChildByRole (FinallyBlockRole); } + } + + public IEnumerable CatchClauses { + get { return GetChildrenByRole (CatchClauseRole).Cast (); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitTryCatchStatement (this, data); + } + } + + public class CatchClause : AbstractNode + { + public INode ReturnType { + get { return (INode)GetChildByRole (Roles.ReturnType); } + } + + public string VariableName { + get { return VariableNameIdentifier.Name; } + } + + public Identifier VariableNameIdentifier { + get { return (Identifier)GetChildByRole (Roles.Identifier); } + } + + public BlockStatement Block { + get { return (BlockStatement)GetChildByRole (Roles.Body); } + } + + public CSharpTokenNode LPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.LPar); } + } + + public CSharpTokenNode RPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + + public CSharpTokenNode CatchKeyword { + get { return (CSharpTokenNode)GetChildByRole (Roles.Keyword); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitCatchClause (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/UncheckedStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/UncheckedStatement.cs new file mode 100644 index 0000000000..b60760db01 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/UncheckedStatement.cs @@ -0,0 +1,43 @@ +// +// UncheckedStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class UncheckedStatement : AbstractNode + { + public INode EmbeddedStatement { + get { return (INode)GetChildByRole (Roles.EmbeddedStatement); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitUncheckedStatement (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/UnsafeStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/UnsafeStatement.cs new file mode 100644 index 0000000000..0cd03e4389 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/UnsafeStatement.cs @@ -0,0 +1,43 @@ +// +// UnsafeStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class UnsafeStatement : AbstractNode + { + public BlockStatement Block { + get { return (BlockStatement)GetChildByRole (Roles.Body); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitUnsafeStatement (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/UsingStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/UsingStatement.cs new file mode 100644 index 0000000000..aa9b9a4a74 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/UsingStatement.cs @@ -0,0 +1,56 @@ +// +// UsingStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class UsingStatement : AbstractNode + { + public INode Statement { + get { return GetChildByRole (Roles.Statement); } + } + + public INode EmbeddedStatement { + get { return (INode)GetChildByRole (Roles.EmbeddedStatement); } + } + + public CSharpTokenNode LPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.LPar); } + } + + public CSharpTokenNode RPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitUsingStatement (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/VariableDeclarationStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/VariableDeclarationStatement.cs new file mode 100644 index 0000000000..90326527c1 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/VariableDeclarationStatement.cs @@ -0,0 +1,53 @@ +// +// VariableDeclarationStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class VariableDeclarationStatement : AbstractNode + { + public IEnumerable Modifiers { + get { return base.GetChildrenByRole (Roles.Modifier); } + } + + public INode ReturnType { + get { return (INode)GetChildByRole (Roles.ReturnType); } + } + + public IEnumerable Variables { + get { return base.GetChildrenByRole (Roles.Initializer).Cast (); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitVariableDeclarationStatement (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/WhileStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/WhileStatement.cs new file mode 100644 index 0000000000..65d3e6a0a4 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/WhileStatement.cs @@ -0,0 +1,81 @@ +// +// WhileStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class WhileStatement : AbstractNode + { + public const int DoKeywordRole = 101; + public const int WhileKeywordRole = 102; + + public WhilePosition WhilePosition { + get; + set; + } + + public INode EmbeddedStatement { + get { return (INode)GetChildByRole (Roles.EmbeddedStatement); } + } + + public INode Condition { + get { return GetChildByRole (Roles.Condition); } + } + + public CSharpTokenNode DoKeyword { + get { return (CSharpTokenNode)GetChildByRole (DoKeywordRole); } + } + + public CSharpTokenNode WhileKeyword { + get { return (CSharpTokenNode)GetChildByRole (WhileKeywordRole); } + } + + public CSharpTokenNode LPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.LPar); } + } + + public CSharpTokenNode RPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitWhileStatement (this, data); + } + + public WhileStatement (WhilePosition whilePosition) + { + this.WhilePosition = whilePosition; + } + } + + public enum WhilePosition { + Begin, + End + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/Statements/YieldStatement.cs b/ICSharpCode.NRefactory/CSharp/Dom/Statements/YieldStatement.cs new file mode 100644 index 0000000000..36c3d396f8 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/Statements/YieldStatement.cs @@ -0,0 +1,46 @@ +// +// YieldStatement.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class YieldStatement : AbstractNode + { + public const int YieldKeywordRole = 100; + public const int ReturnKeywordRole = 101; + public const int BreakKeywordRole = 102; + public INode Expression { + get { return GetChildByRole (Roles.Expression); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitYieldStatement (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/AbstractMember.cs b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/AbstractMember.cs new file mode 100644 index 0000000000..4b9dbfeae5 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/AbstractMember.cs @@ -0,0 +1,63 @@ +// +// AbstractMember.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public abstract class AbstractMember : AbstractMemberBase + { + const int PrivateImplementationTypeRole = 100; + + public INode ReturnType { + get { + return (INode)GetChildByRole (Roles.ReturnType); + } + } + + /// + /// Only supported on members that can be declared in an interface. + /// + public INode PrivateImplementationType { + get { + return (INode)GetChildByRole (PrivateImplementationTypeRole); + } + } + + public Identifier NameIdentifier { + get { + return (Identifier)GetChildByRole (Roles.Identifier); + } + } + + public string Name { + get { + return NameIdentifier.Name; + } + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/AbstractMemberBase.cs b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/AbstractMemberBase.cs new file mode 100644 index 0000000000..5f164350b8 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/AbstractMemberBase.cs @@ -0,0 +1,48 @@ +// +// AbstractMemberBase.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public abstract class AbstractMemberBase : AbstractNode + { + public IEnumerable Modifiers { + get { + return base.GetChildrenByRole (Roles.Modifier); + } + } + + public IEnumerable Attributes { + get { + return base.GetChildrenByRole (Roles.Attribute).Cast (); + } + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/ConstructorDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/ConstructorDeclaration.cs new file mode 100644 index 0000000000..42404a9d60 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/ConstructorDeclaration.cs @@ -0,0 +1,77 @@ +// +// ConstructorDeclaration.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class ConstructorDeclaration : AbstractMemberBase + { + public BlockStatement Body { + get { + return (BlockStatement)GetChildByRole (Roles.Body); + } + } + + public ConstructorInitializer Initializer { + get { + return (ConstructorInitializer)base.GetChildByRole (Roles.Initializer); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitConstructorDeclaration (this, data); + } + } + + public enum ConstructorInitializerType { + Base, + This + } + + public class ConstructorInitializer : AbstractNode + { + public ConstructorInitializerType ConstructorInitializerType { + get; + set; + } + + public IEnumerable Arguments { + get { + return base.GetChildrenByRole (Roles.Argument).Cast (); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitConstructorInitializer (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/DestructorDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/DestructorDeclaration.cs new file mode 100644 index 0000000000..1621fbc44a --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/DestructorDeclaration.cs @@ -0,0 +1,49 @@ +// +// DestructorDeclaration.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class DestructorDeclaration : AbstractMemberBase + { + public const int TildeRole = 100; + + public BlockStatement Body { + get { + return (BlockStatement)GetChildByRole (Roles.Body); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitDestructorDeclaration (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/EventDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/EventDeclaration.cs new file mode 100644 index 0000000000..f87e3b5246 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/EventDeclaration.cs @@ -0,0 +1,66 @@ +// +// EventDeclaration.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class EventDeclaration : AbstractMember + { + public const int EventAddRole = 100; + public const int EventRemoveRole = 101; + + public CSharpTokenNode LBrace { + get { + return (CSharpTokenNode)GetChildByRole (Roles.LBrace); + } + } + + public CSharpTokenNode RBrace { + get { + return (CSharpTokenNode)GetChildByRole (Roles.RBrace); + } + } + + public Accessor AddAccessor { + get { + return (Accessor)GetChildByRole (EventAddRole); + } + } + + public Accessor RemoveAccessor { + get { + return (Accessor)GetChildByRole (EventRemoveRole); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitEventDeclaration (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/FieldDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/FieldDeclaration.cs new file mode 100644 index 0000000000..4768ff9398 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/FieldDeclaration.cs @@ -0,0 +1,51 @@ +// +// FieldDeclaration.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class FieldDeclaration : AbstractMember + { + public CSharpTokenNode Semicolon { + get { return (CSharpTokenNode)GetChildByRole (Roles.Semicolon); } + } + + public IEnumerable Variables { + get { + return base.GetChildrenByRole (Roles.Initializer).Cast (); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitFieldDeclaration (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/IndexerDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/IndexerDeclaration.cs new file mode 100644 index 0000000000..98cfdd417a --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/IndexerDeclaration.cs @@ -0,0 +1,60 @@ +// +// IndexerDeclaration.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class IndexerDeclaration : PropertyDeclaration + { + public IEnumerable Arguments { + get { + return base.GetChildrenByRole (Roles.Argument).Cast (); + } + } + + public CSharpTokenNode LBracket { + get { + return (CSharpTokenNode)GetChildByRole (Roles.LBracket); + } + } + + public CSharpTokenNode RBracket { + get { + return (CSharpTokenNode)GetChildByRole (Roles.RBracket); + } + } + + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitIndexerDeclaration (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/MethodDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/MethodDeclaration.cs new file mode 100644 index 0000000000..76cb8dac48 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/MethodDeclaration.cs @@ -0,0 +1,72 @@ +// +// MethodDeclaration.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using System.Linq; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class MethodDeclaration : AbstractMember + { + public IEnumerable TypeArguments { + get { return GetChildrenByRole (Roles.TypeArgument).Cast (); } + } + + public IEnumerable Constraints { + get { + return base.GetChildrenByRole (Roles.Constraint).Cast (); + } + } + + public IEnumerable Arguments { + get { + return base.GetChildrenByRole (Roles.Argument).Cast (); + } + } + + public CSharpTokenNode LPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.LPar); } + } + + public CSharpTokenNode RPar { + get { return (CSharpTokenNode)GetChildByRole (Roles.RPar); } + } + + public BlockStatement Body { + get { + return (BlockStatement)GetChildByRole (Roles.Body); + } + } + + + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitMethodDeclaration (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/OperatorDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/OperatorDeclaration.cs new file mode 100644 index 0000000000..bd19939784 --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/OperatorDeclaration.cs @@ -0,0 +1,96 @@ +// +// OperatorDeclaration.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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 enum OperatorType { + // Unary operators + LogicalNot, + OnesComplement, + Increment, + Decrement, + True, + False, + + // Unary and Binary operators + Addition, + Subtraction, + + UnaryPlus, + UnaryNegation, + + // Binary operators + Multiply, + Division, + Modulus, + BitwiseAnd, + BitwiseOr, + ExclusiveOr, + LeftShift, + RightShift, + Equality, + Inequality, + GreaterThan, + LessThan, + GreaterThanOrEqual, + LessThanOrEqual, + + // Implicit and Explicit + Implicit, + Explicit + } + + public class OperatorDeclaration : MethodDeclaration + { + public const int OperatorKeywordRole = 100; + public const int OperatorTypeRole = 101; + + public OperatorType OperatorType { + get; + set; + } + + public string OverloadOperator { + get; + set; + } + + public CSharpTokenNode OperatorKeyword { + get { return (CSharpTokenNode)GetChildByRole (OperatorKeywordRole); } + } + + public CSharpTokenNode OperatorTypeKeyword { + get { return (CSharpTokenNode)GetChildByRole (OperatorTypeRole); } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitOperatorDeclaration (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/ParameterDeclarationExpression.cs b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/ParameterDeclarationExpression.cs new file mode 100644 index 0000000000..dec30f7a9b --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/ParameterDeclarationExpression.cs @@ -0,0 +1,64 @@ +// +// ParameterDeclarationExpression.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.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 enum ParameterModifier { + None, + Ref, + Out, + Params, + This + } + + public class ParameterDeclarationExpression : AbstractNode + { + public ParameterModifier ParameterModifier { + get; + set; + } + + public Identifier Identifier { + get { + return (Identifier)GetChildByRole (Roles.Identifier); + } + } + + public INode DefaultExpression { + get { + return (INode)GetChildByRole (Roles.Expression); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitParameterDeclarationExpression (this, data); + } + } +} + diff --git a/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/PropertyDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/PropertyDeclaration.cs new file mode 100644 index 0000000000..6652c5d28f --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/PropertyDeclaration.cs @@ -0,0 +1,86 @@ +// +// PropertyDeclaration.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + + public class Accessor : AbstractMember + { + public DomLocation Location { + get; + set; + } + + public BlockStatement Body { + get { + return (BlockStatement)GetChildByRole (Roles.Body); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitAccessorDeclaration (this, data); + } + } + + public class PropertyDeclaration : AbstractMember + { + public const int PropertyGetRole = 100; + public const int PropertySetRole = 101; + + public CSharpTokenNode LBrace { + get { + return (CSharpTokenNode)GetChildByRole (Roles.LBrace); + } + } + + public CSharpTokenNode RBrace { + get { + return (CSharpTokenNode)GetChildByRole (Roles.RBrace); + } + } + + public Accessor GetAccessor { + get { + return (Accessor)GetChildByRole (PropertyGetRole); + } + } + + public Accessor SetAccessor { + get { + return (Accessor)GetChildByRole (PropertySetRole); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitPropertyDeclaration (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/VariableInitializer.cs b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/VariableInitializer.cs new file mode 100644 index 0000000000..29d485ad6d --- /dev/null +++ b/ICSharpCode.NRefactory/CSharp/Dom/TypeMembers/VariableInitializer.cs @@ -0,0 +1,58 @@ +// +// VariableInitializer.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.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; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + public class VariableInitializer : AbstractNode + { + public string Name { + get { + return NameIdentifier.Name; + } + } + + public Identifier NameIdentifier { + get { + return (Identifier)GetChildByRole (Roles.Identifier); + } + } + + public INode Initializer { + get { + return GetChildByRole (Roles.Initializer); + } + } + + public override S AcceptVisitor (IDomVisitor visitor, T data) + { + return visitor.VisitVariableInitializer (this, data); + } + + } +} diff --git a/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj b/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj index 970627bf93..0c90214606 100644 --- a/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj +++ b/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj @@ -1,86 +1,168 @@ - - - - {3B2A5653-EC97-4001-BB9B-D90F1AF2C371} - Debug - AnyCPU - Library - ICSharpCode.NRefactory - ICSharpCode.NRefactory - v4.0 - Properties - - - AnyCPU - - - bin\Debug\ - True - Full - False - True - DEBUG;TRACE - - - bin\Release\ - False - None - True - False - TRACE - - - - - 3.5 - - - - 3.5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + {3B2A5653-EC97-4001-BB9B-D90F1AF2C371} + Debug + AnyCPU + Library + ICSharpCode.NRefactory + ICSharpCode.NRefactory + v4.0 + Properties + + + AnyCPU + + + bin\Debug\ + True + Full + False + True + DEBUG;TRACE + + + bin\Release\ + False + None + True + False + TRACE + + + + + 3.5 + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file