Update documentation packages to latest versions

* HighlightService was modified to support GetClassifiedSpansAsync method
* Updated Program.cs to pull in the proper location of the Json and ImageSharp extension projects
* Statiq must have changed how they are doing xrefs, so I adjusted those to be more specific with a few links
This commit is contained in:
Phil Scott
2024-11-22 22:02:09 -05:00
committed by Patrik Svensson
parent ab8384acf6
commit 43e9669395
12 changed files with 39 additions and 26 deletions

View File

@ -15,7 +15,7 @@
<div id="container">
<div id="console">
<div class="line"><span style="color:var(--brightBlack)">╭─</span><span style="color:var(--folder)">&#xe0b2;</span><span style="background-color:var(--folder);color:var(--black)"> ~/spectre.console</span><span style="color:var(--folder);background-color:var(--dotnet)">&#xe0b0;</span><span style="background-color:var(--blue)"> .NET 8.0 </span><span style="color:var(--dotnet);background-color:var(--git)">&#xe0b0;</span><span style="background-color:var(--git);color:var(--background)"> &#xe0a0; main </span><span style="color:var(--git)">&#xe0b4;</span></div>
<div class="line"><span style="color:var(--brightBlack)">╭─</span><span style="color:var(--folder)">&#xe0b2;</span><span style="background-color:var(--folder);color:var(--black)"> ~/spectre.console</span><span style="color:var(--folder);background-color:var(--dotnet)">&#xe0b0;</span><span style="background-color:var(--blue)"> .NET 9.0 </span><span style="color:var(--dotnet);background-color:var(--git)">&#xe0b0;</span><span style="background-color:var(--git);color:var(--background)"> &#xe0a0; main </span><span style="color:var(--git)">&#xe0b4;</span></div>
<div class="line"><span style="color:var(--brightBlack)">╰─</span> dotnet run</div>
<div class="line"></div>
<div class="line">╭────────────────────────────────────────────────────────╮</div>

View File

@ -58,21 +58,31 @@ internal static class HighlightService
}
var text = await syntaxReference.SyntaxTree.GetTextAsync();
// we need a workspace, but it seems it is only used to resolve a few services and nothing else so an empty one will suffice
return HighlightElement(_emptyWorkspace, model, text, textSpan, indent);
// we need a document for the syntax highlighter, so create a temporary solution and project to hold it.
var workspace = new AdhocWorkspace();
var solution = workspace.CurrentSolution
.AddProject("TempProject", "TempProject", "C#")
.AddDocument("TempDocument", await syntaxReference.SyntaxTree.GetTextAsync());
var document = solution.Project.Documents.First();
var highlightElement = await HighlightElement(document, text, textSpan, indent);
return highlightElement;
}
private static int GetIndent(SyntaxTriviaList leadingTrivia)
{
var whitespace = leadingTrivia.FirstOrDefault(i => i.Kind() == SyntaxKind.WhitespaceTrivia);
var whitespace = leadingTrivia.FirstOrDefault(i => i.IsKind(SyntaxKind.WhitespaceTrivia));
return whitespace == default ? 0 : whitespace.Span.Length;
}
private static string HighlightElement(Workspace workspace, SemanticModel semanticModel, SourceText fullSourceText,
private static async Task<string> HighlightElement(Document document,
SourceText fullSourceText,
TextSpan textSpan, int indent)
{
var classifiedSpans = Classifier.GetClassifiedSpans(semanticModel, textSpan, workspace);
var classifiedSpans = await Classifier.GetClassifiedSpansAsync(document, textSpan);
return HighlightElement(classifiedSpans, fullSourceText, indent);
}