Browse Source

Fix SD-1866: support for async/await in code completion.

pull/20/merge
Daniel Grunwald 14 years ago
parent
commit
0ec28b887d
  1. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/CSharp-Mode.xshd
  2. 2
      src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs
  3. 6
      src/Libraries/NRefactory/Project/Src/Ast/Enums.cs
  4. 45
      src/Libraries/NRefactory/Project/Src/Ast/Generated.cs
  5. 2
      src/Libraries/NRefactory/Project/Src/IAstVisitor.cs
  6. 8
      src/Libraries/NRefactory/Project/Src/Lexer/CSharp/KeywordList.txt
  7. 7
      src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Keywords.cs
  8. 23
      src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Tokens.cs
  9. 3
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Keywords.cs
  10. 3
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Tokens.cs
  11. 2876
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs
  12. 26
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG
  13. 4
      src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs
  14. 4
      src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs
  15. 2
      src/Libraries/NRefactory/Project/Src/Visitors/AbstractASTVisitor.cs
  16. 2
      src/Libraries/NRefactory/Project/Src/Visitors/AbstractAstTransformer.cs
  17. 2
      src/Libraries/NRefactory/Project/Src/Visitors/NodeTrackingAstVisitor.cs
  18. 2
      src/Libraries/NRefactory/Project/Src/Visitors/NotImplementedAstVisitor.cs
  19. 17
      src/Libraries/NRefactory/Test/Lexer/CSharp/LexerTests.cs
  20. 3
      src/Libraries/NRefactory/Test/Lexer/VBNet/LexerTests.cs
  21. 7
      src/Libraries/NRefactory/Test/Parser/Expressions/AnonymousMethodTests.cs
  22. 7
      src/Libraries/NRefactory/Test/Parser/Expressions/IdentifierExpressionTests.cs
  23. 21
      src/Libraries/NRefactory/Test/Parser/Expressions/LambdaExpressionTests.cs
  24. 16
      src/Libraries/NRefactory/Test/Parser/Expressions/UnaryOperatorExpressionTests.cs
  25. 41
      src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs
  26. 7
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/ResolveVisitor.cs

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/CSharp-Mode.xshd

@ -169,6 +169,7 @@
<Word>equals</Word> <Word>equals</Word>
<Word>var</Word> <Word>var</Word>
<Word>dynamic</Word> <Word>dynamic</Word>
<Word>await</Word>
</Keywords> </Keywords>
<Keywords color="ExceptionKeywords"> <Keywords color="ExceptionKeywords">
@ -238,6 +239,7 @@
<Word>static</Word> <Word>static</Word>
<Word>virtual</Word> <Word>virtual</Word>
<Word>volatile</Word> <Word>volatile</Word>
<Word>async</Word>
</Keywords> </Keywords>
<Keywords color="Visibility"> <Keywords color="Visibility">

2
src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs

@ -175,6 +175,7 @@ namespace NRefactoryASTGenerator.Ast
List<ParameterDeclarationExpression> parameters; List<ParameterDeclarationExpression> parameters;
BlockStatement body; BlockStatement body;
bool hasParameterList; bool hasParameterList;
bool isAsync;
} }
[IncludeMember("public Location ExtendedEndLocation { get; set; }")] [IncludeMember("public Location ExtendedEndLocation { get; set; }")]
@ -183,6 +184,7 @@ namespace NRefactoryASTGenerator.Ast
Statement statementBody; Statement statementBody;
Expression expressionBody; Expression expressionBody;
TypeReference returnType; TypeReference returnType;
bool isAsync;
} }
class CheckedExpression : Expression { class CheckedExpression : Expression {

6
src/Libraries/NRefactory/Project/Src/Ast/Enums.cs

@ -47,6 +47,8 @@ namespace ICSharpCode.NRefactory.Ast
/// <summary>Only for VB properties.</summary> /// <summary>Only for VB properties.</summary>
WriteOnly = 0x400000, // VB specific WriteOnly = 0x400000, // VB specific
Async = 0x800000,
Visibility = Private | Public | Protected | Internal, Visibility = Private | Public | Protected | Internal,
Classes = New | Visibility | Abstract | Sealed | Partial | Static, Classes = New | Visibility | Abstract | Sealed | Partial | Static,
VBModules = Visibility, VBModules = Visibility,
@ -250,7 +252,9 @@ namespace ICSharpCode.NRefactory.Ast
/// <summary>Dereferencing pointer</summary> /// <summary>Dereferencing pointer</summary>
Dereference, Dereference,
/// <summary>Get address of</summary> /// <summary>Get address of</summary>
AddressOf AddressOf,
Await
} }
public enum ContinueType public enum ContinueType

