From 3d04de009845ed4093ddfa154158b260eebda86b Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Thu, 27 May 2010 13:51:08 +0000 Subject: [PATCH] Fixed C# parser when casting the result of a default-expression "(int)default(short)". Code cleanup in OptionPanel. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5856 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/Lexer/CSharp/Tokens.cs | 4 ++-- .../Src/Gui/Dialogs/AbstractOptionPanel.cs | 16 +++++----------- .../Base/Project/Src/Util/ExtensionMethods.cs | 9 +++++---- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Tokens.cs b/src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Tokens.cs index e5f855f495..0ae3a3482b 100644 --- a/src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Tokens.cs +++ b/src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Tokens.cs @@ -172,7 +172,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp public static BitArray TypeKW = NewSet(Char, Bool, Object, String, Sbyte, Byte, Short, Ushort, Int, Uint, Long, Ulong, Float, Double, Decimal); public static BitArray UnaryHead = NewSet(Plus, Minus, Not, BitwiseComplement, Times, Increment, Decrement, BitwiseAnd); public static BitArray AssnStartOp = NewSet(Plus, Minus, Not, BitwiseComplement, Times); - public static BitArray CastFollower = NewSet(Char, Bool, Object, String, Sbyte, Byte, Short, Ushort, Int, Uint, Long, Ulong, Float, Double, Decimal, Identifier, Partial, Where, Get, Set, Add, Remove, Yield, Select, Group, By, Into, From, Ascending, Descending, Orderby, Let, Join, On, Equals, Void, Literal, OpenParenthesis, BitwiseComplement, Not, Base, Delegate, False, New, Null, Sizeof, This, True, Typeof, Checked, Unchecked, From); + public static BitArray CastFollower = NewSet(Char, Bool, Object, String, Sbyte, Byte, Short, Ushort, Int, Uint, Long, Ulong, Float, Double, Decimal, Identifier, Partial, Where, Get, Set, Add, Remove, Yield, Select, Group, By, Into, From, Ascending, Descending, Orderby, Let, Join, On, Equals, Void, Literal, OpenParenthesis, BitwiseComplement, Not, Base, Delegate, False, New, Null, Sizeof, This, True, Typeof, Checked, Unchecked, From, Default); public static BitArray AssgnOps = NewSet(Assign, PlusAssign, MinusAssign, TimesAssign, DivAssign, ModAssign, BitwiseAndAssign, BitwiseOrAssign, ShiftLeftAssign); public static BitArray UnaryOp = NewSet(Plus, Minus, Not, BitwiseComplement, Times, Increment, Decrement, BitwiseAnd); public static BitArray TypeDeclarationKW = NewSet(Class, Interface, Struct, Enum, Delegate); @@ -187,7 +187,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp public static BitArray ExpressionContent = NewSet(As, Is, Out, Ref, In); public static BitArray InterfaceLevel = NewSet(Event); public static BitArray TypeLevel = NewSet(Public, Internal, Class, Interface, Struct, Enum, Delegate, Abstract, Sealed, Static, Unsafe, Partial, Protected, Private, Public, Internal, Const, Event, Explicit, Extern, Fixed, Implicit, New, Operator, Override, Readonly, Virtual, Volatile); - public static BitArray StatementStart = NewSet(Base, Delegate, False, New, Null, Sizeof, This, True, Typeof, Checked, Unchecked, From, As, Is, Out, Ref, In, Break, Case, Catch, Checked, Unchecked, Const, Continue, Default, Do, Else, Finally, Fixed, For, Foreach, Goto, If, Lock, Return, Stackalloc, Switch, Throw, Try, Unsafe, Using, While, Yield); + public static BitArray StatementStart = NewSet(Base, Delegate, False, New, Null, Sizeof, This, True, Typeof, Checked, Unchecked, From, Default, As, Is, Out, Ref, In, Break, Case, Catch, Checked, Unchecked, Const, Continue, Default, Do, Else, Finally, Fixed, For, Foreach, Goto, If, Lock, Return, Stackalloc, Switch, Throw, Try, Unsafe, Using, While, Yield); public static BitArray QueryExpressionClauseStart = NewSet(From, Let, Where, Join, Orderby, Group, Select); public static BitArray InPropertyDeclaration = NewSet(Protected, Private, Public, Internal, Get, Set); public static BitArray InEventDeclaration = NewSet(Add, Remove); diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs b/src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs index c0018cf33b..95789a1549 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs @@ -29,12 +29,11 @@ namespace ICSharpCode.SharpDevelop.Gui public virtual object Owner { get; set; } - IList bindings = new List(); + readonly List bindings = new List(); - public IList Bindings { - get { - return bindings; - } + void IOptionBindingContainer.AddBinding(OptionBinding binding) + { + this.bindings.Add(binding); } public virtual object Control { @@ -49,17 +48,12 @@ namespace ICSharpCode.SharpDevelop.Gui public virtual bool SaveOptions() { - foreach (OptionBinding b in Bindings) { + foreach (OptionBinding b in bindings) { if (!b.Save()) return false; } return true; } - - public void AddBinding(OptionBinding binding) - { - this.bindings.Add(binding); - } } } diff --git a/src/Main/Base/Project/Src/Util/ExtensionMethods.cs b/src/Main/Base/Project/Src/Util/ExtensionMethods.cs index b937a32e78..0eb1a3d3ee 100644 --- a/src/Main/Base/Project/Src/Util/ExtensionMethods.cs +++ b/src/Main/Base/Project/Src/Util/ExtensionMethods.cs @@ -406,12 +406,13 @@ namespace ICSharpCode.SharpDevelop } /// - /// Returns the index of the first element for which constraint returns true. - /// If none of the items in the list fits the constraint -1 is returned. + /// Returns the index of the first element for which returns true. + /// If none of the items in the list fits the , -1 is returned. /// - public static int FindIndex(this IList list, Func constraint) { + public static int FindIndex(this IList list, Func predicate) + { for (int i = 0; i < list.Count; i++) { - if (constraint(list[i])) + if (predicate(list[i])) return i; }