Skip to content

Commit

Permalink
Set legacy indexer as default (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcz717 committed Mar 30, 2022
1 parent 6ef2215 commit 5ec04b4
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion LsifDotnet.Benchmark/SelfEmit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public async Task AsyncEnumerable()
const string fileName =
$@"F:\Code\Science\LsifDotnet\LsifDotnet.Benchmark\bin\Release\test\{nameof(AsyncEnumerable)}.lsif";
await IndexHandler.Process(_host!, SolutionFileInfo, new FileInfo(fileName),
CultureInfo.CurrentUICulture, false, false, true, true, 4, 0);
CultureInfo.CurrentUICulture, false, false, true, 4, 0);
}

[Benchmark]
Expand Down
4 changes: 2 additions & 2 deletions LsifDotnet/IndexHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace LsifDotnet;
public class IndexHandler
{
public static async Task Process(IHost host, FileInfo? solutionFile, FileInfo output, CultureInfo culture, bool dot,
bool svg, bool quiet, bool legacy, uint parallelism, uint index)
bool svg, bool quiet, uint parallelism, uint index)
{
var logger = host.Services.GetRequiredService<ILogger<IndexHandler>>();
ConfigLoggingLevel(host, quiet);
Expand All @@ -33,7 +33,7 @@ public static async Task Process(IHost host, FileInfo? solutionFile, FileInfo ou
var defaultCulture = CultureInfo.CurrentUICulture;
CultureInfo.CurrentUICulture = culture;

if (legacy)
if (parallelism is 0)
await LegacyLsifIndex(host, logger, output, dot, svg);
else
await DataFlowLsifIndex(host, logger, output, dot, svg, parallelism, index);
Expand Down
21 changes: 16 additions & 5 deletions LsifDotnet/Lsif/DataFlowLsifIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class DataFlowLsifIndexer
private int _initId;

public DataFlowLsifIndexer(Workspace workspace, IdentifierCollectorFactory identifierCollectorFactory,
ILogger<LegacyLsifIndexer> logger)
ILogger<DataFlowLsifIndexer> logger)
{
Workspace = workspace;
IdentifierCollectorFactory = identifierCollectorFactory;
Expand All @@ -30,7 +30,7 @@ public DataFlowLsifIndexer(Workspace workspace, IdentifierCollectorFactory ident

public Workspace Workspace { get; }
public IdentifierCollectorFactory IdentifierCollectorFactory { get; }
protected ILogger<LegacyLsifIndexer> Logger { get; }
protected ILogger<DataFlowLsifIndexer> Logger { get; }

public int EmittedItem => _emittedItem - _initId;

Expand Down Expand Up @@ -214,7 +214,14 @@ await hoverHandleBlock.SendAsync(new HoverContentRequest(resultSetVertex.Id, doc
}
}


/// <summary>
/// Build a block that emits a single Lsif item for async enumerable of <see cref="T2"/>
/// </summary>
/// <typeparam name="T1">The transform parameter type</typeparam>
/// <typeparam name="T2">The async output Type</typeparam>
/// <param name="transform">The async transform</param>
/// <param name="executionDataflowBlockOptions">The options</param>
/// <returns></returns>
public static IPropagatorBlock<T1, T2> TransformAsyncEnumerable<T1, T2>(Func<T1, IAsyncEnumerable<T2>> transform,
ExecutionDataflowBlockOptions? executionDataflowBlockOptions = null)
{
Expand Down Expand Up @@ -296,11 +303,15 @@ private static bool NotKnownIdentifier(SyntaxToken token)
/// </summary>
internal const string NullabilityAnalysis = nameof(NullabilityAnalysis);

private static async Task<List<string>> GenerateHoverContent(QuickInfoService quickInfoService, Document document,
private async Task<List<string>> GenerateHoverContent(QuickInfoService quickInfoService, Document document,
int position)
{
var quickInfo = await quickInfoService.GetQuickInfoAsync(document, position);
Debug.Assert(quickInfo != null, nameof(quickInfo) + " != null");
if (quickInfo == null)
{
Logger.LogWarning("No quick info found at {position}", position);
return new List<string>();
}

var contents = new List<string>();

Expand Down
10 changes: 8 additions & 2 deletions LsifDotnet/Lsif/LegacyLsifIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,17 @@ private static bool NotKnownIdentifier(SyntaxToken token)
/// </summary>
internal const string NullabilityAnalysis = nameof(NullabilityAnalysis);

private static async Task<List<string>> GenerateHoverContent(QuickInfoService quickInfoService, Document document,
private async Task<List<string>> GenerateHoverContent(QuickInfoService quickInfoService, Document document,
SyntaxToken token)
{
var quickInfo = await quickInfoService.GetQuickInfoAsync(document, token.SpanStart);
Debug.Assert(quickInfo != null, nameof(quickInfo) + " != null");

if (quickInfo == null)
{
Logger.LogWarning("No quick info found for {token.Value} at {token.GetLocation()}", token.Value,
token.GetLocation());
return new List<string>();
}

var contents = new List<string>();

Expand Down
8 changes: 2 additions & 6 deletions LsifDotnet/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ private static CommandLineBuilder BuildCommandLine()
var quietOption = new Option<bool>("--quiet", "Be more quiet");
quietOption.AddAlias("-q");

var legacyOption = new Option<bool>("--legacy", "Use the legacy indexer, relative slow but need less memory");
legacyOption.AddAlias("-l");

var parallelismOption = new Option<uint>("--parallelism", () => 4,
"How many hover content generation tasks can be handled at the same time.");
var parallelismOption = new Option<uint>("--parallelism",
"How many hover content generation tasks can be handled at the same time. When unset or set to 0, use legacy indexer, relative slow but need less memory.");
parallelismOption.AddAlias("-p");

var startIndexOption = new Option<uint>("--index",
Expand All @@ -69,7 +66,6 @@ private static CommandLineBuilder BuildCommandLine()
svgOption,
cultureOption,
quietOption,
legacyOption,
parallelismOption,
startIndexOption
};
Expand Down

0 comments on commit 5ec04b4

Please sign in to comment.