Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 library analyzer.src.plugin.linter_plugin; | |
| 6 | |
| 7 import 'package:analyzer/plugin/linter.dart'; | |
| 8 import 'package:linter/src/linter.dart'; | |
| 9 import 'package:linter/src/rules/camel_case_types.dart'; | |
| 10 import 'package:linter/src/rules/constant_identifier_names.dart'; | |
| 11 import 'package:linter/src/rules/empty_constructor_bodies.dart'; | |
| 12 import 'package:linter/src/rules/library_names.dart'; | |
| 13 import 'package:linter/src/rules/library_prefixes.dart'; | |
| 14 import 'package:linter/src/rules/non_constant_identifier_names.dart'; | |
| 15 import 'package:linter/src/rules/one_member_abstracts.dart'; | |
| 16 import 'package:linter/src/rules/slash_for_doc_comments.dart'; | |
| 17 import 'package:linter/src/rules/super_goes_last.dart'; | |
| 18 import 'package:linter/src/rules/type_init_formals.dart'; | |
| 19 import 'package:linter/src/rules/unnecessary_brace_in_string_interp.dart'; | |
| 20 import 'package:plugin/plugin.dart'; | |
| 21 | |
| 22 /// A plugin that defines the extension points and extensions that are inherentl y | |
|
kevmoo
2015/05/08 22:30:00
long line
pquitslund
2015/05/08 22:39:19
Done.
| |
| 23 /// defined by the linter. | |
| 24 class LinterPlugin implements Plugin { | |
| 25 | |
| 26 /// A subset of rules that we are considering "default". | |
| 27 static final List<LintRule> _rules = [ | |
| 28 new CamelCaseTypes(), | |
| 29 new ConstantIdentifierNames(), | |
| 30 new EmptyConstructorBodies(), | |
| 31 new LibraryNames(), | |
| 32 new LibraryPrefixes(), | |
| 33 new NonConstantIdentifierNames(), | |
| 34 new OneMemberAbstracts(), | |
| 35 new SlashForDocComments(), | |
| 36 new SuperGoesLast(), | |
| 37 new TypeInitFormals(), | |
| 38 new UnnecessaryBraceInStringInterp() | |
| 39 ]; | |
| 40 | |
| 41 /// The unique identifier of this plugin. | |
| 42 static const String UNIQUE_IDENTIFIER = 'linter.core'; | |
| 43 | |
| 44 /// The simple identifier of the extension point that allows plugins to | |
| 45 /// register new lint rules with the analysis engine. | |
| 46 static const String LINT_RULE_EXTENSION_POINT = 'lint_rule'; | |
| 47 | |
| 48 /// The extension point that allows plugins to register new lint rules tasks w ith | |
|
kevmoo
2015/05/08 22:30:00
long line
pquitslund
2015/05/08 22:39:19
Done.
| |
| 49 /// the analysis engine. | |
| 50 ExtensionPoint lintRuleExtensionPoint; | |
| 51 | |
| 52 /// Return a list containing all contributed lint rules. | |
| 53 List<LintRule> get lintRules => lintRuleExtensionPoint.extensions; | |
| 54 | |
| 55 @override | |
| 56 String get uniqueIdentifier => UNIQUE_IDENTIFIER; | |
| 57 | |
| 58 @override | |
| 59 void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) { | |
| 60 lintRuleExtensionPoint = registerExtensionPoint( | |
| 61 LINT_RULE_EXTENSION_POINT, _validateTaskExtension); | |
| 62 } | |
| 63 | |
| 64 @override | |
| 65 void registerExtensions(RegisterExtension registerExtension) { | |
| 66 _rules.forEach((LintRule rule) => | |
| 67 registerExtension(LINT_RULE_EXTENSION_POINT_ID, rule)); | |
| 68 } | |
| 69 | |
| 70 void _validateTaskExtension(Object extension) { | |
| 71 if (extension is! LintRule) { | |
| 72 String id = lintRuleExtensionPoint.uniqueIdentifier; | |
| 73 throw new ExtensionError('Extensions to $id must implement LintRule'); | |
| 74 } | |
| 75 } | |
| 76 } | |
| OLD | NEW |