Browse Source

try revert critical method

newNRvisualizers
Alex Mizuki 14 years ago
parent
commit
aff71a5d53
  1. 36
      ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs

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

@ -2722,39 +2722,50 @@ namespace ICSharpCode.NRefactory.CSharp
int curComma = 0; int curComma = 0;
if (initLoc != null) if (initLoc != null)
init.AddChild(new CSharpTokenNode(Convert(initLoc[0])), Roles.LBrace); init.AddChild(new CSharpTokenNode(Convert(initLoc[0])), Roles.LBrace);
foreach (var expr in minit.Initializers) { foreach (var expr in minit.Initializers)
{
var collectionInit = expr as CollectionElementInitializer; var collectionInit = expr as CollectionElementInitializer;
if (collectionInit != null) { if (collectionInit != null)
{
var parent = new ArrayInitializerExpression(); var parent = new ArrayInitializerExpression();
parent.AddChild (new CSharpTokenNode (Convert (expr.Location)), Roles.LBrace); var braceLocs = LocationsBag.GetLocations(expr);
if (braceLocs != null)
parent.AddChild(new CSharpTokenNode(Convert(braceLocs[0])), Roles.LBrace);
for (int i = 0; i < collectionInit.Arguments.Count; i++) { for (int i = 0; i < collectionInit.Arguments.Count; i++)
{
var arg = collectionInit.Arguments[i] as CollectionElementInitializer.ElementInitializerArgument; var arg = collectionInit.Arguments[i] as CollectionElementInitializer.ElementInitializerArgument;
if (arg == null) if (arg == null)
continue; continue;
parent.AddChild((ICSharpCode.NRefactory.CSharp.Expression)arg.Expr.Accept(this), Roles.Expression); parent.AddChild((ICSharpCode.NRefactory.CSharp.Expression)arg.Expr.Accept(this), Roles.Expression);
} }
var braceLocs = LocationsBag.GetLocations (expr);
if (braceLocs != null) if (braceLocs != null)
parent.AddChild (new CSharpTokenNode (Convert (braceLocs [0])), Roles.RBrace); parent.AddChild(new CSharpTokenNode(Convert(braceLocs[1])), Roles.RBrace);
init.AddChild(parent, Roles.Expression); init.AddChild(parent, Roles.Expression);
} else { }
else
{
var eleInit = expr as ElementInitializer; var eleInit = expr as ElementInitializer;
if (eleInit != null) { if (eleInit != null)
{
var nexpr = new NamedExpression(); var nexpr = new NamedExpression();
nexpr.AddChild(Identifier.Create(eleInit.Name, Convert(eleInit.Location)), Roles.Identifier); nexpr.AddChild(Identifier.Create(eleInit.Name, Convert(eleInit.Location)), Roles.Identifier);
var assignLoc = LocationsBag.GetLocations(eleInit); var assignLoc = LocationsBag.GetLocations(eleInit);
if (assignLoc != null) if (assignLoc != null)
nexpr.AddChild(new CSharpTokenNode(Convert(assignLoc[0])), Roles.Assign); nexpr.AddChild(new CSharpTokenNode(Convert(assignLoc[0])), Roles.Assign);
if (eleInit.Source != null) { if (eleInit.Source != null)
if (eleInit.Source is CollectionOrObjectInitializers) { {
if (eleInit.Source is CollectionOrObjectInitializers)
{
var arrInit = new ArrayInitializerExpression(); var arrInit = new ArrayInitializerExpression();
AddConvertCollectionOrObjectInitializers(arrInit, eleInit.Source as CollectionOrObjectInitializers); AddConvertCollectionOrObjectInitializers(arrInit, eleInit.Source as CollectionOrObjectInitializers);
nexpr.AddChild(arrInit, Roles.Expression); nexpr.AddChild(arrInit, Roles.Expression);
} else { }
else
{
nexpr.AddChild((Expression)eleInit.Source.Accept(this), Roles.Expression); nexpr.AddChild((Expression)eleInit.Source.Accept(this), Roles.Expression);
} }
} }
@ -2766,7 +2777,8 @@ namespace ICSharpCode.NRefactory.CSharp
init.AddChild(new CSharpTokenNode(Convert(commaLoc[curComma++])), Roles.Comma); init.AddChild(new CSharpTokenNode(Convert(commaLoc[curComma++])), Roles.Comma);
} }
if (initLoc != null) { if (initLoc != null)
{
if (initLoc.Count == 3) // optional comma if (initLoc.Count == 3) // optional comma
init.AddChild(new CSharpTokenNode(Convert(initLoc[1])), Roles.Comma); init.AddChild(new CSharpTokenNode(Convert(initLoc[1])), Roles.Comma);
init.AddChild(new CSharpTokenNode(Convert(initLoc[initLoc.Count - 1])), Roles.RBrace); init.AddChild(new CSharpTokenNode(Convert(initLoc[initLoc.Count - 1])), Roles.RBrace);

Loading…
Cancel
Save