Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Jun 17, 2020
1 parent 3ebccf5 commit 025c04e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,13 @@ private ImmutableArray<IParameterSymbol> DetermineParameters()

private ImmutableArray<ISymbol> DetermineMembers(GenerateTypeOptionsResult options = null)
{
var members = ArrayBuilder<ISymbol>.GetInstance();
using var _ = ArrayBuilder<ISymbol>.GetInstance(out var members);
AddMembers(members, options);

if (_state.IsException)
{
AddExceptionConstructors(members);
}

return members.ToImmutableAndFree();
return members.ToImmutable();
}

private void AddMembers(ArrayBuilder<ISymbol> members, GenerateTypeOptionsResult options = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private ImmutableArray<CodeAction> GetActions(
State state,
CancellationToken cancellationToken)
{
var result = ArrayBuilder<CodeAction>.GetInstance();
using var _ = ArrayBuilder<CodeAction>.GetInstance(out var result);

var generateNewTypeInDialog = false;
if (state.NamespaceToGenerateInOpt != null)
Expand All @@ -127,16 +127,12 @@ private ImmutableArray<CodeAction> GetActions(
}

if (state.TypeToGenerateInOpt != null)
{
result.Add(new GenerateTypeCodeAction((TService)this, document.Document, state, intoNamespace: false, inNewFile: false));
}

if (generateNewTypeInDialog)
{
result.Add(new GenerateTypeCodeActionWithOption((TService)this, document.Document, state));
}

return result.ToImmutableAndFree();
return result.ToImmutable();
}

private static bool CanGenerateIntoContainingNamespace(SemanticDocument semanticDocument, SyntaxNode node, CancellationToken cancellationToken)
Expand Down Expand Up @@ -189,7 +185,7 @@ protected static ImmutableArray<ITypeParameterSymbol> GetTypeParameters(
{
var arguments = typeArguments.ToList();
var arity = arguments.Count;
var typeParameters = ArrayBuilder<ITypeParameterSymbol>.GetInstance();
using var _ = ArrayBuilder<ITypeParameterSymbol>.GetInstance(out var typeParameters);

// For anything that was a type parameter, just use the name (if we haven't already
// used it). Otherwise, synthesize new names for the parameters.
Expand Down Expand Up @@ -227,12 +223,10 @@ protected static ImmutableArray<ITypeParameterSymbol> GetTypeParameters(
for (var i = 0; i < names.Count; i++)
{
if (typeParameters[i] == null || typeParameters[i].Name != names[i])
{
typeParameters[i] = CodeGenerationSymbolFactory.CreateTypeParameterSymbol(names[i]);
}
}

return typeParameters.ToImmutableAndFree();
return typeParameters.ToImmutable();
}

protected static Accessibility DetermineDefaultAccessibility(
Expand Down

0 comments on commit 025c04e

Please sign in to comment.