| OLD | NEW |
| 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.element.builder; | 5 library analyzer.src.dart.element.builder; |
| 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/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| 11 import 'package:analyzer/dart/ast/visitor.dart'; | 11 import 'package:analyzer/dart/ast/visitor.dart'; |
| 12 import 'package:analyzer/dart/element/element.dart'; | 12 import 'package:analyzer/dart/element/element.dart'; |
| 13 import 'package:analyzer/dart/element/type.dart'; | 13 import 'package:analyzer/dart/element/type.dart'; |
| 14 import 'package:analyzer/error/error.dart'; | 14 import 'package:analyzer/error/error.dart'; |
| 15 import 'package:analyzer/exception/exception.dart'; | 15 import 'package:analyzer/exception/exception.dart'; |
| 16 import 'package:analyzer/src/dart/ast/ast.dart'; |
| 16 import 'package:analyzer/src/dart/element/element.dart'; | 17 import 'package:analyzer/src/dart/element/element.dart'; |
| 17 import 'package:analyzer/src/dart/element/type.dart'; | 18 import 'package:analyzer/src/dart/element/type.dart'; |
| 18 import 'package:analyzer/src/error/codes.dart'; | 19 import 'package:analyzer/src/error/codes.dart'; |
| 19 import 'package:analyzer/src/generated/engine.dart'; | 20 import 'package:analyzer/src/generated/engine.dart'; |
| 20 import 'package:analyzer/src/generated/resolver.dart'; | 21 import 'package:analyzer/src/generated/resolver.dart'; |
| 21 import 'package:analyzer/src/generated/sdk.dart'; | 22 import 'package:analyzer/src/generated/sdk.dart'; |
| 22 import 'package:analyzer/src/generated/source.dart'; | 23 import 'package:analyzer/src/generated/source.dart'; |
| 23 import 'package:analyzer/src/generated/utilities_dart.dart'; | 24 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 24 | 25 |
| 25 /** | 26 /** |
| (...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1398 parameter.isExplicitlyCovariant = node.parameter.covariantKeyword != null; | 1399 parameter.isExplicitlyCovariant = node.parameter.covariantKeyword != null; |
| 1399 parameter.isFinal = node.isFinal; | 1400 parameter.isFinal = node.isFinal; |
| 1400 parameter.parameterKind = node.kind; | 1401 parameter.parameterKind = node.kind; |
| 1401 // visible range | 1402 // visible range |
| 1402 _setParameterVisibleRange(node, parameter); | 1403 _setParameterVisibleRange(node, parameter); |
| 1403 if (normalParameter is SimpleFormalParameter && | 1404 if (normalParameter is SimpleFormalParameter && |
| 1404 normalParameter.type == null) { | 1405 normalParameter.type == null) { |
| 1405 parameter.hasImplicitType = true; | 1406 parameter.hasImplicitType = true; |
| 1406 } | 1407 } |
| 1407 _currentHolder.addParameter(parameter); | 1408 _currentHolder.addParameter(parameter); |
| 1409 if (normalParameter is SimpleFormalParameterImpl) { |
| 1410 normalParameter.element = parameter; |
| 1411 } |
| 1408 parameterName.staticElement = parameter; | 1412 parameterName.staticElement = parameter; |
| 1409 normalParameter.accept(this); | 1413 normalParameter.accept(this); |
| 1410 return null; | 1414 return null; |
| 1411 } | 1415 } |
| 1412 | 1416 |
| 1413 @override | 1417 @override |
| 1414 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { | 1418 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { |
| 1415 if (node.parent is! DefaultFormalParameter) { | 1419 if (node.parent is! DefaultFormalParameter) { |
| 1416 SimpleIdentifier parameterName = node.identifier; | 1420 SimpleIdentifier parameterName = node.identifier; |
| 1417 ParameterElementImpl parameter = | 1421 ParameterElementImpl parameter = |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1434 ParameterElementImpl element = node.element; | 1438 ParameterElementImpl element = node.element; |
| 1435 element.metadata = _createElementAnnotations(node.metadata); | 1439 element.metadata = _createElementAnnotations(node.metadata); |
| 1436 element.parameters = holder.parameters; | 1440 element.parameters = holder.parameters; |
| 1437 element.typeParameters = holder.typeParameters; | 1441 element.typeParameters = holder.typeParameters; |
| 1438 holder.validate(); | 1442 holder.validate(); |
| 1439 return null; | 1443 return null; |
| 1440 } | 1444 } |
| 1441 | 1445 |
| 1442 @override | 1446 @override |
| 1443 Object visitSimpleFormalParameter(SimpleFormalParameter node) { | 1447 Object visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 1448 ParameterElementImpl parameter; |
| 1444 if (node.parent is! DefaultFormalParameter) { | 1449 if (node.parent is! DefaultFormalParameter) { |
| 1445 SimpleIdentifier parameterName = node.identifier; | 1450 SimpleIdentifier parameterName = node.identifier; |
| 1446 ParameterElementImpl parameter = | 1451 parameter = new ParameterElementImpl.forNode(parameterName); |
| 1447 new ParameterElementImpl.forNode(parameterName); | |
| 1448 _setCodeRange(parameter, node); | 1452 _setCodeRange(parameter, node); |
| 1449 parameter.isConst = node.isConst; | 1453 parameter.isConst = node.isConst; |
| 1450 parameter.isExplicitlyCovariant = node.covariantKeyword != null; | 1454 parameter.isExplicitlyCovariant = node.covariantKeyword != null; |
| 1451 parameter.isFinal = node.isFinal; | 1455 parameter.isFinal = node.isFinal; |
| 1452 parameter.parameterKind = node.kind; | 1456 parameter.parameterKind = node.kind; |
| 1453 _setParameterVisibleRange(node, parameter); | 1457 _setParameterVisibleRange(node, parameter); |
| 1454 if (node.type == null) { | 1458 if (node.type == null) { |
| 1455 parameter.hasImplicitType = true; | 1459 parameter.hasImplicitType = true; |
| 1456 } | 1460 } |
| 1457 _currentHolder.addParameter(parameter); | 1461 _currentHolder.addParameter(parameter); |
| 1458 parameterName.staticElement = parameter; | 1462 (node as SimpleFormalParameterImpl).element = parameter; |
| 1463 parameterName?.staticElement = parameter; |
| 1459 } | 1464 } |
| 1460 super.visitSimpleFormalParameter(node); | 1465 super.visitSimpleFormalParameter(node); |
| 1461 (node.element as ElementImpl).metadata = | 1466 parameter ??= node.element; |
| 1462 _createElementAnnotations(node.metadata); | 1467 parameter?.metadata = _createElementAnnotations(node.metadata); |
| 1463 return null; | 1468 return null; |
| 1464 } | 1469 } |
| 1465 | 1470 |
| 1466 @override | 1471 @override |
| 1467 Object visitTypeParameter(TypeParameter node) { | 1472 Object visitTypeParameter(TypeParameter node) { |
| 1468 SimpleIdentifier parameterName = node.name; | 1473 SimpleIdentifier parameterName = node.name; |
| 1469 TypeParameterElementImpl typeParameter = | 1474 TypeParameterElementImpl typeParameter = |
| 1470 new TypeParameterElementImpl.forNode(parameterName); | 1475 new TypeParameterElementImpl.forNode(parameterName); |
| 1471 _setCodeRange(typeParameter, node); | 1476 _setCodeRange(typeParameter, node); |
| 1472 typeParameter.metadata = _createElementAnnotations(node.metadata); | 1477 typeParameter.metadata = _createElementAnnotations(node.metadata); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1626 return null; | 1631 return null; |
| 1627 } | 1632 } |
| 1628 | 1633 |
| 1629 /** | 1634 /** |
| 1630 * Return the lexical identifiers associated with the given [identifiers]. | 1635 * Return the lexical identifiers associated with the given [identifiers]. |
| 1631 */ | 1636 */ |
| 1632 static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) { | 1637 static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) { |
| 1633 return identifiers.map((identifier) => identifier.name).toList(); | 1638 return identifiers.map((identifier) => identifier.name).toList(); |
| 1634 } | 1639 } |
| 1635 } | 1640 } |
| OLD | NEW |