public void Dispose() { if (_addLineMapping) { // Verify that the generated length has not already been calculated if (_generatedContentLength == 0) { _generatedContentLength = _writer.GenerateCode().Length - _generatedLocation.AbsoluteIndex; } var generatedLocation = new MappingLocation(_generatedLocation, _generatedContentLength); var documentMapping = _documentMapping; if (documentMapping.ContentLength == -1) { documentMapping = new MappingLocation( location: new SourceLocation( _documentMapping.FilePath, _documentMapping.AbsoluteIndex, _documentMapping.LineIndex, _documentMapping.CharacterIndex), contentLength: _generatedContentLength); } _writer.LineMappingManager.AddMapping( documentLocation: documentMapping, generatedLocation: generatedLocation); } if (_writePragmas) { // Need to add an additional line at the end IF there wasn't one already written. // This is needed to work with the C# editor's handling of #line ... var endsWithNewline = _writer.GenerateCode().EndsWith("\n"); // Always write at least 1 empty line to potentially separate code from pragmas. _writer.WriteLine(); // Check if the previous empty line wasn't enough to separate code from pragmas. if (!endsWithNewline) { _writer.WriteLine(); } _writer.WriteLineDefaultDirective() .WriteLineHiddenDirective(); } // Reset indent back to when it was started _writer.SetIndent(_startIndent); }
public void Dispose() { if (_addLineMapping) { // Verify that the generated length has not already been calculated if (_generatedContentLength == 0) { _generatedContentLength = _writer.GenerateCode().Length - _generatedLocation.AbsoluteIndex; } var generatedLocation = new MappingLocation(_generatedLocation, _generatedContentLength); var documentMapping = _documentMapping; if (documentMapping.ContentLength == -1) { documentMapping = new MappingLocation( location: new SourceLocation( _documentMapping.AbsoluteIndex, _documentMapping.LineIndex, _documentMapping.CharacterIndex), contentLength: _generatedContentLength); } _writer.LineMappingManager.AddMapping( documentLocation: documentMapping, generatedLocation: generatedLocation); } if (_writePragmas) { // Need to add an additional line at the end IF there wasn't one already written. // This is needed to work with the C# editor's handling of #line ... var endsWithNewline = _writer.GenerateCode().EndsWith("\n"); // Always write at least 1 empty line to potentially separate code from pragmas. _writer.WriteLine(); // Check if the previous empty line wasn't enough to separate code from pragmas. if (!endsWithNewline) { _writer.WriteLine(); } _writer.WriteLineDefaultDirective() .WriteLineHiddenDirective(); } // Reset indent back to when it was started _writer.SetIndent(_startIndent); }
public CSharpLineMappingWriter(CSharpCodeWriter writer, SourceLocation documentLocation, int contentLength) : this(writer, addLineMappings: true) { _documentMapping = new MappingLocation(documentLocation, contentLength); _generatedLocation = _writer.GetCurrentSourceLocation(); }
public LineMapping(MappingLocation documentLocation, MappingLocation generatedLocation) { DocumentLocation = documentLocation; GeneratedLocation = generatedLocation; }
public void AddMapping(MappingLocation documentLocation, MappingLocation generatedLocation) { Mappings.Add(new LineMapping(documentLocation, generatedLocation)); }
public CSharpLineMappingWriter(CSharpCodeWriter writer, SourceLocation documentLocation, int contentLength) : this(writer, addLineMappings : true) { _documentMapping = new MappingLocation(documentLocation, contentLength); _generatedLocation = _writer.GetCurrentSourceLocation(); }