Browse Source

Added anonymous methods to c# parser.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@155 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
059e7e904f
  1. 6
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/Indentation.cs
  2. 3
      src/Libraries/NRefactory/Project/NRefactory.csproj
  3. 12
      src/Libraries/NRefactory/Project/Src/Output/CSharp/CSharpOutputVisitor.cs
  4. 6
      src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs
  5. 53
      src/Libraries/NRefactory/Project/Src/Parser/AST/CSharp/Expressions/AnonymousMethodExpression.cs
  6. 314
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs
  7. 23
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG
  8. 34
      src/Libraries/NRefactory/Project/Src/Parser/Visitors/AbstractASTVisitor.cs
  9. 1
      src/Libraries/NRefactory/Project/Src/Parser/Visitors/IASTVisitor.cs
  10. 1
      src/Libraries/NRefactory/Test/NRefactoryTests.csproj
  11. 45
      src/Libraries/NRefactory/Test/Parser/Expressions/AnonymousMethodTests.cs
  12. 9
      src/Main/Base/Project/Src/Commands/ClassMemberMenuBuilder.cs
  13. 7
      src/Main/Base/Project/Src/TextEditor/Bookmarks/Bookmark.cs
  14. 1
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs
  15. 72
      src/Main/Base/Test/GenericResolverTests.cs

6
src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/Indentation.cs

@ -93,7 +93,7 @@ namespace CSharpBinding.FormattingStrategy @@ -93,7 +93,7 @@ namespace CSharpBinding.FormattingStrategy
StringBuilder indent = new StringBuilder();
if (line.Length == 0) {
// Special threatment for empty lines:
// Special treatment for empty lines:
if (blockComment || (inString && verbatim))
return;
indent.Append(block.InnerIndent);
@ -303,7 +303,7 @@ namespace CSharpBinding.FormattingStrategy @@ -303,7 +303,7 @@ namespace CSharpBinding.FormattingStrategy
if (IsSingleStatementKeyword(block.LastWord)) {
block.OneLineBlock = true;
}
} else if (block.LastWord == "else" && lastRealChar == 'e') {
} else if (lastRealChar == 'e' && block.LastWord == "else") {
block.OneLineBlock = true;
block.Continuation = false;
}
@ -369,7 +369,7 @@ namespace CSharpBinding.FormattingStrategy @@ -369,7 +369,7 @@ namespace CSharpBinding.FormattingStrategy
if (!Char.IsWhiteSpace(line[line.Length - 1])) return false;
// one space after an empty comment is allowed
if (line.EndsWith("// "))
if (line.EndsWith("// ") || line.EndsWith("* "))
return false;
doc.Text = line.TrimEnd();

3
src/Libraries/NRefactory/Project/NRefactory.csproj

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.41115</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</ProjectGuid>
<ProjectGuid>{3a9ae6aa-bc07-4a2f-972c-581e3ae2f195}</ProjectGuid>
<RootNamespace>ICSharpCode.NRefactory</RootNamespace>
<AssemblyName>ICSharpCode.NRefactory</AssemblyName>
<OutputTarget>Library</OutputTarget>
@ -183,6 +183,7 @@ @@ -183,6 +183,7 @@
<Compile Include="Src\Parser\Visitors\AbstractASTVisitor.cs" />
<Compile Include="Src\Parser\Visitors\IASTVisitor.cs" />
<Compile Include="Src\Parser\Visitors\LookupTableVisitor.cs" />
<Compile Include="Src\Parser\AST\CSharp\Expressions\AnonymousMethodExpression.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Src\Lexer\CSharp\CSharpKeywordList.txt" />

12
src/Libraries/NRefactory/Project/Src/Output/CSharp/CSharpOutputVisitor.cs

