Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: packages/analyzer/lib/src/services/lint.dart

Issue 1521693002: Roll Observatory deps (charted -> ^0.3.0) (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « packages/analyzer/lib/src/plugin/options_plugin.dart ('k') | packages/analyzer/lib/src/task/dart.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/analyzer/lib/src/services/lint.dart
diff --git a/packages/analyzer/lib/src/services/lint.dart b/packages/analyzer/lib/src/services/lint.dart
index 5efc3eae5b4cfdef094b747c3fa4a547fb78fa0a..a6b55ccbdc4145f6db9ff1806c19eeb46860e0c1 100644
--- a/packages/analyzer/lib/src/services/lint.dart
+++ b/packages/analyzer/lib/src/services/lint.dart
@@ -9,11 +9,25 @@ import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/error.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/visitors.dart';
+import 'package:analyzer/src/task/model.dart';
+import 'package:analyzer/task/model.dart';
-/// A registry containing mappings of contexts to their associated configured
-/// lints.
-final Map<AnalysisContext, List<Linter>> lintRegistry =
- <AnalysisContext, List<Linter>>{};
+const List<Linter> _noLints = const <Linter>[];
+
+/// The descriptor used to associate lints with analysis contexts in
+/// configuration data.
+final ResultDescriptor<List<Linter>> CONFIGURED_LINTS_KEY =
+ new ResultDescriptorImpl('configured.lints', _noLints);
+
+/// Return lints associated with this [context], or an empty list if there are
+/// none.
+List<Linter> getLints(AnalysisContext context) =>
+ context.getConfigurationData(CONFIGURED_LINTS_KEY) ?? _noLints;
+
+/// Associate these [lints] with the given [context].
+void setLints(AnalysisContext context, List<Linter> lints) {
+ context.setConfigurationData(CONFIGURED_LINTS_KEY, lints);
+}
/// Implementers contribute lint warnings via the provided error [reporter].
abstract class Linter {
@@ -32,9 +46,7 @@ abstract class Linter {
///
/// See [LintCode].
class LintGenerator {
- /// A global container for contributed linters.
- @deprecated // Use lintRegistry.
- static final List<Linter> LINTERS = <Linter>[];
+ static const List<Linter> _noLints = const <Linter>[];
final Iterable<CompilationUnit> _compilationUnits;
final AnalysisErrorListener _errorListener;
@@ -42,7 +54,7 @@ class LintGenerator {
LintGenerator(this._compilationUnits, this._errorListener,
[Iterable<Linter> linters])
- : _linters = linters ?? LINTERS;
+ : _linters = linters ?? _noLints;
void generate() {
PerformanceStatistics.lint.makeCurrentWhile(() {
« no previous file with comments | « packages/analyzer/lib/src/plugin/options_plugin.dart ('k') | packages/analyzer/lib/src/task/dart.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698