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

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

Issue 2725013003: Support accessing the parameter element when there is no name (Closed)
Patch Set: Created 3 years, 9 months 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 | pkg/analyzer/lib/src/dart/ast/utilities.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) 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 analyzer.src.dart.ast.ast; 5 library analyzer.src.dart.ast.ast;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/syntactic_entity.dart'; 10 import 'package:analyzer/dart/ast/syntactic_entity.dart';
(...skipping 5813 matching lines...) Expand 10 before | Expand all | Expand 10 after
5824 } 5824 }
5825 5825
5826 @override 5826 @override
5827 Iterable<SyntacticEntity> get childEntities => new ChildEntities() 5827 Iterable<SyntacticEntity> get childEntities => new ChildEntities()
5828 ..addAll(metadata) 5828 ..addAll(metadata)
5829 ..add(typedefKeyword) 5829 ..add(typedefKeyword)
5830 ..add(name) 5830 ..add(name)
5831 ..add(_typeParameters) 5831 ..add(_typeParameters)
5832 ..add(equals) 5832 ..add(equals)
5833 ..add(_functionType); 5833 ..add(_functionType);
5834
5834 @override 5835 @override
5835 Element get element => null; 5836 Element get element => name.staticElement;
5836 5837
5837 @override 5838 @override
5838 GenericFunctionType get functionType => _functionType; 5839 GenericFunctionType get functionType => _functionType;
5839 5840
5840 @override 5841 @override
5841 void set functionType(GenericFunctionType functionType) { 5842 void set functionType(GenericFunctionType functionType) {
5842 _functionType = _becomeParentOf(functionType as AstNodeImpl); 5843 _functionType = _becomeParentOf(functionType as AstNodeImpl);
5843 } 5844 }
5844 5845
5845 @override 5846 @override
5846 TypeParameterList get typeParameters => _typeParameters; 5847 TypeParameterList get typeParameters => _typeParameters;
5847 5848
5848 @override 5849 @override
5849 void set typeParameters(TypeParameterList typeParameters) { 5850 void set typeParameters(TypeParameterList typeParameters) {
5850 _typeParameters = _becomeParentOf(typeParameters as AstNodeImpl); 5851 _typeParameters = _becomeParentOf(typeParameters as AstNodeImpl);
5851 } 5852 }
5852 5853
5853 @override 5854 @override
5854 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) { 5855 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) {
5855 return visitor.visitGenericTypeAlias(this); 5856 return visitor.visitGenericTypeAlias(this);
5856 } 5857 }
5857 5858
5858 // TODO: implement element
5859 @override 5859 @override
5860 void visitChildren(AstVisitor visitor) { 5860 void visitChildren(AstVisitor visitor) {
5861 super.visitChildren(visitor); 5861 super.visitChildren(visitor);
5862 name?.accept(visitor); 5862 name?.accept(visitor);
5863 _typeParameters?.accept(visitor); 5863 _typeParameters?.accept(visitor);
5864 _functionType?.accept(visitor); 5864 _functionType?.accept(visitor);
5865 } 5865 }
5866 } 5866 }
5867 5867
5868 /** 5868 /**
(...skipping 3363 matching lines...) Expand 10 before | Expand all | Expand 10 after
9232 * `null` if no keyword was used. 9232 * `null` if no keyword was used.
9233 */ 9233 */
9234 Token keyword; 9234 Token keyword;
9235 9235
9236 /** 9236 /**
9237 * The name of the declared type of the parameter, or `null` if the parameter 9237 * The name of the declared type of the parameter, or `null` if the parameter
9238 * does not have a declared type. 9238 * does not have a declared type.
9239 */ 9239 */
9240 TypeAnnotation _type; 9240 TypeAnnotation _type;
9241 9241
9242 @override
9243 ParameterElement element;
9244
9242 /** 9245 /**
9243 * Initialize a newly created formal parameter. Either or both of the 9246 * Initialize a newly created formal parameter. Either or both of the
9244 * [comment] and [metadata] can be `null` if the parameter does not have the 9247 * [comment] and [metadata] can be `null` if the parameter does not have the
9245 * corresponding attribute. The [keyword] can be `null` if a type was 9248 * corresponding attribute. The [keyword] can be `null` if a type was
9246 * specified. The [type] must be `null` if the keyword is 'var'. 9249 * specified. The [type] must be `null` if the keyword is 'var'.
9247 */ 9250 */
9248 SimpleFormalParameterImpl( 9251 SimpleFormalParameterImpl(
9249 CommentImpl comment, 9252 CommentImpl comment,
9250 List<Annotation> metadata, 9253 List<Annotation> metadata,
9251 Token covariantKeyword, 9254 Token covariantKeyword,
(...skipping 17 matching lines...) Expand all
9269 return _type.beginToken; 9272 return _type.beginToken;
9270 } 9273 }
9271 return identifier.beginToken; 9274 return identifier.beginToken;
9272 } 9275 }
9273 9276
9274 @override 9277 @override
9275 Iterable<SyntacticEntity> get childEntities => 9278 Iterable<SyntacticEntity> get childEntities =>
9276 super._childEntities..add(keyword)..add(_type)..add(identifier); 9279 super._childEntities..add(keyword)..add(_type)..add(identifier);
9277 9280
9278 @override 9281 @override
9279 Token get endToken => identifier.endToken; 9282 Token get endToken => identifier?.endToken ?? type?.endToken;
9280 9283
9281 @override 9284 @override
9282 bool get isConst => keyword?.keyword == Keyword.CONST; 9285 bool get isConst => keyword?.keyword == Keyword.CONST;
9283 9286
9284 @override 9287 @override
9285 bool get isFinal => keyword?.keyword == Keyword.FINAL; 9288 bool get isFinal => keyword?.keyword == Keyword.FINAL;
9286 9289
9287 @override 9290 @override
9288 TypeAnnotation get type => _type; 9291 TypeAnnotation get type => _type;
9289 9292
(...skipping 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after
11481 11484
11482 @override 11485 @override
11483 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => 11486 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) =>
11484 visitor.visitYieldStatement(this); 11487 visitor.visitYieldStatement(this);
11485 11488
11486 @override 11489 @override
11487 void visitChildren(AstVisitor visitor) { 11490 void visitChildren(AstVisitor visitor) {
11488 _expression?.accept(visitor); 11491 _expression?.accept(visitor);
11489 } 11492 }
11490 } 11493 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/ast/utilities.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698