@ -1807,6 +1807,18 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1807,6 +1807,18 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
return null;
}
public object Visit(AnonymousMethodExpression anonymousMethodExpression, object data)
{
outputFormatter.PrintToken(Tokens.Delegate);
outputFormatter.PrintToken(Tokens.OpenParenthesis);
AppendCommaSeparatedList(anonymousMethodExpression.Parameters);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
OutputBlock(anonymousMethodExpression.Body, this.prettyPrintOptions.MethodBraceStyle);
return null;
}
public object Visit(CheckedExpression checkedExpression, object data)
{
outputFormatter.PrintToken(Tokens.Checked);

6
src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs

@ -1976,6 +1976,12 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1976,6 +1976,12 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
return null;
}
public object Visit(AnonymousMethodExpression anonymousMethodExpression, object data)
{
errors.Error(-1, -1, String.Format("AnonymousMethodExpression is unsupported"));
return null;
}
public object Visit(CheckedExpression checkedExpression, object data)
{
errors.Error(-1, -1, String.Format("CheckedExpression is unsupported"));

53
src/Libraries/NRefactory/Project/Src/Parser/AST/CSharp/Expressions/AnonymousMethodExpression.cs

@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
/*
* Created by SharpDevelop.
* User: Daniel Grunwald
* Date: 21.05.2005
* Time: 21:44
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections;
using System.Diagnostics;
namespace ICSharpCode.NRefactory.Parser.AST
{
public class AnonymousMethodExpression : Expression
{
ArrayList parameters = new ArrayList(4);
public ArrayList Parameters {
get {
return parameters;
}
set {
Debug.Assert(value != null);
parameters = value;
}
}
BlockStatement body = BlockStatement.Null;
public BlockStatement Body {
get {
return body;
}
set {
body = BlockStatement.CheckNull(value);
}
}
public override object AcceptVisitor(IASTVisitor visitor, object data)
{
return visitor.Visit(this, data);
}
public override string ToString()
{
return String.Format("[AnonymousMethodExpression: Parameters={0} Body={1}]",
GetCollectionString(Parameters),
Body);
}
}
}

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

@ -1105,39 +1105,39 @@ templates); @@ -1105,39 +1105,39 @@ templates);
}
void TypeParameterList(
#line 2128 "cs.ATG"
#line 2151 "cs.ATG"
List<TemplateDefinition> templates) {
#line 2130 "cs.ATG"
#line 2153 "cs.ATG"
AttributeSection section;
ArrayList attributes = new ArrayList();
Expect(22);
while (la.kind == 17) {
AttributeSection(
#line 2134 "cs.ATG"
#line 2157 "cs.ATG"
out section);
#line 2134 "cs.ATG"
#line 2157 "cs.ATG"
attributes.Add(section);
}
Expect(1);
#line 2135 "cs.ATG"
#line 2158 "cs.ATG"
templates.Add(new TemplateDefinition(t.val, attributes));
while (la.kind == 13) {
lexer.NextToken();
while (la.kind == 17) {
AttributeSection(
#line 2136 "cs.ATG"
#line 2159 "cs.ATG"
out section);
#line 2136 "cs.ATG"
#line 2159 "cs.ATG"
attributes.Add(section);
}
Expect(1);
#line 2137 "cs.ATG"
#line 2160 "cs.ATG"
templates.Add(new TemplateDefinition(t.val, attributes));
}
Expect(21);
@ -1171,25 +1171,25 @@ out qualident); @@ -1171,25 +1171,25 @@ out qualident);
}
void TypeParameterConstraintsClause(
#line 2141 "cs.ATG"
#line 2164 "cs.ATG"
List<TemplateDefinition> templates) {
#line 2142 "cs.ATG"
#line 2165 "cs.ATG"
string name = ""; TypeReference type;
Expect(1);
#line 2144 "cs.ATG"
#line 2167 "cs.ATG"
if (t.val != "where") Error("where expected");
Expect(1);
#line 2145 "cs.ATG"
#line 2168 "cs.ATG"
name = t.val;
Expect(9);
TypeParameterConstraintsClauseBase(
#line 2147 "cs.ATG"
#line 2170 "cs.ATG"
out type);
#line 2148 "cs.ATG"
#line 2171 "cs.ATG"
TemplateDefinition td = null;
foreach (TemplateDefinition d in templates) {
if (d.Name == name) {
@ -1202,10 +1202,10 @@ out type); @@ -1202,10 +1202,10 @@ out type);
while (la.kind == 13) {
lexer.NextToken();
TypeParameterConstraintsClauseBase(
#line 2157 "cs.ATG"
#line 2180 "cs.ATG"
out type);
#line 2158 "cs.ATG"
#line 2181 "cs.ATG"
td = null;
foreach (TemplateDefinition d in templates) {
if (d.Name == name) {
@ -2581,20 +2581,20 @@ out type); @@ -2581,20 +2581,20 @@ out type);
}
void TypeName(
#line 2110 "cs.ATG"
#line 2133 "cs.ATG"
out string qualident, out List<TypeReference> types) {
#line 2111 "cs.ATG"
#line 2134 "cs.ATG"
List<TypeReference> t; types = new List<TypeReference>();
Qualident(
#line 2113 "cs.ATG"
#line 2136 "cs.ATG"
out qualident);
if (la.kind == 22) {
TypeArgumentList(
#line 2114 "cs.ATG"
#line 2137 "cs.ATG"
out t);
#line 2114 "cs.ATG"
#line 2137 "cs.ATG"
types = t;
}
}
@ -4190,24 +4190,24 @@ out expr); @@ -4190,24 +4190,24 @@ out expr);
}
void ConditionalOrExpr(
#line 1988 "cs.ATG"
#line 2011 "cs.ATG"
ref Expression outExpr) {
#line 1989 "cs.ATG"
#line 2012 "cs.ATG"
Expression expr;
ConditionalAndExpr(
#line 1991 "cs.ATG"
#line 2014 "cs.ATG"
ref outExpr);
while (la.kind == 25) {
lexer.NextToken();
UnaryExpr(
#line 1991 "cs.ATG"
#line 2014 "cs.ATG"
out expr);
ConditionalAndExpr(
#line 1991 "cs.ATG"
#line 2014 "cs.ATG"
ref expr);
#line 1991 "cs.ATG"
#line 2014 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr);
}
}
@ -4631,6 +4631,16 @@ out expr); @@ -4631,6 +4631,16 @@ out expr);
pexpr = new UncheckedExpression(expr);
break;
}
case 62: {
lexer.NextToken();
AnonymousMethodExpr(
#line 1964 "cs.ATG"
out expr);
#line 1964 "cs.ATG"
pexpr = expr;
break;
}
default: SynErr(180); break;
}
while (StartOf(25)) {
@ -4638,353 +4648,395 @@ out expr); @@ -4638,353 +4648,395 @@ out expr);
if (la.kind == 30) {
lexer.NextToken();
#line 1967 "cs.ATG"
#line 1968 "cs.ATG"
pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement);
} else if (la.kind == 31) {
lexer.NextToken();
#line 1968 "cs.ATG"
#line 1969 "cs.ATG"
pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement);
} else SynErr(181);
} else if (la.kind == 46) {
lexer.NextToken();
Expect(1);
#line 1971 "cs.ATG"
#line 1972 "cs.ATG"
pexpr = new PointerReferenceExpression(pexpr, t.val);
} else if (la.kind == 14) {
lexer.NextToken();
Expect(1);
#line 1972 "cs.ATG"
#line 1973 "cs.ATG"
pexpr = new FieldReferenceExpression(pexpr, t.val);
} else if (la.kind == 19) {
lexer.NextToken();
#line 1974 "cs.ATG"
#line 1975 "cs.ATG"
ArrayList parameters = new ArrayList();
if (StartOf(21)) {
Argument(
#line 1975 "cs.ATG"
#line 1976 "cs.ATG"
out expr);
#line 1975 "cs.ATG"
#line 1976 "cs.ATG"
if (expr != null) {parameters.Add(expr);}
while (la.kind == 13) {
lexer.NextToken();
Argument(
#line 1976 "cs.ATG"
#line 1977 "cs.ATG"
out expr);
#line 1976 "cs.ATG"
#line 1977 "cs.ATG"
if (expr != null) {parameters.Add(expr);}
}
}
Expect(20);
#line 1977 "cs.ATG"
#line 1978 "cs.ATG"
pexpr = new InvocationExpression(pexpr, parameters);
} else {
#line 1979 "cs.ATG"
#line 1980 "cs.ATG"
if (isArrayCreation) Error("element access not allow on array creation");
ArrayList indices = new ArrayList();
lexer.NextToken();
Expr(
#line 1982 "cs.ATG"
#line 1983 "cs.ATG"
out expr);
#line 1982 "cs.ATG"
#line 1983 "cs.ATG"
if (expr != null) { indices.Add(expr); }
while (la.kind == 13) {
lexer.NextToken();
Expr(
#line 1983 "cs.ATG"
#line 1984 "cs.ATG"
out expr);
#line 1983 "cs.ATG"
#line 1984 "cs.ATG"
if (expr != null) { indices.Add(expr); }
}
Expect(18);
#line 1984 "cs.ATG"
#line 1985 "cs.ATG"
pexpr = new IndexerExpression(pexpr, indices);
}
}
}
void AnonymousMethodExpr(
#line 1989 "cs.ATG"
out Expression outExpr) {
#line 1991 "cs.ATG"
AnonymousMethodExpression expr = new AnonymousMethodExpression();
Statement stmt;
ArrayList p;
outExpr = expr;
Expect(19);
if (StartOf(9)) {
FormalParameterList(
#line 1998 "cs.ATG"
out p);
#line 1998 "cs.ATG"
expr.Parameters = p;
}
Expect(20);
#line 2002 "cs.ATG"
if (compilationUnit != null) {
Block(
#line 2003 "cs.ATG"
out stmt);
#line 2003 "cs.ATG"
expr.Body = (BlockStatement)stmt;
#line 2004 "cs.ATG"
} else {
Expect(15);
#line 2006 "cs.ATG"
lexer.SkipCurrentBlock();
Expect(16);
#line 2008 "cs.ATG"
}
}
void ConditionalAndExpr(
#line 1994 "cs.ATG"
#line 2017 "cs.ATG"
ref Expression outExpr) {
#line 1995 "cs.ATG"
#line 2018 "cs.ATG"
Expression expr;
InclusiveOrExpr(
#line 1997 "cs.ATG"
#line 2020 "cs.ATG"
ref outExpr);
while (la.kind == 24) {
lexer.NextToken();
UnaryExpr(
#line 1997 "cs.ATG"
#line 2020 "cs.ATG"
out expr);
InclusiveOrExpr(
#line 1997 "cs.ATG"
#line 2020 "cs.ATG"
ref expr);
#line 1997 "cs.ATG"
#line 2020 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr);
}
}
void InclusiveOrExpr(
#line 2000 "cs.ATG"
#line 2023 "cs.ATG"
ref Expression outExpr) {
#line 2001 "cs.ATG"
#line 2024 "cs.ATG"
Expression expr;
ExclusiveOrExpr(
#line 2003 "cs.ATG"
#line 2026 "cs.ATG"
ref outExpr);
while (la.kind == 28) {
lexer.NextToken();
UnaryExpr(
#line 2003 "cs.ATG"
#line 2026 "cs.ATG"
out expr);
ExclusiveOrExpr(
#line 2003 "cs.ATG"
#line 2026 "cs.ATG"
ref expr);
#line 2003 "cs.ATG"
#line 2026 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr);
}
}
void ExclusiveOrExpr(
#line 2006 "cs.ATG"
#line 2029 "cs.ATG"
ref Expression outExpr) {
#line 2007 "cs.ATG"
#line 2030 "cs.ATG"
Expression expr;
AndExpr(
#line 2009 "cs.ATG"
#line 2032 "cs.ATG"
ref outExpr);
while (la.kind == 29) {
lexer.NextToken();
UnaryExpr(
#line 2009 "cs.ATG"
#line 2032 "cs.ATG"
out expr);
AndExpr(
#line 2009 "cs.ATG"
#line 2032 "cs.ATG"
ref expr);
#line 2009 "cs.ATG"
#line 2032 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr);
}
}
void AndExpr(
#line 2012 "cs.ATG"
#line 2035 "cs.ATG"
ref Expression outExpr) {
#line 2013 "cs.ATG"
#line 2036 "cs.ATG"
Expression expr;
EqualityExpr(
#line 2015 "cs.ATG"
#line 2038 "cs.ATG"
ref outExpr);
while (la.kind == 27) {
lexer.NextToken();
UnaryExpr(
#line 2015 "cs.ATG"
#line 2038 "cs.ATG"
out expr);
EqualityExpr(
#line 2015 "cs.ATG"
#line 2038 "cs.ATG"
ref expr);
#line 2015 "cs.ATG"
#line 2038 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr);
}
}
void EqualityExpr(
#line 2018 "cs.ATG"
#line 2041 "cs.ATG"
ref Expression outExpr) {
#line 2020 "cs.ATG"
#line 2043 "cs.ATG"
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
RelationalExpr(
#line 2024 "cs.ATG"
#line 2047 "cs.ATG"
ref outExpr);
while (la.kind == 32 || la.kind == 33) {
if (la.kind == 33) {
lexer.NextToken();
#line 2027 "cs.ATG"
#line 2050 "cs.ATG"
op = BinaryOperatorType.InEquality;
} else {
lexer.NextToken();
#line 2028 "cs.ATG"
#line 2051 "cs.ATG"
op = BinaryOperatorType.Equality;
}
UnaryExpr(
#line 2030 "cs.ATG"
#line 2053 "cs.ATG"
out expr);
RelationalExpr(
#line 2030 "cs.ATG"
#line 2053 "cs.ATG"
ref expr);
#line 2030 "cs.ATG"
#line 2053 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, op, expr);
}
}
void RelationalExpr(
#line 2034 "cs.ATG"
#line 2057 "cs.ATG"
ref Expression outExpr) {
#line 2036 "cs.ATG"
#line 2059 "cs.ATG"
TypeReference type;
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
ShiftExpr(
#line 2041 "cs.ATG"
#line 2064 "cs.ATG"
ref outExpr);
while (StartOf(26)) {
if (StartOf(27)) {
if (la.kind == 22) {
lexer.NextToken();
#line 2044 "cs.ATG"
#line 2067 "cs.ATG"
op = BinaryOperatorType.LessThan;
} else if (la.kind == 21) {
lexer.NextToken();
#line 2045 "cs.ATG"
#line 2068 "cs.ATG"
op = BinaryOperatorType.GreaterThan;
} else if (la.kind == 35) {
lexer.NextToken();
#line 2046 "cs.ATG"
#line 2069 "cs.ATG"
op = BinaryOperatorType.LessThanOrEqual;
} else if (la.kind == 34) {
lexer.NextToken();
#line 2047 "cs.ATG"
#line 2070 "cs.ATG"
op = BinaryOperatorType.GreaterThanOrEqual;
} else SynErr(182);
UnaryExpr(
#line 2049 "cs.ATG"
#line 2072 "cs.ATG"
out expr);
ShiftExpr(
#line 2049 "cs.ATG"
#line 2072 "cs.ATG"
ref expr);
#line 2049 "cs.ATG"
#line 2072 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, op, expr);
} else {
if (la.kind == 83) {
lexer.NextToken();
#line 2052 "cs.ATG"
#line 2075 "cs.ATG"
op = BinaryOperatorType.IS;
} else if (la.kind == 48) {
lexer.NextToken();
#line 2053 "cs.ATG"
#line 2076 "cs.ATG"
op = BinaryOperatorType.AS;
} else SynErr(183);
Type(
#line 2055 "cs.ATG"
#line 2078 "cs.ATG"
out type);
#line 2055 "cs.ATG"
#line 2078 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, op, new TypeReferenceExpression(type));
}
}
}
void ShiftExpr(
#line 2059 "cs.ATG"
#line 2082 "cs.ATG"
ref Expression outExpr) {
#line 2061 "cs.ATG"
#line 2084 "cs.ATG"
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
AdditiveExpr(
#line 2065 "cs.ATG"
#line 2088 "cs.ATG"
ref outExpr);
while (la.kind == 36 ||
#line 2068 "cs.ATG"
#line 2091 "cs.ATG"
IsShiftRight()) {
if (la.kind == 36) {
lexer.NextToken();
#line 2067 "cs.ATG"
#line 2090 "cs.ATG"
op = BinaryOperatorType.ShiftLeft;
} else {
Expect(21);
Expect(21);
#line 2069 "cs.ATG"
#line 2092 "cs.ATG"
op = BinaryOperatorType.ShiftRight;
}
UnaryExpr(
#line 2072 "cs.ATG"
#line 2095 "cs.ATG"
out expr);
AdditiveExpr(
#line 2072 "cs.ATG"
#line 2095 "cs.ATG"
ref expr);
#line 2072 "cs.ATG"
#line 2095 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, op, expr);
}
}
void AdditiveExpr(
#line 2076 "cs.ATG"
#line 2099 "cs.ATG"
ref Expression outExpr) {
#line 2078 "cs.ATG"
#line 2101 "cs.ATG"
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
MultiplicativeExpr(
#line 2082 "cs.ATG"
#line 2105 "cs.ATG"
ref outExpr);
while (la.kind == 4 || la.kind == 5) {
if (la.kind == 4) {
lexer.NextToken();
#line 2085 "cs.ATG"
#line 2108 "cs.ATG"
op = BinaryOperatorType.Add;
} else {
lexer.NextToken();
#line 2086 "cs.ATG"
#line 2109 "cs.ATG"
op = BinaryOperatorType.Subtract;
}
UnaryExpr(
#line 2088 "cs.ATG"
#line 2111 "cs.ATG"
out expr);
MultiplicativeExpr(
#line 2088 "cs.ATG"
#line 2111 "cs.ATG"
ref expr);
#line 2088 "cs.ATG"
#line 2111 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, op, expr);
}
}
void MultiplicativeExpr(
#line 2092 "cs.ATG"
#line 2115 "cs.ATG"
ref Expression outExpr) {
#line 2094 "cs.ATG"
#line 2117 "cs.ATG"
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
@ -4992,84 +5044,84 @@ ref Expression outExpr) { @@ -4992,84 +5044,84 @@ ref Expression outExpr) {
if (la.kind == 6) {
lexer.NextToken();
#line 2100 "cs.ATG"
#line 2123 "cs.ATG"
op = BinaryOperatorType.Multiply;
} else if (la.kind == 7) {
lexer.NextToken();
#line 2101 "cs.ATG"
#line 2124 "cs.ATG"
op = BinaryOperatorType.Divide;
} else {
lexer.NextToken();
#line 2102 "cs.ATG"
#line 2125 "cs.ATG"
op = BinaryOperatorType.Modulus;
}
UnaryExpr(
#line 2104 "cs.ATG"
#line 2127 "cs.ATG"
out expr);
#line 2104 "cs.ATG"
#line 2127 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, op, expr);
}
}
void TypeArgumentList(
#line 2117 "cs.ATG"
#line 2140 "cs.ATG"
out List<TypeReference> types) {
#line 2119 "cs.ATG"
#line 2142 "cs.ATG"
types = new List<TypeReference>();
TypeReference type = null;
Expect(22);
Type(
#line 2123 "cs.ATG"
#line 2146 "cs.ATG"
out type);
#line 2123 "cs.ATG"
#line 2146 "cs.ATG"
types.Add(type);
while (la.kind == 13) {
lexer.NextToken();
Type(
#line 2124 "cs.ATG"
#line 2147 "cs.ATG"
out type);
#line 2124 "cs.ATG"
#line 2147 "cs.ATG"
types.Add(type);
}
Expect(21);
}
void TypeParameterConstraintsClauseBase(
#line 2169 "cs.ATG"
#line 2192 "cs.ATG"
out TypeReference type) {
#line 2170 "cs.ATG"
#line 2193 "cs.ATG"
TypeReference t; type = null;
if (la.kind == 107) {
lexer.NextToken();
#line 2172 "cs.ATG"
#line 2195 "cs.ATG"
type = new TypeReference("struct");
} else if (la.kind == 57) {
lexer.NextToken();
#line 2173 "cs.ATG"
#line 2196 "cs.ATG"
type = new TypeReference("struct");
} else if (la.kind == 87) {
lexer.NextToken();
Expect(19);
Expect(20);
#line 2174 "cs.ATG"
#line 2197 "cs.ATG"
type = new TypeReference("struct");
} else if (StartOf(8)) {
Type(
#line 2175 "cs.ATG"
#line 2198 "cs.ATG"
out t);
#line 2175 "cs.ATG"
#line 2198 "cs.ATG"
type = t;
} else SynErr(184);
}
@ -5324,7 +5376,7 @@ out t); @@ -5324,7 +5376,7 @@ out t);
{x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, x,x,T,T, x,x,x,x, x,x,T,T, T,x,x,x, x,T,x,x, x,T,x,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x},
{x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, x,x,x,T, x,x,x,x, x,x,T,T, T,x,x,x, x,T,x,x, x,T,x,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x},
{x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,T, x,x,x,x, x,x,T,T, T,x,x,x, x,T,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x},
{x,T,T,x, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,T, x,x,T,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, T,x,x,T, T,x,x,x, T,x,x,x, T,x,x,x, x,x,T,x, x,T,x,x, x,x,x,x, T,x,x,x, x,T,x,T, T,T,x,x, x,x,x,x, x,x,x,x, T,x,T,T, x,x,T,x, x,T,x,T, x,T,T,T, T,x,T,x, x,x,x,x, x,x},
{x,T,T,x, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,T, x,x,T,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, T,x,x,T, T,x,x,x, T,x,T,x, T,x,x,x, x,x,T,x, x,T,x,x, x,x,x,x, T,x,x,x, x,T,x,T, T,T,x,x, x,x,x,x, x,x,x,x, T,x,T,T, x,x,T,x, x,T,x,T, x,T,T,T, T,x,T,x, x,x,x,x, x,x},
{x,x,x,x, T,T,T,T, T,T,x,T, T,T,x,x, T,x,T,x, T,T,T,x, T,T,x,T, T,T,x,x, T,T,T,T, T,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
{x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,T, T,T,T,T, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
@ -5340,10 +5392,10 @@ out t); @@ -5340,10 +5392,10 @@ out t);
{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
{x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,T, x,x,x,x, T,x,x,x, T,x,x,T, x,x,x,x, x,T,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,T,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,x,T,x, x,x,x,x, x,x,T,T, x,x,T,x, x,T,x,x, x,x},
{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, x,x,x,x, x,x},
{x,T,T,x, T,T,T,x, x,x,x,T, x,x,x,T, x,x,x,T, x,x,x,T, x,x,T,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,T, T,x,x,T, T,x,T,T, T,x,x,T, T,x,x,x, x,x,T,x, T,T,T,T, T,T,x,x, T,x,x,x, T,T,x,T, T,T,x,x, x,x,x,x, x,x,x,T, T,x,T,T, x,x,T,x, T,T,T,T, T,T,T,T, T,T,T,T, x,x,x,T, x,x},
{x,T,T,x, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,T, x,x,T,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, T,x,x,T, T,x,x,x, T,x,x,x, T,x,x,x, x,x,T,x, x,T,x,x, x,x,x,x, T,x,x,x, x,T,x,T, T,T,x,T, x,x,x,x, x,x,T,x, T,x,T,T, x,x,T,x, x,T,x,T, x,T,T,T, T,x,T,x, x,x,x,x, x,x},
{x,T,T,x, T,T,T,x, x,x,x,T, x,x,x,T, x,x,x,T, x,x,x,T, x,x,T,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,T, T,x,x,T, T,x,x,T, T,x,x,T, T,x,x,x, x,x,T,x, T,T,T,T, T,T,x,x, T,x,x,x, T,T,x,T, T,T,x,x, x,x,x,x, x,x,x,T, T,x,T,T, x,x,T,x, T,T,T,T, T,T,T,T, T,T,T,T, x,x,x,T, x,x},
{x,T,T,x, T,T,T,x, x,x,x,x, x,x,x,T, x,x,x,T, x,x,x,T, x,x,T,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, T,x,x,T, T,x,x,x, T,x,x,x, T,x,x,x, x,x,T,x, x,T,x,x, x,x,x,x, T,x,x,x, x,T,x,T, T,T,x,x, x,x,x,x, x,x,x,x, T,x,T,T, T,x,T,x, x,T,x,T, x,T,T,T, T,x,T,x, x,x,x,x, x,x},
{x,T,T,x, T,T,T,x, x,x,x,T, x,x,x,T, x,x,x,T, x,x,x,T, x,x,T,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,T, T,x,x,T, T,x,T,T, T,x,T,T, T,x,x,x, x,x,T,x, T,T,T,T, T,T,x,x, T,x,x,x, T,T,x,T, T,T,x,x, x,x,x,x, x,x,x,T, T,x,T,T, x,x,T,x, T,T,T,T, T,T,T,T, T,T,T,T, x,x,x,T, x,x},
{x,T,T,x, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,T, x,x,T,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, T,x,x,T, T,x,x,x, T,x,T,x, T,x,x,x, x,x,T,x, x,T,x,x, x,x,x,x, T,x,x,x, x,T,x,T, T,T,x,T, x,x,x,x, x,x,T,x, T,x,T,T, x,x,T,x, x,T,x,T, x,T,T,T, T,x,T,x, x,x,x,x, x,x},
{x,T,T,x, T,T,T,x, x,x,x,T, x,x,x,T, x,x,x,T, x,x,x,T, x,x,T,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,T, T,x,x,T, T,x,x,T, T,x,T,T, T,x,x,x, x,x,T,x, T,T,T,T, T,T,x,x, T,x,x,x, T,T,x,T, T,T,x,x, x,x,x,x, x,x,x,T, T,x,T,T, x,x,T,x, T,T,T,T, T,T,T,T, T,T,T,T, x,x,x,T, x,x},
{x,T,T,x, T,T,T,x, x,x,x,x, x,x,x,T, x,x,x,T, x,x,x,T, x,x,T,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, T,x,x,T, T,x,x,x, T,x,T,x, T,x,x,x, x,x,T,x, x,T,x,x, x,x,x,x, T,x,x,x, x,T,x,T, T,T,x,x, x,x,x,x, x,x,x,x, T,x,T,T, T,x,T,x, x,T,x,T, x,T,T,T, T,x,T,x, x,x,x,x, x,x},
{x,x,x,x, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,T,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
{x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,T,x,T, x,x,x,x, x,x,x,x, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},

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

@ -1961,6 +1961,7 @@ PrimaryExpr<out Expression pexpr> @@ -1961,6 +1961,7 @@ PrimaryExpr<out Expression pexpr>
| "sizeof" "(" Type<out type> ")" (. pexpr = new SizeOfExpression(type); .)
| "checked" "(" Expr<out expr> ")" (. pexpr = new CheckedExpression(expr); .)
| "unchecked" "(" Expr<out expr> ")" (. pexpr = new UncheckedExpression(expr); .)
| "delegate" AnonymousMethodExpr<out expr> (. pexpr = expr; .)
)
{
(
@ -1985,6 +1986,28 @@ PrimaryExpr<out Expression pexpr> @@ -1985,6 +1986,28 @@ PrimaryExpr<out Expression pexpr>
}
.
AnonymousMethodExpr<out Expression outExpr>
(.
AnonymousMethodExpression expr = new AnonymousMethodExpression();
Statement stmt;
ArrayList p;
outExpr = expr;
.)
=
"("
[ FormalParameterList<out p> (. expr.Parameters = p; .) ]
")"
/*--- ParseExpression doesn't set a compilation unit, */
/*--- so we can't use block then -> skip body of anonymous method */
(. if (compilationUnit != null) { .)
Block<out stmt> (. expr.Body = (BlockStatement)stmt; .)
(. } else { .)
"{"
(. lexer.SkipCurrentBlock(); .)
"}"
(. } .)
.
ConditionalOrExpr<ref Expression outExpr>
(. Expression expr; .)
=

34
src/Libraries/NRefactory/Project/Src/Parser/Visitors/AbstractASTVisitor.cs

@ -18,7 +18,6 @@ namespace ICSharpCode.NRefactory.Parser @@ -18,7 +18,6 @@ namespace ICSharpCode.NRefactory.Parser
}
}
#region ICSharpCode.NRefactory.Parser.IASTVisitor interface implementation
public virtual object Visit(INode node, object data)
{
Console.WriteLine("Warning, INode visited!");
@ -75,7 +74,7 @@ namespace ICSharpCode.NRefactory.Parser @@ -75,7 +74,7 @@ namespace ICSharpCode.NRefactory.Parser
return namedArgumentExpression.Expression.AcceptVisitor(this, data);
}
#region global scope
#region global scope
public virtual object Visit(Using @using, object data)
{
Debug.Assert(@using != null);
@ -143,9 +142,9 @@ namespace ICSharpCode.NRefactory.Parser @@ -143,9 +142,9 @@ namespace ICSharpCode.NRefactory.Parser
Debug.Assert(optionDeclaration != null);
return data;
}
#endregion
#endregion
#region type level
#region type level
public virtual object Visit(FieldDeclaration fieldDeclaration, object data)
{
Debug.Assert(fieldDeclaration != null);
@ -420,9 +419,9 @@ namespace ICSharpCode.NRefactory.Parser @@ -420,9 +419,9 @@ namespace ICSharpCode.NRefactory.Parser
}
return data;
}
#endregion
#endregion
#region statements
#region statements
public virtual object Visit(BlockStatement blockStatement, object data)
{
Debug.Assert(blockStatement != null);
@ -836,9 +835,9 @@ namespace ICSharpCode.NRefactory.Parser @@ -836,9 +835,9 @@ namespace ICSharpCode.NRefactory.Parser
return data;
}
#endregion
#endregion
#region expressions
#region expressions
public virtual object Visit(PrimitiveExpression primitiveExpression, object data)
{
Debug.Assert(primitiveExpression != null);
@ -1024,6 +1023,22 @@ namespace ICSharpCode.NRefactory.Parser @@ -1024,6 +1023,22 @@ namespace ICSharpCode.NRefactory.Parser
return data;
}
public object Visit(AnonymousMethodExpression anonymousMethodExpression, object data)
{
Debug.Assert(anonymousMethodExpression != null);
Debug.Assert(anonymousMethodExpression.Parameters != null);
Debug.Assert(anonymousMethodExpression.Body != null);
foreach (ParameterDeclarationExpression p in anonymousMethodExpression.Parameters) {
p.AcceptVisitor(this, data);
}
blockStack.Push(anonymousMethodExpression.Body);
anonymousMethodExpression.Body.AcceptChildren(this, data);
blockStack.Pop();
return data;
}
public virtual object Visit(TypeOfIsExpression typeOfIsExpression, object data)
{
Debug.Assert(typeOfIsExpression != null);
@ -1100,7 +1115,6 @@ namespace ICSharpCode.NRefactory.Parser @@ -1100,7 +1115,6 @@ namespace ICSharpCode.NRefactory.Parser
}
return data;
}
#endregion
#endregion
#endregion
}
}

