public async System.Threading.Tasks.Task<IEnumerable<CodeAction>> GetRefactoringsAsync(Document document, TextSpan textSpan, CancellationToken cancellationToken) { if (textSpan.IsEmpty) { return null; } if (String.IsNullOrWhiteSpace(document.GetText().GetSubText(textSpan).ToString())) { return null; } var tree = (SyntaxTree)document.GetSyntaxTree(cancellationToken); var diagnostics = tree.GetDiagnostics(cancellationToken); if (diagnostics.Any(d => d.Severity == DiagnosticSeverity.Error || d.IsWarningAsError)) return null; var linespan = tree.GetLocation(textSpan).GetLineSpan(false); if (linespan.EndLinePosition.Line <= linespan.StartLinePosition.Line) return null; // single line var semanticModel = (SemanticModel)document.GetSemanticModel(cancellationToken); var sdiag = semanticModel.GetDiagnostics(cancellationToken); if (sdiag == null) return null; if (sdiag.Any(d => d.Severity == DiagnosticSeverity.Error || d.IsWarningAsError)) return null; var methodExtractor = new MethodExtractor(semanticModel, document, textSpan, this.options); var newDocument = methodExtractor.GetRefactoredDocument(cancellationToken); if (newDocument == null) return null; var action = new ClousotExtractMethodAction(newDocument); return new List<CodeAction>{ action }; }