Skip to content

Commit

Permalink
chore: rename and add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyMakkison committed Nov 24, 2023
1 parent 4af3ae1 commit 2e74d8c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static class DerivedTypeMappingBuilder
private static IReadOnlyCollection<TMapping> BuildContainedMappings<TMapping>(
MappingBuilderContext ctx,
IReadOnlyCollection<DerivedTypeMappingConfiguration> configs,
Func<ITypeSymbol, ITypeSymbol, MappingBuildingOptions, Location?, TMapping?> mappingFunction,
Func<ITypeSymbol, ITypeSymbol, MappingBuildingOptions, Location?, TMapping?> findOrBuildMapping,
bool duplicatedSourceTypesAllowed
)
where TMapping : ITypeMapping
Expand Down Expand Up @@ -91,7 +91,7 @@ bool duplicatedSourceTypesAllowed
continue;
}

var mapping = mappingFunction(
var mapping = findOrBuildMapping(
sourceType,
targetType,
MappingBuildingOptions.KeepUserSymbol | MappingBuildingOptions.MarkAsReusable | MappingBuildingOptions.ClearDerivedTypes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public override IEnumerable<StatementSyntax> Build(TypeMappingBuildContext ctx,

private SwitchSectionSyntax BuildSwitchSection(TypeMappingBuildContext ctx, IExistingTargetMapping mapping)
{
var (sectionCtx, sourceVariableName) = ctx.WithNewScopedSource(IdentifierName, SourceName);
var (sectionCtx, sourceVariableName) = ctx.WithNewScopedSource(SourceName);
var targetVariableName = sectionCtx.NameBuilder.New(TargetName);
sectionCtx = sectionCtx.AddIndentation();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,18 @@ SyntaxFactoryHelper syntaxFactory
/// builds the name of the source in this new scope
/// and creates a new context with the new source.
/// </summary>
/// <param name="sourceName">The name for the new scoped source.</param>
/// <returns>The new context and the scoped name of the source.</returns>
public (TypeMappingBuildContext Context, string SourceName) WithNewScopedSource() => WithNewScopedSource(IdentifierName);
public (TypeMappingBuildContext Context, string SourceName) WithNewScopedSource(string sourceName = DefaultSourceName) =>
WithNewScopedSource(IdentifierName, sourceName);

/// <summary>
/// Creates a new scoped name builder,
/// builds the name of the source in this new scope
/// and creates a new context with the new source.
/// </summary>
/// <param name="sourceBuilder">A function to build the source access for the new context.</param>
/// <param name="sourceName">The name for the new scoped source.</param>
/// <returns>The new context and the scoped name of the source.</returns>
public (TypeMappingBuildContext Context, string SourceName) WithNewScopedSource(
Func<string, ExpressionSyntax> sourceBuilder,
Expand Down

0 comments on commit 2e74d8c

Please sign in to comment.