public void MarkSegment(AstNode node, int startLine, int startColumn, string name, Context context) { if (node == null || string.IsNullOrEmpty(name)) { return; } // see if this is within a function object node, // AND if this segment has the same name as the function name // AND this context isn't the same as the entire function context. // this should only be true for the function NAME segment. var functionObject = node as FunctionObject; if (functionObject != null && string.CompareOrdinal(name, functionObject.Name) == 0 && context != functionObject.Context) { // it does -- so this is the segment that corresponds to the function object's name, which // for this format we want to output a separate segment for. It used to be its own Lookup // node child of the function object, so we need to create a fake node here, start a new // symbol from it, end the symbol, then write it. var fakeLookup = new Lookup(context, functionObject.Parser) { Name = name }; var nameSymbol = JavaScriptSymbol.StartNew(fakeLookup, startLine, startColumn, GetSourceFileIndex(functionObject.Context.Document.FileContext)); // the name will never end on a different line -- it's a single unbreakable token. The length is just // the length of the name, so add that number to the column start. And the parent context is the function // name (again) nameSymbol.End(startLine, startColumn + name.Length, name); nameSymbol.WriteTo(m_writer); } }
public object StartSymbol(AstNode node, int startLine, int startColumn) { if (node != null && !node.Context.Document.IsGenerated) { return(JavaScriptSymbol.StartNew(node, startLine, startColumn, GetSourceFileIndex(node.Context.Document.FileContext))); } return(null); }
public ScriptSharpSourceMap(TextWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } var settings = new XmlWriterSettings() { CloseOutput = true, Indent = true }; m_writer = XmlWriter.Create(writer, settings); m_writer.WriteStartDocument(); m_writer.WriteStartElement("map"); JavaScriptSymbol.WriteHeadersTo(m_writer); m_writer.WriteStartElement("scriptFiles"); }