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

Side by Side Diff: pkg/analyzer/lib/src/dart/element/builder.dart

Issue 2027893002: Start separating ClassElementImpl for Class and Enum. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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
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.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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 new _ElementBuilder_visitClassDeclaration(this, nonFields)); 411 new _ElementBuilder_visitClassDeclaration(this, nonFields));
412 _buildFieldMap(holder.fieldsWithoutFlushing); 412 _buildFieldMap(holder.fieldsWithoutFlushing);
413 int count = nonFields.length; 413 int count = nonFields.length;
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_Class.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 List<TypeParameterElement> typeParameters = holder.typeParameters;
425 List<DartType> typeArguments = _createTypeParameterTypes(typeParameters); 425 List<DartType> typeArguments = _createTypeParameterTypes(typeParameters);
426 InterfaceTypeImpl interfaceType = new InterfaceTypeImpl(element); 426 InterfaceTypeImpl interfaceType = new InterfaceTypeImpl(element);
427 interfaceType.typeArguments = typeArguments; 427 interfaceType.typeArguments = typeArguments;
428 element.type = interfaceType; 428 element.type = interfaceType;
429 element.typeParameters = typeParameters; 429 element.typeParameters = typeParameters;
430 setElementDocumentationComment(element, node); 430 setElementDocumentationComment(element, node);
431 element.abstract = node.isAbstract; 431 element.abstract = node.isAbstract;
(...skipping 29 matching lines...) Expand all
461 // 461 //
462 ClassElement classElement = node.element; 462 ClassElement classElement = node.element;
463 _buildFieldMap(classElement.fields); 463 _buildFieldMap(classElement.fields);
464 } 464 }
465 465
466 @override 466 @override
467 Object visitClassTypeAlias(ClassTypeAlias node) { 467 Object visitClassTypeAlias(ClassTypeAlias node) {
468 ElementHolder holder = new ElementHolder(); 468 ElementHolder holder = new ElementHolder();
469 _visitChildren(holder, node); 469 _visitChildren(holder, node);
470 SimpleIdentifier className = node.name; 470 SimpleIdentifier className = node.name;
471 ClassElementImpl element = new ClassElementImpl.forNode(className); 471 ClassElementImpl element = new ClassElementImpl_Class.forNode(className);
472 _setCodeRange(element, node); 472 _setCodeRange(element, node);
473 element.metadata = _createElementAnnotations(node.metadata); 473 element.metadata = _createElementAnnotations(node.metadata);
474 element.abstract = node.abstractKeyword != null; 474 element.abstract = node.abstractKeyword != null;
475 element.mixinApplication = true; 475 element.mixinApplication = true;
476 List<TypeParameterElement> typeParameters = holder.typeParameters; 476 List<TypeParameterElement> typeParameters = holder.typeParameters;
477 element.typeParameters = typeParameters; 477 element.typeParameters = typeParameters;
478 List<DartType> typeArguments = _createTypeParameterTypes(typeParameters); 478 List<DartType> typeArguments = _createTypeParameterTypes(typeParameters);
479 InterfaceTypeImpl interfaceType = new InterfaceTypeImpl(element); 479 InterfaceTypeImpl interfaceType = new InterfaceTypeImpl(element);
480 interfaceType.typeArguments = typeArguments; 480 interfaceType.typeArguments = typeArguments;
481 element.type = interfaceType; 481 element.type = interfaceType;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 _currentHolder.addParameter(parameter); 610 _currentHolder.addParameter(parameter);
611 parameterName.staticElement = parameter; 611 parameterName.staticElement = parameter;
612 normalParameter.accept(this); 612 normalParameter.accept(this);
613 holder.validate(); 613 holder.validate();
614 return null; 614 return null;
615 } 615 }
616 616
617 @override 617 @override
618 Object visitEnumDeclaration(EnumDeclaration node) { 618 Object visitEnumDeclaration(EnumDeclaration node) {
619 SimpleIdentifier enumName = node.name; 619 SimpleIdentifier enumName = node.name;
620 ClassElementImpl enumElement = new ClassElementImpl.forNode(enumName); 620 ClassElementImpl enumElement = new ClassElementImpl_Enum.forNode(enumName);
621 _setCodeRange(enumElement, node); 621 _setCodeRange(enumElement, node);
622 enumElement.metadata = _createElementAnnotations(node.metadata); 622 enumElement.metadata = _createElementAnnotations(node.metadata);
623 enumElement.enum2 = true;
624 setElementDocumentationComment(enumElement, node); 623 setElementDocumentationComment(enumElement, node);
625 InterfaceTypeImpl enumType = new InterfaceTypeImpl(enumElement); 624 InterfaceTypeImpl enumType = new InterfaceTypeImpl(enumElement);
626 enumElement.type = enumType; 625 enumElement.type = enumType;
627 // The equivalent code for enums in the spec shows a single constructor, 626 // The equivalent code for enums in the spec shows a single constructor,
628 // but that constructor is not callable (since it is a compile-time error 627 // but that constructor is not callable (since it is a compile-time error
629 // to subclass, mix-in, implement, or explicitly instantiate an enum). So 628 // to subclass, mix-in, implement, or explicitly instantiate an enum). So
630 // we represent this as having no constructors. 629 // we represent this as having no constructors.
631 enumElement.constructors = ConstructorElement.EMPTY_LIST; 630 enumElement.constructors = ConstructorElement.EMPTY_LIST;
632 // 631 //
633 // Build the elements for the constants. These are minimal elements; the 632 // Build the elements for the constants. These are minimal elements; the
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 return null; 1481 return null;
1483 } 1482 }
1484 1483
1485 /** 1484 /**
1486 * Return the lexical identifiers associated with the given [identifiers]. 1485 * Return the lexical identifiers associated with the given [identifiers].
1487 */ 1486 */
1488 static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) { 1487 static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) {
1489 return identifiers.map((identifier) => identifier.name).toList(); 1488 return identifiers.map((identifier) => identifier.name).toList();
1490 } 1489 }
1491 } 1490 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698