OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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 linter.src.rules.package_api_docs; | 5 library linter.src.rules.package_api_docs; |
6 | 6 |
7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
8 import 'package:linter/src/ast.dart'; | 8 import 'package:linter/src/ast.dart'; |
9 import 'package:linter/src/linter.dart'; | 9 import 'package:linter/src/linter.dart'; |
10 import 'package:linter/src/project.dart'; | 10 import 'package:linter/src/project.dart'; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 class Visitor extends GeneralizingAstVisitor { | 84 class Visitor extends GeneralizingAstVisitor { |
85 PackageApiDocs rule; | 85 PackageApiDocs rule; |
86 Visitor(this.rule); | 86 Visitor(this.rule); |
87 | 87 |
88 DartProject get project => rule.project; | 88 DartProject get project => rule.project; |
89 | 89 |
90 void check(Declaration node) { | 90 void check(Declaration node) { |
| 91 // If no project info is set, bail early. |
| 92 // https://github.com/dart-lang/linter/issues/154 |
| 93 if (project == null) { |
| 94 return; |
| 95 } |
91 if (project.isApi(node.element)) { | 96 if (project.isApi(node.element)) { |
92 if (node.documentationComment == null) { | 97 if (node.documentationComment == null) { |
93 rule.reportLint(getNodeToAnnotate(node)); | 98 rule.reportLint(getNodeToAnnotate(node)); |
94 } | 99 } |
95 } | 100 } |
96 } | 101 } |
97 | 102 |
98 /// classMember ::= | 103 /// classMember ::= |
99 /// [ConstructorDeclaration] | 104 /// [ConstructorDeclaration] |
100 /// | [FieldDeclaration] | 105 /// | [FieldDeclaration] |
(...skipping 13 matching lines...) Expand all Loading... |
114 @override | 119 @override |
115 visitCompilationUnitMember(CompilationUnitMember node) { | 120 visitCompilationUnitMember(CompilationUnitMember node) { |
116 check(node); | 121 check(node); |
117 } | 122 } |
118 | 123 |
119 @override | 124 @override |
120 visitNode(AstNode node) { | 125 visitNode(AstNode node) { |
121 // Don't visit children | 126 // Don't visit children |
122 } | 127 } |
123 } | 128 } |
OLD | NEW |