45
src/Libraries/NRefactory/Project/Src/Ast/Generated.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.1 // Runtime Version:4.0.30319.235
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@ -88,6 +88,8 @@ namespace ICSharpCode.NRefactory.Ast {
bool hasParameterList; bool hasParameterList;
bool isAsync;
public List<ParameterDeclarationExpression> Parameters { public List<ParameterDeclarationExpression> Parameters {
get { get {
return parameters; return parameters;
@ -116,6 +118,15 @@ namespace ICSharpCode.NRefactory.Ast {
} }
} }
public bool IsAsync {
get {
return isAsync;
}
set {
isAsync = value;
}
}
public AnonymousMethodExpression() { public AnonymousMethodExpression() {
parameters = new List<ParameterDeclarationExpression>(); parameters = new List<ParameterDeclarationExpression>();
body = BlockStatement.Null; body = BlockStatement.Null;
@ -126,7 +137,8 @@ namespace ICSharpCode.NRefactory.Ast {
} }
public override string ToString() { public override string ToString() {
return string.Format("[AnonymousMethodExpression Parameters={0} Body={1} HasParameterList={2}]", GetCollectionString(Parameters), Body, HasParameterList); return string.Format("[AnonymousMethodExpression Parameters={0} Body={1} HasParameterList={2} IsAsync={" +
"3}]", GetCollectionString(Parameters), Body, HasParameterList, IsAsync);
} }
} }
@ -2421,9 +2433,9 @@ namespace ICSharpCode.NRefactory.Ast {
elseIfSections = new List<ElseIfSection>(); elseIfSections = new List<ElseIfSection>();
} }
public bool HasElseStatements { public bool HasElseIfSections {
get { get {
return falseStatement.Count > 0; return elseIfSections.Count > 0;
} }
} }
@ -2436,12 +2448,6 @@ namespace ICSharpCode.NRefactory.Ast {
if (falseStatement != null) falseStatement.Parent = this; if (falseStatement != null) falseStatement.Parent = this;
} }
public bool HasElseIfSections {
get {
return elseIfSections.Count > 0;
}
}
public IfElseStatement(Expression condition, Statement trueStatement) public IfElseStatement(Expression condition, Statement trueStatement)
: this(condition) { : this(condition) {
@ -2449,6 +2455,12 @@ namespace ICSharpCode.NRefactory.Ast {
if (trueStatement != null) trueStatement.Parent = this; if (trueStatement != null) trueStatement.Parent = this;
} }
public bool HasElseStatements {
get {
return falseStatement.Count > 0;
}
}
public override object AcceptVisitor(IAstVisitor visitor, object data) { public override object AcceptVisitor(IAstVisitor visitor, object data) {
return visitor.VisitIfElseStatement(this, data); return visitor.VisitIfElseStatement(this, data);
} }
@ -2617,6 +2629,8 @@ namespace ICSharpCode.NRefactory.Ast {
TypeReference returnType; TypeReference returnType;
bool isAsync;
public List<ParameterDeclarationExpression> Parameters { public List<ParameterDeclarationExpression> Parameters {
get { get {
return parameters; return parameters;
@ -2656,6 +2670,15 @@ namespace ICSharpCode.NRefactory.Ast {
} }
} }
public bool IsAsync {
get {
return isAsync;
}
set {
isAsync = value;
}
}
public LambdaExpression() { public LambdaExpression() {
parameters = new List<ParameterDeclarationExpression>(); parameters = new List<ParameterDeclarationExpression>();
statementBody = Statement.Null; statementBody = Statement.Null;
@ -2671,7 +2694,7 @@ public Location ExtendedEndLocation { get; set; }
public override string ToString() { public override string ToString() {
return string.Format("[LambdaExpression Parameters={0} StatementBody={1} ExpressionBody={2} ReturnType=" + return string.Format("[LambdaExpression Parameters={0} StatementBody={1} ExpressionBody={2} ReturnType=" +
"{3}]", GetCollectionString(Parameters), StatementBody, ExpressionBody, ReturnType); "{3} IsAsync={4}]", GetCollectionString(Parameters), StatementBody, ExpressionBody, ReturnType, IsAsync);
} }
} }

2
src/Libraries/NRefactory/Project/Src/IAstVisitor.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.1 // Runtime Version:4.0.30319.235
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.

8
src/Libraries/NRefactory/Project/Src/Lexer/CSharp/KeywordList.txt

@ -174,11 +174,13 @@ LambdaArrow = "=>"
"join" "join"
"on" "on"
"equals" "equals"
"async"
"await"
#Sets #Sets
# When changing IdentifierTokens, ensure you also change the "Identifier" production in cs.ATG # When changing IdentifierTokens, ensure you also change the "Identifier" production in cs.ATG
IdentifierTokens(Identifier, "partial", "where", "get", "set", "add", "remove", "yield", "select", "group", "by", "into", "from", "ascending", "descending", "orderby", "let", "join", "on", "equals") IdentifierTokens(Identifier, "partial", "where", "get", "set", "add", "remove", "yield", "select", "group", "by", "into", "from", "ascending", "descending", "orderby", "let", "join", "on", "equals", "async", "await")
OverloadableUnaryOp("-", "!", "~", "++", "--", "true", "false") OverloadableUnaryOp("-", "!", "~", "++", "--", "true", "false")
OverloadableBinaryOp("+", "-", "*", "/", "%", "&", "|", "^", "<<", "==", "!=", ">", "<", ">=", "<=") OverloadableBinaryOp("+", "-", "*", "/", "%", "&", "|", "^", "<<", "==", "!=", ">", "<", ">=", "<=")
@ -201,11 +203,11 @@ KCCTypeDeclarationStart("public", "internal", @TypeDeclarationKW, @KCCClassModif
KCCMemberVisibilityModifiers("protected", "private", "public", "internal") KCCMemberVisibilityModifiers("protected", "private", "public", "internal")
SimpleTypeName(@TypeKW, @IdentifierTokens, "void") SimpleTypeName(@TypeKW, @IdentifierTokens, "void")
GlobalLevel("namespace", "using", "extern", @KCCTypeDeclarationStart) GlobalLevel("namespace", "using", "extern", @KCCTypeDeclarationStart)
ExpressionStart("base", "delegate", "false", "new", "null", "sizeof", "this", "true", "typeof", "checked", "unchecked", "from", "default") ExpressionStart("base", "delegate", "false", "new", "null", "sizeof", "this", "true", "typeof", "checked", "unchecked", "from", "default", "await")
ExpressionContent("as", "is", "out", "ref", "in") ExpressionContent("as", "is", "out", "ref", "in")
# interfaces cannot have inner classes etc., the only keyword (expect for type names) that may appear in them is "event" # interfaces cannot have inner classes etc., the only keyword (expect for type names) that may appear in them is "event"
InterfaceLevel("event") InterfaceLevel("event")
TypeLevel(@KCCTypeDeclarationStart, @KCCMemberVisibilityModifiers, "const", "event", "explicit", "extern", "fixed", "implicit", "new", "operator", "override", "readonly", "virtual", "volatile") TypeLevel(@KCCTypeDeclarationStart, @KCCMemberVisibilityModifiers, "const", "event", "explicit", "extern", "fixed", "implicit", "new", "operator", "override", "readonly", "virtual", "volatile", "async")
StatementStart(@ExpressionStart, @ExpressionContent, "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") StatementStart(@ExpressionStart, @ExpressionContent, "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")
QueryExpressionClauseStart("from", "let", "where", "join", "orderby", "group", "select") QueryExpressionClauseStart("from", "let", "where", "join", "orderby", "group", "select")
InPropertyDeclaration(@KCCMemberVisibilityModifiers, "get", "set") InPropertyDeclaration(@KCCMemberVisibilityModifiers, "get", "set")

7
src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Keywords.cs

@ -1,6 +1,3 @@
// 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)
// this file was autogenerated by a tool. // this file was autogenerated by a tool.
using System; using System;
@ -104,7 +101,9 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
"let", "let",
"join", "join",
"on", "on",
"equals" "equals",
"async",
"await"
}; };
static LookupTable keywords = new LookupTable(true); static LookupTable keywords = new LookupTable(true);

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

@ -1,6 +1,3 @@
// 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)
// this file was autogenerated by a tool. // this file was autogenerated by a tool.
using System; using System;
using System.Collections; using System.Collections;
@ -159,8 +156,10 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
public const int Join = 142; public const int Join = 142;
public const int On = 143; public const int On = 143;
new public const int Equals = 144; new public const int Equals = 144;
public const int Async = 145;
public const int Await = 146;
public const int MaxToken = 145; public const int MaxToken = 147;
static BitArray NewSet(params int[] values) static BitArray NewSet(params int[] values)
{ {
BitArray bitArray = new BitArray(MaxToken); BitArray bitArray = new BitArray(MaxToken);
@ -169,28 +168,28 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
} }
return bitArray; return bitArray;
} }
public static BitArray IdentifierTokens = NewSet(Identifier, Partial, Where, Get, Set, Add, Remove, Yield, Select, Group, By, Into, From, Ascending, Descending, Orderby, Let, Join, On, Equals); public static BitArray IdentifierTokens = NewSet(Identifier, Partial, Where, Get, Set, Add, Remove, Yield, Select, Group, By, Into, From, Ascending, Descending, Orderby, Let, Join, On, Equals, Async, Await);
public static BitArray OverloadableUnaryOp = NewSet(Minus, Not, BitwiseComplement, Increment, Decrement, True, False); public static BitArray OverloadableUnaryOp = NewSet(Minus, Not, BitwiseComplement, Increment, Decrement, True, False);
public static BitArray OverloadableBinaryOp = NewSet(Plus, Minus, Times, Div, Mod, BitwiseAnd, BitwiseOr, Xor, ShiftLeft, Equal, NotEqual, GreaterThan, LessThan, GreaterEqual, LessEqual); public static BitArray OverloadableBinaryOp = NewSet(Plus, Minus, Times, Div, Mod, BitwiseAnd, BitwiseOr, Xor, ShiftLeft, Equal, NotEqual, GreaterThan, LessThan, GreaterEqual, LessEqual);
public static BitArray TypeKW = NewSet(Char, Bool, Object, String, Sbyte, Byte, Short, Ushort, Int, Uint, Long, Ulong, Float, Double, Decimal); 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 UnaryHead = NewSet(Plus, Minus, Not, BitwiseComplement, Times, Increment, Decrement, BitwiseAnd);
public static BitArray AssnStartOp = NewSet(Plus, Minus, Not, BitwiseComplement, Times); 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, Default); 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, Async, Await, Void, Literal, OpenParenthesis, BitwiseComplement, Not, Base, Delegate, False, New, Null, Sizeof, This, True, Typeof, Checked, Unchecked, From, Default, Await);
public static BitArray AssgnOps = NewSet(Assign, PlusAssign, MinusAssign, TimesAssign, DivAssign, ModAssign, BitwiseAndAssign, BitwiseOrAssign, ShiftLeftAssign); 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 UnaryOp = NewSet(Plus, Minus, Not, BitwiseComplement, Times, Increment, Decrement, BitwiseAnd);
public static BitArray TypeDeclarationKW = NewSet(Class, Interface, Struct, Enum, Delegate); public static BitArray TypeDeclarationKW = NewSet(Class, Interface, Struct, Enum, Delegate);
public static BitArray GenericFollower = NewSet(OpenParenthesis, CloseParenthesis, CloseSquareBracket, CloseCurlyBrace, Colon, Semicolon, Comma, Dot, Question, Equal, NotEqual); public static BitArray GenericFollower = NewSet(OpenParenthesis, CloseParenthesis, CloseSquareBracket, CloseCurlyBrace, Colon, Semicolon, Comma, Dot, Question, Equal, NotEqual);
public static BitArray ValidInsideTypeName = NewSet(Identifier, Partial, Where, Get, Set, Add, Remove, Yield, Select, Group, By, Into, From, Ascending, Descending, Orderby, Let, Join, On, Equals, Char, Bool, Object, String, Sbyte, Byte, Short, Ushort, Int, Uint, Long, Ulong, Float, Double, Decimal, LessThan, GreaterThan, Dot, Question, OpenSquareBracket, Comma, CloseSquareBracket, Times, DoubleColon); public static BitArray ValidInsideTypeName = NewSet(Identifier, Partial, Where, Get, Set, Add, Remove, Yield, Select, Group, By, Into, From, Ascending, Descending, Orderby, Let, Join, On, Equals, Async, Await, Char, Bool, Object, String, Sbyte, Byte, Short, Ushort, Int, Uint, Long, Ulong, Float, Double, Decimal, LessThan, GreaterThan, Dot, Question, OpenSquareBracket, Comma, CloseSquareBracket, Times, DoubleColon);
public static BitArray KCCClassModifiers = NewSet(Abstract, Sealed, Static, Unsafe, Partial); public static BitArray KCCClassModifiers = NewSet(Abstract, Sealed, Static, Unsafe, Partial);
public static BitArray KCCTypeDeclarationStart = NewSet(Public, Internal, Class, Interface, Struct, Enum, Delegate, Abstract, Sealed, Static, Unsafe, Partial); public static BitArray KCCTypeDeclarationStart = NewSet(Public, Internal, Class, Interface, Struct, Enum, Delegate, Abstract, Sealed, Static, Unsafe, Partial);
public static BitArray KCCMemberVisibilityModifiers = NewSet(Protected, Private, Public, Internal); public static BitArray KCCMemberVisibilityModifiers = NewSet(Protected, Private, Public, Internal);
public static BitArray SimpleTypeName = 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); public static BitArray SimpleTypeName = 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, Async, Await, Void);
public static BitArray GlobalLevel = NewSet(Namespace, Using, Extern, Public, Internal, Class, Interface, Struct, Enum, Delegate, Abstract, Sealed, Static, Unsafe, Partial); public static BitArray GlobalLevel = NewSet(Namespace, Using, Extern, Public, Internal, Class, Interface, Struct, Enum, Delegate, Abstract, Sealed, Static, Unsafe, Partial);
public static BitArray ExpressionStart = NewSet(Base, Delegate, False, New, Null, Sizeof, This, True, Typeof, Checked, Unchecked, From, Default); public static BitArray ExpressionStart = NewSet(Base, Delegate, False, New, Null, Sizeof, This, True, Typeof, Checked, Unchecked, From, Default, Await);
public static BitArray ExpressionContent = NewSet(As, Is, Out, Ref, In); public static BitArray ExpressionContent = NewSet(As, Is, Out, Ref, In);
public static BitArray InterfaceLevel = NewSet(Event); 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 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, Async);
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 StatementStart = NewSet(Base, Delegate, False, New, Null, Sizeof, This, True, Typeof, Checked, Unchecked, From, Default, Await, 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 QueryExpressionClauseStart = NewSet(From, Let, Where, Join, Orderby, Group, Select);
public static BitArray InPropertyDeclaration = NewSet(Protected, Private, Public, Internal, Get, Set); public static BitArray InPropertyDeclaration = NewSet(Protected, Private, Public, Internal, Get, Set);
public static BitArray InEventDeclaration = NewSet(Add, Remove); public static BitArray InEventDeclaration = NewSet(Add, Remove);
@ -344,6 +343,8 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
"join", "join",
"on", "on",
"equals", "equals",
"async",
"await",
}; };
public static string GetTokenString(int token) public static string GetTokenString(int token)
{ {

3
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Keywords.cs

@ -1,6 +1,3 @@
// 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)
// this file was autogenerated by a tool. // this file was autogenerated by a tool.
using System; using System;

3
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Tokens.cs

@ -1,6 +1,3 @@
// 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)
// this file was autogenerated by a tool. // this file was autogenerated by a tool.
using System; using System;
using System.Collections; using System.Collections;

2876
src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs

File diff suppressed because it is too large Load Diff

26
src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG

@ -166,6 +166,8 @@ TOKENS
"join" "join"
"on" "on"
"equals" "equals"
"async"
"await"
/* END AUTOGENERATED TOKENS SECTION */ /* END AUTOGENERATED TOKENS SECTION */
/*------------------------------------------------------------------------* /*------------------------------------------------------------------------*
@ -744,6 +746,7 @@ MemberModifiers<ModifierList m>
| "virtual" (. m.Add(Modifiers.Virtual, t.Location); .) | "virtual" (. m.Add(Modifiers.Virtual, t.Location); .)
| "volatile" (. m.Add(Modifiers.Volatile, t.Location); .) | "volatile" (. m.Add(Modifiers.Volatile, t.Location); .)
| "partial" (. m.Add(Modifiers.Partial, t.Location); .) | "partial" (. m.Add(Modifiers.Partial, t.Location); .)
| "async" (. m.Add(Modifiers.Async, t.Location); .)
} }
. .
@ -1847,6 +1850,7 @@ UnaryExpr<out Expression uExpr>
| "++" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Increment) { StartLocation = t.Location }); .) | "++" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Increment) { StartLocation = t.Location }); .)
| "--" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Decrement) { StartLocation = t.Location }); .) | "--" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Decrement) { StartLocation = t.Location }); .)
| "&" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.AddressOf) { StartLocation = t.Location }); .) | "&" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.AddressOf) { StartLocation = t.Location }); .)
| "await" (. expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Await) { StartLocation = t.Location }); .)
/*--- cast expression: */ /*--- cast expression: */
/* Problem: "(" Type ")" from here and * /* Problem: "(" Type ")" from here and *
@ -1908,6 +1912,22 @@ PrimaryExpr<out Expression pexpr>
"::" (. pexpr = new TypeReferenceExpression(type); .) "::" (. pexpr = new TypeReferenceExpression(type); .)
Identifier (. if (type.Type == "global") { type.IsGlobal = true; type.Type = t.val ?? "?"; } else type.Type += "." + (t.val ?? "?"); .) Identifier (. if (type.Type == "global") { type.IsGlobal = true; type.Type = t.val ?? "?"; } else type.Type += "." + (t.val ?? "?"); .)
| "delegate" AnonymousMethodExpr<out expr> (. pexpr = expr; .)
| IF (la.kind == Tokens.Async && Peek(1).kind == Tokens.Delegate)
"async" "delegate" AnonymousMethodExpr<out expr> (. pexpr = expr; .)
(. ((AnonymousMethodExpression)expr).IsAsync = true; .)
| IF (la.kind == Tokens.Async && Peek(1).kind == Tokens.OpenParenthesis)
"async"
LambdaExpression<out pexpr>
(. ((LambdaExpression)pexpr).IsAsync = true; .)
| IF (la.kind == Tokens.Async && IsIdentifierToken(Peek(1)))
"async"
Identifier (. pexpr = new IdentifierExpression(t.val); .)
ShortedLambdaExpression<(IdentifierExpression)pexpr, out pexpr>
(. ((LambdaExpression)pexpr).IsAsync = true; .)
/*--- simple name (IdentifierExpression): */ /*--- simple name (IdentifierExpression): */
| Identifier | Identifier
(. pexpr = new IdentifierExpression(t.val); .) (. pexpr = new IdentifierExpression(t.val); .)
@ -1918,9 +1938,10 @@ PrimaryExpr<out Expression pexpr>
TypeArgumentList<out typeList, false> TypeArgumentList<out typeList, false>
(. ((IdentifierExpression)pexpr).TypeArguments = typeList; .) (. ((IdentifierExpression)pexpr).TypeArguments = typeList; .)
] ]
| IF (IsLambdaExpression()) /* Lambda expression */ | IF (IsLambdaExpression()) /* Lambda expression */
LambdaExpression<out pexpr> LambdaExpression<out pexpr>
/*--- parenthesized expression: */ /*--- parenthesized expression: */
| "(" Expr<out expr> ")" (. pexpr = new ParenthesizedExpression(expr); .) | "(" Expr<out expr> ")" (. pexpr = new ParenthesizedExpression(expr); .)
@ -1964,7 +1985,6 @@ PrimaryExpr<out Expression pexpr>
| "sizeof" "(" Type<out type> ")" (. pexpr = new SizeOfExpression(type); .) | "sizeof" "(" Type<out type> ")" (. pexpr = new SizeOfExpression(type); .)
| "checked" "(" Expr<out expr> ")" (. pexpr = new CheckedExpression(expr); .) | "checked" "(" Expr<out expr> ")" (. pexpr = new CheckedExpression(expr); .)
| "unchecked" "(" Expr<out expr> ")" (. pexpr = new UncheckedExpression(expr); .) | "unchecked" "(" Expr<out expr> ")" (. pexpr = new UncheckedExpression(expr); .)
| "delegate" AnonymousMethodExpr<out expr> (. pexpr = expr; .)
) )
(. if (pexpr != null) { (. if (pexpr != null) {
if (pexpr.StartLocation.IsEmpty) if (pexpr.StartLocation.IsEmpty)
@ -2616,6 +2636,8 @@ Identifier
| "join" | "join"
| "on" | "on"
| "equals" | "equals"
| "async"
| "await"
. .

4
src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs

@ -2458,6 +2458,10 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
case UnaryOperatorType.AddressOf: case UnaryOperatorType.AddressOf:
outputFormatter.PrintToken(Tokens.BitwiseAnd); outputFormatter.PrintToken(Tokens.BitwiseAnd);
break; break;
case UnaryOperatorType.Await:
outputFormatter.PrintToken(Tokens.Await);
outputFormatter.Space();
break;
default: default:
Error(unaryOperatorExpression, String.Format("Unknown unary operator {0}", unaryOperatorExpression.Op)); Error(unaryOperatorExpression, String.Format("Unknown unary operator {0}", unaryOperatorExpression.Op));
return null; return null;

4
src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs

@ -2370,6 +2370,10 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintToken(Tokens.AddressOf); outputFormatter.PrintToken(Tokens.AddressOf);
TrackedVisit(unaryOperatorExpression.Expression, data); TrackedVisit(unaryOperatorExpression.Expression, data);
return null; return null;
case UnaryOperatorType.Await:
outputFormatter.PrintText("Await ");
TrackedVisit(unaryOperatorExpression.Expression, data);
return null;
default: default:
Error("unknown unary operator: " + unaryOperatorExpression.Op.ToString(), unaryOperatorExpression.StartLocation); Error("unknown unary operator: " + unaryOperatorExpression.Op.ToString(), unaryOperatorExpression.StartLocation);
outputFormatter.PrintText(unaryOperatorExpression.Op.ToString()); outputFormatter.PrintText(unaryOperatorExpression.Op.ToString());

2
src/Libraries/NRefactory/Project/Src/Visitors/AbstractASTVisitor.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.1 // Runtime Version:4.0.30319.235
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.

2
src/Libraries/NRefactory/Project/Src/Visitors/AbstractAstTransformer.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.1 // Runtime Version:4.0.30319.235
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.

2
src/Libraries/NRefactory/Project/Src/Visitors/NodeTrackingAstVisitor.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.1 // Runtime Version:4.0.30319.235
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.

2
src/Libraries/NRefactory/Project/Src/Visitors/NotImplementedAstVisitor.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.1 // Runtime Version:4.0.30319.235
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.

17
src/Libraries/NRefactory/Test/Lexer/CSharp/LexerTests.cs

@ -1,6 +1,3 @@
// 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)
// this file was autogenerated by a tool. // this file was autogenerated by a tool.
using System; using System;
using System.IO; using System.IO;
@ -1012,5 +1009,19 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp
ILexer lexer = GenerateLexer(new StringReader("equals")); ILexer lexer = GenerateLexer(new StringReader("equals"));
Assert.AreEqual(Tokens.Equals, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Equals, lexer.NextToken().Kind);
} }
[Test]
public void TestAsync()
{
ILexer lexer = GenerateLexer(new StringReader("async"));
Assert.AreEqual(Tokens.Async, lexer.NextToken().Kind);
}
[Test]
public void TestAwait()
{
ILexer lexer = GenerateLexer(new StringReader("await"));
Assert.AreEqual(Tokens.Await, lexer.NextToken().Kind);
}
} }
} }

