diff --git a/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/ImportsStatementTests.cs b/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/ImportsStatementTests.cs index 0e7546f9e5..34519e64cf 100644 --- a/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/ImportsStatementTests.cs +++ b/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/ImportsStatementTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; @@ -47,7 +47,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Ast string program = "Imports My.Name.Space\n"; var clause2 = new MemberImportsClause { - Member = new QualifiedType(new QualifiedType(new SimpleType("My"), new Identifier("Name", AstLocation.Empty)), new Identifier("Space", AstLocation.Empty)) + Member = new QualifiedType(new QualifiedType(new SimpleType("My"), Identifier.Create ("Name", AstLocation.Empty)), Identifier.Create ("Space", AstLocation.Empty)) }; var node = new ImportsStatement(); diff --git a/ICSharpCode.NRefactory.VB/Ast/General/TypeParameterDeclaration.cs b/ICSharpCode.NRefactory.VB/Ast/General/TypeParameterDeclaration.cs index 794615fc2a..45133bab0a 100644 --- a/ICSharpCode.NRefactory.VB/Ast/General/TypeParameterDeclaration.cs +++ b/ICSharpCode.NRefactory.VB/Ast/General/TypeParameterDeclaration.cs @@ -1,4 +1,4 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; @@ -21,7 +21,7 @@ namespace ICSharpCode.NRefactory.VB.Ast public string Name { get { return GetChildByRole (Roles.Identifier).Name; } - set { SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); } + set { SetChildByRole(Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } public AstNodeCollection Constraints { diff --git a/ICSharpCode.NRefactory.VB/Ast/GlobalScope/NamespaceDeclaration.cs b/ICSharpCode.NRefactory.VB/Ast/GlobalScope/NamespaceDeclaration.cs index b91a753e03..beea69bf50 100644 --- a/ICSharpCode.NRefactory.VB/Ast/GlobalScope/NamespaceDeclaration.cs +++ b/ICSharpCode.NRefactory.VB/Ast/GlobalScope/NamespaceDeclaration.cs @@ -1,4 +1,4 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; @@ -30,7 +30,7 @@ namespace ICSharpCode.NRefactory.VB.Ast return builder.ToString (); } set { - GetChildrenByRole(Roles.Identifier).ReplaceWith(value.Split('.').Select(ident => new Identifier(ident, AstLocation.Empty))); + GetChildrenByRole(Roles.Identifier).ReplaceWith(value.Split('.').Select(ident => Identifier.Create (ident, AstLocation.Empty))); } } diff --git a/ICSharpCode.NRefactory.VB/Ast/GlobalScope/TypeDeclaration.cs b/ICSharpCode.NRefactory.VB/Ast/GlobalScope/TypeDeclaration.cs index 38caba30b9..04aeb330e1 100644 --- a/ICSharpCode.NRefactory.VB/Ast/GlobalScope/TypeDeclaration.cs +++ b/ICSharpCode.NRefactory.VB/Ast/GlobalScope/TypeDeclaration.cs @@ -1,4 +1,4 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; @@ -23,7 +23,7 @@ namespace ICSharpCode.NRefactory.VB.Ast public string Name { get { return GetChildByRole(Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory.VB/Ast/TypeName/QualifiedType.cs b/ICSharpCode.NRefactory.VB/Ast/TypeName/QualifiedType.cs index 2dbb28516b..bfb064a347 100644 --- a/ICSharpCode.NRefactory.VB/Ast/TypeName/QualifiedType.cs +++ b/ICSharpCode.NRefactory.VB/Ast/TypeName/QualifiedType.cs @@ -1,4 +1,4 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; @@ -24,7 +24,7 @@ namespace ICSharpCode.NRefactory.VB.Ast return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory.VB/Ast/TypeName/SimpleType.cs b/ICSharpCode.NRefactory.VB/Ast/TypeName/SimpleType.cs index 6ddc198d77..7914428c44 100644 --- a/ICSharpCode.NRefactory.VB/Ast/TypeName/SimpleType.cs +++ b/ICSharpCode.NRefactory.VB/Ast/TypeName/SimpleType.cs @@ -1,4 +1,4 @@ -// +// // FullTypeName.cs // // Author: @@ -44,7 +44,7 @@ namespace ICSharpCode.NRefactory.VB.Ast public SimpleType(string identifier, AstLocation location) { - SetChildByRole (Roles.Identifier, new Identifier(identifier, location)); + SetChildByRole (Roles.Identifier, Identifier.Create (identifier, location)); } public string Identifier { @@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.VB.Ast return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory.VB/Parser/Parser.cs b/ICSharpCode.NRefactory.VB/Parser/Parser.cs index 1b2b8d9394..530b0fc2d9 100644 --- a/ICSharpCode.NRefactory.VB/Parser/Parser.cs +++ b/ICSharpCode.NRefactory.VB/Parser/Parser.cs @@ -402,7 +402,7 @@ partial class VBParser while (la.kind == 26) { Get(); Identifier(); - type = new QualifiedType(type, new Identifier(t.val, t.Location)); + type = new QualifiedType(type, Identifier.Create (t.val, t.Location)); } } @@ -445,7 +445,7 @@ partial class VBParser var result = new AliasImportsClause(); NodeStart(result); AstType alias; Identifier(); - result.Name = new Identifier(t.val, t.Location); + result.Name = Identifier.Create (t.val, t.Location); Expect(20); TypeName(out alias); result.Alias = alias; diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/IdentifierExpression.cs b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/IdentifierExpression.cs index bbc6898c1d..e982f13201 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/IdentifierExpression.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/IdentifierExpression.cs @@ -40,7 +40,7 @@ namespace ICSharpCode.NRefactory.CSharp public IdentifierExpression(string identifier, AstLocation location) { - SetChildByRole(Roles.Identifier, new Identifier(identifier, location)); + SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (identifier, location)); } // public Identifier IdentifierToken { @@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/MemberReferenceExpression.cs b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/MemberReferenceExpression.cs index 8ae269de5f..4a7decbe0e 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/MemberReferenceExpression.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/MemberReferenceExpression.cs @@ -1,4 +1,4 @@ -// +// // MemberReferenceExpression.cs // // Author: @@ -43,7 +43,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier (value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/NamedArgumentExpression.cs b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/NamedArgumentExpression.cs index df51dcf937..bef665927e 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/NamedArgumentExpression.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/NamedArgumentExpression.cs @@ -15,7 +15,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/PointerReferenceExpression.cs b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/PointerReferenceExpression.cs index 3ac10d3874..21e805b671 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/PointerReferenceExpression.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/PointerReferenceExpression.cs @@ -1,4 +1,4 @@ -// +// // PointerReferenceExpression.cs // // Author: @@ -45,7 +45,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/QueryExpression.cs b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/QueryExpression.cs index 9841a74685..5cf8877030 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Expressions/QueryExpression.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Expressions/QueryExpression.cs @@ -89,7 +89,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, AstLocation.Empty)); } } @@ -120,7 +120,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, AstLocation.Empty)); } } @@ -153,7 +153,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole(Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, AstLocation.Empty)); } } @@ -237,7 +237,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole(JoinIdentifierRole).Name; } set { - SetChildByRole(JoinIdentifierRole, new Identifier(value, AstLocation.Empty)); + SetChildByRole(JoinIdentifierRole, Identifier.Create (value, AstLocation.Empty)); } } @@ -277,7 +277,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (IntoIdentifierRole).Name; } set { - SetChildByRole(IntoIdentifierRole, new Identifier(value, AstLocation.Empty)); + SetChildByRole(IntoIdentifierRole, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Constraint.cs b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Constraint.cs index 8bac245c76..48c4e0ecb4 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Constraint.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Constraint.cs @@ -1,4 +1,4 @@ -// +// // Constraint.cs // // Author: @@ -50,7 +50,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/DelegateDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/DelegateDeclaration.cs index 2fe790e022..c33c0bf246 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/DelegateDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/DelegateDeclaration.cs @@ -1,4 +1,4 @@ -// +// // DelegateDeclaration.cs // // Author: @@ -50,7 +50,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier (value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/ExternAliasDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/ExternAliasDeclaration.cs index bdd8c0f043..7d9a33df4f 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/ExternAliasDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/ExternAliasDeclaration.cs @@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier (value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/NamespaceDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/NamespaceDeclaration.cs index 07dee45b76..c580f3790c 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/NamespaceDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/NamespaceDeclaration.cs @@ -1,4 +1,4 @@ -// +// // NamespaceDeclaration.cs // // Author: @@ -54,7 +54,7 @@ namespace ICSharpCode.NRefactory.CSharp return builder.ToString (); } set { - GetChildrenByRole(Roles.Identifier).ReplaceWith(value.Split('.').Select(ident => new Identifier(ident, AstLocation.Empty))); + GetChildrenByRole(Roles.Identifier).ReplaceWith(value.Split('.').Select(ident => Identifier.Create (ident, AstLocation.Empty))); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeDeclaration.cs index 5ef0c7d3b5..945c936cd6 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeDeclaration.cs @@ -1,4 +1,4 @@ -// +// // TypeDeclaration.cs // // Author: @@ -55,7 +55,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier (value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeParameterDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeParameterDeclaration.cs index 1e415639ce..ee2d58eb37 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeParameterDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeParameterDeclaration.cs @@ -35,7 +35,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/UsingAliasDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/UsingAliasDeclaration.cs index a157ce62fc..7fd3dfa096 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/UsingAliasDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/UsingAliasDeclaration.cs @@ -1,4 +1,4 @@ -// +// // UsingAliasDeclaration.cs // // Author: @@ -49,7 +49,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (AliasRole).Name; } set { - SetChildByRole(AliasRole, new Identifier(value, AstLocation.Empty)); + SetChildByRole(AliasRole, Identifier.Create (value, AstLocation.Empty)); } } @@ -72,13 +72,13 @@ namespace ICSharpCode.NRefactory.CSharp public UsingAliasDeclaration (string alias, string nameSpace) { - AddChild (new Identifier (alias, AstLocation.Empty), AliasRole); + AddChild (Identifier.Create (alias, AstLocation.Empty), AliasRole); AddChild (new SimpleType (nameSpace), ImportRole); } public UsingAliasDeclaration (string alias, AstType import) { - AddChild (new Identifier (alias, AstLocation.Empty), AliasRole); + AddChild (Identifier.Create (alias, AstLocation.Empty), AliasRole); AddChild (import, ImportRole); } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Identifier.cs b/ICSharpCode.NRefactory/CSharp/Ast/Identifier.cs index acd8063bdd..293584e0ac 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Identifier.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Identifier.cs @@ -30,7 +30,7 @@ namespace ICSharpCode.NRefactory.CSharp { public class Identifier : AstNode, IRelocatable { - public static readonly new Identifier Null = new NullIdentifier (); + public static readonly Identifier Null = new NullIdentifier (); class NullIdentifier : Identifier { public override bool IsNull { @@ -66,14 +66,6 @@ namespace ICSharpCode.NRefactory.CSharp } } - /// - /// True if this is a verbatim identifier (starting with '@') - /// - public bool IsVerbatim { - get; - set; - } - AstLocation startLocation; public override AstLocation StartLocation { get { @@ -91,23 +83,46 @@ namespace ICSharpCode.NRefactory.CSharp public override AstLocation EndLocation { get { - return new AstLocation (StartLocation.Line, StartLocation.Column + (Name ?? "").Length + (IsVerbatim ? 1 : 0)); + return new AstLocation (StartLocation.Line, StartLocation.Column + (Name ?? "").Length); } } - private Identifier () + Identifier () { this.name = string.Empty; } - public Identifier (string name, AstLocation location) + protected Identifier (string name, AstLocation location) { if (name == null) throw new ArgumentNullException("name"); - IsVerbatim = name.Length > 0 && name[0] == '@'; - this.Name = IsVerbatim ? name.Substring (1) : name; + this.Name = name; this.startLocation = location; } + + public static Identifier Create (string name) + { + return Create (name, AstLocation.Empty); + } + + public static Identifier Create (string name, AstLocation location) + { + if (name == null) + throw new ArgumentNullException("name"); + if (name.Length > 0 && name[0] == '@') + return new VerbatimIdentifier(name.Substring (1), location); + return Identifier.Create (name, location); + } + + public static Identifier Create (string name, AstLocation location, bool isVerbatim) + { + if (name == null) + throw new ArgumentNullException("name"); + + if (isVerbatim) + return new VerbatimIdentifier(name, location); + return Identifier.Create (name, location); + } public override S AcceptVisitor (IAstVisitor visitor, T data) { @@ -119,5 +134,19 @@ namespace ICSharpCode.NRefactory.CSharp Identifier o = other as Identifier; return o != null && !o.IsNull && MatchString(this.Name, o.Name); } + + public class VerbatimIdentifier : Identifier + { + public override AstLocation EndLocation { + get { + return new AstLocation (StartLocation.Line, StartLocation.Column + (Name ?? "").Length + 1); // @"..." + } + } + + public VerbatimIdentifier(string name, AstLocation location) : base (name, location) + { + + } + } } -} +} \ No newline at end of file diff --git a/ICSharpCode.NRefactory/CSharp/Ast/MemberType.cs b/ICSharpCode.NRefactory/CSharp/Ast/MemberType.cs index 1c14456b66..0277fd60ba 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/MemberType.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/MemberType.cs @@ -1,4 +1,4 @@ -// +// // FullTypeName.cs // // Author: @@ -47,7 +47,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier (value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/SimpleType.cs b/ICSharpCode.NRefactory/CSharp/Ast/SimpleType.cs index e81ade530f..48a95c6bb9 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/SimpleType.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/SimpleType.cs @@ -1,4 +1,4 @@ -// +// // FullTypeName.cs // // Author: @@ -44,7 +44,7 @@ namespace ICSharpCode.NRefactory.CSharp public SimpleType(string identifier, AstLocation location) { - SetChildByRole (Roles.Identifier, new Identifier(identifier, location)); + SetChildByRole (Roles.Identifier, CSharp.Identifier.Create (identifier, location)); } public string Identifier { @@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, CSharp.Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Statements/ForeachStatement.cs b/ICSharpCode.NRefactory/CSharp/Ast/Statements/ForeachStatement.cs index 6caf3883e7..8dcc78e385 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Statements/ForeachStatement.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Statements/ForeachStatement.cs @@ -1,4 +1,4 @@ -// +// // ForeachStatement.cs // // Author: @@ -49,7 +49,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Statements/GotoStatement.cs b/ICSharpCode.NRefactory/CSharp/Ast/Statements/GotoStatement.cs index 2eeeb0bc39..0bcc5e2388 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Statements/GotoStatement.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Statements/GotoStatement.cs @@ -1,4 +1,4 @@ -// +// // GotoStatement.cs // // Author: @@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp if (string.IsNullOrEmpty(value)) SetChildByRole(Roles.Identifier, null); else - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Statements/LabelStatement.cs b/ICSharpCode.NRefactory/CSharp/Ast/Statements/LabelStatement.cs index 3ebdc3302c..b23c80a4c2 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Statements/LabelStatement.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Statements/LabelStatement.cs @@ -1,4 +1,4 @@ -// +// // LabelStatement.cs // // Author: @@ -36,7 +36,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole(Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Statements/TryCatchStatement.cs b/ICSharpCode.NRefactory/CSharp/Ast/Statements/TryCatchStatement.cs index ccd1fb7b6e..068af49ab8 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/Statements/TryCatchStatement.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/Statements/TryCatchStatement.cs @@ -1,4 +1,4 @@ -// +// // TryCatchStatement.cs // // Author: @@ -140,7 +140,7 @@ namespace ICSharpCode.NRefactory.CSharp if (string.IsNullOrEmpty(value)) SetChildByRole (Roles.Identifier, null); else - SetChildByRole (Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/EnumMemberDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/EnumMemberDeclaration.cs index 705efe59ff..8c31562983 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/EnumMemberDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/EnumMemberDeclaration.cs @@ -1,4 +1,4 @@ -// +// // EnumMemberDeclaration.cs // // Author: @@ -36,7 +36,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier(value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FixedVariableInitializer.cs b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FixedVariableInitializer.cs index 085b474798..1d5d9da935 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FixedVariableInitializer.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FixedVariableInitializer.cs @@ -1,4 +1,4 @@ -// +// // FixedFieldDeclaration.cs // // Author: @@ -54,7 +54,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier (value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/MemberDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/MemberDeclaration.cs index 4bfbfc9bec..f2fd816830 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/MemberDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/MemberDeclaration.cs @@ -1,4 +1,4 @@ -// +// // AbstractMember.cs // // Author: @@ -48,7 +48,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier (value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ParameterDeclaration.cs b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ParameterDeclaration.cs index b4a2241b6c..287611ef69 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ParameterDeclaration.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ParameterDeclaration.cs @@ -1,4 +1,4 @@ -// +// // ParameterDeclarationExpression.cs // // Author: @@ -68,7 +68,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier (value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/VariableInitializer.cs b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/VariableInitializer.cs index c20a104ab2..6e1d572727 100644 --- a/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/VariableInitializer.cs +++ b/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/VariableInitializer.cs @@ -1,4 +1,4 @@ -// +// // VariableInitializer.cs // // Author: @@ -85,7 +85,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, new Identifier (value, AstLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value, AstLocation.Empty)); } } diff --git a/ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs b/ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs index f559de79c9..7d6bcf1094 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs @@ -1,4 +1,4 @@ -// +// // CSharpParser.cs // // Author: @@ -126,7 +126,7 @@ namespace ICSharpCode.NRefactory.CSharp var memberType = new MemberType (); memberType.AddChild (ConvertToType (ma.LeftExpression), MemberType.TargetRole); - memberType.MemberNameToken = new Identifier (ma.Name, Convert (ma.Location)); + memberType.MemberNameToken = Identifier.Create (ma.Name, Convert (ma.Location)); AddTypeArguments (ma, memberType); return memberType; @@ -257,7 +257,7 @@ namespace ICSharpCode.NRefactory.CSharp { AstNode insertPos = null; while (memberName != null) { - Identifier newIdent = new Identifier (memberName.Name, Convert (memberName.Location)); + Identifier newIdent = Identifier.Create (memberName.Name, Convert (memberName.Location)); namespaceDecl.InsertChildBefore (insertPos, newIdent, NamespaceDeclaration.Roles.Identifier); insertPos = newIdent; memberName = memberName.Left; @@ -277,7 +277,7 @@ namespace ICSharpCode.NRefactory.CSharp { UsingAliasDeclaration ud = new UsingAliasDeclaration (); ud.AddChild (new CSharpTokenNode (Convert (u.UsingLocation), "using".Length), UsingAliasDeclaration.Roles.Keyword); - ud.AddChild (new Identifier (u.Identifier.Value, Convert (u.Identifier.Location)), UsingAliasDeclaration.AliasRole); + ud.AddChild (Identifier.Create (u.Identifier.Value, Convert (u.Identifier.Location)), UsingAliasDeclaration.AliasRole); ud.AddChild (new CSharpTokenNode (Convert (u.AssignLocation), 1), UsingAliasDeclaration.Roles.Assign); ud.AddChild (ConvertImport (u.Nspace), UsingAliasDeclaration.ImportRole); ud.AddChild (new CSharpTokenNode (Convert (u.SemicolonLocation), 1), UsingAliasDeclaration.Roles.Semicolon); @@ -289,7 +289,7 @@ namespace ICSharpCode.NRefactory.CSharp var ud = new ExternAliasDeclaration (); ud.AddChild (new CSharpTokenNode (Convert (u.ExternLocation), "extern".Length), ExternAliasDeclaration.Roles.Keyword); ud.AddChild (new CSharpTokenNode (Convert (u.AliasLocation), "alias".Length), ExternAliasDeclaration.AliasRole); - ud.AddChild (new Identifier (u.Identifier.Value, Convert (u.Identifier.Location)), ExternAliasDeclaration.Roles.Identifier); + ud.AddChild (Identifier.Create (u.Identifier.Value, Convert (u.Identifier.Location)), ExternAliasDeclaration.Roles.Identifier); ud.AddChild (new CSharpTokenNode (Convert (u.SemicolonLocation), 1), UsingAliasDeclaration.Roles.Semicolon); AddToNamespace (ud); } @@ -301,12 +301,12 @@ namespace ICSharpCode.NRefactory.CSharp var t = new MemberType(); t.IsDoubleColon = memberName.IsDoubleColon; t.AddChild (ConvertImport (memberName.Left), MemberType.TargetRole); - t.AddChild (new Identifier (memberName.Name, Convert(memberName.Location)), MemberType.Roles.Identifier); + t.AddChild (Identifier.Create (memberName.Name, Convert(memberName.Location)), MemberType.Roles.Identifier); AddTypeArguments (t, (List)null, memberName.TypeArguments); return t; } else { SimpleType t = new SimpleType(); - t.AddChild (new Identifier (memberName.Name, Convert(memberName.Location)), SimpleType.Roles.Identifier); + t.AddChild (Identifier.Create (memberName.Name, Convert(memberName.Location)), SimpleType.Roles.Identifier); AddTypeArguments (t, (List)null, memberName.TypeArguments); return t; } @@ -330,7 +330,7 @@ namespace ICSharpCode.NRefactory.CSharp AddModifiers (newType, location); if (location != null) newType.AddChild (new CSharpTokenNode (Convert (location[0]), "class".Length), TypeDeclaration.Roles.Keyword); - newType.AddChild (new Identifier (c.MemberName.Name, Convert (c.MemberName.Location)), AstNode.Roles.Identifier); + newType.AddChild (Identifier.Create (c.MemberName.Name, Convert (c.MemberName.Location)), AstNode.Roles.Identifier); if (c.MemberName.TypeArguments != null) { var typeArgLocation = LocationsBag.GetLocations (c.MemberName); if (typeArgLocation != null) @@ -364,7 +364,7 @@ namespace ICSharpCode.NRefactory.CSharp AddModifiers (newType, location); if (location != null) newType.AddChild (new CSharpTokenNode (Convert (location[0]), "struct".Length), TypeDeclaration.Roles.Keyword); - newType.AddChild (new Identifier (s.MemberName.Name, Convert (s.MemberName.Location)), AstNode.Roles.Identifier); + newType.AddChild (Identifier.Create (s.MemberName.Name, Convert (s.MemberName.Location)), AstNode.Roles.Identifier); if (s.MemberName.TypeArguments != null) { var typeArgLocation = LocationsBag.GetLocations (s.MemberName); if (typeArgLocation != null) @@ -400,7 +400,7 @@ namespace ICSharpCode.NRefactory.CSharp AddModifiers (newType, location); if (location != null) newType.AddChild (new CSharpTokenNode (Convert (location[0]), "interface".Length), TypeDeclaration.Roles.Keyword); - newType.AddChild (new Identifier (i.MemberName.Name, Convert (i.MemberName.Location)), AstNode.Roles.Identifier); + newType.AddChild (Identifier.Create (i.MemberName.Name, Convert (i.MemberName.Location)), AstNode.Roles.Identifier); if (i.MemberName.TypeArguments != null) { var typeArgLocation = LocationsBag.GetLocations (i.MemberName); if (typeArgLocation != null) @@ -434,7 +434,7 @@ namespace ICSharpCode.NRefactory.CSharp if (location != null) newDelegate.AddChild (new CSharpTokenNode (Convert (location[0]), "delegate".Length), TypeDeclaration.Roles.Keyword); newDelegate.AddChild (ConvertToType (d.ReturnType), AstNode.Roles.Type); - newDelegate.AddChild (new Identifier (d.MemberName.Name, Convert (d.MemberName.Location)), AstNode.Roles.Identifier); + newDelegate.AddChild (Identifier.Create (d.MemberName.Name, Convert (d.MemberName.Location)), AstNode.Roles.Identifier); if (d.MemberName.TypeArguments != null) { var typeArgLocation = LocationsBag.GetLocations (d.MemberName); if (typeArgLocation != null) @@ -483,7 +483,7 @@ namespace ICSharpCode.NRefactory.CSharp AddModifiers (newType, location); if (location != null) newType.AddChild (new CSharpTokenNode (Convert (location [0]), "enum".Length), TypeDeclaration.Roles.Keyword); - newType.AddChild (new Identifier (e.MemberName.Name, Convert (e.MemberName.Location)), AstNode.Roles.Identifier); + newType.AddChild (Identifier.Create (e.MemberName.Name, Convert (e.MemberName.Location)), AstNode.Roles.Identifier); if (e.BaseTypeExpression != null) newType.AddChild (ConvertToType (e.BaseTypeExpression), TypeDeclaration.BaseTypeRole); @@ -502,7 +502,7 @@ namespace ICSharpCode.NRefactory.CSharp { EnumMemberDeclaration newField = new EnumMemberDeclaration (); AddAttributeSection (newField, em); - newField.AddChild (new Identifier (em.Name, Convert (em.Location)), AstNode.Roles.Identifier); + newField.AddChild (Identifier.Create (em.Name, Convert (em.Location)), AstNode.Roles.Identifier); if (em.Initializer != null) { newField.AddChild ((Expression)em.Initializer.Accept (this), EnumMemberDeclaration.InitializerRole); @@ -527,7 +527,7 @@ namespace ICSharpCode.NRefactory.CSharp newField.AddChild (ConvertToType (f.TypeName), FixedFieldDeclaration.Roles.Type); var variable = new FixedVariableInitializer (); - variable.AddChild (new Identifier (f.MemberName.Name, Convert (f.MemberName.Location)), FixedFieldDeclaration.Roles.Identifier); + variable.AddChild (Identifier.Create (f.MemberName.Name, Convert (f.MemberName.Location)), FixedFieldDeclaration.Roles.Identifier); if (!f.Initializer.IsNull) { var bracketLocations = LocationsBag.GetLocations (f.Initializer); if (bracketLocations != null && bracketLocations.Count > 1) @@ -546,7 +546,7 @@ namespace ICSharpCode.NRefactory.CSharp newField.AddChild (new CSharpTokenNode (Convert (declLoc [0]), 1), FieldDeclaration.Roles.Comma); variable = new FixedVariableInitializer (); - variable.AddChild (new Identifier (decl.Name.Value, Convert (decl.Name.Location)), FieldDeclaration.Roles.Identifier); + variable.AddChild (Identifier.Create (decl.Name.Value, Convert (decl.Name.Location)), FieldDeclaration.Roles.Identifier); if (!decl.Initializer.IsNull) { var bracketLocations = LocationsBag.GetLocations (f.Initializer); if (bracketLocations != null && bracketLocations.Count > 1) @@ -574,7 +574,7 @@ namespace ICSharpCode.NRefactory.CSharp newField.AddChild (ConvertToType (f.TypeName), FieldDeclaration.Roles.Type); VariableInitializer variable = new VariableInitializer (); - variable.AddChild (new Identifier (f.MemberName.Name, Convert (f.MemberName.Location)), FieldDeclaration.Roles.Identifier); + variable.AddChild (Identifier.Create (f.MemberName.Name, Convert (f.MemberName.Location)), FieldDeclaration.Roles.Identifier); if (f.Initializer != null) { if (location != null) @@ -589,7 +589,7 @@ namespace ICSharpCode.NRefactory.CSharp newField.AddChild (new CSharpTokenNode (Convert (declLoc[0]), 1), FieldDeclaration.Roles.Comma); variable = new VariableInitializer (); - variable.AddChild (new Identifier (decl.Name.Value, Convert (decl.Name.Location)), VariableInitializer.Roles.Identifier); + variable.AddChild (Identifier.Create (decl.Name.Value, Convert (decl.Name.Location)), VariableInitializer.Roles.Identifier); if (decl.Initializer != null) { variable.AddChild (new CSharpTokenNode (Convert (decl.Initializer.Location), 1), FieldDeclaration.Roles.Assign); variable.AddChild ((Expression)decl.Initializer.Accept (this), VariableInitializer.Roles.Expression); @@ -615,7 +615,7 @@ namespace ICSharpCode.NRefactory.CSharp newField.AddChild (ConvertToType (f.TypeName), FieldDeclaration.Roles.Type); VariableInitializer variable = new VariableInitializer (); - variable.AddChild (new Identifier (f.MemberName.Name, Convert (f.MemberName.Location)), VariableInitializer.Roles.Identifier); + variable.AddChild (Identifier.Create (f.MemberName.Name, Convert (f.MemberName.Location)), VariableInitializer.Roles.Identifier); if (f.Initializer != null) { variable.AddChild (new CSharpTokenNode (Convert (f.Initializer.Location), 1), VariableInitializer.Roles.Assign); @@ -629,7 +629,7 @@ namespace ICSharpCode.NRefactory.CSharp newField.AddChild (new CSharpTokenNode (Convert (declLoc[0]), 1), FieldDeclaration.Roles.Comma); variable = new VariableInitializer (); - variable.AddChild (new Identifier (decl.Name.Value, Convert (decl.Name.Location)), FieldDeclaration.Roles.Identifier); + variable.AddChild (Identifier.Create (decl.Name.Value, Convert (decl.Name.Location)), FieldDeclaration.Roles.Identifier); if (decl.Initializer != null) { variable.AddChild (new CSharpTokenNode (Convert (decl.Initializer.Location), 1), FieldDeclaration.Roles.Assign); variable.AddChild ((Expression)decl.Initializer.Accept (this), VariableInitializer.Roles.Expression); @@ -764,7 +764,7 @@ namespace ICSharpCode.NRefactory.CSharp if (m.MethodName.Left != null) newMethod.AddChild (ConvertToType (m.MethodName.Left), MethodDeclaration.PrivateImplementationTypeRole); - newMethod.AddChild (new Identifier (m.MethodName.Name, Convert (m.Location)), AstNode.Roles.Identifier); + newMethod.AddChild (Identifier.Create (m.MethodName.Name, Convert (m.Location)), AstNode.Roles.Identifier); if (m.MemberName.TypeArguments != null) { var typeArgLocation = LocationsBag.GetLocations (m.MemberName); @@ -854,7 +854,7 @@ namespace ICSharpCode.NRefactory.CSharp if (p.MemberName.Left != null) newProperty.AddChild (ConvertToType (p.MemberName.Left), PropertyDeclaration.PrivateImplementationTypeRole); - newProperty.AddChild (new Identifier (p.MemberName.Name, Convert (p.Location)), PropertyDeclaration.Roles.Identifier); + newProperty.AddChild (Identifier.Create (p.MemberName.Name, Convert (p.Location)), PropertyDeclaration.Roles.Identifier); if (location != null) newProperty.AddChild (new CSharpTokenNode (Convert (location[0]), 1), MethodDeclaration.Roles.LBrace); @@ -902,7 +902,7 @@ namespace ICSharpCode.NRefactory.CSharp AddAttributeSection (newConstructor, c); var location = LocationsBag.GetMemberLocation (c); AddModifiers (newConstructor, location); - newConstructor.AddChild (new Identifier (c.MemberName.Name, Convert (c.MemberName.Location)), AstNode.Roles.Identifier); + newConstructor.AddChild (Identifier.Create (c.MemberName.Name, Convert (c.MemberName.Location)), AstNode.Roles.Identifier); if (location != null) newConstructor.AddChild (new CSharpTokenNode (Convert (location[0]), 1), MethodDeclaration.Roles.LPar); @@ -939,7 +939,7 @@ namespace ICSharpCode.NRefactory.CSharp AddModifiers (newDestructor, location); if (location != null) newDestructor.AddChild (new CSharpTokenNode (Convert (location[0]), 1), DestructorDeclaration.TildeRole); - newDestructor.AddChild (new Identifier (d.MemberName.Name, Convert (d.MemberName.Location)), AstNode.Roles.Identifier); + newDestructor.AddChild (Identifier.Create (d.MemberName.Name, Convert (d.MemberName.Location)), AstNode.Roles.Identifier); if (location != null) { newDestructor.AddChild (new CSharpTokenNode (Convert (location[1]), 1), DestructorDeclaration.Roles.LPar); @@ -964,7 +964,7 @@ namespace ICSharpCode.NRefactory.CSharp newEvent.AddChild (ConvertToType (e.TypeName), AstNode.Roles.Type); VariableInitializer variable = new VariableInitializer (); - variable.AddChild (new Identifier (e.MemberName.Name, Convert (e.MemberName.Location)), FieldDeclaration.Roles.Identifier); + variable.AddChild (Identifier.Create (e.MemberName.Name, Convert (e.MemberName.Location)), FieldDeclaration.Roles.Identifier); if (e.Initializer != null) { if (location != null) @@ -979,7 +979,7 @@ namespace ICSharpCode.NRefactory.CSharp newEvent.AddChild (new CSharpTokenNode (Convert (declLoc[0]), 1), FieldDeclaration.Roles.Comma); variable = new VariableInitializer (); - variable.AddChild (new Identifier (decl.Name.Value, Convert (decl.Name.Location)), VariableInitializer.Roles.Identifier); + variable.AddChild (Identifier.Create (decl.Name.Value, Convert (decl.Name.Location)), VariableInitializer.Roles.Identifier); if (decl.Initializer != null) { variable.AddChild (new CSharpTokenNode (Convert (decl.Initializer.Location), 1), FieldDeclaration.Roles.Assign); @@ -1008,7 +1008,7 @@ namespace ICSharpCode.NRefactory.CSharp if (ep.MemberName.Left != null) newEvent.AddChild (ConvertToType (ep.MemberName.Left), CustomEventDeclaration.PrivateImplementationTypeRole); - newEvent.AddChild (new Identifier (ep.MemberName.Name, Convert (ep.Location)), CustomEventDeclaration.Roles.Identifier); + newEvent.AddChild (Identifier.Create (ep.MemberName.Name, Convert (ep.Location)), CustomEventDeclaration.Roles.Identifier); if (location != null && location.Count >= 2) newEvent.AddChild (new CSharpTokenNode (Convert (location[1]), 1), CustomEventDeclaration.Roles.LBrace); @@ -1057,7 +1057,7 @@ namespace ICSharpCode.NRefactory.CSharp var varInit = new VariableInitializer (); var location = LocationsBag.GetLocations (blockVariableDeclaration); - varInit.AddChild (new Identifier (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), VariableInitializer.Roles.Identifier); + varInit.AddChild (Identifier.Create (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), VariableInitializer.Roles.Identifier); if (blockVariableDeclaration.Initializer != null) { if (location != null) varInit.AddChild (new CSharpTokenNode (Convert (location[0]), 1), VariableInitializer.Roles.Assign); @@ -1072,7 +1072,7 @@ namespace ICSharpCode.NRefactory.CSharp var init = new VariableInitializer (); if (loc != null && loc.Count > 0) result.AddChild (new CSharpTokenNode (Convert (loc [0]), 1), VariableInitializer.Roles.Comma); - init.AddChild (new Identifier (decl.Variable.Name, Convert (decl.Variable.Location)), VariableInitializer.Roles.Identifier); + init.AddChild (Identifier.Create (decl.Variable.Name, Convert (decl.Variable.Location)), VariableInitializer.Roles.Identifier); if (decl.Initializer != null) { if (loc != null && loc.Count > 1) result.AddChild (new CSharpTokenNode (Convert (loc [1]), 1), VariableInitializer.Roles.Assign); @@ -1098,7 +1098,7 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (ConvertToType (blockVariableDeclaration.TypeExpression), VariableDeclarationStatement.Roles.Type); var varInit = new VariableInitializer (); - varInit.AddChild (new Identifier (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), VariableInitializer.Roles.Identifier); + varInit.AddChild (Identifier.Create (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), VariableInitializer.Roles.Identifier); if (blockVariableDeclaration.Initializer != null) { if (location != null) varInit.AddChild (new CSharpTokenNode (Convert (location[1]), 1), VariableInitializer.Roles.Assign); @@ -1111,7 +1111,7 @@ namespace ICSharpCode.NRefactory.CSharp foreach (var decl in blockVariableDeclaration.Declarators) { var loc = LocationsBag.GetLocations (decl); var init = new VariableInitializer (); - init.AddChild (new Identifier (decl.Variable.Name, Convert (decl.Variable.Location)), VariableInitializer.Roles.Identifier); + init.AddChild (Identifier.Create (decl.Variable.Name, Convert (decl.Variable.Location)), VariableInitializer.Roles.Identifier); if (decl.Initializer != null) { if (loc != null) init.AddChild (new CSharpTokenNode (Convert (loc[0]), 1), VariableInitializer.Roles.Assign); @@ -1280,7 +1280,7 @@ namespace ICSharpCode.NRefactory.CSharp var result = new GotoStatement (); var location = LocationsBag.GetLocations (gotoStatement); result.AddChild (new CSharpTokenNode (Convert (gotoStatement.loc), "goto".Length), GotoStatement.Roles.Keyword); - result.AddChild (new Identifier (gotoStatement.Target, Convert (gotoStatement.loc)), GotoStatement.Roles.Identifier); + result.AddChild (Identifier.Create (gotoStatement.Target, Convert (gotoStatement.loc)), GotoStatement.Roles.Identifier); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), GotoStatement.Roles.Semicolon); @@ -1290,7 +1290,7 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (LabeledStatement labeledStatement) { var result = new LabelStatement (); - result.AddChild (new Identifier (labeledStatement.Name, Convert (labeledStatement.loc)), LabelStatement.Roles.Identifier); + result.AddChild (Identifier.Create (labeledStatement.Name, Convert (labeledStatement.loc)), LabelStatement.Roles.Identifier); return result; } @@ -1370,7 +1370,7 @@ namespace ICSharpCode.NRefactory.CSharp usingResult.AddChild (new CSharpTokenNode (Convert (blockStatement.StartLocation), 1), UsingStatement.Roles.LPar); if (u.Variables != null) { usingResult.AddChild (ConvertToType (u.Variables.TypeExpression), UsingStatement.Roles.Type); - usingResult.AddChild (new Identifier (u.Variables.Variable.Name, Convert (u.Variables.Variable.Location)), UsingStatement.Roles.Identifier); + usingResult.AddChild (Identifier.Create (u.Variables.Variable.Name, Convert (u.Variables.Variable.Location)), UsingStatement.Roles.Identifier); var loc = LocationsBag.GetLocations (u.Variables); if (loc != null) usingResult.AddChild (new CSharpTokenNode (Convert (loc[1]), 1), ContinueStatement.Roles.Assign); @@ -1516,7 +1516,7 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (ConvertToType (blockVariableDeclaration.TypeExpression), FixedStatement.Roles.Type); var varInit = new VariableInitializer (); var initLocation = LocationsBag.GetLocations (blockVariableDeclaration); - varInit.AddChild (new Identifier (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), VariableInitializer.Roles.Identifier); + varInit.AddChild (Identifier.Create (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), VariableInitializer.Roles.Identifier); if (blockVariableDeclaration.Initializer != null) { if (initLocation != null) varInit.AddChild (new CSharpTokenNode (Convert (location[0]), 1), VariableInitializer.Roles.Assign); @@ -1531,7 +1531,7 @@ namespace ICSharpCode.NRefactory.CSharp var init = new VariableInitializer (); if (loc != null && loc.Count > 0) result.AddChild (new CSharpTokenNode (Convert (loc [0]), 1), VariableInitializer.Roles.Comma); - init.AddChild (new Identifier (decl.Variable.Name, Convert (decl.Variable.Location)), VariableInitializer.Roles.Identifier); + init.AddChild (Identifier.Create (decl.Variable.Name, Convert (decl.Variable.Location)), VariableInitializer.Roles.Identifier); if (decl.Initializer != null) { if (loc != null && loc.Count > 1) result.AddChild (new CSharpTokenNode (Convert (loc [1]), 1), VariableInitializer.Roles.Assign); @@ -1580,7 +1580,7 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (ConvertToType (ctch.TypeExpression), CatchClause.Roles.Type); if (ctch.Variable != null && !string.IsNullOrEmpty (ctch.Variable.Name)) - result.AddChild (new Identifier (ctch.Variable.Name, Convert (ctch.Variable.Location)), CatchClause.Roles.Identifier); + result.AddChild (Identifier.Create (ctch.Variable.Name, Convert (ctch.Variable.Location)), CatchClause.Roles.Identifier); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), CatchClause.Roles.RPar); @@ -1639,7 +1639,7 @@ namespace ICSharpCode.NRefactory.CSharp if (foreachStatement.TypeExpr != null) result.AddChild (ConvertToType (foreachStatement.TypeExpr), ForeachStatement.Roles.Type); if (foreachStatement.Variable != null) - result.AddChild (new Identifier (foreachStatement.Variable.Name, Convert (foreachStatement.Variable.Location)), ForeachStatement.Roles.Identifier); + result.AddChild (Identifier.Create (foreachStatement.Variable.Name, Convert (foreachStatement.Variable.Location)), ForeachStatement.Roles.Identifier); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location [1]), "in".Length), ForeachStatement.Roles.InKeyword); @@ -1704,7 +1704,7 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (LocalVariableReference localVariableReference) { - return new Identifier (localVariableReference.Name, Convert (localVariableReference.Location));; + return Identifier.Create (localVariableReference.Name, Convert (localVariableReference.Location));; } public override object Visit (MemberAccess memberAccess) @@ -1723,7 +1723,7 @@ namespace ICSharpCode.NRefactory.CSharp } } - result.AddChild (new Identifier (memberAccess.Name, Convert (memberAccess.Location)), MemberReferenceExpression.Roles.Identifier); + result.AddChild (Identifier.Create (memberAccess.Name, Convert (memberAccess.Location)), MemberReferenceExpression.Roles.Identifier); if (memberAccess.TypeArguments != null) { var location = LocationsBag.GetLocations (memberAccess); @@ -1742,7 +1742,7 @@ namespace ICSharpCode.NRefactory.CSharp result.Target = new SimpleType (qualifiedAliasMember.alias, Convert (qualifiedAliasMember.Location)); result.IsDoubleColon = true; var location = LocationsBag.GetLocations (qualifiedAliasMember); - result.AddChild (new Identifier (qualifiedAliasMember.Name, location != null ? Convert (location[0]) : AstLocation.Empty), MemberReferenceExpression.Roles.Identifier); + result.AddChild (Identifier.Create (qualifiedAliasMember.Name, location != null ? Convert (location[0]) : AstLocation.Empty), MemberReferenceExpression.Roles.Identifier); return new TypeReferenceExpression () { Type = result }; } @@ -1763,7 +1763,7 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (SimpleName simpleName) { var result = new IdentifierExpression (); - result.AddChild (new Identifier (simpleName.Name, Convert (simpleName.Location)), IdentifierExpression.Roles.Identifier); + result.AddChild (Identifier.Create (simpleName.Name, Convert (simpleName.Location)), IdentifierExpression.Roles.Identifier); if (simpleName.TypeArguments != null) { var location = LocationsBag.GetLocations (simpleName); if (location != null) @@ -2073,7 +2073,7 @@ namespace ICSharpCode.NRefactory.CSharp if (p.TypeExpression != null) // lambdas may have no types (a, b) => ... parameterDeclarationExpression.AddChild (ConvertToType (p.TypeExpression), ParameterDeclaration.Roles.Type); if (p.Name != null) - parameterDeclarationExpression.AddChild (new Identifier (p.Name, Convert (p.Location)), ParameterDeclaration.Roles.Identifier); + parameterDeclarationExpression.AddChild (Identifier.Create (p.Name, Convert (p.Location)), ParameterDeclaration.Roles.Identifier); if (p.HasDefaultValue) { if (location != null) parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location [1]), 1), ParameterDeclaration.Roles.Assign); @@ -2097,7 +2097,7 @@ namespace ICSharpCode.NRefactory.CSharp // TODO: attributes // if (arg.Variance != Variance.None) // throw new NotImplementedException(); // TODO: variance - tp.AddChild (new Identifier (arg.Name, Convert (arg.Location)), InvocationExpression.Roles.Identifier); + tp.AddChild (Identifier.Create (arg.Name, Convert (arg.Location)), InvocationExpression.Roles.Identifier); parent.AddChild (tp, InvocationExpression.Roles.TypeParameter); } } @@ -2140,7 +2140,7 @@ namespace ICSharpCode.NRefactory.CSharp var constraint = new Constraint (); if (location != null) constraint.AddChild (new CSharpTokenNode (Convert (location [0]), "where".Length), InvocationExpression.Roles.Keyword); - constraint.AddChild (new Identifier (c.TypeParameter.Value, Convert (c.TypeParameter.Location)), InvocationExpression.Roles.Identifier); + constraint.AddChild (Identifier.Create (c.TypeParameter.Value, Convert (c.TypeParameter.Location)), InvocationExpression.Roles.Identifier); if (location != null && location.Count > 1) constraint.AddChild (new CSharpTokenNode (Convert (location [1]), 1), Constraint.ColonRole); foreach (var expr in c.ConstraintExpressions) @@ -2154,7 +2154,7 @@ namespace ICSharpCode.NRefactory.CSharp if (arg is NamedArgument) { var na = (NamedArgument)arg; NamedArgumentExpression newArg = new NamedArgumentExpression(); - newArg.AddChild (new Identifier (na.Name, Convert (na.Location)), NamedArgumentExpression.Roles.Identifier); + newArg.AddChild (Identifier.Create (na.Name, Convert (na.Location)), NamedArgumentExpression.Roles.Identifier); var loc = LocationsBag.GetLocations (na); if (loc != null) @@ -2251,7 +2251,7 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild ((Expression)par.Expr.Accept (this), AnonymousTypeCreateExpression.Roles.Expression); } else { var namedArgument = new NamedArgumentExpression (); - namedArgument.AddChild (new Identifier (par.Name, Convert (par.Location)), AnonymousTypeCreateExpression.Roles.Identifier); + namedArgument.AddChild (Identifier.Create (par.Name, Convert (par.Location)), AnonymousTypeCreateExpression.Roles.Identifier); namedArgument.AddChild (new CSharpTokenNode (Convert (location[0]), 1), AnonymousTypeCreateExpression.Roles.Assign); namedArgument.AddChild ((Expression)par.Expr.Accept (this), AnonymousTypeCreateExpression.Roles.Expression); result.AddChild (namedArgument, AnonymousTypeCreateExpression.Roles.Expression); @@ -2659,7 +2659,7 @@ namespace ICSharpCode.NRefactory.CSharp if (queryStart.Expr == null) { var intoClause = new QueryContinuationClause (); intoClause.AddChild (new CSharpTokenNode (Convert (queryStart.Location), "into".Length), QueryContinuationClause.IntoKeywordRole); - intoClause.AddChild (new Identifier (queryStart.IntoVariable.Name, Convert(queryStart.IntoVariable.Location)), QueryContinuationClause.Roles.Identifier); + intoClause.AddChild (Identifier.Create (queryStart.IntoVariable.Name, Convert(queryStart.IntoVariable.Location)), QueryContinuationClause.Roles.Identifier); return intoClause; } @@ -2671,7 +2671,7 @@ namespace ICSharpCode.NRefactory.CSharp if (queryStart.IdentifierType != null) fromClause.AddChild (ConvertToType (queryStart.IdentifierType), QueryFromClause.Roles.Type); - fromClause.AddChild (new Identifier (queryStart.IntoVariable.Name, Convert(queryStart.IntoVariable.Location)), QueryFromClause.Roles.Identifier); + fromClause.AddChild (Identifier.Create (queryStart.IntoVariable.Name, Convert(queryStart.IntoVariable.Location)), QueryFromClause.Roles.Identifier); if (location != null) fromClause.AddChild (new CSharpTokenNode (Convert (location[0]), "in".Length), QueryFromClause.InKeywordRole); @@ -2689,7 +2689,7 @@ namespace ICSharpCode.NRefactory.CSharp if (queryStart.IdentifierType != null) fromClause.AddChild (ConvertToType (queryStart.IdentifierType), QueryFromClause.Roles.Type); - fromClause.AddChild (new Identifier (queryStart.IntoVariable.Name, Convert(queryStart.IntoVariable.Location)), QueryFromClause.Roles.Identifier); + fromClause.AddChild (Identifier.Create (queryStart.IntoVariable.Name, Convert(queryStart.IntoVariable.Location)), QueryFromClause.Roles.Identifier); if (location != null) fromClause.AddChild (new CSharpTokenNode (Convert (location[0]), "in".Length), QueryFromClause.InKeywordRole); @@ -2723,7 +2723,7 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetLocations (l); result.AddChild (new CSharpTokenNode (Convert (l.Location), "let".Length), QueryLetClause.Roles.Keyword); - result.AddChild (new Identifier (l.IntoVariable.Name, Convert (l.IntoVariable.Location)), Identifier.Roles.Identifier); + result.AddChild (Identifier.Create (l.IntoVariable.Name, Convert (l.IntoVariable.Location)), Identifier.Roles.Identifier); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), QueryLetClause.Roles.Assign); result.AddChild ((Expression)l.Expr.Accept (this), QueryLetClause.Roles.Expression); @@ -2746,7 +2746,7 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetLocations (join); result.AddChild (new CSharpTokenNode (Convert (join.Location), "join".Length), QueryJoinClause.JoinKeywordRole); - result.AddChild (new Identifier (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), Identifier.Roles.Identifier); + result.AddChild (Identifier.Create (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), Identifier.Roles.Identifier); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[0]), "in".Length), QueryJoinClause.InKeywordRole); @@ -2770,7 +2770,7 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetLocations (join); result.AddChild (new CSharpTokenNode (Convert (join.Location), "join".Length), QueryJoinClause.JoinKeywordRole); - result.AddChild (new Identifier (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), Identifier.Roles.Identifier); + result.AddChild (Identifier.Create (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), Identifier.Roles.Identifier); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[0]), "in".Length), QueryJoinClause.InKeywordRole); @@ -2789,7 +2789,7 @@ namespace ICSharpCode.NRefactory.CSharp if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[3]), "into".Length), QueryJoinClause.IntoKeywordRole); - result.AddChild (new Identifier (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), Identifier.Roles.Identifier); + result.AddChild (Identifier.Create (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), Identifier.Roles.Identifier); return result; } diff --git a/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs b/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs index 0eeaa64ed3..a4127a8f58 100644 --- a/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs +++ b/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs @@ -637,7 +637,7 @@ namespace ICSharpCode.NRefactory.CSharp { DomRegion region = MakeRegion(attr); ITypeReference type = ConvertType(attr.Type); - if (!attr.Type.GetChildByRole(AstNode.Roles.Identifier).IsVerbatim) { + if (!(attr.Type.GetChildByRole(AstNode.Roles.Identifier) is Identifier.VerbatimIdentifier)) { // Try to add "Attribute" suffix, but only if the identifier // (=last identifier in fully qualified name) isn't a verbatim identifier. SimpleTypeOrNamespaceReference st = type as SimpleTypeOrNamespaceReference;