diff --git a/ICSharpCode.NRefactory.CSharp/Ast/CSharpModifierToken.cs b/ICSharpCode.NRefactory.CSharp/Ast/CSharpModifierToken.cs index 8236be4cfd..ac59c72460 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/CSharpModifierToken.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/CSharpModifierToken.cs @@ -61,7 +61,7 @@ namespace ICSharpCode.NRefactory.CSharp // Not worth using a dictionary for such few elements. // This table is sorted in the order that modifiers should be output when generating code. static readonly Modifiers[] allModifiers = { - Modifiers.Public, Modifiers.Internal, Modifiers.Protected, Modifiers.Private, Modifiers.ProtectedAndInternal, + Modifiers.Public, Modifiers.Protected, Modifiers.Private, Modifiers.Internal, Modifiers.New, Modifiers.Unsafe, Modifiers.Abstract, Modifiers.Virtual, Modifiers.Sealed, Modifiers.Static, Modifiers.Override, @@ -89,8 +89,6 @@ namespace ICSharpCode.NRefactory.CSharp return "internal"; case Modifiers.Protected: return "protected"; - case Modifiers.ProtectedAndInternal: - return "internal protected"; case Modifiers.Public: return "public"; case Modifiers.Abstract: diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Modifiers.cs b/ICSharpCode.NRefactory.CSharp/Ast/Modifiers.cs index 9809cbda52..eb320495c3 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Modifiers.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Modifiers.cs @@ -54,10 +54,8 @@ namespace ICSharpCode.NRefactory.CSharp Volatile = 0x4000, Unsafe = 0x8000, Async = 0x10000, - - ProtectedOrInternal = Protected | Internal, - ProtectedAndInternal = 0x20000, - VisibilityMask = Private | Internal | Protected | Public | ProtectedAndInternal, + + VisibilityMask = Private | Internal | Protected | Public, /// /// Special value used to match any modifiers during pattern matching. diff --git a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/EntityDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/EntityDeclaration.cs index 0e7c8bae23..ca8f69338d 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/EntityDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/EntityDeclaration.cs @@ -76,11 +76,7 @@ namespace ICSharpCode.NRefactory.CSharp { Modifiers m = 0; foreach (CSharpModifierToken t in node.GetChildrenByRole (ModifierRole)) { - if (t.Modifier == Modifiers.Internal && m.HasFlag (Modifiers.Protected)) { - m = (m & ~Modifiers.Protected) | Modifiers.ProtectedAndInternal; - } else { - m |= t.Modifier; - } + m |= t.Modifier; } return m; } @@ -93,38 +89,17 @@ namespace ICSharpCode.NRefactory.CSharp if ((m & newValue) != 0) { if ((m & oldValue) == 0) { // Modifier was added - if (m == Modifiers.ProtectedAndInternal) { - // This modifier is a special case - it consists out of 2 tokens. - // note that protected or internal is handled by the ordering of the AllModifiers array. - var newToken = new CSharpModifierToken(TextLocation.Empty, Modifiers.Protected); - node.InsertChildAfter(insertionPos, newToken, ModifierRole); - insertionPos = newToken; - - newToken = new CSharpModifierToken(TextLocation.Empty, Modifiers.Internal); - node.InsertChildAfter(insertionPos, newToken, ModifierRole); - insertionPos = newToken; - } else { - var newToken = new CSharpModifierToken(TextLocation.Empty, m); - node.InsertChildAfter(insertionPos, newToken, ModifierRole); - insertionPos = newToken; - } + var newToken = new CSharpModifierToken(TextLocation.Empty, m); + node.InsertChildAfter(insertionPos, newToken, ModifierRole); + insertionPos = newToken; } else { // Modifier already exists - if (m == Modifiers.ProtectedAndInternal) { - insertionPos = node.GetChildrenByRole(ModifierRole).First(t => t.Modifier == Modifiers.Internal); - } else { - insertionPos = node.GetChildrenByRole(ModifierRole).First(t => t.Modifier == m); - } + insertionPos = node.GetChildrenByRole(ModifierRole).First(t => t.Modifier == m); } } else { if ((m & oldValue) != 0) { // Modifier was removed - if (m == Modifiers.ProtectedAndInternal) { - node.GetChildrenByRole (ModifierRole).First(t => t.Modifier == Modifiers.Protected).Remove(); - node.GetChildrenByRole (ModifierRole).First(t => t.Modifier == Modifiers.Internal).Remove(); - } else { - node.GetChildrenByRole (ModifierRole).First(t => t.Modifier == m).Remove(); - } + node.GetChildrenByRole (ModifierRole).First(t => t.Modifier == m).Remove(); } } } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs b/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs index ca48ead9bb..2ac9f86e4f 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs @@ -1093,22 +1093,14 @@ namespace ICSharpCode.NRefactory.CSharp { if (location == null || location.Modifiers == null) return; - Modifiers entityModifierMask = Modifiers.None; foreach (var modifier in location.Modifiers) { ICSharpCode.NRefactory.CSharp.Modifiers mod; if (!modifierTable.TryGetValue (modifier.Item1, out mod)) { Console.WriteLine ("modifier " + modifier.Item1 + " can't be converted,"); } - - if (mod == Modifiers.Internal && entityModifierMask.HasFlag (Modifiers.Protected)) { - entityModifierMask = (entityModifierMask & ~Modifiers.Protected) | Modifiers.ProtectedAndInternal; - } else { - entityModifierMask |= mod; - } parent.AddChild (new CSharpModifierToken (Convert (modifier.Item2), mod), EntityDeclaration.ModifierRole); } - parent.Modifiers |= entityModifierMask; } public override void Visit (Property p) diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/TypeSystemAstBuilder.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/TypeSystemAstBuilder.cs index a4c1bd4a27..12faf6e8ab 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/TypeSystemAstBuilder.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/TypeSystemAstBuilder.cs @@ -753,9 +753,8 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring case Accessibility.Internal: return Modifiers.Internal; case Accessibility.ProtectedOrInternal: - return Modifiers.ProtectedOrInternal; case Accessibility.ProtectedAndInternal: - return Modifiers.ProtectedAndInternal; + return Modifiers.Protected | Modifiers.Internal; default: return Modifiers.None; } diff --git a/ICSharpCode.NRefactory.CSharp/TypeSystem/TypeSystemConvertVisitor.cs b/ICSharpCode.NRefactory.CSharp/TypeSystem/TypeSystemConvertVisitor.cs index 81e8377d21..cfc9e421f3 100644 --- a/ICSharpCode.NRefactory.CSharp/TypeSystem/TypeSystemConvertVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/TypeSystem/TypeSystemConvertVisitor.cs @@ -829,12 +829,10 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem switch (modifiers & Modifiers.VisibilityMask) { case Modifiers.Private: return Accessibility.Private; - case Modifiers.ProtectedOrInternal: // Modifiers.Protected | Modifiers.Internal - return Accessibility.ProtectedOrInternal; - case Modifiers.ProtectedAndInternal: - return Accessibility.ProtectedAndInternal; case Modifiers.Internal: return Accessibility.Internal; + case Modifiers.Protected | Modifiers.Internal: + return Accessibility.ProtectedOrInternal; case Modifiers.Protected: return Accessibility.Protected; case Modifiers.Public: diff --git a/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/DeclareLocalVariableTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/DeclareLocalVariableTests.cs index e93b5f2395..5247afcf9d 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/DeclareLocalVariableTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/DeclareLocalVariableTests.cs @@ -206,7 +206,7 @@ namespace ICSharpCode.NRefactory.CSharp.CodeActions void DoStuff() { System.Func getInt = GetInt; - if (getInt() == 0) { + if (getInt () == 0) { } } diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/FieldDeclarationTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/FieldDeclarationTests.cs index 513e4dcb69..ab851606ab 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/FieldDeclarationTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/FieldDeclarationTests.cs @@ -30,9 +30,9 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers ParseUtilCSharp.AssertTypeMember( "int[,,,] myField;", new FieldDeclaration { - ReturnType = new PrimitiveType("int").MakeArrayType(4), - Variables = { new VariableInitializer("myField") } - }); + ReturnType = new PrimitiveType("int").MakeArrayType(4), + Variables = { new VariableInitializer("myField") } + }); } [Test] @@ -77,8 +77,8 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers ParseUtilCSharp.AssertTypeMember( "public unsafe fixed int Field[100];", new FixedFieldDeclaration() { - Modifiers = Modifiers.Public | Modifiers.Unsafe, - ReturnType = new PrimitiveType("int"), + Modifiers = Modifiers.Public | Modifiers.Unsafe, + ReturnType = new PrimitiveType("int"), Variables = { new FixedVariableInitializer { Name = "Field", @@ -87,31 +87,5 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers } }); } - - [Test] - public void InternalAndProtectedFieldTest() - { - ParseUtilCSharp.AssertTypeMember( - "protected internal int myField;", - new FieldDeclaration { - Modifiers = Modifiers.ProtectedAndInternal, - ReturnType = new PrimitiveType("int"), - Variables = { new VariableInitializer("myField") } - } - ); - } - - [Test] - public void InternalOrProtectedFieldTest() - { - ParseUtilCSharp.AssertTypeMember( - "internal protected int myField;", - new FieldDeclaration { - Modifiers = Modifiers.ProtectedOrInternal, - ReturnType = new PrimitiveType("int"), - Variables = { new VariableInitializer("myField") } - } - ); - } } }