OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library context.directory.manager; | 5 library context.directory.manager; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'dart:core' hide Resource; | 10 import 'dart:core' hide Resource; |
11 | 11 |
12 import 'package:analysis_server/plugin/analysis/resolver_provider.dart'; | 12 import 'package:analysis_server/plugin/analysis/resolver_provider.dart'; |
13 import 'package:analysis_server/src/analysis_server.dart'; | 13 import 'package:analysis_server/src/analysis_server.dart'; |
14 import 'package:analyzer/file_system/file_system.dart'; | 14 import 'package:analyzer/file_system/file_system.dart'; |
15 import 'package:analyzer/instrumentation/instrumentation.dart'; | 15 import 'package:analyzer/instrumentation/instrumentation.dart'; |
16 import 'package:analyzer/plugin/options.dart'; | 16 import 'package:analyzer/plugin/options.dart'; |
17 import 'package:analyzer/source/analysis_options_provider.dart'; | 17 import 'package:analyzer/source/analysis_options_provider.dart'; |
18 import 'package:analyzer/source/package_map_provider.dart'; | 18 import 'package:analyzer/source/package_map_provider.dart'; |
19 import 'package:analyzer/source/package_map_resolver.dart'; | 19 import 'package:analyzer/source/package_map_resolver.dart'; |
20 import 'package:analyzer/source/path_filter.dart'; | 20 import 'package:analyzer/source/path_filter.dart'; |
21 import 'package:analyzer/source/pub_package_map_provider.dart'; | 21 import 'package:analyzer/source/pub_package_map_provider.dart'; |
22 import 'package:analyzer/source/sdk_ext.dart'; | 22 import 'package:analyzer/source/sdk_ext.dart'; |
23 import 'package:analyzer/src/context/context.dart' as context; | 23 import 'package:analyzer/src/context/context.dart' as context; |
24 import 'package:analyzer/src/generated/engine.dart'; | 24 import 'package:analyzer/src/generated/engine.dart'; |
| 25 import 'package:analyzer/src/generated/error.dart'; |
25 import 'package:analyzer/src/generated/java_engine.dart'; | 26 import 'package:analyzer/src/generated/java_engine.dart'; |
26 import 'package:analyzer/src/generated/java_io.dart'; | 27 import 'package:analyzer/src/generated/java_io.dart'; |
27 import 'package:analyzer/src/generated/source.dart'; | 28 import 'package:analyzer/src/generated/source.dart'; |
28 import 'package:analyzer/src/generated/source_io.dart'; | 29 import 'package:analyzer/src/generated/source_io.dart'; |
29 import 'package:package_config/packages.dart'; | 30 import 'package:package_config/packages.dart'; |
30 import 'package:package_config/packages_file.dart' as pkgfile show parse; | 31 import 'package:package_config/packages_file.dart' as pkgfile show parse; |
31 import 'package:package_config/src/packages_impl.dart' show MapPackages; | 32 import 'package:package_config/src/packages_impl.dart' show MapPackages; |
32 import 'package:path/path.dart' as pathos; | 33 import 'package:path/path.dart' as pathos; |
33 import 'package:watcher/watcher.dart'; | 34 import 'package:watcher/watcher.dart'; |
34 import 'package:yaml/yaml.dart'; | 35 import 'package:yaml/yaml.dart'; |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 new AnalysisOptionsImpl.from(context.analysisOptions); | 514 new AnalysisOptionsImpl.from(context.analysisOptions); |
514 options.strongMode = strongMode; | 515 options.strongMode = strongMode; |
515 context.analysisOptions = options; | 516 context.analysisOptions = options; |
516 } | 517 } |
517 | 518 |
518 // Set ignore patterns. | 519 // Set ignore patterns. |
519 YamlList exclude = analyzer['exclude']; | 520 YamlList exclude = analyzer['exclude']; |
520 if (exclude != null) { | 521 if (exclude != null) { |
521 setIgnorePatternsForContext(info, exclude); | 522 setIgnorePatternsForContext(info, exclude); |
522 } | 523 } |
| 524 |
| 525 // Set filters. |
| 526 YamlList filters = analyzer['suppress']; |
| 527 setFiltersForContext(info, filters ?? const []); |
523 } | 528 } |
524 | 529 |
525 @override | 530 @override |
526 void refresh(List<Resource> roots) { | 531 void refresh(List<Resource> roots) { |
527 // Destroy old contexts | 532 // Destroy old contexts |
528 List<ContextInfo> contextInfos = _rootInfo.descendants.toList(); | 533 List<ContextInfo> contextInfos = _rootInfo.descendants.toList(); |
529 if (roots == null) { | 534 if (roots == null) { |
530 contextInfos.forEach(_destroyContext); | 535 contextInfos.forEach(_destroyContext); |
531 } else { | 536 } else { |
532 roots.forEach((Resource resource) { | 537 roots.forEach((Resource resource) { |
533 contextInfos.forEach((ContextInfo contextInfo) { | 538 contextInfos.forEach((ContextInfo contextInfo) { |
534 if (resource is Folder && | 539 if (resource is Folder && |
535 resource.isOrContains(contextInfo.folder.path)) { | 540 resource.isOrContains(contextInfo.folder.path)) { |
536 _destroyContext(contextInfo); | 541 _destroyContext(contextInfo); |
537 } | 542 } |
538 }); | 543 }); |
539 }); | 544 }); |
540 } | 545 } |
541 | 546 |
542 // Rebuild contexts based on the data last sent to setRoots(). | 547 // Rebuild contexts based on the data last sent to setRoots(). |
543 setRoots(includedPaths, excludedPaths, packageRoots); | 548 setRoots(includedPaths, excludedPaths, packageRoots); |
544 } | 549 } |
545 | 550 |
| 551 void setFiltersForContext(ContextInfo info, List<String> codes) { |
| 552 // Case-insensitive. |
| 553 codes = codes.map((code) => code.toUpperCase()).toList(); |
| 554 List<ErrorFilter> filters = codes |
| 555 .map((code) => (AnalysisError error) => error.errorCode.name == code) |
| 556 .toList(); |
| 557 info.context.setConfigurationData(CONFIGURED_ERROR_FILTERS, filters); |
| 558 } |
| 559 |
546 /** | 560 /** |
547 * Sets the [ignorePatterns] for the context having info [info]. | 561 * Sets the [ignorePatterns] for the context having info [info]. |
548 */ | 562 */ |
549 void setIgnorePatternsForContext( | 563 void setIgnorePatternsForContext( |
550 ContextInfo info, List<String> ignorePatterns) { | 564 ContextInfo info, List<String> ignorePatterns) { |
551 info.pathFilter.setIgnorePatterns(ignorePatterns); | 565 info.pathFilter.setIgnorePatterns(ignorePatterns); |
552 } | 566 } |
553 | 567 |
554 @override | 568 @override |
555 void setRoots(List<String> includedPaths, List<String> excludedPaths, | 569 void setRoots(List<String> includedPaths, List<String> excludedPaths, |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1445 var path = resourceProvider.pathContext.fromUri(uri); | 1459 var path = resourceProvider.pathContext.fromUri(uri); |
1446 packageMap[name] = <Folder>[resourceProvider.getFolder(path)]; | 1460 packageMap[name] = <Folder>[resourceProvider.getFolder(path)]; |
1447 } | 1461 } |
1448 }); | 1462 }); |
1449 return <UriResolver>[new SdkExtUriResolver(packageMap)]; | 1463 return <UriResolver>[new SdkExtUriResolver(packageMap)]; |
1450 } else { | 1464 } else { |
1451 return const <UriResolver>[]; | 1465 return const <UriResolver>[]; |
1452 } | 1466 } |
1453 } | 1467 } |
1454 } | 1468 } |
OLD | NEW |