public override bool Walk(ObjectLiteral node) { if (node != null) { foreach (var prop in node.Properties) { prop.Walk(this); } } return(false); }
public override bool Walk(ObjectLiteral node) { // If a single file has a bunch of duplicate ObjectLiteral values with the same // property names we will merge them together into a single ObjectLiteralValue to // avoid an explosion in object literals. We only do this for literals with // at least one member defined. if (node.Properties.Length > 0) { // first see if we have a object literal that we should share with... string[] propNames = new string[node.Properties.Length]; for (int i = 0; i < node.Properties.Length; i++) { string propName = null; if (node.Properties[i].Name.Value != null) { propName = node.Properties[i].Name.Value.ToString(); } propNames[i] = propName; } var key = new ObjectLiteralKey(propNames); IAnalysisSet value; if (_scope.GlobalEnvironment.TryGetNodeValue( NodeEnvironmentKind.ObjectLiteralValue, key, out value)) { // cache the value under our node... _scope.GlobalEnvironment.AddNodeValue( NodeEnvironmentKind.ObjectLiteralValue, node, value ); } else { // create the value and cache it under oru node and the // shared key. var objLiteral = new ObjectLiteralValue(_entry, node); _scope.GlobalEnvironment.AddNodeValue( NodeEnvironmentKind.ObjectLiteralValue, node, objLiteral.Proxy ); _scope.GlobalEnvironment.AddNodeValue( NodeEnvironmentKind.ObjectLiteralValue, key, objLiteral.Proxy ); } } else { _scope.GlobalEnvironment.AddNodeValue( NodeEnvironmentKind.ObjectLiteralValue, node, new ObjectLiteralValue(_entry, node).Proxy ); } return base.Walk(node); }
public override bool Walk(ObjectLiteral node) { AddNode(node); return true; }
public override bool Walk(ObjectLiteral node) { if (node != null) { foreach (var prop in node.Properties) { prop.Walk(this); } } return false; }
public override bool Walk(ObjectLiteral node) { if (_typedChar == '}' && node.GetEndIndex(_tree.LocationResolver) == _position) { Span = node.GetSpan(_tree.LocationResolver); return false; } return base.Walk(node); }
public override bool Walk(ObjectLiteral node) { bool isMultiLine = ContainsLineFeed(node.GetStartIndex(_tree.LocationResolver), node.GetEndIndex(_tree.LocationResolver)); // Body. if (node.Properties.Length != 0) { Indent(); if (isMultiLine) { // multiline block statement, make sure the 1st statement // starts on a new line EnsureNewLineFollowing(node.GetStartIndex(_tree.LocationResolver) + "{".Length); } WalkStatements(node, node.Properties, isMultiLine); Dedent(); } // Format the indentation of the block along with whitespace. if (isMultiLine) { ReplacePreceedingIncludingNewLines(node.GetEndIndex(_tree.LocationResolver) - 1, ReplaceWith.InsertNewLineAndIndentation, replaceOnNewLine: true); } else if (node.Properties.Length == 0) { ReplacePreceedingWhiteSpace(node.GetEndIndex(_tree.LocationResolver) - 1, ""); } else { ReplacePreceedingWhiteSpace(node.GetEndIndex(_tree.LocationResolver) - 1, " "); } return false; }