3
src/Libraries/NRefactory/Test/Lexer/VBNet/LexerTests.cs

@ -1,6 +1,3 @@
// 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)
// this file was autogenerated by a tool. // this file was autogenerated by a tool.
using System; using System;
using System.IO; using System.IO;

7
src/Libraries/NRefactory/Test/Parser/Expressions/AnonymousMethodTests.cs

@ -55,5 +55,12 @@ namespace ICSharpCode.NRefactory.Tests.Ast
//Assert.AreEqual(1, ame.Body.Children.Count); //Assert.AreEqual(1, ame.Body.Children.Count);
//Assert.IsTrue(ame.Body.Children[0] is ReturnStatement); //Assert.IsTrue(ame.Body.Children[0] is ReturnStatement);
} }
[Test]
public void AsyncSimpleAnonymousMethod()
{
AnonymousMethodExpression ame = Parse("async delegate { }");
Assert.IsTrue(ame.IsAsync);
}
} }
} }

7
src/Libraries/NRefactory/Test/Parser/Expressions/IdentifierExpressionTests.cs

@ -42,6 +42,13 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual("TargetMethod", ident.Identifier); Assert.AreEqual("TargetMethod", ident.Identifier);
Assert.AreEqual(1, ident.TypeArguments.Count); Assert.AreEqual(1, ident.TypeArguments.Count);
} }
[Test]
public void AsyncIsIdentifier()
{
IdentifierExpression ident = ParseUtilCSharp.ParseExpression<IdentifierExpression>("async");
Assert.AreEqual("async", ident.Identifier);
}
#endregion #endregion
#region VB.NET #region VB.NET

