本文整理汇总了C#中ArrayInitializerExpression类的典型用法代码示例。如果您正苦于以下问题:C# ArrayInitializerExpression类的具体用法?C# ArrayInitializerExpression怎么用?C# ArrayInitializerExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArrayInitializerExpression类属于命名空间,在下文中一共展示了ArrayInitializerExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitArrayInitializerExpression
public override void VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression)
{
if (DoWrap(policy.ArrayInitializerWrapping, arrayInitializerExpression.RBraceToken, arrayInitializerExpression.Elements.Count)) {
FixOpenBrace(policy.ArrayInitializerBraceStyle, arrayInitializerExpression.LBraceToken);
curIndent.Push(IndentType.Block);
foreach (var init in arrayInitializerExpression.Elements) {
FixStatementIndentation(init.StartLocation);
init.AcceptVisitor(this);
}
curIndent.Pop();
FixClosingBrace(policy.ArrayInitializerBraceStyle, arrayInitializerExpression.RBraceToken);
} else if (policy.ArrayInitializerWrapping == Wrapping.DoNotWrap) {
ForceSpacesBeforeRemoveNewLines(arrayInitializerExpression.LBraceToken);
ForceSpacesBeforeRemoveNewLines(arrayInitializerExpression.RBraceToken);
foreach (var init in arrayInitializerExpression.Elements) {
ForceSpacesBeforeRemoveNewLines(init);
init.AcceptVisitor(this);
}
} else {
var lBrace = arrayInitializerExpression.LBraceToken;
var rBrace = arrayInitializerExpression.RBraceToken;
foreach (var child in arrayInitializerExpression.Children) {
if (child.Role == Roles.LBrace) {
if (lBrace.StartLocation.Line == rBrace.StartLocation.Line && policy.AllowOneLinedArrayInitialziers) {
ForceSpaceBefore(child, true);
ForceSpacesAfter(child, true);
} else {
FixOpenBrace(policy.ArrayInitializerBraceStyle, child);
}
curIndent.Push(IndentType.Block);
continue;
}
if (child.Role == Roles.RBrace) {
curIndent.Pop();
if (lBrace.StartLocation.Line == rBrace.StartLocation.Line && policy.AllowOneLinedArrayInitialziers) {
ForceSpaceBefore(child, true);
} else {
FixClosingBrace(policy.ArrayInitializerBraceStyle, child);
}
continue;
}
if (child.Role == Roles.Expression) {
if (child.PrevSibling != null) {
if (child.PrevSibling.Role == Roles.NewLine)
FixIndentation(child);
if (child.PrevSibling.Role == Roles.Comma)
ForceSpaceBefore(child, true);
}
child.AcceptVisitor(this);
if (child.NextSibling != null && child.NextSibling.Role == Roles.Comma)
ForceSpacesAfter(child, false);
continue;
}
child.AcceptVisitor(this);
}
}
}
示例2: VisitArrayInitializerExpression
public virtual void VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression)
{
if (this.ThrowException)
{
throw (Exception)this.CreateException(arrayInitializerExpression);
}
}
示例3: VisitArrayInitializerExpression
public override object VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression, object data)
{
if(arrayInitializerExpression.Parent is ArrayCreateExpression)
{
UnlockWith(arrayInitializerExpression);
}
return base.VisitArrayInitializerExpression(arrayInitializerExpression, data);
}
示例4: VisitArrayInitializerExpression
public override void VisitArrayInitializerExpression (ArrayInitializerExpression arrayInitializerExpression)
{
base.VisitArrayInitializerExpression (arrayInitializerExpression);
if (arrayInitializerExpression.IsSingleElement)
return;
var commaToken = arrayInitializerExpression.RBraceToken.PrevSibling as CSharpTokenNode;
if (commaToken == null || commaToken.GetText () != ",")
return;
AddIssue (commaToken, ctx.TranslateString ("Remove redundant comma in array initializer"),
script => script.Remove (commaToken));
}
示例5: VisitArrayInitializerExpression
public override void VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression)
{
if (DoWrap(policy.ArrayInitializerWrapping, arrayInitializerExpression.RBraceToken, arrayInitializerExpression.Elements.Count)) {
FixOpenBrace(policy.ArrayInitializerBraceStyle, arrayInitializerExpression.LBraceToken);
curIndent.Push(IndentType.Block);
foreach (var init in arrayInitializerExpression.Elements) {
FixStatementIndentation(init.StartLocation);
init.AcceptVisitor(this);
}
curIndent.Pop();
FixClosingBrace(policy.ArrayInitializerBraceStyle, arrayInitializerExpression.RBraceToken);
} else if (policy.ArrayInitializerWrapping == Wrapping.DoNotWrap) {
ForceSpacesBeforeRemoveNewLines(arrayInitializerExpression.LBraceToken);
ForceSpacesBeforeRemoveNewLines(arrayInitializerExpression.RBraceToken);
foreach (var init in arrayInitializerExpression.Elements) {
ForceSpacesBeforeRemoveNewLines(init);
init.AcceptVisitor(this);
}
} else {
base.VisitArrayInitializerExpression(arrayInitializerExpression);
}
}
示例6: VisitArrayInitializerExpression
public override void VisitArrayInitializerExpression (ArrayInitializerExpression arrayInitializerExpression)
{
base.VisitArrayInitializerExpression (arrayInitializerExpression);
if (arrayInitializerExpression.IsSingleElement)
return;
var commaToken = arrayInitializerExpression.RBraceToken.PrevSibling as CSharpTokenNode;
if (commaToken == null || commaToken.GetText () != ",")
return;
string initializerType;
if (arrayInitializerExpression.Parent is ObjectCreateExpression) {
if (arrayInitializerExpression.Elements.FirstOrNullObject () is NamedExpression) {
initializerType = "object";
} else {
initializerType = "collection";
}
} else {
initializerType = "array";
}
AddIssue (commaToken,
ctx.TranslateString (string.Format("Remove redundant comma in {0} initializer", initializerType)),
script => script.Remove (commaToken));
}
示例7: VisitArrayInitializerExpression
public override void VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression)
{
new ArrayInitializerBlock(this, arrayInitializerExpression).Emit();
}
示例8: InsertImplicitInitializersForPath
bool InsertImplicitInitializersForPath(AccessPath path)
{
if (accessPaths.ContainsKey(path))
return true;
if (path.MemberPath.Count == 0)
return false;
var parentPath = path.GetParentPath();
var success = InsertImplicitInitializersForPath(parentPath);
if (!success)
return false;
var parentInitializer = accessPaths [parentPath];
var initializer = new ArrayInitializerExpression();
var namedExpression = new NamedExpression(path.MemberPath [path.MemberPath.Count - 1].Name, initializer);
AddToInitializer(parentInitializer, namedExpression);
accessPaths [path] = initializer;
return true;
}
示例9: Visit
public override object Visit(ArrayInitializerExpression arrayInitializerExpression, object data)
{
// no calls allowed !!!
return null;
}
示例10: VisitArrayInitializerExpression
public virtual void VisitArrayInitializerExpression (ArrayInitializerExpression arrayInitializerExpression)
{
VisitChildren (arrayInitializerExpression);
}
示例11: Visit
public override object Visit(ArrayCreation arrayCreationExpression)
{
var result = new ArrayCreateExpression();
var location = LocationsBag.GetLocations(arrayCreationExpression);
result.AddChild(new CSharpTokenNode(Convert(arrayCreationExpression.Location), ArrayCreateExpression.NewKeywordRole), ArrayCreateExpression.NewKeywordRole);
if (arrayCreationExpression.TypeExpression != null)
result.AddChild(ConvertToType(arrayCreationExpression.TypeExpression), Roles.Type);
var next = arrayCreationExpression.Rank;
if (arrayCreationExpression.Arguments != null) {
// skip first array rank.
next = next.Next;
if (location != null)
result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LBracket), Roles.LBracket);
var commaLocations = LocationsBag.GetLocations(arrayCreationExpression.Arguments);
for (int i = 0; i < arrayCreationExpression.Arguments.Count; i++) {
var arg = arrayCreationExpression.Arguments [i];
if (arg != null)
result.AddChild((Expression)arg.Accept(this), Roles.Argument);
if (commaLocations != null && i < commaLocations.Count)
result.AddChild(new CSharpTokenNode(Convert(commaLocations [i]), Roles.Comma), Roles.Comma);
}
if (location != null && location.Count > 1)
result.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.RBracket), Roles.RBracket);
}
while (next != null) {
var spec = new ArraySpecifier(next.Dimension);
var loc = LocationsBag.GetLocations(next);
spec.AddChild(new CSharpTokenNode(Convert(next.Location), Roles.LBracket), Roles.LBracket);
result.AddChild(spec, ArrayCreateExpression.AdditionalArraySpecifierRole);
if (loc != null)
result.AddChild(new CSharpTokenNode(Convert(loc [0]), Roles.RBracket), Roles.RBracket);
next = next.Next;
}
if (arrayCreationExpression.Initializers != null) {
var initLocation = LocationsBag.GetLocations(arrayCreationExpression.Initializers);
var initializer = new ArrayInitializerExpression();
initializer.AddChild(new CSharpTokenNode(Convert(arrayCreationExpression.Initializers.Location), Roles.LBrace), Roles.LBrace);
var commaLocations = LocationsBag.GetLocations(arrayCreationExpression.Initializers.Elements);
for (int i = 0; i < arrayCreationExpression.Initializers.Count; i++) {
var init = arrayCreationExpression.Initializers [i];
if (init == null)
continue;
initializer.AddChild((Expression)init.Accept(this), Roles.Expression);
if (commaLocations != null && i < commaLocations.Count) {
initializer.AddChild(new CSharpTokenNode(Convert(commaLocations [i]), Roles.Comma), Roles.Comma);
}
}
if (initLocation != null) {
if (initLocation.Count == 2) // optional comma
initializer.AddChild(new CSharpTokenNode(Convert(initLocation [0]), Roles.Comma), Roles.Comma);
initializer.AddChild(new CSharpTokenNode(Convert(initLocation [initLocation.Count - 1]), Roles.RBrace), Roles.RBrace);
}
result.AddChild(initializer, ArrayCreateExpression.InitializerRole);
}
return result;
}
示例12: ConvertCollectionOrObjectInitializers
ArrayInitializerExpression ConvertCollectionOrObjectInitializers(CollectionOrObjectInitializers minit)
{
if (minit == null)
return null;
var init = new ArrayInitializerExpression();
AddConvertCollectionOrObjectInitializers(init, minit);
return init;
}
示例13: ConvertElementInit
ArrayInitializerExpression ConvertElementInit(Expression elementsArray)
{
IList<Expression> elements = ConvertExpressionsArray(elementsArray);
if (elements != null) {
return new ArrayInitializerExpression(elements);
}
Match m = elementInitArrayPattern.Match(elementsArray);
if (!m.Success)
return null;
ArrayInitializerExpression result = new ArrayInitializerExpression();
foreach (var elementInit in m.Get<Expression>("addArgumentsArrays")) {
IList<Expression> arguments = ConvertExpressionsArray(elementInit);
if (arguments == null)
return null;
result.Elements.Add(new ArrayInitializerExpression(arguments));
}
return result;
}
示例14: ConvertCollectionOrObjectInitializers
ArrayInitializerExpression ConvertCollectionOrObjectInitializers (CollectionOrObjectInitializers minit)
{
if (minit == null)
return null;
var init = new ArrayInitializerExpression ();
var braceLocs = LocationsBag.GetLocations (minit);
if (braceLocs != null)
init.AddChild (new CSharpTokenNode (Convert (braceLocs[0]), 1), ArrayInitializerExpression.Roles.LBrace);
AddConvertCollectionOrObjectInitializers (init, minit);
if (braceLocs != null)
init.AddChild (new CSharpTokenNode (Convert (braceLocs[1]), 1), ArrayInitializerExpression.Roles.RBrace);
return init;
}
示例15: VisitArrayInitializerExpression
public abstract StringBuilder VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression, int data);