public static async Task ComputeRefactoringAsync( RefactoringContext context, LocalDeclarationStatementSyntax localDeclaration) { if (localDeclaration.IsEmbedded()) { return; } SingleLocalDeclarationStatementInfo localInfo = SyntaxInfo.SingleLocalDeclarationStatementInfo(localDeclaration); if (!localInfo.Success) { return; } if (!context.Span.IsEmptyAndContainedInSpan(localInfo.EqualsToken)) { return; } ExpressionSyntax value = localInfo.Initializer?.Value; if (value == null) { return; } SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false); TypeSyntax type = localInfo.Type; if (type.IsVar) { ITypeSymbol typeSymbol = semanticModel.GetTypeSymbol(value, context.CancellationToken); if (typeSymbol?.SupportsExplicitDeclaration() != true) { return; } type = typeSymbol.ToMinimalTypeSyntax(semanticModel, type.SpanStart); } else { ITypeSymbol typeSymbol = semanticModel.GetTypeSymbol(type, context.CancellationToken); if (typeSymbol?.IsErrorType() != false) { return; } } context.RegisterRefactoring( "Split declaration and initialization", f => RefactorAsync(context.Document, localInfo, type, f)); }