21
src/Libraries/NRefactory/Test/Parser/Expressions/LambdaExpressionTests.cs

@ -88,6 +88,27 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.IsTrue(e.ReturnType.IsNull); Assert.IsTrue(e.ReturnType.IsNull);
} }
[Test]
public void AsyncLambdaWithParentheses()
{
LambdaExpression e = ParseCSharp("async (x) => x + 1");
Assert.IsTrue(e.IsAsync);
Assert.AreEqual("x", e.Parameters[0].ParameterName);
Assert.IsTrue(e.Parameters[0].TypeReference.IsNull);
Assert.IsTrue(e.ExpressionBody is BinaryOperatorExpression);
Assert.IsTrue(e.ReturnType.IsNull);
}
[Test]
public void AsyncLambdaWithoutParentheses()
{
LambdaExpression e = ParseCSharp("async x => x + 1");
Assert.IsTrue(e.IsAsync);
Assert.AreEqual("x", e.Parameters[0].ParameterName);
Assert.IsTrue(e.Parameters[0].TypeReference.IsNull);
Assert.IsTrue(e.ExpressionBody is BinaryOperatorExpression);
Assert.IsTrue(e.ReturnType.IsNull);
}
#endregion #endregion
#region VB.NET #region VB.NET

16
src/Libraries/NRefactory/Test/Parser/Expressions/UnaryOperatorExpressionTests.cs

