Path: blob/main/extensions/copilot/test/inline/fixing.stest.ts
13388 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/4import assert from 'assert';5import { Intent } from '../../src/extension/common/constants';6import '../../src/extension/intents/node/allIntents';7import { ssuite, stest } from '../base/stest';8import { KnownDiagnosticProviders } from '../simulation/diagnosticProviders';9import { forInlineChatIntent, simulateInlineChatWithStrategy } from '../simulation/inlineChatSimulator';10import { assertLessDiagnosticsAsync, assertNoDiagnosticsAsync, getWorkspaceDiagnostics } from '../simulation/outcomeValidators';11import { assertConversationalOutcome, assertInlineEdit, assertNoOccurrence, assertOccursOnce, fromFixture, toFile } from '../simulation/stestUtil';121314forInlineChatIntent((strategy, nonExtensionConfigurations, suffix) => {1516ssuite({ title: `fix${suffix}`, subtitle: 'ruff', location: 'inline' }, () => {17stest({ description: `Ruff(E231) Missing whitespace after ':'`, language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {18return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {19files: [fromFixture('fixing/ruff/ruff_error_E231.py')],20queries: [21{22file: 'ruff_error_E231.py',23selection: [5, 1, 5, 10],24query: [25`/fix Missing whitespace after ':'`,26`To fix the problem.`27].join('\n'),28expectedIntent: Intent.Fix,29diagnostics: 'ruff',30validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'ruff')31}32]33});34});35});3637ssuite({ title: `fix${suffix}`, subtitle: 'TSC', location: 'inline' }, () => {38stest({ description: 'Error 2322 - type undefined is not assignable to type', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {39return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {40files: [fromFixture('fixing/typescript/tsc_error_2322.ts')],41queries: [42{43file: 'tsc_error_2322.ts',44selection: [37, 10, 37, 10],45query: [46`/fix Type 'RangeMapping[] | undefined' is not assignable to type 'RangeMapping[]'. `,47` Type 'undefined' is not assignable to type 'RangeMapping[]'.`48].join('\n'),49expectedIntent: Intent.Fix,50diagnostics: 'tsc',51validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')52}53]54});55});5657stest({ description: '22222 Error 2322 - type undefined is not assignable to type', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {58return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {59files: [fromFixture('fixing/typescript/tsc_error_2322.ts')],60queries: [61{62file: 'tsc_error_2322.ts',63selection: [37, 10, 37, 10],64query: [65`/fix Type 'RangeMapping[] | undefined' is not assignable to type 'RangeMapping[]'. `,66` Type 'undefined' is not assignable to type 'RangeMapping[]'.`67].join('\n'),68expectedIntent: Intent.Fix,69diagnostics: 'tsc',70validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')71}72]73});74});7576stest({ description: 'Error 1015 - parameter cannot have question mark and initializer, with corresponding diagnostics', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {77return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {78files: [fromFixture('fixing/typescript/tsc_error_1015.ts')],79queries: [80{81file: 'tsc_error_1015.ts',82selection: [0, 24, 0, 24],83query: `/fix Parameter cannot have question mark and initializer.`,84expectedIntent: Intent.Fix,85diagnostics: 'tsc',86validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')87}88]89});90});9192stest({ description: 'Error 1015 - parameter cannot have question mark and initializer, without corresponding diagnostics', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {93return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {94files: [fromFixture('fixing/typescript/tsc_error_1015.ts')],95queries: [96{97file: 'tsc_error_1015.ts',98selection: [0, 24, 0, 24],99query: `/fix Parameter cannot have question mark and initializer.`,100expectedIntent: Intent.Fix,101diagnostics: 'tsc',102validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')103}104]105});106});107108stest({ description: 'Error 2420 - incorrect interface implementation', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {109return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {110files: [111fromFixture('fixing/typescript/tsc_error_2420/file0.ts'),112fromFixture('fixing/typescript/tsc_error_2420/file1.ts')113],114queries: [115{116file: 'file0.ts',117selection: [2, 6, 2, 6],118query: [119`/fix Class 'Far' incorrectly implements interface 'IFar'.`,120` Property 'foo' is missing in type 'Far' but required in type 'IFar'.`121].join('\n'),122expectedIntent: Intent.Fix,123diagnostics: 'tsc',124validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')125}126]127});128});129130stest({ description: 'Error 2420 - incorrect interface implementation, with related information', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {131return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {132files: [133fromFixture('fixing/typescript/tsc_error_2420/file0.ts'),134fromFixture('fixing/typescript/tsc_error_2420/file1.ts')135],136queries: [137{138file: 'file0.ts',139selection: [2, 6, 9, 1],140query: [141`/fix Class 'Far' incorrectly implements interface 'IFar'.`,142` Property 'foo' is missing in type 'Far' but required in type 'IFar'.`143].join('\n'),144expectedIntent: Intent.Fix,145diagnostics: 'tsc',146validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')147}148]149});150});151152stest({ description: 'Error 2391 - function implementation is missing or not immediately following the declaration', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {153return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {154files: [fromFixture('fixing/typescript/tsc_error_2391.ts')],155queries: [156{157file: 'tsc_error_2391.ts',158selection: [6, 4, 6, 13],159query: [160`/fix Function implementation is missing or not immediately following the declaration.`,161`'function1', which lacks return-type annotation, implicitly has an 'any' return type.`162].join('\n'),163expectedIntent: Intent.Fix,164diagnostics: 'tsc',165validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')166}167]168});169});170171stest({ description: 'Error 2454 - variable is used before being assigned', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {172return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {173files: [fromFixture('fixing/typescript/tsc_error_2454.ts')],174queries: [175{176file: 'tsc_error_2454.ts',177selection: [21, 6, 21, 24],178query: `/fix Variable 'telemetryEventName' is used before being assigned.`,179expectedIntent: Intent.Fix,180diagnostics: 'tsc',181validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')182}183]184});185});186187stest({ description: 'Error 2339 - property does not exist on type 1', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {188return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {189files: [fromFixture('fixing/typescript/tsc_error_2339_1.ts')],190queries: [191{192file: 'tsc_error_2339_1.ts',193selection: [16, 21, 16, 29],194query: `/fix Property 'response' does not exist on type 'DocContext'.`,195expectedIntent: Intent.Fix,196diagnostics: 'tsc',197validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')198}199]200});201});202203stest({ description: 'Error 2554 - expected m arguments, but got n.', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {204return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {205files: [fromFixture('fixing/typescript/tsc_error_2554.ts')],206queries: [207{208file: 'tsc_error_2554.ts',209selection: [8, 7, 8, 21],210query: `/fix Expected 1 arguments, but got 0.`,211expectedIntent: Intent.Fix,212diagnostics: 'tsc',213validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')214}215]216});217});218219stest({ description: 'Error 2341 - property is private and only accessible within class', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {220return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {221files: [fromFixture('fixing/typescript/tsc_error_2341.ts')],222queries: [223{224file: 'tsc_error_2341.ts',225selection: [7, 8, 7, 10],226query: `/fix Property 'hi' is private and only accessible within class 'Bar'.`,227expectedIntent: Intent.Fix,228diagnostics: 'tsc',229validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')230}231]232});233});234235stest({ description: 'Error 2355 - a function whose declared type is neither undefined, void, nor any must return a value.', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {236return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {237files: [fromFixture('fixing/typescript/tsc_error_2355.ts')],238queries: [239{240file: 'tsc_error_2355.ts',241selection: [2, 37, 2, 44],242query: `/fix A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value.`,243expectedIntent: Intent.Fix,244diagnostics: 'tsc',245validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')246}247]248});249});250251// Inspired by case 55 in /fix dataset version 10252// The fix in nice_egg_479lg7cb9q was too big, it was not a minimal change, and it was incorrect253stest({ description: 'Error 2339 - (AML-10-55) property does not exist on type 2', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {254return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {255files: [fromFixture('fixing/typescript/tsc_error_2339_2.ts')],256queries: [257{258file: 'tsc_error_2339_2.ts',259selection: [5, 8, 5, 8],260query: `/fix Property 'send' does not exist on type 'AutoUpdater'.`,261expectedIntent: Intent.Fix,262diagnostics: 'tsc',263validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')264}265]266});267});268269// Inspired by case 98 in /fix dataset version 10270// Copilot proposed an incorrect fix, it should have added an additional method, instead it added a catch statement271stest({ description: 'Error 2339 - (AML-10-98) property does not exist on type 3', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {272return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {273files: [fromFixture('fixing/typescript/tsc_error_2339_3.ts')],274queries: [275{276file: 'tsc_error_2339_3.ts',277selection: [65, 11, 65, 11],278query: `/fix Property 'send' does not exist on type 'IpcRendererWithCommands'.`,279expectedIntent: Intent.Fix,280diagnostics: 'tsc',281validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')282}283]284});285});286287288// Add a missing impor at the right place289stest({ description: 'Error 2304 - can not find name', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {290return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {291files: [292fromFixture('fixing/typescript/tsc_error_2304/file0.ts'),293fromFixture('fixing/typescript/tsc_error_2304/file1.ts')294],295queries: [296{297file: 'file0.ts',298selection: [10, 26, 10, 26],299query: `/fix Cannot find name 'readFileSync'.`,300expectedIntent: Intent.Fix,301diagnostics: 'tsc',302validate: async (outcome, workspace, accessor) => {303await assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc');304if (outcome.type === 'inlineEdit') {305const indexOfFsImport = outcome.fileContents.indexOf(`import { readFileSync } from 'fs';`);306assert.ok(indexOfFsImport >= 0, 'contains readFileSync import');307const indexOfDeclare = outcome.fileContents.indexOf(`declare function`);308assert.ok(indexOfFsImport < indexOfDeclare, 'is before declare function');309}310}311}312]313});314});315316stest({ description: 'Error 2304 - (AML-10-14) can not find module', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {317return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {318files: [fromFixture('fixing/typescript/tsc_error_2304_1.ts')],319queries: [320{321file: 'tsc_error_2304_1.ts',322selection: [25, 1, 25, 1],323query: `/fix Cannot find name 'expect'.`,324expectedIntent: Intent.Fix,325diagnostics: 'tsc',326validate: async (outcome, workspace, accessor) => {327assert.strictEqual(outcome.type, 'inlineEdit');328const diagnostics = await getWorkspaceDiagnostics(accessor, workspace, 'tsc');329const filtered = diagnostics.filter(d => d.code !== 2307 && d.code !== 2305); // filter module not found, module has not exported member330assert.equal(filtered.length, 0, 'only module not found diagnostics');331}332}333]334});335});336337stest({ description: 'Error 2307 - can not find module', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {338return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {339files: [fromFixture('fixing/typescript/tsc_error_2307_can_not_find_module.ts')],340queries: [341{342file: 'tsc_error_2307_can_not_find_module.ts',343selection: [0, 25, 0, 40],344query: [345`/fix Cannot find module '@angular/core' or its corresponding type declarations..`,346].join('\n'),347expectedIntent: Intent.Fix,348diagnostics: 'tsc',349validate: async (outcome, workspace, accessor) => {350assertConversationalOutcome(outcome);351const match = outcome.chatResponseMarkdown.match(/```(ps|bash)[.\n\r]*npm install.*@angular\/core/);352assert.ok(match, 'contains npm install @angular/core');353}354}355]356});357});358359// Inspired by case 64 of /fix dataset version 10360// The fix was not correct, it just added a new line and did not resolve the error361stest({ description: 'Error 18047 - (AML-10-64) possibly null', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {362return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {363files: [fromFixture('fixing/typescript/tsc_error_18047.ts')],364queries: [365{366file: 'tsc_error_18047.ts',367selection: [4, 4, 4, 4],368query: `/fix 'measurementSpan' is possibly 'null'.`,369expectedIntent: Intent.Fix,370diagnostics: 'tsc',371validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')372}373]374});375});376377// Inspired by case 23 of /fix dataset version 10378stest({ description: 'Error 7006 - (AML-10-23) implicitly has any type', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {379return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {380files: [fromFixture('fixing/typescript/tsc_error_7006.ts')],381queries: [382{383file: 'tsc_error_7006.ts',384selection: [1, 53, 1, 53],385query: `/fix Parameter 'data' implicitly has an 'any' type.`,386expectedIntent: Intent.Fix,387diagnostics: 'tsc',388validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')389}390]391});392});393394// Inspired by case 1 of /fix dataset version 8395stest({ description: 'Error 18047 - (AML-8-1) property does not exist on type window', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {396return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {397files: [fromFixture('fixing/typescript/tsc_error_2339_4.ts')],398queries: [399{400file: 'tsc_error_2339_4.ts',401selection: [1, 12, 1, 12],402query: `/fix Property 'lx' does not exist on type 'Window & typeof globalThis'.`,403expectedIntent: Intent.Fix,404diagnostics: 'tsc',405validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')406}407]408});409});410411// Inspired by case 86 of /fix dataset version 10412stest({ description: 'Error 18048 - (AML-10-86) possibly undefined', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {413return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {414files: [fromFixture('fixing/typescript/tsc_error_18048.ts')],415queries: [416{417file: 'tsc_error_18048.ts',418selection: [3, 20, 3, 20],419query: `/fix 'poppedElement' is possibly 'undefined'`,420expectedIntent: Intent.Fix,421diagnostics: 'tsc',422validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')423}424]425});426});427428// Inspired by case 125 of /fix dataset version 8429stest({ description: 'Error 2304 - (AML-8-125) can not find name', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {430return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {431files: [fromFixture('fixing/typescript/tsc_error_2304_2.ts')],432queries: [433{434file: 'tsc_error_2304_2.ts',435selection: [7, 2, 7, 2],436query: `/fix Cannot find name 'cy'.`,437expectedIntent: Intent.Fix,438diagnostics: 'tsc',439validate: async (outcome, workspace, accessor) => {440if (outcome.type === 'conversational') {441const match = outcome.chatResponseMarkdown.match(/```(ps|bash)[.\n\r]*npm install.*cypress/);442assert.ok(match, 'contains npm install cypress');443} else if (outcome.type === 'inlineEdit') {444const diagnostics = await getWorkspaceDiagnostics(accessor, workspace, 'tsc');445const filtered = diagnostics.filter(d => d.code !== 2307 && d.code !== 2305); // filter module not found, module has not exported member446assert.equal(filtered.length, 0, 'only module not found diagnostics');447} else {448assert.fail('unexpected outcome type');449}450}451}452]453});454});455456stest({ description: 'Error 2304 - (AML-8-125) can not find name 2', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {457return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {458files: [fromFixture('fixing/typescript/tsc_error_2304_3.ts')],459queries: [460{461file: 'tsc_error_2304_3.ts',462selection: [1, 10, 1, 10],463query: `/fix Cannot find name 'promises'. Did you mean 'Promise'?.`,464expectedIntent: Intent.Fix,465diagnostics: 'tsc',466validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')467}468]469});470});471472// Inspired by case 25 of /fix dataset version 10473// The fix was not correct, it just added a new line and did not resolve the error474stest({ description: `Error 7053 - (AML-10-25) expression of type can't be used to index`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {475return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {476files: [fromFixture('fixing/typescript/tsc_error_7053.ts')],477queries: [478{479file: 'tsc_error_7053.ts',480selection: [9, 2, 9, 2],481query: [482`/fix Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ Pi: number; PiTimes2: number; PiOn2: number; PiOn4: number; E: number; }.`,483` No index signature with a parameter of type 'string' was found on type '{ Pi: number; PiTimes2: number; PiOn2: number; PiOn4: number; E: number; }'.`484].join('\n'),485expectedIntent: Intent.Fix,486diagnostics: 'tsc',487validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')488}489]490});491});492493// Inspired by case 31 in /fix dataset version 10494stest({ description: '(AML-10-31) Parameter data implicitly has an any type.', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {495return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {496files: [fromFixture('fixing/typescript/tsc_implicit_any.ts')],497queries: [498{499file: 'tsc_implicit_any.ts',500selection: [7, 38, 7, 42],501query: `/fix Parameter 'data' implicitly has an 'any' type`,502expectedIntent: Intent.Fix,503diagnostics: 'tsc',504validate: async (outcome, workspace, accessor) => {505await assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc');506}507}508]509});510});511512stest({ description: 'declaration or statement expected', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {513return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {514files: [fromFixture('fixing/typescript/tsc_error_1128.ts')],515queries: [516{517file: 'tsc_error_1128.ts',518selection: [8, 0, 8, 1],519query: `/fix Declaration or statement expected.`,520expectedIntent: Intent.Fix,521diagnostics: 'tsc',522validate: async (outcome, workspace, accessor) => {523await assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc');524}525}526]527});528});529530stest({ description: 'left side of comma operator is unused', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {531return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {532files: [fromFixture('fixing/typescript/tsc_error_2695.ts')],533queries: [534{535file: 'tsc_error_2695.ts',536selection: [3, 9, 3, 10],537query: `/fix Left side of comma operator is unused and has no side effects.`,538expectedIntent: Intent.Fix,539diagnostics: 'tsc',540validate: async (outcome, workspace, accessor) => {541await assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc');542}543}544]545});546});547548stest({ description: 'object is possibly undefined', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {549return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {550files: [fromFixture('fixing/typescript/tsc_error_2532.ts')],551queries: [552{553file: 'tsc_error_2532.ts',554selection: [2, 12, 2, 15],555query: `/fix 'obj' is possibly 'undefined'.`,556expectedIntent: Intent.Fix,557diagnostics: 'tsc',558validate: async (outcome, workspace, accessor) => {559await assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc');560}561}562]563});564});565566stest({ description: 'duplicate identifier', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {567return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {568files: [fromFixture('fixing/typescript/tsc_error_2300.ts')],569queries: [570{571file: 'tsc_error_2300.ts',572selection: [1, 6, 1, 13],573query: `/fix Duplicate identifier 'MyArray'.`,574expectedIntent: Intent.Fix,575diagnostics: 'tsc',576validate: async (outcome, workspace, accessor) => {577await assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc');578}579}580]581});582});583584stest({ description: 'Error 2802 - large file - Type Uint32Array can only be iterated through', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {585return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {586files: [fromFixture('fixing/typescript/tsc_large_onigscanner/tsc_error_2802.ts')],587queries: [588{589file: 'tsc_error_2802.ts',590selection: [442, 16, 454, 10],591query: `/fix Type 'Uint32Array' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.`,592expectedIntent: Intent.Fix,593diagnostics: 'tsc',594validate: async (outcome, workspace, accessor) => {595if (outcome.type === 'conversational') {596// change to tsconfig.json597} else {598await assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc');599}600}601}602]603});604});605606stest({ description: 'can not assign to parameter of type', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {607return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {608files: [fromFixture('fixing/typescript/tsc_error_2345.ts')],609queries: [610{611file: 'tsc_error_2345.ts',612selection: [1, 22, 1, 31],613query: `/fix Argument of type 'T' is not assignable to parameter of type 'object | null'.`,614expectedIntent: Intent.Fix,615diagnostics: 'tsc',616validate: async (outcome, workspace, accessor) => {617await assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc');618}619}620]621});622});623624stest({ description: 'Error 2345 - Last two arguments swapped', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {625const files = [626fromFixture('fixing/typescript/tsc_error_2345_2/file0.ts'),627fromFixture('fixing/typescript/tsc_error_2345_2/file1.ts'),628fromFixture('fixing/typescript/tsc_error_2345_2/database_mock.ts')629];630return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {631files,632queries: [633{634file: 'file0.ts',635selection: [3, 35, 3, 40],636query: [637`/fix Argument of type 'boolean' is not assignable to parameter of type 'number'.`,638].join('\n'),639expectedIntent: Intent.Fix,640diagnostics: 'tsc',641validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')642}643]644});645});646647stest({ description: 'Error 2345 - Got boolean but expected options bag', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {648const files = [649fromFixture('fixing/typescript/tsc_error_2345_3/file0.ts'),650fromFixture('fixing/typescript/tsc_error_2345_3/database_mock.ts')651];652return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {653files,654queries: [655{656file: 'file0.ts',657selection: [3, 41, 3, 46],658query: [659`/fix Argument of type 'boolean' is not assignable to parameter of type '{ timeout?: number | undefined; loose: boolean; }'.`,660].join('\n'),661expectedIntent: Intent.Fix,662diagnostics: 'tsc',663validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')664}665]666});667});668669stest({ description: 'Error 2554 - Got two args but expected options bag', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {670return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {671files: [672fromFixture('fixing/typescript/tsc_error_2554/legacy_database.ts'),673fromFixture('fixing/typescript/tsc_error_2554/file1.ts'),674fromFixture('fixing/typescript/tsc_error_2554/database_mock.ts')675],676queries: [677{678file: 'legacy_database.ts',679selection: [9, 37, 9, 42],680query: `/fix Expected 1-2 arguments, but got 3.`,681expectedIntent: Intent.Fix,682diagnostics: 'tsc',683validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')684}685]686});687});688689stest({ description: 'Issue 6571', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {690return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {691files: [fromFixture('fixing/typescript/inlineChatSimulator.ts')],692queries: [693{694file: 'inlineChatSimulator.ts',695selection: [302, 16, 302, 27],696query: `/fix Cannot find name 'startOffset'.`,697diagnostics: 'tsc',698expectedIntent: 'fix',699validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'tsc')700}701]702});703});704705stest({ description: 'Issue #7300', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {706return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {707files: [toFile({708fileName: 'textureAtlasAllocator.test.ts',709fileContents: `/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License. See License.txt in the project root for license information.\r\n *--------------------------------------------------------------------------------------------*/\r\n\r\nimport { deepStrictEqual, strictEqual } from 'assert';\r\nimport { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';\r\nimport { TextureAtlasShelfAllocator } from 'vs/editor/browser/view/gpu/atlas/textureAtlasAllocator';\r\nimport { ensureNonNullable } from 'vs/editor/browser/view/gpu/gpuUtils';\r\nimport type { IRasterizedGlyph } from 'vs/editor/browser/view/gpu/raster/glyphRasterizer';\r\n\r\nconst blackInt = 0x000000FF;\r\nconst blackArr = [0x00, 0x00, 0x00, 0xFF];\r\n\r\nconst pixel1x1 = createRasterizedGlyph(1, 1, [...blackArr]);\r\nconst pixel2x1 = createRasterizedGlyph(2, 1, [...blackArr, ...blackArr]);\r\nconst pixel1x2 = createRasterizedGlyph(1, 2, [...blackArr, ...blackArr]);\r\n\r\nfunction initAllocator(w: number, h: number): { canvas: OffscreenCanvas; ctx: OffscreenCanvasRenderingContext2D; allocator: TextureAtlasShelfAllocator } {\r\n\tconst canvas = new OffscreenCanvas(w, h);\r\n\tconst ctx = ensureNonNullable(canvas.getContext('2d'));\r\n\tconst allocator = new TextureAtlasShelfAllocator(canvas, ctx);\r\n\treturn { canvas, ctx, allocator };\r\n}\r\n\r\nfunction createRasterizedGlyph(w: number, h: number, data: ArrayLike<number>): IRasterizedGlyph {\r\n\tstrictEqual(w * h * 4, data.length);\r\n\tconst source = new OffscreenCanvas(w, h);\r\n\tconst imageData = new ImageData(w, h);\r\n\timageData.data.set(data);\r\n\tensureNonNullable(source.getContext('2d')).putImageData(imageData, 0, 0);\r\n\treturn {\r\n\t\tsource,\r\n\t\tboundingBox: { top: 0, left: 0, bottom: h - 1, right: w - 1 },\r\n\t\toriginOffset: { x: 0, y: 0 },\r\n\t};\r\n}\r\n\r\nsuite('TextureAtlasShelfAllocator', () => {\r\n\tensureNoDisposablesAreLeakedInTestSuite();\r\n\r\n\tlet lastUniqueGlyph: string | undefined;\r\n\tfunction getUniqueGlyphId(): [string, number] {\r\n\t\tif (!lastUniqueGlyph) {\r\n\t\t\tlastUniqueGlyph = 'a';\r\n\t\t} else {\r\n\t\t\tlastUniqueGlyph = String.fromCharCode(lastUniqueGlyph.charCodeAt(0) + 1);\r\n\t\t}\r\n\t\treturn [lastUniqueGlyph, blackInt];\r\n\t}\r\n\r\n\tsuiteSetup(() => {\r\n\t\tlastUniqueGlyph = undefined;\r\n\t});\r\n\r\n\ttest('single allocation', () => {\r\n\t\tconst { allocator } = initAllocator(2, 2);\r\n\t\t// 1o\r\n\t\t// oo\r\n\t\tdeepStrictEqual(allocator.allocate(...getUniqueGlyphId(), pixel1x1), {\r\n\t\t\tindex: 0,\r\n\t\t\tx: 0, y: 0,\r\n\t\t\tw: 1, h: 1,\r\n\t\t\toriginOffsetX: 0, originOffsetY: 0,\r\n\t\t});\r\n\t});\r\n\ttest('wrapping', () => {\r\n\t\tconst { allocator } = initAllocator(5, 4);\r\n\t\t// 1oooo\r\n\t\t// ooooo\r\n\t\t// ooooo\r\n\t\t// ooooo\r\n\t\tdeepStrictEqual(allocator.allocate(...getUniqueGlyphId(), pixel1x1), {\r\n\t\t\tindex: 0,\r\n\t\t\tx: 0, y: 0,\r\n\t\t\tw: 1, h: 1,\r\n\t\t\toriginOffsetX: 0, originOffsetY: 0,\r\n\t\t});\r\n\t\t// 12ooo\r\n\t\t// o2ooo\r\n\t\t// ooooo\r\n\t\t// ooooo\r\n\t\tdeepStrictEqual(allocator.allocate(...getUniqueGlyphId(), pixel1x2), {\r\n\t\t\tindex: 1,\r\n\t\t\tx: 1, y: 0,\r\n\t\t\tw: 1, h: 2,\r\n\t\t\toriginOffsetX: 0, originOffsetY: 0,\r\n\t\t});\r\n\t\t// 1233o\r\n\t\t// o2ooo\r\n\t\t// ooooo\r\n\t\t// ooooo\r\n\t\tdeepStrictEqual(allocator.allocate(...getUniqueGlyphId(), pixel2x1), {\r\n\t\t\tindex: 2,\r\n\t\t\tx: 2, y: 0,\r\n\t\t\tw: 2, h: 1,\r\n\t\t\toriginOffsetX: 0, originOffsetY: 0,\r\n\t\t});\r\n\t\t// 1233x\r\n\t\t// x2xxx\r\n\t\t// 44ooo\r\n\t\t// ooooo\r\n\t\tdeepStrictEqual(allocator.allocate(...getUniqueGlyphId(), pixel2x1), {\r\n\t\t\tindex: 3,\r\n\t\t\tx: 0, y: 2,\r\n\t\t\tw: 2, h: 1,\r\n\t\t\toriginOffsetX: 0, originOffsetY: 0,\r\n\t\t}, 'should wrap to next line as there\\'s no room left');\r\n\t\t// 1233x\r\n\t\t// x2xxx\r\n\t\t// 4455o\r\n\t\t// ooooo\r\n\t\tdeepStrictEqual(allocator.allocate(...getUniqueGlyphId(), pixel2x1), {\r\n\t\t\tindex: 4,\r\n\t\t\tx: 2, y: 2,\r\n\t\t\tw: 2, h: 1,\r\n\t\t\toriginOffsetX: 0, originOffsetY: 0,\r\n\t\t});\r\n\t\t// 1233x\r\n\t\t// x2xxx\r\n\t\t// 44556\r\n\t\t// ooooo\r\n\t\tdeepStrictEqual(allocator.allocate(...getUniqueGlyphId(), pixel1x1), {\r\n\t\t\tindex: 5,\r\n\t\t\tx: 4, y: 2,\r\n\t\t\tw: 1, h: 1,\r\n\t\t\toriginOffsetX: 0, originOffsetY: 0,\r\n\t\t});\r\n\t\t// 1233x\r\n\t\t// x2xxx\r\n\t\t// 44556\r\n\t\t// 7oooo\r\n\t\tdeepStrictEqual(allocator.allocate(...getUniqueGlyphId(), pixel1x1), {\r\n\t\t\tindex: 6,\r\n\t\t\tx: 0, y: 3,\r\n\t\t\tw: 1, h: 1,\r\n\t\t\toriginOffsetX: 0, originOffsetY: 0,\r\n\t\t}, 'should wrap to next line as there\\'s no room left');\r\n\t});\r\n\ttest('full', () => {\r\n\t\tconst { allocator } = initAllocator(3, 2);\r\n\t\t// 1oo\r\n\t\t// 1oo\r\n\t\tdeepStrictEqual(allocator.allocate(...getUniqueGlyphId(), pixel1x2), {\r\n\t\t\tindex: 0,\r\n\t\t\tx: 0, y: 0,\r\n\t\t\tw: 1, h: 2,\r\n\t\t\toriginOffsetX: 0, originOffsetY: 0,\r\n\t\t});\r\n\t\t// 122\r\n\t\t// 1oo\r\n\t\tdeepStrictEqual(allocator.allocate(...getUniqueGlyphId(), pixel2x1), {\r\n\t\t\tindex: 1,\r\n\t\t\tx: 1, y: 0,\r\n\t\t\tw: 2, h: 1,\r\n\t\t\toriginOffsetX: 0, originOffsetY: 0,\r\n\t\t});\r\n\t\tdeepStrictEqual(allocator.allocate(...getUniqueGlyphId(), pixel1x1), undefined, 'should return undefined when the canvas is full');\r\n\t});\r\n});\r\n\r\nsuite('TextureAtlasSlabAllocator', () => {\r\n\ttest('a', () => {\r\n\t});\r\n});\r\n`710})],711queries: [712{713file: 'textureAtlasAllocator.test.ts',714selection: [161, 0, 164, 2],715query: '/fix Suites should include a call to `ensureNoDisposablesAreLeakedInTestSuite()` to ensure no disposables are leaked in tests.',716diagnostics: 'tsc',717expectedIntent: 'fix',718validate: async (outcome, workspace, accessor) => {719assertInlineEdit(outcome);720await assertNoDiagnosticsAsync(accessor, outcome, workspace, KnownDiagnosticProviders.tscIgnoreImportErrors);721}722}723]724});725});726});727728ssuite({ title: `fix${suffix}`, subtitle: 'eslint', location: 'inline' }, () => {729stest({ description: 'unexpected token', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {730return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {731files: [fromFixture('fixing/typescript/eslint_unexpected_token.ts')],732queries: [733{734file: 'eslint_unexpected_token.ts',735selection: [14, 4, 14, 4],736query: `/fix Parsing error: Expression expected.`,737expectedIntent: Intent.Fix,738diagnostics: 'eslint',739validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')740}741]742});743});744745// Inspired by case 52 of /fix dataset version 10746// The fix was not correct, it just added a new line and did not resolve the error747stest({ description: '(AML-10-52) expected conditional expression', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {748return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {749files: [fromFixture('fixing/typescript/eslint_expected_conditional_expression.ts')],750queries: [751{752file: 'eslint_expected_conditional_expression.ts',753selection: [8, 6, 8, 6],754query: `/fix`,755expectedIntent: Intent.Fix,756diagnostics: 'eslint',757validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')758}759]760});761});762763// Inspired by case 1 in /fix dataset version 10764stest({ description: '(AML-10-1) do not access hasOwnProperty', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {765return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {766files: [fromFixture('fixing/typescript/eslint_do_not_access_hasOwnProperty.ts')],767queries: [768{769file: 'eslint_do_not_access_hasOwnProperty.ts',770selection: [9, 23, 9, 23],771query: `/fix Do not access Object.prototype method 'hasOwnProperty' from target object.`,772expectedIntent: Intent.Fix,773diagnostics: 'eslint',774validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')775}776]777});778});779780stest({ description: `comma expected`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {781return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {782files: [fromFixture('fixing/typescript/eslint_comma_expected.ts')],783queries: [784{785file: 'eslint_comma_expected.ts',786selection: [8, 2, 8, 2],787query: [788`/fix Parsing error: ',' expected.`789].join('\n'),790expectedIntent: Intent.Fix,791diagnostics: 'eslint',792validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')793}794]795});796});797798// Inspired by case 10 of /fix dataset version 17799stest({ description: `(AML-17-10) unexpected constant condition 1`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {800return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {801files: [fromFixture('fixing/typescript/eslint_unexpected_constant_condition_1.ts')],802queries: [803{804file: 'eslint_unexpected_constant_condition_1.ts',805selection: [1, 4, 1, 4],806query: [807`/fix Unexpected constant condition.`808].join('\n'),809expectedIntent: Intent.Fix,810diagnostics: 'eslint',811validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')812}813]814});815});816817// Inspired by case 152 of /fix dataset version 17818stest({ description: `(AML-17-152) unreachable code`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {819return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {820files: [fromFixture('fixing/typescript/eslint_unreachable_code.ts')],821queries: [822{823file: 'eslint_unreachable_code.ts',824selection: [5, 3, 5, 3],825query: [826`/fix Unreachable code.`827].join('\n'),828expectedIntent: Intent.Fix,829diagnostics: 'eslint',830validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')831}832]833});834});835836// Inspired by case 166 of /fix dataset version 17837stest({ description: `(AML-17-166) unexpected control character`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {838return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {839files: [fromFixture('fixing/typescript/eslint_unexpected_control_character.ts')],840queries: [841{842file: 'eslint_unexpected_control_character.ts',843selection: [0, 11, 0, 11],844query: [845`/fix Unexpected control character(s) in regular expression: \\x00.`846].join('\n'),847expectedIntent: Intent.Fix,848diagnostics: 'eslint',849validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')850}851]852});853});854855// Inspired by case 243 of /fix dataset version 17856stest({ description: `(AML-17-243) unexpected constant condition 2`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {857return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {858files: [fromFixture('fixing/typescript/eslint_unexpected_constant_condition_2.ts')],859queries: [860{861file: 'eslint_unexpected_constant_condition_2.ts',862selection: [4, 9, 4, 9],863query: [864`/fix Unexpected constant condition.`865].join('\n'),866expectedIntent: Intent.Fix,867diagnostics: 'eslint',868validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')869}870]871});872});873874stest({ description: `class-methods-use-this with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {875return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {876files: [fromFixture('fixing/typescript/eslint_class_methods_use_this.ts')],877queries: [878{879file: 'eslint_class_methods_use_this.ts',880selection: [14, 1, 14, 7],881query: [882`/fix Expected 'this' to be used by class method 'append'.`,883].join('\n'),884expectedIntent: Intent.Fix,885diagnostics: 'eslint',886validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')887}888]889});890});891892stest({ description: `consistent-this with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {893return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {894files: [fromFixture('fixing/typescript/eslint_consistent_this.ts')],895queries: [896{897file: 'eslint_consistent_this.ts',898selection: [8, 8, 8, 19],899query: [900`/fix Unexpected alias 'self' for 'this'.`,901].join('\n'),902expectedIntent: Intent.Fix,903diagnostics: 'eslint',904validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')905}906]907});908});909910stest({ description: `constructor-super with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {911return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {912files: [fromFixture('fixing/typescript/eslint_constructor_super.ts')],913queries: [914{915file: 'eslint_constructor_super.ts',916selection: [22, 1, 25, 2],917query: [918`/fix Expected to call 'super()'.`,919`Constructors for derived classes must contain a 'super' call.`920].join('\n'),921expectedIntent: Intent.Fix,922diagnostics: 'eslint',923validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')924}925]926});927});928929stest({ description: `func-names with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {930return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {931files: [fromFixture('fixing/typescript/eslint_func_names.ts')],932queries: [933{934file: 'eslint_func_names.ts',935selection: [4, 25, 4, 34],936query: [937`/fix Unexpected unnamed function.`,938].join('\n'),939expectedIntent: Intent.Fix,940diagnostics: 'eslint',941validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')942}943]944});945});946947stest({ description: `func-style with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {948return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {949files: [fromFixture('fixing/typescript/eslint_func_style.ts')],950queries: [951{952file: 'eslint_func_style.ts',953selection: [4, 7, 10, 1],954query: [955`/fix Expected a function expression.`,956].join('\n'),957expectedIntent: Intent.Fix,958diagnostics: 'eslint',959validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')960}961]962});963});964stest({ description: `max-lines-per-function with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {965return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {966files: [fromFixture('fixing/typescript/eslint_max_lines_per_function.ts')],967queries: [968{969file: 'eslint_max_lines_per_function.ts',970selection: [4, 7, 58, 1],971query: [972`/fix Function 'fastMark' has too many lines (55). Maximum allowed is 50.`,973].join('\n'),974expectedIntent: Intent.Fix,975diagnostics: 'eslint',976validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')977}978]979});980});981982stest({ description: `max-params with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {983return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {984files: [fromFixture('fixing/typescript/eslint_max_params.ts')],985queries: [986{987file: 'eslint_max_params.ts',988selection: [10, 1, 10, 12],989query: [990`/fix Constructor has too many parameters (5). Maximum allowed is 3.`,991].join('\n'),992expectedIntent: Intent.Fix,993diagnostics: 'eslint',994validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')995}996]997});998});999stest({ description: `max-statements with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {1000return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1001files: [fromFixture('fixing/typescript/eslint_max_statements.ts')],1002queries: [1003{1004file: 'eslint_max_statements.ts',1005selection: [5, 7, 59, 1],1006query: [1007`/fix Function 'fastMark' has too many statements (34). Maximum allowed is 10.`,1008].join('\n'),1009expectedIntent: Intent.Fix,1010diagnostics: 'eslint',1011validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')1012}1013]1014});1015});10161017stest({ description: `no-case-declarations with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {1018return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1019files: [fromFixture('fixing/typescript/eslint_no_case_declarations.ts')],1020queries: [1021{1022file: 'eslint_no_case_declarations.ts',1023selection: [9, 3, 9, 61],1024query: [1025`/fix Unexpected lexical declaration in case block.`,1026].join('\n'),1027expectedIntent: Intent.Fix,1028diagnostics: 'eslint',1029validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')1030}1031]1032});1033});10341035stest({ description: `no-dupe-else-if with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {1036return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1037files: [fromFixture('fixing/typescript/eslint_no_dupe_else_if.ts')],1038queries: [1039{1040file: 'eslint_no_dupe_else_if.ts',1041selection: [11, 13, 11, 34],1042query: [1043`/fix This branch can never execute. Its condition is a duplicate or covered by previous conditions in the if-else-if chain.`,1044].join('\n'),1045expectedIntent: Intent.Fix,1046diagnostics: 'eslint',1047validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')1048}1049]1050});1051});1052stest({ description: `no-duplicate-case with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {1053return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1054files: [fromFixture('fixing/typescript/eslint_no_duplicate_case.ts')],1055queries: [1056{1057file: 'eslint_no_duplicate_case.ts',1058selection: [20, 1, 21, 137],1059query: [1060`/fix Please fix the problem at the location`,1061].join('\n'),1062expectedIntent: Intent.Fix,1063diagnostics: 'eslint',1064validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')1065}1066]1067});1068});10691070stest({ description: `no-duplicate-imports with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {1071return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1072files: [fromFixture('fixing/typescript/eslint_no_duplicate_imports.ts')],1073queries: [1074{1075file: 'eslint_no_duplicate_imports.ts',1076selection: [7, 0, 7, 55],1077query: [1078`/fix './eslint_no_duplicate_case'' import is duplicated.`,1079].join('\n'),1080expectedIntent: Intent.Fix,1081diagnostics: 'eslint',1082validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')1083}1084]1085});1086});1087stest({ description: `no-fallthrough with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {1088return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1089files: [fromFixture('fixing/typescript/eslint_no_fallthrough.ts')],1090queries: [1091{1092file: 'eslint_no_fallthrough.ts',1093selection: [9, 2, 9, 9],1094query: [1095`/fix Expected a 'break' statement before 'case'.`,1096`Constructors for derived classes must contain a 'super' call.`1097].join('\n'),1098expectedIntent: Intent.Fix,1099diagnostics: 'eslint',1100validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')1101}1102]1103});1104});11051106stest({ description: `no-inner-declarations with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {1107return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1108files: [fromFixture('fixing/typescript/eslint_no_inner_declarations.ts')],1109queries: [1110{1111file: 'eslint_no_inner_declarations.ts',1112selection: [11, 2, 15, 3],1113query: [1114`/fix Move function declaration to function body root.`,1115].join('\n'),1116expectedIntent: Intent.Fix,1117diagnostics: 'eslint',1118validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')1119}1120]1121});1122});11231124stest({ description: `no-multi-assign with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {1125return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1126files: [fromFixture('fixing/typescript/eslint_no_multi_assign.ts')],1127queries: [1128{1129file: 'eslint_no_multi_assign.ts',1130selection: [10, 8, 10, 8],1131query: [1132`/fix Unexpected chained assignment.`,1133].join('\n'),1134expectedIntent: Intent.Fix,1135diagnostics: 'eslint',1136validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')1137}1138]1139});1140});11411142stest({ description: `no-negated-condition with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {1143return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1144files: [fromFixture('fixing/typescript/eslint_no_negated_condition.ts')],1145queries: [1146{1147file: 'eslint_no_negated_condition.ts',1148selection: [8, 8, 8, 53],1149query: [1150`/fix Unexpected negated condition.`,1151].join('\n'),1152expectedIntent: Intent.Fix,1153diagnostics: 'eslint',1154validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')1155}1156]1157});1158});11591160stest({ description: `no-negated-condition 2 with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {1161return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1162files: [fromFixture('fixing/typescript/eslint_no_negated_condition_2.ts')],1163queries: [1164{1165file: 'eslint_no_negated_condition_2.ts',1166selection: [6, 2, 11, 3],1167query: [1168`/fix Unexpected negated condition.`,1169].join('\n'),1170expectedIntent: Intent.Fix,1171diagnostics: 'eslint',1172validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')1173}1174]1175});1176});11771178stest({ description: `no-new with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {1179return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1180files: [fromFixture('fixing/typescript/eslint_no_new.ts')],1181queries: [1182{1183file: 'eslint_no_new.ts',1184selection: [38, 0, 38, 30],1185query: [1186`/fix Please fix the problem at the location`,1187].join('\n'),1188expectedIntent: Intent.Fix,1189diagnostics: 'eslint',1190validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')1191}1192]1193});1194});1195stest({ description: `no-sequences with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {1196return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1197files: [fromFixture('fixing/typescript/eslint_no_sequences.ts')],1198queries: [1199{1200file: 'eslint_no_sequences.ts',1201selection: [16, 26, 16, 27],1202query: [1203`/fix Please fix the problem at the location`,1204].join('\n'),1205expectedIntent: Intent.Fix,1206diagnostics: 'eslint',1207validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')1208}1209]1210});1211});12121213stest({ description: `no-sparse-arrays with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {1214return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1215files: [fromFixture('fixing/typescript/eslint_no_sparse_arrays.ts')],1216queries: [1217{1218file: 'eslint_no_sparse_arrays.ts',1219selection: [4, 25, 4, 30],1220query: [1221`/fix Unexpected comma in middle of array.`,1222].join('\n'),1223expectedIntent: Intent.Fix,1224diagnostics: 'eslint',1225validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')1226}1227]1228});1229});1230stest({ description: `no-sparse-arrays 2 with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {1231return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1232files: [fromFixture('fixing/typescript/eslint_no_sparse_arrays_2.ts')],1233queries: [1234{1235file: 'eslint_no_sparse_arrays_2.ts',1236selection: [4, 29, 4, 66],1237query: [1238`/fix Unexpected comma in middle of array.`,1239].join('\n'),1240expectedIntent: Intent.Fix,1241diagnostics: 'eslint',1242validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')1243}1244]1245});1246});12471248stest({ description: `no-sparse-arrays 3 with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {1249return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1250files: [fromFixture('fixing/typescript/eslint_no_sparse_arrays_3.ts')],1251queries: [1252{1253file: 'eslint_no_sparse_arrays_3.ts',1254selection: [4, 26, 4, 56],1255query: [1256`/fix Unexpected comma in middle of array.`,1257].join('\n'),1258expectedIntent: Intent.Fix,1259diagnostics: 'eslint',1260validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')1261}1262]1263});1264});12651266stest({ description: `require-await with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {1267return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1268files: [fromFixture('fixing/typescript/eslint_require_await.ts')],1269queries: [1270{1271file: 'eslint_require_await.ts',1272selection: [6, 7, 6, 32],1273query: [1274`/fix Async function 'readConfig' has no 'await' expression.`,1275].join('\n'),1276expectedIntent: Intent.Fix,1277diagnostics: 'eslint',1278validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')1279}1280]1281});1282});1283stest({ description: `sort-keys with cookbook`, language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {1284return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1285files: [fromFixture('fixing/typescript/eslint_sort_keys.ts')],1286queries: [1287{1288file: 'eslint_sort_keys.ts',1289selection: [21, 2, 21, 10],1290query: [1291`/fix Expected object keys to be in ascending order. 'extended' should be before 'value'.`,1292].join('\n'),1293expectedIntent: Intent.Fix,1294diagnostics: 'eslint',1295validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'eslint')1296}1297]1298});1299});13001301stest({ description: 'Issue #7544', language: 'typescript', nonExtensionConfigurations }, (accessor) => {1302return simulateInlineChatWithStrategy(strategy, accessor, {1303files: [toFile({1304filePath: fromFixture('fix/issue-7544/notebookMulticursor.ts')1305})],1306queries: [1307{1308file: 'notebookMulticursor.ts',1309selection: [262, 41, 262, 41],1310query: 'fix the error',1311diagnostics: 'tsc',1312expectedIntent: 'fix',1313validate: async (outcome, workspace, accessor) => {1314assertInlineEdit(outcome);1315assertOccursOnce(outcome.fileContents, '\tundoRedo?: {\n\t\telements: IPastFutureElements;\n\t};');1316}1317}1318]1319});1320});1321});13221323ssuite({ title: `fix${suffix}`, subtitle: 'pylint', location: 'inline' }, () => {13241325stest({ description: 'unecessary parenthesis', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1326return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1327files: [fromFixture('fixing/python/pylint_unecessary_parenthesis.py')],1328queries: [1329{1330file: 'pylint_unecessary_parenthesis.py',1331selection: [7, 0, 7, 0],1332query: `/fix Unnecessary parens after 'if' keyword`,1333expectedIntent: Intent.Fix,1334diagnostics: 'pylint',1335validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pylint')1336}1337]1338});1339});13401341stest({ description: 'unused module imported', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1342return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1343files: [fromFixture('fixing/python/pylint_unused_import.py')],1344queries: [1345{1346file: 'pylint_unused_import.py',1347selection: [0, 0, 0, 0],1348query: `/fix Unused Path imported from pathlib`,1349expectedIntent: Intent.Fix,1350diagnostics: 'pylint',1351validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pylint')1352}1353]1354});1355});13561357stest({ description: `line-too-long cookbook 1 function definition with long parameters`, language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1358return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1359files: [fromFixture('fixing/python/pylint_line_too_long_1.py')],1360queries: [1361{1362file: 'pylint_line_too_long_1.py',1363selection: [8, 0, 8, 2],1364query: [1365`/fix`,1366].join('\n'),1367expectedIntent: Intent.Fix,1368diagnostics: 'pylint',1369validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pylint')1370}1371]1372});1373});13741375stest({ description: `line-too-long cookbook 2 long print statememt`, language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1376return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1377files: [fromFixture('fixing/python/pylint_line_too_long_2.py')],1378queries: [1379{1380file: 'pylint_line_too_long_2.py',1381selection: [7, 0, 7, 0],1382query: [1383`/fix`,1384].join('\n'),1385expectedIntent: Intent.Fix,1386diagnostics: 'pylint',1387validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pylint')1388}1389]1390});1391});13921393stest({ description: `line-too-long cookbook 3 long dictionary / list`, language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1394return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1395files: [fromFixture('fixing/python/pylint_line_too_long_3.py')],1396queries: [1397{1398file: 'pylint_line_too_long_3.py',1399selection: [8, 0, 8, 0],1400query: [1401`/fix`,1402].join('\n'),1403expectedIntent: Intent.Fix,1404diagnostics: 'pylint',1405validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pylint')1406}1407]1408});1409});14101411stest({ description: `line-too-long cookbook 4 long if condition and function call`, language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1412return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1413files: [fromFixture('fixing/python/pylint_line_too_long_4.py')],1414queries: [1415{1416file: 'pylint_line_too_long_4.py',1417selection: [15, 0, 15, 2],1418query: [1419`/fix`,1420].join('\n'),1421expectedIntent: Intent.Fix,1422diagnostics: 'pylint',1423validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pylint')1424}1425]1426});1427});14281429stest({ description: `line-too-long cookbook 5 multi-line docstring`, language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1430return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1431files: [fromFixture('fixing/python/pylint_line_too_long_5.py')],1432queries: [1433{1434file: 'pylint_line_too_long_5.py',1435selection: [7, 8, 9, 8],1436query: [1437`/fix`,1438].join('\n'),1439expectedIntent: Intent.Fix,1440diagnostics: 'pylint',1441validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pylint')1442}1443]1444});1445});14461447});14481449ssuite({ title: `fix${suffix}`, subtitle: 'pyright', location: 'inline' }, () => {14501451stest({ description: 'cannot instantiate abstract class', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1452return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1453files: [fromFixture('fixing/python/pyright_no_abstract_class_instantiation.py')],1454queries: [1455{1456file: 'pyright_no_abstract_class_instantiation.py',1457selection: [9, 4, 9, 4],1458query: `/fix Cannot instantiate abstract class "Base"\n "Base.foo" is abstract`,1459expectedIntent: Intent.Fix,1460diagnostics: 'pyright',1461validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1462}1463]1464});1465});14661467stest({ description: 'all Annotated types should include at least two type arguments', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1468return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1469files: [fromFixture('fixing/python/pyright_annotated_types_missing_argument.py')],1470queries: [1471{1472file: 'pyright_annotated_types_missing_argument.py',1473selection: [4, 3, 4, 3],1474query: `/fix Expected one type argument and one or more annotations for "Annotated"`,1475expectedIntent: Intent.Fix,1476diagnostics: 'pyright',1477validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1478}1479]1480});1481});14821483stest({ description: 'should not generate an error for variables declared in outer scopes', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1484return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1485files: [fromFixture('fixing/python/pyright_assignment_scopes.py')],1486queries: [1487{1488file: 'pyright_assignment_scopes.py',1489selection: [24, 8, 24, 8],1490query: `/fix "d" is not defined`,1491expectedIntent: Intent.Fix,1492diagnostics: 'pyright',1493validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1494}1495]1496});1497});14981499stest({ description: 'async cannot be used in a non-async function', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1500return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1501files: [fromFixture('fixing/python/pyright_async_in_non_async_function.py')],1502queries: [1503{1504file: 'pyright_async_in_non_async_function.py',1505selection: [17, 4, 17, 4],1506query: `/fix Use of "async" not allowed outside of async function`,1507expectedIntent: Intent.Fix,1508diagnostics: 'pyright',1509validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1510}1511]1512});1513});15141515stest({ description: 'await cannot be used in a non-async function', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1516return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1517files: [fromFixture('fixing/python/pyright_await_in_non_async_function.py')],1518queries: [1519{1520file: 'pyright_await_in_non_async_function.py',1521selection: [14, 0, 14, 0],1522query: `/fix "await" allowed only within async function`,1523expectedIntent: Intent.Fix,1524diagnostics: 'pyright',1525validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1526}1527]1528});1529});15301531stest({ description: 'bad token', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1532return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1533files: [fromFixture('fixing/python/pyright_badtoken.py')],1534queries: [1535{1536file: 'pyright_badtoken.py',1537selection: [4, 7, 4, 7],1538query: `/fix Invalid character in identifier`,1539expectedIntent: Intent.Fix,1540diagnostics: 'pyright',1541validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1542}1543]1544});1545});15461547stest({ description: 'Bar does not define a do_something2 method', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1548return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1549files: [fromFixture('fixing/python/pyright_missing_method.py')],1550queries: [1551{1552file: 'pyright_missing_method.py',1553selection: [28, 0, 28, 0],1554query: [1555`/fix Cannot access member "do_something2" for type "Bar"`,1556` Member "do_something2" is unknown`1557].join('\n'),1558expectedIntent: Intent.Fix,1559diagnostics: 'pyright',1560validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1561}1562]1563});1564});15651566// Inspired by case 2 in /fix dataset version 101567// Copilot misunderstood the directive and did a non-null check on the wrong variable1568stest({ description: '(AML-10-2) can not be assigned 1', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1569return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1570files: [fromFixture('fixing/python/pyright_can_not_be_assigned_to_1.py')],1571queries: [1572{1573file: 'pyright_can_not_be_assigned_to_1.py',1574selection: [13, 15, 13, 15],1575query: [1576`/fix Expression of type "tuple[str | None, Path]" cannot be assigned to return type "Tuple[str, Path]`,1577` Type "str | None" cannot be assigned to type "str"`,1578` Type "None" cannot be assigned to type "str"`,1579].join('\n'),1580expectedIntent: Intent.Fix,1581diagnostics: 'pyright',1582validate: async (outcome, workspace, accessor) => assertLessDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1583}1584]1585});1586});15871588// Inspired by case 15 in /fix dataset version 101589// The error was that Copilot was not able to localize exactly the code that is causing the error and it didn't provide any edit1590// This test has three times the error1591stest({ description: '(AML-10-15) object not subscriptable', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1592return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1593files: [fromFixture('fixing/python/pyright_object_not_subscriptable.py')],1594queries: [1595{1596file: 'pyright_object_not_subscriptable.py',1597selection: [17, 8, 17, 8],1598query: `/fix Object of type "None" is not subscriptable`,1599expectedIntent: Intent.Fix,1600diagnostics: 'pyright',1601validate: async (outcome, workspace, accessor) => assertLessDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1602}1603]1604});1605});16061607// Inspired by case 35 of /fix dataset version 101608// In the AML run, copilot did not understand the error and did not fix it1609stest({ description: '(AML-10-35) can not access member', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1610return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1611files: [fromFixture('fixing/python/pyright_can_not_access_member.py')],1612queries: [1613{1614file: 'pyright_can_not_access_member.py',1615selection: [2, 23, 2, 23],1616query: [1617`/fix Cannot access member "includes" for type "set[Unknown]"`,1618` Member "includes" is unknown`1619].join('\n'),1620expectedIntent: Intent.Fix,1621diagnostics: 'pyright',1622validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1623}1624]1625});1626});16271628// Inspired by case 36 of /fix dataset version 101629// In the AML run, copilot did not understand the error and did not fix it1630stest({ description: '(AML-10-36) can not be assigned 2', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1631return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1632files: [fromFixture('fixing/python/pyright_can_not_be_assigned_to_2.py')],1633queries: [1634{1635file: 'pyright_can_not_be_assigned_to_2.py',1636selection: [4, 19, 4, 19],1637query: `/fix Expression of type "list[None]" cannot be assigned to declared type "List[int] | None"`,1638expectedIntent: Intent.Fix,1639diagnostics: 'pyright',1640validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1641}1642]1643});1644});16451646// Inspired by case 4 of /fix dataset version 101647// In the AML run, copilot did not understand the error and did not fix it1648stest({ description: '(AML-10-4) parameter already assigned', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1649return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1650files: [fromFixture('fixing/python/pyright_parameter_already_assigned.py')],1651queries: [1652{1653file: 'pyright_parameter_already_assigned.py',1654selection: [7, 33, 7, 33],1655query: `/fix Parameter "input_shape" is already assigned`,1656expectedIntent: Intent.Fix,1657diagnostics: 'pyright',1658validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1659}1660]1661});1662});16631664// Inspired by case 48 of /fix dataset version 101665// In the AML run, copilot did not understand the error and did not fix it1666stest({ description: '(AML-10-48) can not be assigned 3', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1667return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1668files: [fromFixture('fixing/python/pyright_can_not_be_assigned_to_3.py')],1669queries: [1670{1671file: 'pyright_can_not_be_assigned_to_3.py',1672selection: [9, 14, 9, 14],1673query: [1674`/fix Argument of type "dict[str, int]" cannot be assigned to parameter "platforms" of type "list[str] | str" in function "setup"`,1675` Type "dict[str, int]" cannot be assigned to type "list[str] | str"`,1676` "dict[str, int]" is incompatible with "list[str]"`,1677` "dict[str, int]" is incompatible with "str"`,1678].join('\n'),1679expectedIntent: Intent.Fix,1680diagnostics: 'pyright',1681validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1682}1683]1684});1685});16861687// Inspired by case 58 of /fix dataset version 101688// The AML run has removed a big part of the code and replaced with non-minimal edits, this initial issue was not resolved1689stest({ description: '(AML-10-58) not defined', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1690return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1691files: [fromFixture('fixing/python/pyright_not_defined.py')],1692queries: [1693{1694file: 'pyright_not_defined.py',1695selection: [7, 20, 7, 20],1696query: `/fix "T_Or" is not defined`,1697expectedIntent: Intent.Fix,1698diagnostics: 'pyright',1699validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1700}1701]1702});1703});17041705// Inspired by case 29 of /fix dataset version 101706stest({ description: '(AML-10-29) instance of bool has no to_string member', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1707return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1708files: [fromFixture('fixing/python/pyright_no_to_string_member.py')],1709queries: [1710{1711file: 'pyright_no_to_string_member.py',1712selection: [1, 19, 1, 19],1713query: `/fix`,1714expectedIntent: Intent.Fix,1715diagnostics: 'pyright',1716validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1717}1718]1719});1720});17211722// Inspired by case 110 of /fix dataset version 81723stest({ description: '(AML-8-110) not defined', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1724return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1725files: [fromFixture('fixing/python/pyright_self_as_first_argument.py')],1726queries: [1727{1728file: 'pyright_self_as_first_argument.py',1729selection: [7, 20, 7, 20],1730query: `/fix Instance methods should take a "self" parameter`,1731expectedIntent: Intent.Fix,1732diagnostics: 'pyright',1733validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1734}1735]1736});1737});173817391740// Inspired by case 73 of /fix dataset version 81741stest({ description: '(AML-8-73) no value for argument in function call', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1742return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1743files: [fromFixture('fixing/python/pyright_no_value_for_argument.py')],1744queries: [1745{1746file: 'pyright_no_value_for_argument.py',1747selection: [12, 16, 12, 16],1748query: `/fix Argument missing for parameter "error_message"`,1749expectedIntent: Intent.Fix,1750diagnostics: 'pyright',1751validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1752}1753]1754});1755});17561757stest({ description: 'undefined variable', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1758return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1759files: [fromFixture('fixing/python/pyright_undefined_variable.py')],1760queries: [1761{1762file: 'pyright_undefined_variable.py',1763selection: [0, 0, 0, 4],1764query: `/fix "Play" is not defined`,1765expectedIntent: Intent.Fix,1766diagnostics: 'pyright',1767validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1768}1769]1770});1771});17721773stest({ description: 'import missing', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1774return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1775files: [fromFixture('fixing/python/pyright_missing_import.py')],1776queries: [1777{1778file: 'pyright_missing_import.py',1779selection: [3, 26, 3, 34],1780query: `/fix "unittest" is not defined`,1781expectedIntent: Intent.Fix,1782diagnostics: 'pyright',1783validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1784}1785]1786});1787});17881789stest({ description: 'general type issue', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1790return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1791files: [fromFixture('fixing/python/pyright_general_type_issue.py')],1792queries: [1793{1794file: 'pyright_general_type_issue.py',1795selection: [29, 22, 29, 25],1796query: [1797`/fix Argument of type "Msg[Foo]" cannot be assigned to parameter "msg" of type "Msg[FooBar]" in function "handle"`,1798` "Msg[Foo]" is incompatible with "Msg[FooBar]"`,1799` Type parameter "T@Msg" is invariant, but "Foo" is not the same as "FooBar"`1800].join('\n'),1801expectedIntent: Intent.Fix,1802diagnostics: 'pyright',1803validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1804}1805]1806});1807});18081809stest({ description: 'optional member access', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1810return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1811files: [fromFixture('fixing/python/pyright_optional_member_access.py')],1812queries: [1813{1814file: 'pyright_optional_member_access.py',1815selection: [12, 23, 12, 28],1816query: `/fix "upper" is not a known member of "None"`,1817expectedIntent: Intent.Fix,1818diagnostics: 'pyright',1819validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1820}1821]1822});1823});18241825stest({ description: 'unbound variable', language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {1826return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1827files: [fromFixture('fixing/python/pyright_unbound_variable.py')],1828queries: [1829{1830file: 'pyright_unbound_variable.py',1831selection: [4, 11, 4, 12],1832query: `/fix "a" is possibly unbound`,1833expectedIntent: Intent.Fix,1834diagnostics: 'pyright',1835validate: async (outcome, workspace, accessor) => assertNoDiagnosticsAsync(accessor, outcome, workspace, 'pyright')1836}1837]1838});1839});1840});18411842ssuite({ title: `fix${suffix}`, subtitle: 'cpp', location: 'inline' }, () => {1843stest({ description: 'code fix for C++', language: 'cpp', nonExtensionConfigurations }, (testingServiceCollection) => {1844return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1845files: [1846fromFixture('fixing/cpp/basic/main.cpp'),1847],1848queries: [1849{1850file: 'main.cpp',1851selection: [5, 32],1852query: '/fix too few arguments in function call',1853expectedIntent: Intent.Fix,1854diagnostics: 'cpp',1855validate: async (outcome, workspace, accessor) => {1856assert.strictEqual(outcome.type, 'inlineEdit');1857assertNoOccurrence(outcome.fileContents, 'getName();');1858await assertLessDiagnosticsAsync(accessor, outcome, workspace, 'cpp');1859},1860},1861],1862});1863});1864});18651866/**1867* This method validates the outcome by finding if after the edit, there remain errors1868*/1869ssuite({ title: `fix${suffix}`, subtitle: 'roslyn', location: 'inline' }, () => {18701871// Inspired by case 28 of /fix dataset version 101872// Final edit does not correspond to fetched response1873stest({ description: '(AML-10-28) field is never used', language: 'csharp', nonExtensionConfigurations }, (testingServiceCollection) => {1874return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1875files: [fromFixture('fixing/csharp/roslyn_field_never_used.cs')],1876queries: [1877{1878file: 'roslyn_field_never_used.cs',1879selection: [29, 37, 29, 37],1880query: `/fix "The event 'Class3.event3' is never used"`,1881expectedIntent: Intent.Fix,1882diagnostics: 'roslyn',1883validate: async (outcome, workspace, accessor) => assertLessDiagnosticsAsync(accessor, outcome, workspace, 'roslyn')1884}1885]1886});1887});18881889// Inspired by case 57 of /fix dataset version 101890stest({ description: '(AML-10-57) call is not awaited, execution continues', language: 'csharp', nonExtensionConfigurations }, (testingServiceCollection) => {1891return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1892files: [fromFixture('fixing/csharp/roslyn_call_not_awaited.cs')],1893queries: [1894{1895file: 'roslyn_call_not_awaited.cs',1896selection: [5, 12, 5, 12],1897query: `/fix Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.`,1898expectedIntent: Intent.Fix,1899diagnostics: 'roslyn',1900validate: async (outcome, workspace, accessor) => assertLessDiagnosticsAsync(accessor, outcome, workspace, 'roslyn')1901}1902]1903});1904});19051906// Inspired by case 3523 of /fix dataset version 171907stest({ description: '(AML-17-3523) has same name as', language: 'csharp', nonExtensionConfigurations }, (testingServiceCollection) => {1908return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1909files: [fromFixture('fixing/csharp/roslyn_has_same_name_as.cs')],1910queries: [1911{1912file: 'roslyn_has_same_name_as.cs',1913selection: [3, 23, 3, 24],1914query: `/fix Type parameter 'W' has the same name as the type parameter from outer type 'Class1<T, U>.Class11<V, W, X, Y>'.`,1915expectedIntent: Intent.Fix,1916diagnostics: 'roslyn',1917validate: async (outcome, workspace, accessor) => assertLessDiagnosticsAsync(accessor, outcome, workspace, 'roslyn')1918}1919]1920});1921});19221923stest({ description: 'does not exist', language: 'csharp', nonExtensionConfigurations }, (testingServiceCollection) => {1924return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1925files: [fromFixture('fixing/csharp/roslyn_does_not_exist.cs')],1926queries: [1927{1928file: 'roslyn_does_not_exist.cs',1929selection: [3, 26, 3, 32],1930query: `/fix The name 'mesage' does not exist in the current context`,1931expectedIntent: Intent.Fix,1932diagnostics: 'roslyn',1933validate: async (outcome, workspace, accessor) => assertLessDiagnosticsAsync(accessor, outcome, workspace, 'roslyn')1934}1935]1936});1937});19381939stest({ description: 'does not contain a definition', language: 'csharp', nonExtensionConfigurations }, (testingServiceCollection) => {1940return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1941files: [fromFixture('fixing/csharp/roslyn_does_not_contain_definition_for.cs')],1942queries: [1943{1944file: 'roslyn_does_not_contain_definition_for.cs',1945selection: [4, 23, 4, 28],1946query: `/fix 'C' does not contain a definition for 'Field'`,1947expectedIntent: Intent.Fix,1948diagnostics: 'roslyn',1949validate: async (outcome, workspace, accessor) => assertLessDiagnosticsAsync(accessor, outcome, workspace, 'roslyn')1950}1951]1952});1953});19541955stest({ description: 'no argument given', language: 'csharp', nonExtensionConfigurations }, (testingServiceCollection) => {1956return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1957files: [fromFixture('fixing/csharp/roslyn_no_argument_given.cs')],1958queries: [1959{1960file: 'roslyn_no_argument_given.cs',1961selection: [6, 19, 6, 20],1962query: `/fix There is no argument given that corresponds to the required parameter 'count' of 'C.C(int)'`,1963expectedIntent: Intent.Fix,1964diagnostics: 'roslyn',1965validate: async (outcome, workspace, accessor) => assertLessDiagnosticsAsync(accessor, outcome, workspace, 'roslyn')1966}1967]1968});1969});19701971stest({ description: 'missing using directive', language: 'csharp', nonExtensionConfigurations }, (testingServiceCollection) => {1972return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1973files: [fromFixture('fixing/csharp/roslyn_missing_using_directive.cs')],1974queries: [1975{1976file: 'roslyn_missing_using_directive.cs',1977selection: [2, 5, 2, 16],1978query: `/fix The type or namespace name 'ConditionalAttribute' could not be found (are you missing a using directive or an assembly reference?)`,1979expectedIntent: Intent.Fix,1980diagnostics: 'roslyn',1981validate: async (outcome, workspace, accessor) => assertLessDiagnosticsAsync(accessor, outcome, workspace, 'roslyn')1982}1983]1984});1985});19861987stest({ description: 'semi-colon expected', language: 'csharp', nonExtensionConfigurations }, (testingServiceCollection) => {1988return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {1989files: [fromFixture('fixing/csharp/roslyn_semi_colon_expected.cs')],1990queries: [1991{1992file: 'roslyn_semi_colon_expected.cs',1993selection: [4, 11, 4, 11],1994query: `/fix ; expected`,1995expectedIntent: Intent.Fix,1996diagnostics: 'roslyn',1997validate: async (outcome, workspace, accessor) => assertLessDiagnosticsAsync(accessor, outcome, workspace, 'roslyn')1998}1999]2000});2001});200220032004});20052006ssuite({ title: `fix${suffix}`, subtitle: 'powershell', location: 'inline' }, () => {2007stest({ description: 'Issue #7894', language: 'powershell', nonExtensionConfigurations }, (accessor) => {2008return simulateInlineChatWithStrategy(strategy, accessor, {2009files: [toFile({2010filePath: fromFixture('fix/issue-7894/shellIntegration.ps1')2011})],2012queries: [2013{2014file: 'shellIntegration.ps1',2015selection: [175, 0, 175, 3],2016query: '[psscriptanalyzer:Error]: MissingEndCurlyBrace: MissingEndCurlyBrace (in fix/issue-7894/shellIntegration.ps1)',2017expectedIntent: 'fix',2018validate: async (outcome, workspace) => {2019assertInlineEdit(outcome);2020const newText = outcome.appliedEdits.map(e => e.newText).join('');2021assert.strictEqual(newText.includes('param'), true);2022}2023}2024]2025});2026});2027});20282029});203020312032