public Classify ( Microsoft.CodeAnalysis.Document document, Microsoft.CodeAnalysis.Text.SourceText text ) : Task |
||
document | Microsoft.CodeAnalysis.Document | |
text | Microsoft.CodeAnalysis.Text.SourceText | |
Résultat | Task |
private async Task GenerateHtml(StreamWriter writer) { var title = Document.Name; var lineCount = Text.Lines.Count; // if the document is very long, pregenerate line numbers statically // to make the page load faster and avoid JavaScript cost bool pregenerateLineNumbers = IsLargeFile(lineCount); // pass a value larger than 0 to generate line numbers in JavaScript (to reduce HTML size) var prefix = Markup.GetDocumentPrefix(title, relativePathToRoot, pregenerateLineNumbers ? 0 : lineCount); writer.Write(prefix); GenerateHeader(writer.WriteLine); var ranges = (await classifier.Classify(Document, Text)).ToArray(); // pass a value larger than 0 to generate line numbers statically at HTML generation time var table = Markup.GetTablePrefix( DocumentUrl, pregenerateLineNumbers ? lineCount : 0, GenerateGlyphs(ranges)); writer.WriteLine(table); GeneratePre(ranges, writer, lineCount); var suffix = Markup.GetDocumentSuffix(); writer.WriteLine(suffix); }
private async Task GeneratePre(StreamWriter writer, int lineCount = 0) { var ranges = await classifier.Classify(Document, Text); if (ranges == null) { // if there was an error in Roslyn, don't fail the entire index, just return return; } foreach (var range in ranges) { string html = GenerateRange(writer, range, lineCount); writer.Write(html); } }