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

Side by Side Diff: lib/src/ast.dart

Issue 1407283008: Verify type annotations on public APIs (#24). (Closed) Base URL: https://github.com/dart-lang/linter.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | lib/src/rules.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /// Common AST helpers. 5 /// Common AST helpers.
6 library linter.src.ast; 6 library linter.src.ast;
7 7
8 import 'package:analyzer/src/generated/ast.dart' 8 import 'package:analyzer/src/generated/ast.dart'
9 show 9 show
10 AssignmentExpression, 10 AssignmentExpression,
11 AstNode, 11 AstNode,
12 Block, 12 Block,
13 BlockFunctionBody, 13 BlockFunctionBody,
14 ClassDeclaration, 14 ClassDeclaration,
15 ClassMember, 15 ClassMember,
16 ClassTypeAlias, 16 ClassTypeAlias,
17 ConstructorDeclaration, 17 ConstructorDeclaration,
18 Declaration, 18 Declaration,
19 EnumConstantDeclaration, 19 EnumConstantDeclaration,
20 EnumDeclaration, 20 EnumDeclaration,
21 Expression, 21 Expression,
22 ExpressionFunctionBody, 22 ExpressionFunctionBody,
23 ExpressionStatement, 23 ExpressionStatement,
24 FieldDeclaration, 24 FieldDeclaration,
25 FunctionDeclaration, 25 FunctionDeclaration,
26 FunctionTypeAlias, 26 FunctionTypeAlias,
27 Identifier,
27 MethodDeclaration, 28 MethodDeclaration,
28 ReturnStatement, 29 ReturnStatement,
29 SimpleIdentifier, 30 SimpleIdentifier,
30 TopLevelVariableDeclaration, 31 TopLevelVariableDeclaration,
31 TypeParameter, 32 TypeParameter,
32 VariableDeclaration; 33 VariableDeclaration;
33 import 'package:analyzer/src/generated/element.dart' 34 import 'package:analyzer/src/generated/element.dart'
34 show 35 show
35 Element, 36 Element,
36 GeneralizingElementVisitor, 37 GeneralizingElementVisitor,
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 237 }
237 if (node is TypeParameter) { 238 if (node is TypeParameter) {
238 return node.name; 239 return node.name;
239 } 240 }
240 if (node is VariableDeclaration) { 241 if (node is VariableDeclaration) {
241 return node.name; 242 return node.name;
242 } 243 }
243 return null; 244 return null;
244 } 245 }
245 246
247 /// Check if the given identifier has a private name.
248 bool isPrivate(SimpleIdentifier identifier) =>
249 identifier != null ? Identifier.isPrivateName(identifier.name) : false;
250
246 /// An [Element] processor function type. 251 /// An [Element] processor function type.
247 /// If `true` is returned, children of [element] will be visited. 252 /// If `true` is returned, children of [element] will be visited.
248 typedef bool ElementProcessor(Element element); 253 typedef bool ElementProcessor(Element element);
249 254
250 /// A [GeneralizingElementVisitor] adapter for [ElementProcessor]. 255 /// A [GeneralizingElementVisitor] adapter for [ElementProcessor].
251 class _ElementVisitorAdapter extends GeneralizingElementVisitor { 256 class _ElementVisitorAdapter extends GeneralizingElementVisitor {
252 final ElementProcessor processor; 257 final ElementProcessor processor;
253 _ElementVisitorAdapter(this.processor); 258 _ElementVisitorAdapter(this.processor);
254 259
255 @override 260 @override
256 void visitElement(Element element) { 261 void visitElement(Element element) {
257 bool visitChildren = processor(element); 262 bool visitChildren = processor(element);
258 if (visitChildren == true) { 263 if (visitChildren == true) {
259 element.visitChildren(this); 264 element.visitChildren(this);
260 } 265 }
261 } 266 }
262 } 267 }
OLDNEW
« no previous file with comments | « no previous file | lib/src/rules.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698