@ -27,6 +27,12 @@ namespace ICSharpCode.NRefactory.Tests.Ast
CSharpTestUnaryOperatorExpressionTest("!a", UnaryOperatorType.Not); CSharpTestUnaryOperatorExpressionTest("!a", UnaryOperatorType.Not);
} }
[Test]
public void CSharpAwaitTest()
{
CSharpTestUnaryOperatorExpressionTest("await a", UnaryOperatorType.Await);
}
[Test] [Test]
public void CSharpBitNotTest() public void CSharpBitNotTest()
{ {
@ -93,6 +99,16 @@ namespace ICSharpCode.NRefactory.Tests.Ast
UnaryOperatorExpression adrOf = (UnaryOperatorExpression)ce.Expression; UnaryOperatorExpression adrOf = (UnaryOperatorExpression)ce.Expression;
Assert.AreEqual(UnaryOperatorType.AddressOf, adrOf.Op); Assert.AreEqual(UnaryOperatorType.AddressOf, adrOf.Op);
} }
[Test]
public void NestedAwait()
{
var uoe = ParseUtilCSharp.ParseExpression<UnaryOperatorExpression>("await await a");
Assert.AreEqual(UnaryOperatorType.Await, uoe.Op);
var nested = (UnaryOperatorExpression)uoe.Expression;
Assert.AreEqual(UnaryOperatorType.Await, nested.Op);
Assert.IsTrue(nested.Expression is IdentifierExpression);
}
#endregion #endregion
#region VB.NET #region VB.NET

