private Dictionary <ISymbol, List <SyntaxToken> > GetSymbolMap(SemanticModel model) { var context = _selectionResult.GetContainingScope(); var symbolMap = SymbolMapBuilder.Build(model, context, _selectionResult.GetFinalSpan(), _cancellationToken); return(symbolMap); }
public async Task <SemanticDocument> GenerateAsync(CancellationToken cancellationToken) { // Call Site Method Replacement var root = _semanticDocument.Root; root = root.ReplaceNode(_selectionResult.GetContainingScope(), await GenerateBodyForCallSiteContainerAsync(cancellationToken).ConfigureAwait(false)); var callSiteDocument = await _semanticDocument.WithSyntaxRootAsync(root, cancellationToken).ConfigureAwait(false); // New Method Insertion root = callSiteDocument.Root; var destination = root.DescendantNodes().OfType <ClassDeclarationSyntax>().First(); var extractedMethod = GenerateMethodDefinition(cancellationToken); var newDestination = destination.AddMembers(extractedMethod); root = root.ReplaceNode(destination, newDestination); var newMethodDocument = await callSiteDocument.WithSyntaxRootAsync(root, cancellationToken).ConfigureAwait(false); return(newMethodDocument); }