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'; |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 for (int i = 0; i < count; i++) { | 414 for (int i = 0; i < count; i++) { |
415 nonFields[i].accept(this); | 415 nonFields[i].accept(this); |
416 } | 416 } |
417 } finally { | 417 } finally { |
418 _currentHolder = previousHolder; | 418 _currentHolder = previousHolder; |
419 } | 419 } |
420 SimpleIdentifier className = node.name; | 420 SimpleIdentifier className = node.name; |
421 ClassElementImpl element = new ClassElementImpl.forNode(className); | 421 ClassElementImpl element = new ClassElementImpl.forNode(className); |
422 _setCodeRange(element, node); | 422 _setCodeRange(element, node); |
423 element.metadata = _createElementAnnotations(node.metadata); | 423 element.metadata = _createElementAnnotations(node.metadata); |
424 List<TypeParameterElement> typeParameters = holder.typeParameters; | 424 element.typeParameters = holder.typeParameters; |
425 List<DartType> typeArguments = _createTypeParameterTypes(typeParameters); | |
426 InterfaceTypeImpl interfaceType = new InterfaceTypeImpl(element); | |
427 interfaceType.typeArguments = typeArguments; | |
428 element.type = interfaceType; | |
429 element.typeParameters = typeParameters; | |
430 setElementDocumentationComment(element, node); | 425 setElementDocumentationComment(element, node); |
431 element.abstract = node.isAbstract; | 426 element.abstract = node.isAbstract; |
432 element.accessors = holder.accessors; | 427 element.accessors = holder.accessors; |
433 List<ConstructorElement> constructors = holder.constructors; | 428 List<ConstructorElement> constructors = holder.constructors; |
434 if (constructors.isEmpty) { | 429 if (constructors.isEmpty) { |
435 constructors = _createDefaultConstructors(element); | 430 constructors = _createDefaultConstructors(element); |
436 } | 431 } |
437 element.constructors = constructors; | 432 element.constructors = constructors; |
438 element.fields = holder.fields; | 433 element.fields = holder.fields; |
439 element.methods = holder.methods; | 434 element.methods = holder.methods; |
(...skipping 26 matching lines...) Expand all Loading... |
466 @override | 461 @override |
467 Object visitClassTypeAlias(ClassTypeAlias node) { | 462 Object visitClassTypeAlias(ClassTypeAlias node) { |
468 ElementHolder holder = new ElementHolder(); | 463 ElementHolder holder = new ElementHolder(); |
469 _visitChildren(holder, node); | 464 _visitChildren(holder, node); |
470 SimpleIdentifier className = node.name; | 465 SimpleIdentifier className = node.name; |
471 ClassElementImpl element = new ClassElementImpl.forNode(className); | 466 ClassElementImpl element = new ClassElementImpl.forNode(className); |
472 _setCodeRange(element, node); | 467 _setCodeRange(element, node); |
473 element.metadata = _createElementAnnotations(node.metadata); | 468 element.metadata = _createElementAnnotations(node.metadata); |
474 element.abstract = node.abstractKeyword != null; | 469 element.abstract = node.abstractKeyword != null; |
475 element.mixinApplication = true; | 470 element.mixinApplication = true; |
476 List<TypeParameterElement> typeParameters = holder.typeParameters; | 471 element.typeParameters = holder.typeParameters; |
477 element.typeParameters = typeParameters; | |
478 List<DartType> typeArguments = _createTypeParameterTypes(typeParameters); | |
479 InterfaceTypeImpl interfaceType = new InterfaceTypeImpl(element); | |
480 interfaceType.typeArguments = typeArguments; | |
481 element.type = interfaceType; | |
482 setElementDocumentationComment(element, node); | 472 setElementDocumentationComment(element, node); |
483 _currentHolder.addType(element); | 473 _currentHolder.addType(element); |
484 className.staticElement = element; | 474 className.staticElement = element; |
485 holder.validate(); | 475 holder.validate(); |
486 return null; | 476 return null; |
487 } | 477 } |
488 | 478 |
489 @override | 479 @override |
490 Object visitCompilationUnit(CompilationUnit node) { | 480 Object visitCompilationUnit(CompilationUnit node) { |
491 if (compilationUnitElement is ElementImpl) { | 481 if (compilationUnitElement is ElementImpl) { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 return null; | 604 return null; |
615 } | 605 } |
616 | 606 |
617 @override | 607 @override |
618 Object visitEnumDeclaration(EnumDeclaration node) { | 608 Object visitEnumDeclaration(EnumDeclaration node) { |
619 SimpleIdentifier enumName = node.name; | 609 SimpleIdentifier enumName = node.name; |
620 EnumElementImpl enumElement = new EnumElementImpl.forNode(enumName); | 610 EnumElementImpl enumElement = new EnumElementImpl.forNode(enumName); |
621 _setCodeRange(enumElement, node); | 611 _setCodeRange(enumElement, node); |
622 enumElement.metadata = _createElementAnnotations(node.metadata); | 612 enumElement.metadata = _createElementAnnotations(node.metadata); |
623 setElementDocumentationComment(enumElement, node); | 613 setElementDocumentationComment(enumElement, node); |
624 InterfaceTypeImpl enumType = new InterfaceTypeImpl(enumElement); | 614 InterfaceTypeImpl enumType = enumElement.type; |
625 enumElement.type = enumType; | |
626 // | 615 // |
627 // Build the elements for the constants. These are minimal elements; the | 616 // Build the elements for the constants. These are minimal elements; the |
628 // rest of the constant elements (and elements for other fields) must be | 617 // rest of the constant elements (and elements for other fields) must be |
629 // built later after we can access the type provider. | 618 // built later after we can access the type provider. |
630 // | 619 // |
631 List<FieldElement> fields = new List<FieldElement>(); | 620 List<FieldElement> fields = new List<FieldElement>(); |
632 NodeList<EnumConstantDeclaration> constants = node.constants; | 621 NodeList<EnumConstantDeclaration> constants = node.constants; |
633 for (EnumConstantDeclaration constant in constants) { | 622 for (EnumConstantDeclaration constant in constants) { |
634 SimpleIdentifier constantName = constant.name; | 623 SimpleIdentifier constantName = constant.name; |
635 FieldElementImpl constantField = | 624 FieldElementImpl constantField = |
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1474 return null; | 1463 return null; |
1475 } | 1464 } |
1476 | 1465 |
1477 /** | 1466 /** |
1478 * Return the lexical identifiers associated with the given [identifiers]. | 1467 * Return the lexical identifiers associated with the given [identifiers]. |
1479 */ | 1468 */ |
1480 static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) { | 1469 static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) { |
1481 return identifiers.map((identifier) => identifier.name).toList(); | 1470 return identifiers.map((identifier) => identifier.name).toList(); |
1482 } | 1471 } |
1483 } | 1472 } |
OLD | NEW |