@@ -24,6 +24,7 @@ import 'package:analyzer/dart/ast/token.dart';
24
24
import 'package:analyzer/dart/element/element.dart' ;
25
25
import 'package:analyzer/dart/element/type.dart' ;
26
26
import 'package:analyzer/error/error.dart' ;
27
+ import 'package:analyzer/exception/exception.dart' ;
27
28
import 'package:analyzer/file_system/file_system.dart' ;
28
29
import 'package:analyzer/src/dart/analysis/driver.dart' ;
29
30
import 'package:analyzer/src/dart/analysis/top_level_declaration.dart' ;
@@ -1513,13 +1514,17 @@ class FixProcessor {
1513
1514
String file = source.fullName;
1514
1515
if (isAbsolute (file) && AnalysisEngine .isDartFileName (file)) {
1515
1516
String libName = _computeLibraryName (file);
1516
- DartChangeBuilder changeBuilder = new DartChangeBuilder (session);
1517
- await changeBuilder.addFileEdit (source.fullName,
1518
- (DartFileEditBuilder builder) {
1519
- builder.addSimpleInsertion (0 , 'library $libName ;$eol $eol ' );
1520
- });
1521
- _addFixFromBuilder (changeBuilder, DartFixKind .CREATE_FILE ,
1522
- args: [source.shortName]);
1517
+ try {
1518
+ DartChangeBuilder changeBuilder = new DartChangeBuilder (session);
1519
+ await changeBuilder.addFileEdit (source.fullName,
1520
+ (DartFileEditBuilder builder) {
1521
+ builder.addSimpleInsertion (0 , 'library $libName ;$eol $eol ' );
1522
+ });
1523
+ _addFixFromBuilder (changeBuilder, DartFixKind .CREATE_FILE ,
1524
+ args: [source.shortName]);
1525
+ } on AnalysisException {
1526
+ // Ignore the exception and just don't create a fix.
1527
+ }
1523
1528
}
1524
1529
}
1525
1530
}
0 commit comments