1
src/Libraries/NRefactory/Project/Src/Parser/Visitors/IASTVisitor.cs

@ -101,6 +101,7 @@ namespace ICSharpCode.NRefactory.Parser @@ -101,6 +101,7 @@ namespace ICSharpCode.NRefactory.Parser
object Visit(TypeOfExpression typeOfExpression, object data);
object Visit(TypeOfIsExpression typeOfIsExpression, object data);
object Visit(AddressOfExpression addressOfExpression, object data);
object Visit(AnonymousMethodExpression anonymousMethodExpression, object data);
object Visit(CheckedExpression checkedExpression, object data);
object Visit(UncheckedExpression uncheckedExpression, object data);
object Visit(PointerReferenceExpression pointerReferenceExpression, object data);

1
src/Libraries/NRefactory/Test/NRefactoryTests.csproj

@ -123,6 +123,7 @@ @@ -123,6 +123,7 @@
<Compile Include="Lexer\CSharp\NumberLexerTest.cs" />
<Compile Include="Lexer\VBNet\LiteralsTests.cs" />
<Compile Include="Parser\SkipMethodBodiesTest.cs" />
<Compile Include="Parser\Expressions\AnonymousMethodTests.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="General\" />

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

@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
/*
* Created by SharpDevelop.
* User: Daniel Grunwald
* Date: 21.05.2005
* Time: 21:33
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
namespace ICSharpCode.NRefactory.Tests.AST
{
[TestFixture]
public class AnonymousMethodTests
{
AnonymousMethodExpression Parse(string program)
{
return (AnonymousMethodExpression)ParseUtilCSharp.ParseExpression(program, typeof(AnonymousMethodExpression));
}
[Test]
public void EmptyAnonymousMethod()
{
AnonymousMethodExpression ame = Parse("delegate() {}");
Assert.AreEqual(0, ame.Parameters.Count);
Assert.AreEqual(0, ame.Body.Children.Count);
}
[Test]
public void SimpleAnonymousMethod()
{
AnonymousMethodExpression ame = Parse("delegate(int a, int b) { return a + b; }");
Assert.AreEqual(2, ame.Parameters.Count);
// blocks can't be added without compilation unit -> anonymous method body
// is always empty when using ParseExpression
//Assert.AreEqual(1, ame.Body.Children.Count);
//Assert.IsTrue(ame.Body.Children[0] is ReturnStatement);
}
}
}

9
src/Main/Base/Project/Src/Commands/ClassMemberMenuBuilder.cs

@ -31,11 +31,14 @@ namespace ICSharpCode.SharpDevelop.Commands @@ -31,11 +31,14 @@ namespace ICSharpCode.SharpDevelop.Commands
MenuCommand cmd;
ClassMemberBookmark bookmark = (ClassMemberBookmark)owner;
IMember member = bookmark.Member;
IMethod method = member as IMethod;
List<ToolStripItem> list = new List<ToolStripItem>();
cmd = new MenuCommand("&Rename", Rename);
cmd.Tag = member;
list.Add(cmd);
if (method == null || !method.IsConstructor) {
cmd = new MenuCommand("&Rename", Rename);
cmd.Tag = member;
list.Add(cmd);
}
if (member.IsOverride) {
cmd = new MenuCommand("Go to &base class", GoToBase);
cmd.Tag = member;

7
src/Main/Base/Project/Src/TextEditor/Bookmarks/Bookmark.cs

@ -53,8 +53,11 @@ namespace ICSharpCode.SharpDevelop.Bookmarks @@ -53,8 +53,11 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
public void ChangeFilename(string newFileName)
{
fileName = newFileName;
foreach (SDBookmark mark in manager.Marks) {
mark.FileName = newFileName;
foreach (Bookmark mark in manager.Marks) {
SDBookmark sdMark = mark as SDBookmark;
if (sdMark != null) {
sdMark.FileName = newFileName;
}
}
}

1
src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs

@ -445,6 +445,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -445,6 +445,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
{
BookmarkManager bm = textAreaControl.Document.BookmarkManager;
bm.RemoveMarks(new Predicate<Bookmark>(IsClassMemberBookmark));
if (parseInfo == null) return;
foreach (IClass c in parseInfo.MostRecentCompilationUnit.Classes) {
foreach (IMethod m in c.Methods) {
if (m.Region == null || m.Region.BeginLine <= 0) continue;

72
src/Main/Base/Test/GenericResolverTests.cs

@ -0,0 +1,72 @@ @@ -0,0 +1,72 @@
using System;
using System.Collections;
using System.IO;
using NUnit.Framework;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver;
namespace ICSharpCode.SharpDevelop.Tests
{
[TestFixture]
public class GenericResolverTests
{
#region Test helper methods
NRefactoryResolverTests nrrt = new NRefactoryResolverTests();
ResolveResult Resolve(string program, string expression, int line)
{
return nrrt.Resolve(program, expression, line);
}
ResolveResult ResolveVB(string program, string expression, int line)
{
return nrrt.ResolveVB(program, expression, line);
}
#endregion
const string listProgram = @"using System.Collections.Generic;
class TestClass {
void Method() {
List<TestClass> list = new List<TestClass>();
}
}
";
[Test]
public void ListAddTest()
{
ResolveResult result = Resolve(listProgram, "list.Add(new A())", 5);
Assert.IsNotNull(result);
Assert.IsTrue(result is MemberResolveResult);
IMethod m = (IMethod)((MemberResolveResult)result).ResolvedMember;
Assert.AreEqual(1, m.Parameters.Count);
Assert.AreEqual("TestClass", m.Parameters[0].ReturnType.FullyQualifiedName);
}
[Test]
public void ListAddRangeTest()
{
ResolveResult result = Resolve(listProgram, "list.AddRange(new A[0])", 5);
Assert.IsNotNull(result);
Assert.IsTrue(result is MemberResolveResult);
IMethod m = (IMethod)((MemberResolveResult)result).ResolvedMember;
Assert.AreEqual(1, m.Parameters.Count);
Assert.IsTrue(m.Parameters[0].ReturnType is SpecificReturnType);
Assert.AreEqual("System.Collections.Generic.IEnumerable", m.Parameters[0].ReturnType.FullyQualifiedName);
Assert.AreEqual("TestClass", ((SpecificReturnType)m.Parameters[0].ReturnType).TypeParameters[0].FullyQualifiedName);
}
[Test]
public void ListToArrayTest()
{
ResolveResult result = Resolve(listProgram, "list.ToArray()", 5);
Assert.IsNotNull(result);
Assert.IsTrue(result is MemberResolveResult);
IMethod m = (IMethod)((MemberResolveResult)result).ResolvedMember;
Assert.AreEqual("TestClass", m.ReturnType.FullyQualifiedName);
Assert.AreEqual(1, m.ReturnType.ArrayDimensions);
}
}
}
Loading…
Cancel
Save