Browse Source

Fixed attribute argument commas.

newNRvisualizers
Mike Krüger 15 years ago
parent
commit
9d55421ef3
  1. 17
      ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
  2. 1370
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs
  3. 9
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay

17
ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs

@ -198,8 +198,9 @@ namespace ICSharpCode.NRefactory.CSharp @@ -198,8 +198,9 @@ namespace ICSharpCode.NRefactory.CSharp
result.Type = ConvertToType (attr.TypeNameExpression);
var loc = LocationsBag.GetLocations (attr);
result.HasArgumentList = loc != null;
int pos = 0;
if (loc != null)
result.AddChild (new CSharpTokenNode (Convert (loc [0]), 1), AttributeSection.Roles.LPar);
result.AddChild (new CSharpTokenNode (Convert (loc [pos++]), 1), AttributeSection.Roles.LPar);
if (attr.PosArguments != null) {
foreach (var arg in attr.PosArguments) {
@ -210,12 +211,14 @@ namespace ICSharpCode.NRefactory.CSharp @@ -210,12 +211,14 @@ namespace ICSharpCode.NRefactory.CSharp
var argLoc = LocationsBag.GetLocations (na);
if (argLoc != null)
newArg.AddChild (new CSharpTokenNode (Convert (argLoc[0]), 1), NamedArgumentExpression.Roles.Colon);
newArg.AddChild (new CSharpTokenNode (Convert (argLoc [0]), 1), NamedArgumentExpression.Roles.Colon);
newArg.AddChild ((Expression)na.Expr.Accept (this), NamedExpression.Roles.Expression);
result.AddChild (newArg, Attribute.Roles.Argument);
continue;
} else {
result.AddChild ((Expression)arg.Expr.Accept (this), Attribute.Roles.Argument);
}
result.AddChild ((Expression)arg.Expr.Accept (this), Attribute.Roles.Argument);
if (loc != null && pos + 1 < loc.Count)
result.AddChild (new CSharpTokenNode (Convert (loc [pos++]), 1), AttributeSection.Roles.Comma);
}
}
if (attr.NamedArguments != null) {
@ -228,10 +231,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -228,10 +231,12 @@ namespace ICSharpCode.NRefactory.CSharp
newArg.AddChild (new CSharpTokenNode (Convert (argLoc[0]), 1), NamedExpression.Roles.Assign);
newArg.AddChild ((Expression)na.Expr.Accept (this), NamedExpression.Roles.Expression);
result.AddChild (newArg, Attribute.Roles.Argument);
if (loc != null && pos + 1 < loc.Count)
result.AddChild (new CSharpTokenNode (Convert (loc [pos++]), 1), AttributeSection.Roles.Comma);
}
}
if (loc != null)
result.AddChild (new CSharpTokenNode (Convert (loc [1]), 1), AttributeSection.Roles.RPar);
if (loc != null && pos < loc.Count)
result.AddChild (new CSharpTokenNode (Convert (loc [pos++]), 1), AttributeSection.Roles.RPar);
yield return result;
}

1370
ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs

File diff suppressed because it is too large Load Diff

9
ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay

@ -147,6 +147,7 @@ namespace Mono.CSharp @@ -147,6 +147,7 @@ namespace Mono.CSharp
Location savedAttrParenOpenLocation, savedAttrParenCloseLocation, savedOperatorLocation;
Stack<List<Location>> locationListStack = new Stack<List<Location>> (); // used for type parameters
List<Location> attributeCommas = new List<Location> ();
List<Location> attributeArgumentCommas = new List<Location> ();
List<Location> parameterListCommas = new List<Location> ();
List<Location> enumCommas = new List<Location> ();
@ -797,7 +798,9 @@ attribute @@ -797,7 +798,9 @@ attribute
ATypeNameExpression expr = mname.GetTypeExpression ();
$$ = new Attribute (current_attr_target, expr, arguments, mname.Location, lexer.IsEscapedIdentifier (mname));
if (arguments != null) {
lbag.AddLocation ($$, savedAttrParenOpenLocation, savedAttrParenCloseLocation);
attributeArgumentCommas.Insert (0, savedAttrParenOpenLocation);
attributeArgumentCommas.Add (savedAttrParenCloseLocation);
lbag.AddLocation ($$, attributeArgumentCommas);
}
}
;
@ -844,7 +847,7 @@ attribute_arguments @@ -844,7 +847,7 @@ attribute_arguments
Error_NamedArgumentExpected ((NamedArgument) args [args.Count - 1]);
args.Add ((Argument) $3);
lbag.AppendTo (args, GetLocation ($2));
attributeArgumentCommas.Add (GetLocation ($2));
}
| attribute_arguments COMMA named_attribute_argument
{
@ -854,7 +857,7 @@ attribute_arguments @@ -854,7 +857,7 @@ attribute_arguments
}
((Arguments) o [1]).Add ((Argument) $3);
lbag.AppendTo (o[1], GetLocation ($2));
attributeArgumentCommas.Add (GetLocation ($2));
}
;

Loading…
Cancel
Save