Skip to content

Commit

Permalink
Restructure possible inferred symbol ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
dpoeschl committed May 27, 2020
1 parent ddea455 commit 15bc3ea
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -934,17 +934,23 @@ protected virtual async Task<SeparatedSyntaxList<SyntaxNode>> AddNewArgumentsToL
semanticModel, position, workspace, cancellationToken: cancellationToken).ConfigureAwait(false);

var sourceSymbols = recommendations.Where(r => r.IsNonImplicitAndFromSource());
var sourceSymbolsWithTypes = sourceSymbols.Where(s => s.GetSymbolType() != null);
var orderedSourceSymbolsWithTypes = sourceSymbolsWithTypes.OrderByDescending(s => s.Locations.First().SourceSpan.Start);
var orderedLocalAndParameterSymbols = sourceSymbols
.Where(s => s.IsKind(SymbolKind.Local) || s.IsKind(SymbolKind.Parameter))
.OrderByDescending(s => s.Locations.First().SourceSpan.Start);

var localsAndParameters = orderedSourceSymbolsWithTypes.Where(s => s.IsKind(SymbolKind.Local) || s.IsKind(SymbolKind.Parameter));
var propertiesAndFields = orderedSourceSymbolsWithTypes.Where(s => s.IsKind(SymbolKind.Property) || s.IsKind(SymbolKind.Field));
var orderedPropertiesAndFields = sourceSymbols
.Where(s => s.IsKind(SymbolKind.Property) || s.IsKind(SymbolKind.Field))
.OrderByDescending(s => s.Locations.First().SourceSpan.Start);

var fullyOrderedSymbolsByKind = localsAndParameters.Concat(propertiesAndFields);
var fullyOrderedSymbols = orderedLocalAndParameterSymbols.Concat(orderedPropertiesAndFields);

foreach (var symbol in fullyOrderedSymbolsByKind)
foreach (var symbol in fullyOrderedSymbols)
{
var symbolType = symbol.GetSymbolType();
if (symbolType == null)
{
continue;
}

if (semanticModel.Compilation.ClassifyCommonConversion(symbolType, targetType).IsImplicit)
{
Expand Down

0 comments on commit 15bc3ea

Please sign in to comment.