41
src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs

@ -20,6 +20,47 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.IsFalse(md.IsExtensionMethod); Assert.IsFalse(md.IsExtensionMethod);
} }
[Test]
public void CSharpAsyncMethodDeclarationTest()
{
MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("async void MyMethod() {} ");
Assert.AreEqual("System.Void", md.TypeReference.Type);
Assert.AreEqual(0, md.Parameters.Count);
Assert.AreEqual(Modifiers.Async, md.Modifier);
}
[Test, Ignore("doesn't work")]
public void AsyncAsyncAsync()
{
MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("async async async(async async) { }");
Assert.AreEqual("async", md.TypeReference.Type);
Assert.AreEqual(Modifiers.Async, md.Modifier);
Assert.AreEqual("async", md.Name);
Assert.AreEqual("async", md.Parameters[0].TypeReference.Type);
Assert.AreEqual("async", md.Parameters[0].ParameterName);
}
[Test]
public void AsyncVoidAsync()
{
MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("async void async(async async) { }");
Assert.AreEqual("System.Void", md.TypeReference.Type);
Assert.AreEqual(Modifiers.Async, md.Modifier);
Assert.AreEqual("async", md.Name);
Assert.AreEqual("async", md.Parameters[0].TypeReference.Type);
Assert.AreEqual("async", md.Parameters[0].ParameterName);
}
[Test]
public void BoolAsyncParameter()
{
MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("void Work(bool async) { }");
Assert.AreEqual(Modifiers.None, md.Modifier);
Assert.AreEqual("Work", md.Name);
Assert.AreEqual("System.Boolean", md.Parameters[0].TypeReference.Type);
Assert.AreEqual("async", md.Parameters[0].ParameterName);
}
[Test] [Test]
public void CSharpAbstractMethodDeclarationTest() public void CSharpAbstractMethodDeclarationTest()
{ {

7
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/ResolveVisitor.cs

@ -691,6 +691,13 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
} else { } else {
return null; return null;
} }
case UnaryOperatorType.Await:
var crt = type.CastToConstructedReturnType();
if (crt != null && crt.Name == "Task" && crt.TypeArguments.Count == 1) {
return CreateResolveResult(crt.TypeArguments[0]);
} else {
return null;
}
default: default:
return CreateResolveResult(type); return CreateResolveResult(type);
} }

Loading…
Cancel
Save