Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/MarkdownSnippets/Processing/IncludeProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public IncludeProcessor(
this.allFiles = allFiles;
}

public bool TryProcessInclude(List<Line> lines, Line line, List<Include> used, int index, List<MissingInclude> missing, string? relativePath)
public bool TryProcessInclude(List<Line> lines, Line line, ICollection<Include> used, int index, List<MissingInclude> missing, string? relativePath)
{
var current = line.Current;

Expand Down Expand Up @@ -79,7 +79,7 @@ static string GetIncludeKey(CharSpan substring)
return false;
}

void Inner(List<Line> lines, Line line, List<Include> used, int index, List<MissingInclude> missing, string includeKey, string? relativePath)
void Inner(List<Line> lines, Line line, ICollection<Include> used, int index, List<MissingInclude> missing, string includeKey, string? relativePath)
{
if (includesLookup.TryGetValue(includeKey, out var include))
{
Expand Down Expand Up @@ -125,7 +125,7 @@ void Inner(List<Line> lines, Line line, List<Include> used, int index, List<Miss
line.Current = $"** Could not find include '{includeKey}' ** <!-- singleLineInclude: {includeKey} -->";
}

void AddInclude(List<Line> lines, Line line, List<Include> used, int index, Include include, bool writePath)
void AddInclude(List<Line> lines, Line line, ICollection<Include> used, int index, Include include, bool writePath)
{
used.Add(include);
var linesToInject = BuildIncludes(line, include, writePath).ToList();
Expand Down
14 changes: 7 additions & 7 deletions src/MarkdownSnippets/Processing/MarkdownProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ internal ProcessResult Apply(List<Line> lines, string newLine, string? relativeP
var missingSnippets = new List<MissingSnippet>();
var validationErrors = new List<ValidationError>();
var missingIncludes = new List<MissingInclude>();
var usedSnippets = new List<Snippet>();
var usedIncludes = new List<Include>();
var usedSnippets = new HashSet<Snippet>();
var usedIncludes = new HashSet<Include>();
var builder = new StringBuilder();
Line? tocLine = null;

Expand Down Expand Up @@ -263,8 +263,8 @@ void AppendWebSnippet(string url, string snippetKey, string? viewUrl = null)

return new(
missingSnippets: missingSnippets,
usedSnippets: usedSnippets.Distinct().ToList(),
usedIncludes: usedIncludes.Distinct().ToList(),
usedSnippets: usedSnippets.ToList(),
usedIncludes: usedIncludes.ToList(),
missingIncludes: missingIncludes,
validationErrors: validationErrors);
}
Expand Down Expand Up @@ -292,15 +292,15 @@ bool ValidateContent(string? relativePath, Line line, List<ValidationError> vali
return found;
}

void ProcessSnippetLine(Action<string> appendLine, List<MissingSnippet> missings, List<Snippet> used, string key, string? relativePath, Line line)
void ProcessSnippetLine(Action<string> appendLine, List<MissingSnippet> missings, HashSet<Snippet> used, string key, string? relativePath, Line line)
{
appendLine($"<!-- snippet: {key} -->");

if (TryGetSnippets(key, relativePath, line.Path, out var snippetsForKey))
{
appendSnippets(key, snippetsForKey, appendLine);
appendLine("<!-- endSnippet -->");
used.AddRange(snippetsForKey);
used.UnionWith(snippetsForKey);
return;
}

Expand All @@ -312,7 +312,7 @@ void ProcessSnippetLine(Action<string> appendLine, List<MissingSnippet> missings
appendLine("<!-- endSnippet -->");
}

void ProcessWebSnippetLine(Action<string> appendLine, List<MissingSnippet> missings, List<Snippet> used, string url, string snippetKey, string? viewUrl, Line line)
void ProcessWebSnippetLine(Action<string> appendLine, List<MissingSnippet> missings, HashSet<Snippet> used, string url, string snippetKey, string? viewUrl, Line line)
{
var commentText = viewUrl == null
? $"<!-- web-snippet: {url}#{snippetKey} -->"
Expand Down
Loading