File tree 2 files changed +48
-2
lines changed
pkg/analysis_server/test/src/services/correction/fix
2 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -264,8 +264,7 @@ abstract class FixProcessorTest extends BaseFixProcessorTest {
264
264
265
265
Future <void > addUnimportedFile (String filePath, String content) async {
266
266
addSource (filePath, content);
267
- var result = await session.getResolvedUnit (convertPath (filePath));
268
- extensionCache.cacheFromResult (result as ResolvedUnitResult );
267
+ await cacheExtensionsForFile (filePath);
269
268
}
270
269
271
270
Future <void > assertHasFix (String expected,
@@ -378,6 +377,11 @@ abstract class FixProcessorTest extends BaseFixProcessorTest {
378
377
await _assertNoFixAllFix (error);
379
378
}
380
379
380
+ Future <void > cacheExtensionsForFile (String path) async {
381
+ var result = await session.getResolvedUnit (convertPath (path));
382
+ extensionCache.cacheFromResult (result as ResolvedUnitResult );
383
+ }
384
+
381
385
List <LinkedEditSuggestion > expectedSuggestions (
382
386
LinkedEditSuggestionKind kind, List <String > values) {
383
387
return values.map ((value) {
Original file line number Diff line number Diff line change @@ -234,6 +234,48 @@ void f(String s) {
234
234
''' );
235
235
}
236
236
237
+ @FailingTest (reason: 'We suggest importing src/b.dart' )
238
+ Future <void > test_extension_otherPackage_exported_fromSrc () async {
239
+ var pkgRootPath = '/.pub-cache/aaa' ;
240
+
241
+ var a = newFile ('$pkgRootPath /lib/a.dart' , content: r'''
242
+ export 'src/b.dart';
243
+ ''' );
244
+
245
+ var b = newFile ('$pkgRootPath /lib/src/b.dart' , content: r'''
246
+ extension IntExtension on int {
247
+ int get foo => 0;
248
+ }
249
+ ''' );
250
+
251
+ writeTestPackageConfig (
252
+ config: PackageConfigFileBuilder ()
253
+ ..add (name: 'aaa' , rootPath: pkgRootPath),
254
+ );
255
+
256
+ updateTestPubspecFile ('''
257
+ dependencies:
258
+ aaa: any
259
+ ''' );
260
+
261
+ await cacheExtensionsForFile (a.path);
262
+ await cacheExtensionsForFile (b.path);
263
+
264
+ await resolveTestCode ('''
265
+ void f() {
266
+ 0.foo;
267
+ }
268
+ ''' );
269
+
270
+ await assertHasFix ('''
271
+ import 'package:aaa/a.dart';
272
+
273
+ void f() {
274
+ 0.foo;
275
+ }
276
+ ''' );
277
+ }
278
+
237
279
Future <void > test_invalidUri_interpolation () async {
238
280
addSource ('$testPackageLibPath /lib.dart' , r'''
239
281
class Test {
You can’t perform that action at this time.
0 commit comments