Browse Source

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
pull/1/head
Daniel Grunwald 15 years ago
parent
commit
3d04de0098
  1. 4
      src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Tokens.cs
  2. 16
      src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs
  3. 9
      src/Main/Base/Project/Src/Util/ExtensionMethods.cs

4
src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Tokens.cs

@ -172,7 +172,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -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 @@ -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);

16
src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs

@ -29,12 +29,11 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -29,12 +29,11 @@ namespace ICSharpCode.SharpDevelop.Gui
public virtual object Owner { get; set; }
IList<OptionBinding> bindings = new List<OptionBinding>();
readonly List<OptionBinding> bindings = new List<OptionBinding>();
public IList<OptionBinding> 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 @@ -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);
}
}
}

9
src/Main/Base/Project/Src/Util/ExtensionMethods.cs

@ -406,12 +406,13 @@ namespace ICSharpCode.SharpDevelop @@ -406,12 +406,13 @@ namespace ICSharpCode.SharpDevelop
}
/// <summary>
/// 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 <paramref name="predicate"/> returns true.
/// If none of the items in the list fits the <paramref name="predicate"/>, -1 is returned.
/// </summary>
public static int FindIndex<T>(this IList<T> list, Func<T, bool> constraint) {
public static int FindIndex<T>(this IList<T> list, Func<T, bool> predicate)
{
for (int i = 0; i < list.Count; i++) {
if (constraint(list[i]))
if (predicate(list[i]))
return i;
}

Loading…
Cancel
Save