public async Task Disabled() { var markup = @"from os import path [|socket|]()"; MarkupUtils.GetSpan(markup, out var code, out var span); var analysis = await GetAnalysisAsync(code); var diagnostics = GetDiagnostics(analysis, span.ToSourceSpan(analysis.Ast), MissingImportCodeActionProvider.Instance.FixableDiagnostics); diagnostics.Should().NotBeEmpty(); var codeActions = await new QuickFixCodeActionSource(analysis.ExpressionEvaluator.Services).GetCodeActionsAsync(analysis, CodeActionSettings.Default, diagnostics, TestCancellationToken); codeActions.Should().NotBeEmpty(); var emptyActions = await new QuickFixCodeActionSource(analysis.ExpressionEvaluator.Services).GetCodeActionsAsync( analysis, new CodeActionSettings(null, new Dictionary <string, object>() { { "addimports", false } }), diagnostics, TestCancellationToken); emptyActions.Should().BeEmpty(); }
public async Task Missing() { MarkupUtils.GetSpan(@"[|missingModule|]", out var code, out var span); var analysis = await GetAnalysisAsync(code); var diagnostics = GetDiagnostics(analysis, span.ToSourceSpan(analysis.Ast), MissingImportCodeActionProvider.Instance.FixableDiagnostics); diagnostics.Should().NotBeEmpty(); var codeActions = await new QuickFixCodeActionSource(analysis.ExpressionEvaluator.Services).GetCodeActionsAsync(analysis, CodeActionSettings.Default, diagnostics, TestCancellationToken); codeActions.Should().BeEmpty(); }
public async Task CodeActionOrdering() { MarkupUtils.GetSpan(@"def TestMethod(): [|test|]", out var code, out var span); var analysis = await GetAnalysisAsync(code); var diagnostics = GetDiagnostics(analysis, span.ToSourceSpan(analysis.Ast), MissingImportCodeActionProvider.Instance.FixableDiagnostics); diagnostics.Should().NotBeEmpty(); var codeActions = await new QuickFixCodeActionSource(analysis.ExpressionEvaluator.Services).GetCodeActionsAsync(analysis, CodeActionSettings.Default, diagnostics, TestCancellationToken); var list = codeActions.Select(c => c.title).ToList(); var zipList = Enumerable.Range(0, list.Count).Zip(list); var locallyImportedPrefix = Resources.ImportLocally.Substring(0, Resources.ImportLocally.IndexOf("'")); var maxIndexOfTopAddImports = zipList.Where(t => !t.Second.StartsWith(locallyImportedPrefix)).Max(t => t.First); var minIndexOfLocalAddImports = zipList.Where(t => t.Second.StartsWith(locallyImportedPrefix)).Min(t => t.First); maxIndexOfTopAddImports.Should().BeLessThan(minIndexOfLocalAddImports); }