| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.resolver; | 8 library engine.resolver; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 import 'element.dart'; | 22 import 'element.dart'; |
| 23 import 'html.dart' as ht; | 23 import 'html.dart' as ht; |
| 24 import 'engine.dart'; | 24 import 'engine.dart'; |
| 25 import 'constant.dart'; | 25 import 'constant.dart'; |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * Instances of the class `AngularCompilationUnitBuilder` build an Angular speci
fic element | 28 * Instances of the class `AngularCompilationUnitBuilder` build an Angular speci
fic element |
| 29 * model for a single compilation unit. | 29 * model for a single compilation unit. |
| 30 */ | 30 */ |
| 31 class AngularCompilationUnitBuilder { | 31 class AngularCompilationUnitBuilder { |
| 32 static String _NG_COMPONENT = "NgComponent"; | 32 static String _NG_COMPONENT = "Component"; |
| 33 | 33 |
| 34 static String _NG_CONTROLLER = "NgController"; | 34 static String _NG_CONTROLLER = "Controller"; |
| 35 | 35 |
| 36 static String _NG_DIRECTIVE = "NgDirective"; | 36 static String _NG_DECORATOR = "Decorator"; |
| 37 | 37 |
| 38 static String _NG_FILTER = "NgFilter"; | 38 static String _NG_FORMATTER = "Formatter"; |
| 39 | 39 |
| 40 static String _NAME = "name"; | 40 static String _NAME = "name"; |
| 41 | 41 |
| 42 static String _SELECTOR = "selector"; | 42 static String _SELECTOR = "selector"; |
| 43 | 43 |
| 44 static String _PUBLISH_AS = "publishAs"; | 44 static String _PUBLISH_AS = "publishAs"; |
| 45 | 45 |
| 46 static String _TEMPLATE_URL = "templateUrl"; | 46 static String _TEMPLATE_URL = "templateUrl"; |
| 47 | 47 |
| 48 static String _CSS_URL = "cssUrl"; | 48 static String _CSS_URL = "cssUrl"; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 if (_isNameCoveredByLiteral(selector, node)) { | 96 if (_isNameCoveredByLiteral(selector, node)) { |
| 97 return selector; | 97 return selector; |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 // try properties of AngularComponentElement | 100 // try properties of AngularComponentElement |
| 101 if (toolkitObject is AngularComponentElement) { | 101 if (toolkitObject is AngularComponentElement) { |
| 102 AngularComponentElement component = toolkitObject; | 102 AngularComponentElement component = toolkitObject; |
| 103 properties = component.properties; | 103 properties = component.properties; |
| 104 } | 104 } |
| 105 // try properties of AngularDirectiveElement | 105 // try properties of AngularDirectiveElement |
| 106 if (toolkitObject is AngularDirectiveElement) { | 106 if (toolkitObject is AngularDecoratorElement) { |
| 107 AngularDirectiveElement directive = toolkitObject; | 107 AngularDecoratorElement directive = toolkitObject; |
| 108 properties = directive.properties; | 108 properties = directive.properties; |
| 109 } | 109 } |
| 110 // check properties | 110 // check properties |
| 111 for (AngularPropertyElement property in properties) { | 111 for (AngularPropertyElement property in properties) { |
| 112 // property name (use complete node range) | 112 // property name (use complete node range) |
| 113 if (_isNameCoveredByLiteral(property, node)) { | 113 if (_isNameCoveredByLiteral(property, node)) { |
| 114 return property; | 114 return property; |
| 115 } | 115 } |
| 116 // field name (use complete node range, including @, => and <=>) | 116 // field name (use complete node range, including @, => and <=>) |
| 117 FieldElement field = property.field; | 117 FieldElement field = property.field; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 this._classDeclaration = unitMember; | 266 this._classDeclaration = unitMember; |
| 267 this._classElement = _classDeclaration.element as ClassElementImpl; | 267 this._classElement = _classDeclaration.element as ClassElementImpl; |
| 268 // process annotations | 268 // process annotations |
| 269 NodeList<Annotation> annotations = _classDeclaration.metadata; | 269 NodeList<Annotation> annotations = _classDeclaration.metadata; |
| 270 for (Annotation annotation in annotations) { | 270 for (Annotation annotation in annotations) { |
| 271 // verify annotation | 271 // verify annotation |
| 272 if (annotation.arguments == null) { | 272 if (annotation.arguments == null) { |
| 273 continue; | 273 continue; |
| 274 } | 274 } |
| 275 this._annotation = annotation; | 275 this._annotation = annotation; |
| 276 // @NgFilter | 276 // @Formatter |
| 277 if (_isAngularAnnotation(annotation, _NG_FILTER)) { | 277 if (_isAngularAnnotation(annotation, _NG_FORMATTER)) { |
| 278 _parseNgFilter(); | 278 _parseFormatter(); |
| 279 continue; | 279 continue; |
| 280 } | 280 } |
| 281 // @NgComponent | 281 // @Component |
| 282 if (_isAngularAnnotation(annotation, _NG_COMPONENT)) { | 282 if (_isAngularAnnotation(annotation, _NG_COMPONENT)) { |
| 283 _parseNgComponent(); | 283 _parseComponent(); |
| 284 continue; | 284 continue; |
| 285 } | 285 } |
| 286 // @NgController | 286 // @Controller |
| 287 if (_isAngularAnnotation(annotation, _NG_CONTROLLER)) { | 287 if (_isAngularAnnotation(annotation, _NG_CONTROLLER)) { |
| 288 _parseNgController(); | 288 _parseController(); |
| 289 continue; | 289 continue; |
| 290 } | 290 } |
| 291 // @NgDirective | 291 // @Decorator |
| 292 if (_isAngularAnnotation(annotation, _NG_DIRECTIVE)) { | 292 if (_isAngularAnnotation(annotation, _NG_DECORATOR)) { |
| 293 _parseNgDirective(); | 293 _parseDecorator(); |
| 294 continue; | 294 continue; |
| 295 } | 295 } |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 } | 299 } |
| 300 | 300 |
| 301 /** | 301 /** |
| 302 * @return the argument [Expression] with given name form [annotation], may be | 302 * @return the argument [Expression] with given name form [annotation], may be |
| 303 * `null` if not found. | 303 * `null` if not found. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 */ | 350 */ |
| 351 bool _isAngularAnnotation(Annotation annotation, String name) { | 351 bool _isAngularAnnotation(Annotation annotation, String name) { |
| 352 Element element = annotation.element; | 352 Element element = annotation.element; |
| 353 if (element is ConstructorElement) { | 353 if (element is ConstructorElement) { |
| 354 ConstructorElement constructorElement = element; | 354 ConstructorElement constructorElement = element; |
| 355 return constructorElement.returnType.displayName == name; | 355 return constructorElement.returnType.displayName == name; |
| 356 } | 356 } |
| 357 return false; | 357 return false; |
| 358 } | 358 } |
| 359 | 359 |
| 360 void _parseNgComponent() { | 360 void _parseComponent() { |
| 361 bool isValid = true; | 361 bool isValid = true; |
| 362 // publishAs | 362 // publishAs |
| 363 String name = null; | 363 String name = null; |
| 364 int nameOffset = -1; | 364 int nameOffset = -1; |
| 365 if (_hasStringArgument(_PUBLISH_AS)) { | 365 if (_hasStringArgument(_PUBLISH_AS)) { |
| 366 name = _getStringArgument(_PUBLISH_AS); | 366 name = _getStringArgument(_PUBLISH_AS); |
| 367 nameOffset = _getStringArgumentOffset(_PUBLISH_AS); | 367 nameOffset = _getStringArgumentOffset(_PUBLISH_AS); |
| 368 } | 368 } |
| 369 // selector | 369 // selector |
| 370 AngularSelectorElement selector = null; | 370 AngularSelectorElement selector = null; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 394 styleUriOffset = _getStringArgumentOffset(_CSS_URL); | 394 styleUriOffset = _getStringArgumentOffset(_CSS_URL); |
| 395 } | 395 } |
| 396 // create | 396 // create |
| 397 if (isValid) { | 397 if (isValid) { |
| 398 AngularComponentElementImpl element = new AngularComponentElementImpl(name
, nameOffset, _annotation.offset); | 398 AngularComponentElementImpl element = new AngularComponentElementImpl(name
, nameOffset, _annotation.offset); |
| 399 element.selector = selector; | 399 element.selector = selector; |
| 400 element.templateUri = templateUri; | 400 element.templateUri = templateUri; |
| 401 element.templateUriOffset = templateUriOffset; | 401 element.templateUriOffset = templateUriOffset; |
| 402 element.styleUri = styleUri; | 402 element.styleUri = styleUri; |
| 403 element.styleUriOffset = styleUriOffset; | 403 element.styleUriOffset = styleUriOffset; |
| 404 element.properties = _parseNgComponentProperties(); | 404 element.properties = _parseComponentProperties(); |
| 405 element.scopeProperties = _parseScopeProperties(); | 405 element.scopeProperties = _parseScopeProperties(); |
| 406 _classElement.addToolkitObjects(element); | 406 _classElement.addToolkitObjects(element); |
| 407 } | 407 } |
| 408 } | 408 } |
| 409 | 409 |
| 410 /** | 410 /** |
| 411 * Parses [AngularPropertyElement]s from [annotation] and [classDeclaration]. | 411 * Parses [AngularPropertyElement]s from [annotation] and [classDeclaration]. |
| 412 */ | 412 */ |
| 413 List<AngularPropertyElement> _parseNgComponentProperties() { | 413 List<AngularPropertyElement> _parseComponentProperties() { |
| 414 List<AngularPropertyElement> properties = []; | 414 List<AngularPropertyElement> properties = []; |
| 415 _parseNgComponentProperties_fromMap(properties); | 415 _parseComponentProperties_fromMap(properties); |
| 416 _parseNgComponentProperties_fromFields(properties); | 416 _parseComponentProperties_fromFields(properties); |
| 417 return new List.from(properties); | 417 return new List.from(properties); |
| 418 } | 418 } |
| 419 | 419 |
| 420 /** | 420 /** |
| 421 * Parses [AngularPropertyElement]s from [annotation]. | 421 * Parses [AngularPropertyElement]s from [annotation]. |
| 422 */ | 422 */ |
| 423 void _parseNgComponentProperties_fromFields(List<AngularPropertyElement> prope
rties) { | 423 void _parseComponentProperties_fromFields(List<AngularPropertyElement> propert
ies) { |
| 424 NodeList<ClassMember> members = _classDeclaration.members; | 424 NodeList<ClassMember> members = _classDeclaration.members; |
| 425 for (ClassMember member in members) { | 425 for (ClassMember member in members) { |
| 426 if (member is FieldDeclaration) { | 426 if (member is FieldDeclaration) { |
| 427 FieldDeclaration fieldDeclaration = member; | 427 FieldDeclaration fieldDeclaration = member; |
| 428 for (Annotation annotation in fieldDeclaration.metadata) { | 428 for (Annotation annotation in fieldDeclaration.metadata) { |
| 429 // prepare property kind (if property annotation at all) | 429 // prepare property kind (if property annotation at all) |
| 430 AngularPropertyKind kind = null; | 430 AngularPropertyKind kind = null; |
| 431 if (_isAngularAnnotation(annotation, _NG_ATTR)) { | 431 if (_isAngularAnnotation(annotation, _NG_ATTR)) { |
| 432 kind = AngularPropertyKind.ATTR; | 432 kind = AngularPropertyKind.ATTR; |
| 433 } else if (_isAngularAnnotation(annotation, _NG_CALLBACK)) { | 433 } else if (_isAngularAnnotation(annotation, _NG_CALLBACK)) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 451 } | 451 } |
| 452 } | 452 } |
| 453 } | 453 } |
| 454 } | 454 } |
| 455 } | 455 } |
| 456 } | 456 } |
| 457 | 457 |
| 458 /** | 458 /** |
| 459 * Parses [AngularPropertyElement]s from [annotation]. | 459 * Parses [AngularPropertyElement]s from [annotation]. |
| 460 */ | 460 */ |
| 461 void _parseNgComponentProperties_fromMap(List<AngularPropertyElement> properti
es) { | 461 void _parseComponentProperties_fromMap(List<AngularPropertyElement> properties
) { |
| 462 Expression mapExpression = _getArgument("map"); | 462 Expression mapExpression = _getArgument("map"); |
| 463 // may be not properties | 463 // may be not properties |
| 464 if (mapExpression == null) { | 464 if (mapExpression == null) { |
| 465 return; | 465 return; |
| 466 } | 466 } |
| 467 // prepare map literal | 467 // prepare map literal |
| 468 if (mapExpression is! MapLiteral) { | 468 if (mapExpression is! MapLiteral) { |
| 469 _reportErrorForNode(AngularCode.INVALID_PROPERTY_MAP, mapExpression, []); | 469 _reportErrorForNode(AngularCode.INVALID_PROPERTY_MAP, mapExpression, []); |
| 470 return; | 470 return; |
| 471 } | 471 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 FieldElement field = setter.variable as FieldElement; | 522 FieldElement field = setter.variable as FieldElement; |
| 523 // add property | 523 // add property |
| 524 AngularPropertyElementImpl property = new AngularPropertyElementImpl(name,
nameOffset); | 524 AngularPropertyElementImpl property = new AngularPropertyElementImpl(name,
nameOffset); |
| 525 property.field = field; | 525 property.field = field; |
| 526 property.propertyKind = kind; | 526 property.propertyKind = kind; |
| 527 property.fieldNameOffset = fieldNameOffset; | 527 property.fieldNameOffset = fieldNameOffset; |
| 528 properties.add(property); | 528 properties.add(property); |
| 529 } | 529 } |
| 530 } | 530 } |
| 531 | 531 |
| 532 void _parseNgController() { | 532 void _parseController() { |
| 533 bool isValid = true; | 533 bool isValid = true; |
| 534 // publishAs | 534 // publishAs |
| 535 if (!_hasStringArgument(_PUBLISH_AS)) { | 535 if (!_hasStringArgument(_PUBLISH_AS)) { |
| 536 _reportErrorForAnnotation(AngularCode.MISSING_PUBLISH_AS, []); | 536 _reportErrorForAnnotation(AngularCode.MISSING_PUBLISH_AS, []); |
| 537 isValid = false; | 537 isValid = false; |
| 538 } | 538 } |
| 539 // selector | 539 // selector |
| 540 AngularSelectorElement selector = null; | 540 AngularSelectorElement selector = null; |
| 541 if (!_hasStringArgument(_SELECTOR)) { | 541 if (!_hasStringArgument(_SELECTOR)) { |
| 542 _reportErrorForAnnotation(AngularCode.MISSING_SELECTOR, []); | 542 _reportErrorForAnnotation(AngularCode.MISSING_SELECTOR, []); |
| 543 isValid = false; | 543 isValid = false; |
| 544 } else { | 544 } else { |
| 545 SimpleStringLiteral selectorLiteral = _getStringLiteral(_SELECTOR); | 545 SimpleStringLiteral selectorLiteral = _getStringLiteral(_SELECTOR); |
| 546 selector = _parseSelectorFromString(selectorLiteral); | 546 selector = _parseSelectorFromString(selectorLiteral); |
| 547 if (selector == null) { | 547 if (selector == null) { |
| 548 _reportErrorForArgument(_SELECTOR, AngularCode.CANNOT_PARSE_SELECTOR, [s
electorLiteral]); | 548 _reportErrorForArgument(_SELECTOR, AngularCode.CANNOT_PARSE_SELECTOR, [s
electorLiteral]); |
| 549 isValid = false; | 549 isValid = false; |
| 550 } | 550 } |
| 551 } | 551 } |
| 552 // create | 552 // create |
| 553 if (isValid) { | 553 if (isValid) { |
| 554 String name = _getStringArgument(_PUBLISH_AS); | 554 String name = _getStringArgument(_PUBLISH_AS); |
| 555 int nameOffset = _getStringArgumentOffset(_PUBLISH_AS); | 555 int nameOffset = _getStringArgumentOffset(_PUBLISH_AS); |
| 556 AngularControllerElementImpl element = new AngularControllerElementImpl(na
me, nameOffset); | 556 AngularControllerElementImpl element = new AngularControllerElementImpl(na
me, nameOffset); |
| 557 element.selector = selector; | 557 element.selector = selector; |
| 558 _classElement.addToolkitObjects(element); | 558 _classElement.addToolkitObjects(element); |
| 559 } | 559 } |
| 560 } | 560 } |
| 561 | 561 |
| 562 void _parseNgDirective() { | 562 void _parseDecorator() { |
| 563 bool isValid = true; | 563 bool isValid = true; |
| 564 // selector | 564 // selector |
| 565 AngularSelectorElement selector = null; | 565 AngularSelectorElement selector = null; |
| 566 if (!_hasStringArgument(_SELECTOR)) { | 566 if (!_hasStringArgument(_SELECTOR)) { |
| 567 _reportErrorForAnnotation(AngularCode.MISSING_SELECTOR, []); | 567 _reportErrorForAnnotation(AngularCode.MISSING_SELECTOR, []); |
| 568 isValid = false; | 568 isValid = false; |
| 569 } else { | 569 } else { |
| 570 SimpleStringLiteral selectorLiteral = _getStringLiteral(_SELECTOR); | 570 SimpleStringLiteral selectorLiteral = _getStringLiteral(_SELECTOR); |
| 571 selector = _parseSelectorFromString(selectorLiteral); | 571 selector = _parseSelectorFromString(selectorLiteral); |
| 572 if (selector == null) { | 572 if (selector == null) { |
| 573 _reportErrorForArgument(_SELECTOR, AngularCode.CANNOT_PARSE_SELECTOR, [s
electorLiteral]); | 573 _reportErrorForArgument(_SELECTOR, AngularCode.CANNOT_PARSE_SELECTOR, [s
electorLiteral]); |
| 574 isValid = false; | 574 isValid = false; |
| 575 } | 575 } |
| 576 } | 576 } |
| 577 // create | 577 // create |
| 578 if (isValid) { | 578 if (isValid) { |
| 579 int offset = _annotation.offset; | 579 int offset = _annotation.offset; |
| 580 AngularDirectiveElementImpl element = new AngularDirectiveElementImpl(offs
et); | 580 AngularDecoratorElementImpl element = new AngularDecoratorElementImpl(offs
et); |
| 581 element.selector = selector; | 581 element.selector = selector; |
| 582 element.properties = _parseNgComponentProperties(); | 582 element.properties = _parseComponentProperties(); |
| 583 _classElement.addToolkitObjects(element); | 583 _classElement.addToolkitObjects(element); |
| 584 } | 584 } |
| 585 } | 585 } |
| 586 | 586 |
| 587 void _parseNgFilter() { | 587 void _parseFormatter() { |
| 588 bool isValid = true; | 588 bool isValid = true; |
| 589 // name | 589 // name |
| 590 if (!_hasStringArgument(_NAME)) { | 590 if (!_hasStringArgument(_NAME)) { |
| 591 _reportErrorForAnnotation(AngularCode.MISSING_NAME, []); | 591 _reportErrorForAnnotation(AngularCode.MISSING_NAME, []); |
| 592 isValid = false; | 592 isValid = false; |
| 593 } | 593 } |
| 594 // create | 594 // create |
| 595 if (isValid) { | 595 if (isValid) { |
| 596 String name = _getStringArgument(_NAME); | 596 String name = _getStringArgument(_NAME); |
| 597 int nameOffset = _getStringArgumentOffset(_NAME); | 597 int nameOffset = _getStringArgumentOffset(_NAME); |
| 598 _classElement.addToolkitObjects(new AngularFilterElementImpl(name, nameOff
set)); | 598 _classElement.addToolkitObjects(new AngularFormatterElementImpl(name, name
Offset)); |
| 599 } | 599 } |
| 600 } | 600 } |
| 601 | 601 |
| 602 List<AngularScopePropertyElement> _parseScopeProperties() { | 602 List<AngularScopePropertyElement> _parseScopeProperties() { |
| 603 List<AngularScopePropertyElement> properties = []; | 603 List<AngularScopePropertyElement> properties = []; |
| 604 _classDeclaration.accept(new RecursiveAstVisitor_AngularCompilationUnitBuild
er_parseScopeProperties(properties)); | 604 _classDeclaration.accept(new RecursiveAstVisitor_AngularCompilationUnitBuild
er_parseScopeProperties(properties)); |
| 605 return new List.from(properties); | 605 return new List.from(properties); |
| 606 } | 606 } |
| 607 | 607 |
| 608 /** | 608 /** |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 InterfaceTypeImpl interfaceType = new InterfaceTypeImpl.con1(element); | 906 InterfaceTypeImpl interfaceType = new InterfaceTypeImpl.con1(element); |
| 907 interfaceType.typeArguments = typeArguments; | 907 interfaceType.typeArguments = typeArguments; |
| 908 element.type = interfaceType; | 908 element.type = interfaceType; |
| 909 List<ConstructorElement> constructors = holder.constructors; | 909 List<ConstructorElement> constructors = holder.constructors; |
| 910 if (constructors.length == 0) { | 910 if (constructors.length == 0) { |
| 911 // | 911 // |
| 912 // Create the default constructor. | 912 // Create the default constructor. |
| 913 // | 913 // |
| 914 constructors = _createDefaultConstructors(interfaceType); | 914 constructors = _createDefaultConstructors(interfaceType); |
| 915 } | 915 } |
| 916 element.abstract = node.abstractKeyword != null; | 916 element.abstract = node.isAbstract; |
| 917 element.accessors = holder.accessors; | 917 element.accessors = holder.accessors; |
| 918 element.constructors = constructors; | 918 element.constructors = constructors; |
| 919 element.fields = holder.fields; | 919 element.fields = holder.fields; |
| 920 element.methods = holder.methods; | 920 element.methods = holder.methods; |
| 921 element.typeParameters = typeParameters; | 921 element.typeParameters = typeParameters; |
| 922 element.validMixin = _isValidMixin; | 922 element.validMixin = _isValidMixin; |
| 923 int functionTypeCount = _functionTypesToFix.length; | 923 int functionTypeCount = _functionTypesToFix.length; |
| 924 for (int i = 0; i < functionTypeCount; i++) { | 924 for (int i = 0; i < functionTypeCount; i++) { |
| 925 _functionTypesToFix[i].typeArguments = typeArguments; | 925 _functionTypesToFix[i].typeArguments = typeArguments; |
| 926 } | 926 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 _isValidMixin = false; | 964 _isValidMixin = false; |
| 965 ElementHolder holder = new ElementHolder(); | 965 ElementHolder holder = new ElementHolder(); |
| 966 bool wasInFunction = _inFunction; | 966 bool wasInFunction = _inFunction; |
| 967 _inFunction = true; | 967 _inFunction = true; |
| 968 try { | 968 try { |
| 969 _visitChildren(holder, node); | 969 _visitChildren(holder, node); |
| 970 } finally { | 970 } finally { |
| 971 _inFunction = wasInFunction; | 971 _inFunction = wasInFunction; |
| 972 } | 972 } |
| 973 SimpleIdentifier constructorName = node.name; | 973 SimpleIdentifier constructorName = node.name; |
| 974 ConstructorElementImpl element = new ConstructorElementImpl.con1(constructor
Name); | 974 ConstructorElementImpl element = new ConstructorElementImpl.forNode(construc
torName); |
| 975 if (node.factoryKeyword != null) { | 975 if (node.factoryKeyword != null) { |
| 976 element.factory = true; | 976 element.factory = true; |
| 977 } | 977 } |
| 978 element.functions = holder.functions; | 978 element.functions = holder.functions; |
| 979 element.labels = holder.labels; | 979 element.labels = holder.labels; |
| 980 element.localVariables = holder.localVariables; | 980 element.localVariables = holder.localVariables; |
| 981 element.parameters = holder.parameters; | 981 element.parameters = holder.parameters; |
| 982 element.const2 = node.constKeyword != null; | 982 element.const2 = node.constKeyword != null; |
| 983 _currentHolder.addConstructor(element); | 983 _currentHolder.addConstructor(element); |
| 984 node.element = element; | 984 node.element = element; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 } else { | 1025 } else { |
| 1026 parameter = new DefaultParameterElementImpl(parameterName); | 1026 parameter = new DefaultParameterElementImpl(parameterName); |
| 1027 } | 1027 } |
| 1028 parameter.const3 = node.isConst; | 1028 parameter.const3 = node.isConst; |
| 1029 parameter.final2 = node.isFinal; | 1029 parameter.final2 = node.isFinal; |
| 1030 parameter.parameterKind = node.kind; | 1030 parameter.parameterKind = node.kind; |
| 1031 // set initializer, default value range | 1031 // set initializer, default value range |
| 1032 Expression defaultValue = node.defaultValue; | 1032 Expression defaultValue = node.defaultValue; |
| 1033 if (defaultValue != null) { | 1033 if (defaultValue != null) { |
| 1034 _visit(holder, defaultValue); | 1034 _visit(holder, defaultValue); |
| 1035 FunctionElementImpl initializer = new FunctionElementImpl.con2(defaultValu
e.beginToken.offset); | 1035 FunctionElementImpl initializer = new FunctionElementImpl.forOffset(defaul
tValue.beginToken.offset); |
| 1036 initializer.functions = holder.functions; | 1036 initializer.functions = holder.functions; |
| 1037 initializer.labels = holder.labels; | 1037 initializer.labels = holder.labels; |
| 1038 initializer.localVariables = holder.localVariables; | 1038 initializer.localVariables = holder.localVariables; |
| 1039 initializer.parameters = holder.parameters; | 1039 initializer.parameters = holder.parameters; |
| 1040 initializer.synthetic = true; | 1040 initializer.synthetic = true; |
| 1041 parameter.initializer = initializer; | 1041 parameter.initializer = initializer; |
| 1042 parameter.setDefaultValueRange(defaultValue.offset, defaultValue.length); | 1042 parameter.setDefaultValueRange(defaultValue.offset, defaultValue.length); |
| 1043 } | 1043 } |
| 1044 // visible range | 1044 // visible range |
| 1045 _setParameterVisibleRange(node, parameter); | 1045 _setParameterVisibleRange(node, parameter); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 bool wasInFunction = _inFunction; | 1095 bool wasInFunction = _inFunction; |
| 1096 _inFunction = true; | 1096 _inFunction = true; |
| 1097 try { | 1097 try { |
| 1098 _visitChildren(holder, expression); | 1098 _visitChildren(holder, expression); |
| 1099 } finally { | 1099 } finally { |
| 1100 _inFunction = wasInFunction; | 1100 _inFunction = wasInFunction; |
| 1101 } | 1101 } |
| 1102 sc.Token property = node.propertyKeyword; | 1102 sc.Token property = node.propertyKeyword; |
| 1103 if (property == null) { | 1103 if (property == null) { |
| 1104 SimpleIdentifier functionName = node.name; | 1104 SimpleIdentifier functionName = node.name; |
| 1105 FunctionElementImpl element = new FunctionElementImpl.con1(functionName)
; | 1105 FunctionElementImpl element = new FunctionElementImpl.forNode(functionNa
me); |
| 1106 element.functions = holder.functions; | 1106 element.functions = holder.functions; |
| 1107 element.labels = holder.labels; | 1107 element.labels = holder.labels; |
| 1108 element.localVariables = holder.localVariables; | 1108 element.localVariables = holder.localVariables; |
| 1109 element.parameters = holder.parameters; | 1109 element.parameters = holder.parameters; |
| 1110 if (_inFunction) { | 1110 if (_inFunction) { |
| 1111 Block enclosingBlock = node.getAncestor((node) => node is Block); | 1111 Block enclosingBlock = node.getAncestor((node) => node is Block); |
| 1112 if (enclosingBlock != null) { | 1112 if (enclosingBlock != null) { |
| 1113 int functionEnd = node.offset + node.length; | 1113 int functionEnd = node.offset + node.length; |
| 1114 int blockEnd = enclosingBlock.offset + enclosingBlock.length; | 1114 int blockEnd = enclosingBlock.offset + enclosingBlock.length; |
| 1115 element.setVisibleRange(functionEnd, blockEnd - functionEnd - 1); | 1115 element.setVisibleRange(functionEnd, blockEnd - functionEnd - 1); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1126 } | 1126 } |
| 1127 String propertyName = propertyNameNode.name; | 1127 String propertyName = propertyNameNode.name; |
| 1128 TopLevelVariableElementImpl variable = _currentHolder.getTopLevelVariabl
e(propertyName) as TopLevelVariableElementImpl; | 1128 TopLevelVariableElementImpl variable = _currentHolder.getTopLevelVariabl
e(propertyName) as TopLevelVariableElementImpl; |
| 1129 if (variable == null) { | 1129 if (variable == null) { |
| 1130 variable = new TopLevelVariableElementImpl.con2(node.name.name); | 1130 variable = new TopLevelVariableElementImpl.con2(node.name.name); |
| 1131 variable.final2 = true; | 1131 variable.final2 = true; |
| 1132 variable.synthetic = true; | 1132 variable.synthetic = true; |
| 1133 _currentHolder.addTopLevelVariable(variable); | 1133 _currentHolder.addTopLevelVariable(variable); |
| 1134 } | 1134 } |
| 1135 if (_matches(property, sc.Keyword.GET)) { | 1135 if (_matches(property, sc.Keyword.GET)) { |
| 1136 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.c
on1(propertyNameNode); | 1136 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.f
orNode(propertyNameNode); |
| 1137 getter.functions = holder.functions; | 1137 getter.functions = holder.functions; |
| 1138 getter.labels = holder.labels; | 1138 getter.labels = holder.labels; |
| 1139 getter.localVariables = holder.localVariables; | 1139 getter.localVariables = holder.localVariables; |
| 1140 getter.variable = variable; | 1140 getter.variable = variable; |
| 1141 getter.getter = true; | 1141 getter.getter = true; |
| 1142 getter.static = true; | 1142 getter.static = true; |
| 1143 variable.getter = getter; | 1143 variable.getter = getter; |
| 1144 _currentHolder.addAccessor(getter); | 1144 _currentHolder.addAccessor(getter); |
| 1145 expression.element = getter; | 1145 expression.element = getter; |
| 1146 propertyNameNode.staticElement = getter; | 1146 propertyNameNode.staticElement = getter; |
| 1147 } else { | 1147 } else { |
| 1148 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.c
on1(propertyNameNode); | 1148 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.f
orNode(propertyNameNode); |
| 1149 setter.functions = holder.functions; | 1149 setter.functions = holder.functions; |
| 1150 setter.labels = holder.labels; | 1150 setter.labels = holder.labels; |
| 1151 setter.localVariables = holder.localVariables; | 1151 setter.localVariables = holder.localVariables; |
| 1152 setter.parameters = holder.parameters; | 1152 setter.parameters = holder.parameters; |
| 1153 setter.variable = variable; | 1153 setter.variable = variable; |
| 1154 setter.setter = true; | 1154 setter.setter = true; |
| 1155 setter.static = true; | 1155 setter.static = true; |
| 1156 variable.setter = setter; | 1156 variable.setter = setter; |
| 1157 variable.final2 = false; | 1157 variable.final2 = false; |
| 1158 _currentHolder.addAccessor(setter); | 1158 _currentHolder.addAccessor(setter); |
| 1159 expression.element = setter; | 1159 expression.element = setter; |
| 1160 propertyNameNode.staticElement = setter; | 1160 propertyNameNode.staticElement = setter; |
| 1161 } | 1161 } |
| 1162 } | 1162 } |
| 1163 holder.validate(); | 1163 holder.validate(); |
| 1164 } | 1164 } |
| 1165 return null; | 1165 return null; |
| 1166 } | 1166 } |
| 1167 | 1167 |
| 1168 @override | 1168 @override |
| 1169 Object visitFunctionExpression(FunctionExpression node) { | 1169 Object visitFunctionExpression(FunctionExpression node) { |
| 1170 ElementHolder holder = new ElementHolder(); | 1170 ElementHolder holder = new ElementHolder(); |
| 1171 bool wasInFunction = _inFunction; | 1171 bool wasInFunction = _inFunction; |
| 1172 _inFunction = true; | 1172 _inFunction = true; |
| 1173 try { | 1173 try { |
| 1174 _visitChildren(holder, node); | 1174 _visitChildren(holder, node); |
| 1175 } finally { | 1175 } finally { |
| 1176 _inFunction = wasInFunction; | 1176 _inFunction = wasInFunction; |
| 1177 } | 1177 } |
| 1178 FunctionElementImpl element = new FunctionElementImpl.con2(node.beginToken.o
ffset); | 1178 FunctionElementImpl element = new FunctionElementImpl.forOffset(node.beginTo
ken.offset); |
| 1179 element.functions = holder.functions; | 1179 element.functions = holder.functions; |
| 1180 element.labels = holder.labels; | 1180 element.labels = holder.labels; |
| 1181 element.localVariables = holder.localVariables; | 1181 element.localVariables = holder.localVariables; |
| 1182 element.parameters = holder.parameters; | 1182 element.parameters = holder.parameters; |
| 1183 if (_inFunction) { | 1183 if (_inFunction) { |
| 1184 Block enclosingBlock = node.getAncestor((node) => node is Block); | 1184 Block enclosingBlock = node.getAncestor((node) => node is Block); |
| 1185 if (enclosingBlock != null) { | 1185 if (enclosingBlock != null) { |
| 1186 int functionEnd = node.offset + node.length; | 1186 int functionEnd = node.offset + node.length; |
| 1187 int blockEnd = enclosingBlock.offset + enclosingBlock.length; | 1187 int blockEnd = enclosingBlock.offset + enclosingBlock.length; |
| 1188 element.setVisibleRange(functionEnd, blockEnd - functionEnd - 1); | 1188 element.setVisibleRange(functionEnd, blockEnd - functionEnd - 1); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 _inFunction = wasInFunction; | 1261 _inFunction = wasInFunction; |
| 1262 } | 1262 } |
| 1263 bool isStatic = node.isStatic; | 1263 bool isStatic = node.isStatic; |
| 1264 sc.Token property = node.propertyKeyword; | 1264 sc.Token property = node.propertyKeyword; |
| 1265 if (property == null) { | 1265 if (property == null) { |
| 1266 SimpleIdentifier methodName = node.name; | 1266 SimpleIdentifier methodName = node.name; |
| 1267 String nameOfMethod = methodName.name; | 1267 String nameOfMethod = methodName.name; |
| 1268 if (nameOfMethod == sc.TokenType.MINUS.lexeme && node.parameters.parameter
s.length == 0) { | 1268 if (nameOfMethod == sc.TokenType.MINUS.lexeme && node.parameters.parameter
s.length == 0) { |
| 1269 nameOfMethod = "unary-"; | 1269 nameOfMethod = "unary-"; |
| 1270 } | 1270 } |
| 1271 MethodElementImpl element = new MethodElementImpl.con2(nameOfMethod, metho
dName.offset); | 1271 MethodElementImpl element = new MethodElementImpl(nameOfMethod, methodName
.offset); |
| 1272 element.abstract = node.isAbstract; | 1272 element.abstract = node.isAbstract; |
| 1273 element.functions = holder.functions; | 1273 element.functions = holder.functions; |
| 1274 element.labels = holder.labels; | 1274 element.labels = holder.labels; |
| 1275 element.localVariables = holder.localVariables; | 1275 element.localVariables = holder.localVariables; |
| 1276 element.parameters = holder.parameters; | 1276 element.parameters = holder.parameters; |
| 1277 element.static = isStatic; | 1277 element.static = isStatic; |
| 1278 _currentHolder.addMethod(element); | 1278 _currentHolder.addMethod(element); |
| 1279 methodName.staticElement = element; | 1279 methodName.staticElement = element; |
| 1280 } else { | 1280 } else { |
| 1281 SimpleIdentifier propertyNameNode = node.name; | 1281 SimpleIdentifier propertyNameNode = node.name; |
| 1282 String propertyName = propertyNameNode.name; | 1282 String propertyName = propertyNameNode.name; |
| 1283 FieldElementImpl field = _currentHolder.getField(propertyName) as FieldEle
mentImpl; | 1283 FieldElementImpl field = _currentHolder.getField(propertyName) as FieldEle
mentImpl; |
| 1284 if (field == null) { | 1284 if (field == null) { |
| 1285 field = new FieldElementImpl.con2(node.name.name); | 1285 field = new FieldElementImpl.con2(node.name.name); |
| 1286 field.final2 = true; | 1286 field.final2 = true; |
| 1287 field.static = isStatic; | 1287 field.static = isStatic; |
| 1288 field.synthetic = true; | 1288 field.synthetic = true; |
| 1289 _currentHolder.addField(field); | 1289 _currentHolder.addField(field); |
| 1290 } | 1290 } |
| 1291 if (_matches(property, sc.Keyword.GET)) { | 1291 if (_matches(property, sc.Keyword.GET)) { |
| 1292 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con
1(propertyNameNode); | 1292 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.for
Node(propertyNameNode); |
| 1293 getter.functions = holder.functions; | 1293 getter.functions = holder.functions; |
| 1294 getter.labels = holder.labels; | 1294 getter.labels = holder.labels; |
| 1295 getter.localVariables = holder.localVariables; | 1295 getter.localVariables = holder.localVariables; |
| 1296 getter.variable = field; | 1296 getter.variable = field; |
| 1297 getter.abstract = node.body is EmptyFunctionBody && node.externalKeyword
== null; | 1297 getter.abstract = node.body is EmptyFunctionBody && node.externalKeyword
== null; |
| 1298 getter.getter = true; | 1298 getter.getter = true; |
| 1299 getter.static = isStatic; | 1299 getter.static = isStatic; |
| 1300 field.getter = getter; | 1300 field.getter = getter; |
| 1301 _currentHolder.addAccessor(getter); | 1301 _currentHolder.addAccessor(getter); |
| 1302 propertyNameNode.staticElement = getter; | 1302 propertyNameNode.staticElement = getter; |
| 1303 } else { | 1303 } else { |
| 1304 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con
1(propertyNameNode); | 1304 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.for
Node(propertyNameNode); |
| 1305 setter.functions = holder.functions; | 1305 setter.functions = holder.functions; |
| 1306 setter.labels = holder.labels; | 1306 setter.labels = holder.labels; |
| 1307 setter.localVariables = holder.localVariables; | 1307 setter.localVariables = holder.localVariables; |
| 1308 setter.parameters = holder.parameters; | 1308 setter.parameters = holder.parameters; |
| 1309 setter.variable = field; | 1309 setter.variable = field; |
| 1310 setter.abstract = node.body is EmptyFunctionBody && !_matches(node.exter
nalKeyword, sc.Keyword.EXTERNAL); | 1310 setter.abstract = node.body is EmptyFunctionBody && !_matches(node.exter
nalKeyword, sc.Keyword.EXTERNAL); |
| 1311 setter.setter = true; | 1311 setter.setter = true; |
| 1312 setter.static = isStatic; | 1312 setter.static = isStatic; |
| 1313 field.setter = setter; | 1313 field.setter = setter; |
| 1314 field.final2 = false; | 1314 field.final2 = false; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1424 element.final2 = isFinal; | 1424 element.final2 = isFinal; |
| 1425 if (hasInitializer) { | 1425 if (hasInitializer) { |
| 1426 ElementHolder holder = new ElementHolder(); | 1426 ElementHolder holder = new ElementHolder(); |
| 1427 bool wasInFieldContext = _inFieldContext; | 1427 bool wasInFieldContext = _inFieldContext; |
| 1428 _inFieldContext = false; | 1428 _inFieldContext = false; |
| 1429 try { | 1429 try { |
| 1430 _visit(holder, node.initializer); | 1430 _visit(holder, node.initializer); |
| 1431 } finally { | 1431 } finally { |
| 1432 _inFieldContext = wasInFieldContext; | 1432 _inFieldContext = wasInFieldContext; |
| 1433 } | 1433 } |
| 1434 FunctionElementImpl initializer = new FunctionElementImpl.con2(node.initia
lizer.beginToken.offset); | 1434 FunctionElementImpl initializer = new FunctionElementImpl.forOffset(node.i
nitializer.beginToken.offset); |
| 1435 initializer.functions = holder.functions; | 1435 initializer.functions = holder.functions; |
| 1436 initializer.labels = holder.labels; | 1436 initializer.labels = holder.labels; |
| 1437 initializer.localVariables = holder.localVariables; | 1437 initializer.localVariables = holder.localVariables; |
| 1438 initializer.synthetic = true; | 1438 initializer.synthetic = true; |
| 1439 element.initializer = initializer; | 1439 element.initializer = initializer; |
| 1440 holder.validate(); | 1440 holder.validate(); |
| 1441 } | 1441 } |
| 1442 if (element is PropertyInducingElementImpl) { | 1442 if (element is PropertyInducingElementImpl) { |
| 1443 PropertyInducingElementImpl variable = element as PropertyInducingElementI
mpl; | 1443 PropertyInducingElementImpl variable = element as PropertyInducingElementI
mpl; |
| 1444 if (_inFieldContext) { | 1444 if (_inFieldContext) { |
| 1445 (variable as FieldElementImpl).static = _matches((node.parent.parent as
FieldDeclaration).staticKeyword, sc.Keyword.STATIC); | 1445 (variable as FieldElementImpl).static = _matches((node.parent.parent as
FieldDeclaration).staticKeyword, sc.Keyword.STATIC); |
| 1446 } | 1446 } |
| 1447 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(
variable); | 1447 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl(varia
ble); |
| 1448 getter.getter = true; | 1448 getter.getter = true; |
| 1449 getter.static = variable.isStatic; | 1449 getter.static = variable.isStatic; |
| 1450 _currentHolder.addAccessor(getter); | 1450 _currentHolder.addAccessor(getter); |
| 1451 variable.getter = getter; | 1451 variable.getter = getter; |
| 1452 if (!isFinal) { | 1452 if (!isFinal) { |
| 1453 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con
2(variable); | 1453 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl(var
iable); |
| 1454 setter.setter = true; | 1454 setter.setter = true; |
| 1455 setter.static = variable.isStatic; | 1455 setter.static = variable.isStatic; |
| 1456 ParameterElementImpl parameter = new ParameterElementImpl.con2("_${varia
ble.name}", variable.nameOffset); | 1456 ParameterElementImpl parameter = new ParameterElementImpl.con2("_${varia
ble.name}", variable.nameOffset); |
| 1457 parameter.synthetic = true; | 1457 parameter.synthetic = true; |
| 1458 parameter.parameterKind = ParameterKind.REQUIRED; | 1458 parameter.parameterKind = ParameterKind.REQUIRED; |
| 1459 setter.parameters = <ParameterElement> [parameter]; | 1459 setter.parameters = <ParameterElement> [parameter]; |
| 1460 _currentHolder.addAccessor(setter); | 1460 _currentHolder.addAccessor(setter); |
| 1461 variable.setter = setter; | 1461 variable.setter = setter; |
| 1462 } | 1462 } |
| 1463 } | 1463 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1479 } | 1479 } |
| 1480 } | 1480 } |
| 1481 | 1481 |
| 1482 /** | 1482 /** |
| 1483 * Creates the [ConstructorElement]s array with the single default constructor
element. | 1483 * Creates the [ConstructorElement]s array with the single default constructor
element. |
| 1484 * | 1484 * |
| 1485 * @param interfaceType the interface type for which to create a default const
ructor | 1485 * @param interfaceType the interface type for which to create a default const
ructor |
| 1486 * @return the [ConstructorElement]s array with the single default constructor
element | 1486 * @return the [ConstructorElement]s array with the single default constructor
element |
| 1487 */ | 1487 */ |
| 1488 List<ConstructorElement> _createDefaultConstructors(InterfaceTypeImpl interfac
eType) { | 1488 List<ConstructorElement> _createDefaultConstructors(InterfaceTypeImpl interfac
eType) { |
| 1489 ConstructorElementImpl constructor = new ConstructorElementImpl.con1(null); | 1489 ConstructorElementImpl constructor = new ConstructorElementImpl.forNode(null
); |
| 1490 constructor.synthetic = true; | 1490 constructor.synthetic = true; |
| 1491 constructor.returnType = interfaceType; | 1491 constructor.returnType = interfaceType; |
| 1492 FunctionTypeImpl type = new FunctionTypeImpl.con1(constructor); | 1492 FunctionTypeImpl type = new FunctionTypeImpl.con1(constructor); |
| 1493 _functionTypesToFix.add(type); | 1493 _functionTypesToFix.add(type); |
| 1494 constructor.type = type; | 1494 constructor.type = type; |
| 1495 return <ConstructorElement> [constructor]; | 1495 return <ConstructorElement> [constructor]; |
| 1496 } | 1496 } |
| 1497 | 1497 |
| 1498 /** | 1498 /** |
| 1499 * Create the types associated with the given type parameters, setting the typ
e of each type | 1499 * Create the types associated with the given type parameters, setting the typ
e of each type |
| (...skipping 4555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6055 // | 6055 // |
| 6056 Expression target = node.realTarget; | 6056 Expression target = node.realTarget; |
| 6057 if (target is SuperExpression && !_isSuperInValidContext(target)) { | 6057 if (target is SuperExpression && !_isSuperInValidContext(target)) { |
| 6058 return null; | 6058 return null; |
| 6059 } | 6059 } |
| 6060 Element staticElement; | 6060 Element staticElement; |
| 6061 Element propagatedElement; | 6061 Element propagatedElement; |
| 6062 if (target == null) { | 6062 if (target == null) { |
| 6063 staticElement = _resolveInvokedElement(methodName); | 6063 staticElement = _resolveInvokedElement(methodName); |
| 6064 propagatedElement = null; | 6064 propagatedElement = null; |
| 6065 } else if (_isDeferredPrefix(target) && methodName.name == FunctionElement.L
OAD_LIBRARY_NAME) { |
| 6066 LibraryElement importedLibrary = _getImportedLibrary(target); |
| 6067 methodName.staticElement = importedLibrary.loadLibraryFunction; |
| 6068 return null; |
| 6065 } else { | 6069 } else { |
| 6066 DartType staticType = _getStaticType(target); | 6070 DartType staticType = _getStaticType(target); |
| 6067 // | 6071 // |
| 6068 // If this method invocation is of the form 'C.m' where 'C' is a class, th
en we don't call | 6072 // If this method invocation is of the form 'C.m' where 'C' is a class, th
en we don't call |
| 6069 // resolveInvokedElement(..) which walks up the class hierarchy, instead w
e just look for the | 6073 // resolveInvokedElement(..) which walks up the class hierarchy, instead w
e just look for the |
| 6070 // member in the type only. | 6074 // member in the type only. |
| 6071 // | 6075 // |
| 6072 ClassElementImpl typeReference = getTypeReference(target); | 6076 ClassElementImpl typeReference = getTypeReference(target); |
| 6073 if (typeReference != null) { | 6077 if (typeReference != null) { |
| 6074 staticElement = propagatedElement = _resolveElement(typeReference, metho
dName); | 6078 staticElement = propagatedElement = _resolveElement(typeReference, metho
dName); |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6708 } else { | 6712 } else { |
| 6709 element = MultiplyDefinedElementImpl.fromElements(_definingLibrary.c
ontext, element, importedElement); | 6713 element = MultiplyDefinedElementImpl.fromElements(_definingLibrary.c
ontext, element, importedElement); |
| 6710 } | 6714 } |
| 6711 } | 6715 } |
| 6712 } | 6716 } |
| 6713 } | 6717 } |
| 6714 return element; | 6718 return element; |
| 6715 } | 6719 } |
| 6716 | 6720 |
| 6717 /** | 6721 /** |
| 6722 * Assuming that the given expression is a prefix for a deferred import, retur
n the library that |
| 6723 * is being imported. |
| 6724 * |
| 6725 * @param expression the expression representing the deferred import's prefix |
| 6726 * @return the library that is being imported by the import associated with th
e prefix |
| 6727 */ |
| 6728 LibraryElement _getImportedLibrary(Expression expression) { |
| 6729 PrefixElement prefixElement = (expression as SimpleIdentifier).staticElement
as PrefixElement; |
| 6730 List<ImportElement> imports = prefixElement.enclosingElement.getImportsWithP
refix(prefixElement); |
| 6731 return imports[0].importedLibrary; |
| 6732 } |
| 6733 |
| 6734 /** |
| 6718 * Return the name of the method invoked by the given postfix expression. | 6735 * Return the name of the method invoked by the given postfix expression. |
| 6719 * | 6736 * |
| 6720 * @param node the postfix expression being invoked | 6737 * @param node the postfix expression being invoked |
| 6721 * @return the name of the method invoked by the expression | 6738 * @return the name of the method invoked by the expression |
| 6722 */ | 6739 */ |
| 6723 String _getPostfixOperator(PostfixExpression node) => (node.operator.type == s
c.TokenType.PLUS_PLUS) ? sc.TokenType.PLUS.lexeme : sc.TokenType.MINUS.lexeme; | 6740 String _getPostfixOperator(PostfixExpression node) => (node.operator.type == s
c.TokenType.PLUS_PLUS) ? sc.TokenType.PLUS.lexeme : sc.TokenType.MINUS.lexeme; |
| 6724 | 6741 |
| 6725 /** | 6742 /** |
| 6726 * Return the name of the method invoked by the given postfix expression. | 6743 * Return the name of the method invoked by the given postfix expression. |
| 6727 * | 6744 * |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6773 if (staticType is FunctionType) { | 6790 if (staticType is FunctionType) { |
| 6774 // | 6791 // |
| 6775 // All function types are subtypes of 'Function', which is itself a subcla
ss of 'Object'. | 6792 // All function types are subtypes of 'Function', which is itself a subcla
ss of 'Object'. |
| 6776 // | 6793 // |
| 6777 staticType = _resolver.typeProvider.functionType; | 6794 staticType = _resolver.typeProvider.functionType; |
| 6778 } | 6795 } |
| 6779 return staticType; | 6796 return staticType; |
| 6780 } | 6797 } |
| 6781 | 6798 |
| 6782 /** | 6799 /** |
| 6800 * Return `true` if the given expression is a prefix for a deferred import. |
| 6801 * |
| 6802 * @param expression the expression being tested |
| 6803 * @return `true` if the given expression is a prefix for a deferred import |
| 6804 */ |
| 6805 bool _isDeferredPrefix(Expression expression) { |
| 6806 if (expression is! SimpleIdentifier) { |
| 6807 return false; |
| 6808 } |
| 6809 Element element = (expression as SimpleIdentifier).staticElement; |
| 6810 if (element is! PrefixElement) { |
| 6811 return false; |
| 6812 } |
| 6813 PrefixElement prefixElement = element as PrefixElement; |
| 6814 List<ImportElement> imports = prefixElement.enclosingElement.getImportsWithP
refix(prefixElement); |
| 6815 if (imports.length != 1) { |
| 6816 return false; |
| 6817 } |
| 6818 return imports[0].isDeferred; |
| 6819 } |
| 6820 |
| 6821 /** |
| 6783 * Return `true` if the given type represents an object that could be invoked
using the call | 6822 * Return `true` if the given type represents an object that could be invoked
using the call |
| 6784 * operator '()'. | 6823 * operator '()'. |
| 6785 * | 6824 * |
| 6786 * @param type the type being tested | 6825 * @param type the type being tested |
| 6787 * @return `true` if the given type represents an object that could be invoked | 6826 * @return `true` if the given type represents an object that could be invoked |
| 6788 */ | 6827 */ |
| 6789 bool _isExecutableType(DartType type) { | 6828 bool _isExecutableType(DartType type) { |
| 6790 if (type.isDynamic || (type is FunctionType) || type.isDartCoreFunction || t
ype.isObject) { | 6829 if (type.isDynamic || (type is FunctionType) || type.isDartCoreFunction || t
ype.isObject) { |
| 6791 return true; | 6830 return true; |
| 6792 } else if (type is InterfaceType) { | 6831 } else if (type is InterfaceType) { |
| (...skipping 2564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9357 libraryNameNode = directive.name; | 9396 libraryNameNode = directive.name; |
| 9358 directivesToResolve.add(directive); | 9397 directivesToResolve.add(directive); |
| 9359 } | 9398 } |
| 9360 } else if (directive is PartDirective) { | 9399 } else if (directive is PartDirective) { |
| 9361 PartDirective partDirective = directive; | 9400 PartDirective partDirective = directive; |
| 9362 StringLiteral partUri = partDirective.uri; | 9401 StringLiteral partUri = partDirective.uri; |
| 9363 Source partSource = partDirective.source; | 9402 Source partSource = partDirective.source; |
| 9364 if (_analysisContext.exists(partSource)) { | 9403 if (_analysisContext.exists(partSource)) { |
| 9365 hasPartDirective = true; | 9404 hasPartDirective = true; |
| 9366 CompilationUnit partUnit = library.getAST(partSource); | 9405 CompilationUnit partUnit = library.getAST(partSource); |
| 9367 CompilationUnitElementImpl part = builder.buildCompilationUnit(partSou
rce, partUnit); | 9406 if (partUnit != null) { |
| 9368 part.uriOffset = partUri.offset; | 9407 CompilationUnitElementImpl part = builder.buildCompilationUnit(partS
ource, partUnit); |
| 9369 part.uriEnd = partUri.end; | 9408 part.uriOffset = partUri.offset; |
| 9370 part.uri = partDirective.uriContent; | 9409 part.uriEnd = partUri.end; |
| 9371 // | 9410 part.uri = partDirective.uriContent; |
| 9372 // Validate that the part contains a part-of directive with the same n
ame as the library. | 9411 // |
| 9373 // | 9412 // Validate that the part contains a part-of directive with the same
name as the library. |
| 9374 String partLibraryName = _getPartLibraryName(partSource, partUnit, dir
ectivesToResolve); | 9413 // |
| 9375 if (partLibraryName == null) { | 9414 String partLibraryName = _getPartLibraryName(partSource, partUnit, d
irectivesToResolve); |
| 9376 _errorListener.onError(new AnalysisError.con2(librarySource, partUri
.offset, partUri.length, CompileTimeErrorCode.PART_OF_NON_PART, [partUri.toSourc
e()])); | 9415 if (partLibraryName == null) { |
| 9377 } else if (libraryNameNode == null) { | 9416 _errorListener.onError(new AnalysisError.con2(librarySource, partU
ri.offset, partUri.length, CompileTimeErrorCode.PART_OF_NON_PART, [partUri.toSou
rce()])); |
| 9378 } else if (libraryNameNode.name != partLibraryName) { | 9417 } else if (libraryNameNode == null) { |
| 9379 _errorListener.onError(new AnalysisError.con2(librarySource, partUri
.offset, partUri.length, StaticWarningCode.PART_OF_DIFFERENT_LIBRARY, [libraryNa
meNode.name, partLibraryName])); | 9418 } else if (libraryNameNode.name != partLibraryName) { |
| 9419 _errorListener.onError(new AnalysisError.con2(librarySource, partU
ri.offset, partUri.length, StaticWarningCode.PART_OF_DIFFERENT_LIBRARY, [library
NameNode.name, partLibraryName])); |
| 9420 } |
| 9421 if (entryPoint == null) { |
| 9422 entryPoint = _findEntryPoint(part); |
| 9423 } |
| 9424 directive.element = part; |
| 9425 sourcedCompilationUnits.add(part); |
| 9380 } | 9426 } |
| 9381 if (entryPoint == null) { | |
| 9382 entryPoint = _findEntryPoint(part); | |
| 9383 } | |
| 9384 directive.element = part; | |
| 9385 sourcedCompilationUnits.add(part); | |
| 9386 } | 9427 } |
| 9387 } | 9428 } |
| 9388 } | 9429 } |
| 9389 if (hasPartDirective && libraryNameNode == null) { | 9430 if (hasPartDirective && libraryNameNode == null) { |
| 9390 _errorListener.onError(new AnalysisError.con1(librarySource, ResolverError
Code.MISSING_LIBRARY_DIRECTIVE_WITH_PART, [])); | 9431 _errorListener.onError(new AnalysisError.con1(librarySource, ResolverError
Code.MISSING_LIBRARY_DIRECTIVE_WITH_PART, [])); |
| 9391 } | 9432 } |
| 9392 // | 9433 // |
| 9393 // Create and populate the library element. | 9434 // Create and populate the library element. |
| 9394 // | 9435 // |
| 9395 LibraryElementImpl libraryElement = new LibraryElementImpl(_analysisContext,
libraryNameNode); | 9436 LibraryElementImpl libraryElement = new LibraryElementImpl(_analysisContext,
libraryNameNode); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9580 instrumentation.metric("fullAnalysis", fullAnalysis); | 9621 instrumentation.metric("fullAnalysis", fullAnalysis); |
| 9581 instrumentation.data3("fullName", librarySource.fullName); | 9622 instrumentation.data3("fullName", librarySource.fullName); |
| 9582 // | 9623 // |
| 9583 // Create the objects representing the library being resolved and the core
library. | 9624 // Create the objects representing the library being resolved and the core
library. |
| 9584 // | 9625 // |
| 9585 Library targetLibrary = _createLibraryWithUnit(librarySource, modification
Stamp, unit); | 9626 Library targetLibrary = _createLibraryWithUnit(librarySource, modification
Stamp, unit); |
| 9586 _coreLibrary = _libraryMap[_coreLibrarySource]; | 9627 _coreLibrary = _libraryMap[_coreLibrarySource]; |
| 9587 if (_coreLibrary == null) { | 9628 if (_coreLibrary == null) { |
| 9588 // This will be true unless the library being analyzed is the core libra
ry. | 9629 // This will be true unless the library being analyzed is the core libra
ry. |
| 9589 _coreLibrary = createLibrary(_coreLibrarySource); | 9630 _coreLibrary = createLibrary(_coreLibrarySource); |
| 9631 if (_coreLibrary == null) { |
| 9632 throw new AnalysisException.con1("Core library does not exist"); |
| 9633 } |
| 9590 } | 9634 } |
| 9591 instrumentation.metric3("createLibrary", "complete"); | 9635 instrumentation.metric3("createLibrary", "complete"); |
| 9592 // | 9636 // |
| 9593 // Compute the set of libraries that need to be resolved together. | 9637 // Compute the set of libraries that need to be resolved together. |
| 9594 // | 9638 // |
| 9595 _computeEmbeddedLibraryDependencies(targetLibrary, unit); | 9639 _computeEmbeddedLibraryDependencies(targetLibrary, unit); |
| 9596 _librariesInCycles = _computeLibrariesInCycles(targetLibrary); | 9640 _librariesInCycles = _computeLibrariesInCycles(targetLibrary); |
| 9597 // | 9641 // |
| 9598 // Build the element models representing the libraries being resolved. Thi
s is done in three | 9642 // Build the element models representing the libraries being resolved. Thi
s is done in three |
| 9599 // steps: | 9643 // steps: |
| (...skipping 6448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16048 * Create an implicit constructor that is copied from the given constructor, b
ut that is in the | 16092 * Create an implicit constructor that is copied from the given constructor, b
ut that is in the |
| 16049 * given class. | 16093 * given class. |
| 16050 * | 16094 * |
| 16051 * @param classType the class in which the implicit constructor is defined | 16095 * @param classType the class in which the implicit constructor is defined |
| 16052 * @param explicitConstructor the constructor on which the implicit constructo
r is modeled | 16096 * @param explicitConstructor the constructor on which the implicit constructo
r is modeled |
| 16053 * @param parameterTypes the types to be replaced when creating parameters | 16097 * @param parameterTypes the types to be replaced when creating parameters |
| 16054 * @param argumentTypes the types with which the parameters are to be replaced | 16098 * @param argumentTypes the types with which the parameters are to be replaced |
| 16055 * @return the implicit constructor that was created | 16099 * @return the implicit constructor that was created |
| 16056 */ | 16100 */ |
| 16057 ConstructorElement _createImplicitContructor(InterfaceType classType, Construc
torElement explicitConstructor, List<DartType> parameterTypes, List<DartType> ar
gumentTypes) { | 16101 ConstructorElement _createImplicitContructor(InterfaceType classType, Construc
torElement explicitConstructor, List<DartType> parameterTypes, List<DartType> ar
gumentTypes) { |
| 16058 ConstructorElementImpl implicitConstructor = new ConstructorElementImpl.con2
(explicitConstructor.name, -1); | 16102 ConstructorElementImpl implicitConstructor = new ConstructorElementImpl(expl
icitConstructor.name, -1); |
| 16059 implicitConstructor.synthetic = true; | 16103 implicitConstructor.synthetic = true; |
| 16060 implicitConstructor.redirectedConstructor = explicitConstructor; | 16104 implicitConstructor.redirectedConstructor = explicitConstructor; |
| 16061 implicitConstructor.const2 = explicitConstructor.isConst; | 16105 implicitConstructor.const2 = explicitConstructor.isConst; |
| 16062 implicitConstructor.returnType = classType; | 16106 implicitConstructor.returnType = classType; |
| 16063 List<ParameterElement> explicitParameters = explicitConstructor.parameters; | 16107 List<ParameterElement> explicitParameters = explicitConstructor.parameters; |
| 16064 int count = explicitParameters.length; | 16108 int count = explicitParameters.length; |
| 16065 if (count > 0) { | 16109 if (count > 0) { |
| 16066 List<ParameterElement> implicitParameters = new List<ParameterElement>(cou
nt); | 16110 List<ParameterElement> implicitParameters = new List<ParameterElement>(cou
nt); |
| 16067 for (int i = 0; i < count; i++) { | 16111 for (int i = 0; i < count; i++) { |
| 16068 ParameterElement explicitParameter = explicitParameters[i]; | 16112 ParameterElement explicitParameter = explicitParameters[i]; |
| (...skipping 6654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22723 } | 22767 } |
| 22724 | 22768 |
| 22725 /** | 22769 /** |
| 22726 * This verifies that if the given class declaration implements the class Func
tion that it has a | 22770 * This verifies that if the given class declaration implements the class Func
tion that it has a |
| 22727 * concrete implementation of the call method. | 22771 * concrete implementation of the call method. |
| 22728 * | 22772 * |
| 22729 * @return `true` if and only if an error code is generated on the passed node | 22773 * @return `true` if and only if an error code is generated on the passed node |
| 22730 * @see StaticWarningCode#FUNCTION_WITHOUT_CALL | 22774 * @see StaticWarningCode#FUNCTION_WITHOUT_CALL |
| 22731 */ | 22775 */ |
| 22732 bool _checkImplementsFunctionWithoutCall(ClassDeclaration node) { | 22776 bool _checkImplementsFunctionWithoutCall(ClassDeclaration node) { |
| 22733 if (node.abstractKeyword != null) { | 22777 if (node.isAbstract) { |
| 22734 return false; | 22778 return false; |
| 22735 } | 22779 } |
| 22736 ClassElement classElement = node.element; | 22780 ClassElement classElement = node.element; |
| 22737 if (classElement == null) { | 22781 if (classElement == null) { |
| 22738 return false; | 22782 return false; |
| 22739 } | 22783 } |
| 22740 if (!classElement.type.isSubtypeOf(_typeProvider.functionType)) { | 22784 if (!classElement.type.isSubtypeOf(_typeProvider.functionType)) { |
| 22741 return false; | 22785 return false; |
| 22742 } | 22786 } |
| 22743 // If there is a noSuchMethod method, then don't report the warning, see dar
tbug.com/16078 | 22787 // If there is a noSuchMethod method, then don't report the warning, see dar
tbug.com/16078 |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23241 * | 23285 * |
| 23242 * @param type the type of this error | 23286 * @param type the type of this error |
| 23243 * @param message the template used to create the message to be displayed for
the error | 23287 * @param message the template used to create the message to be displayed for
the error |
| 23244 * @param correction the template used to create the correction to be displaye
d for the error | 23288 * @param correction the template used to create the correction to be displaye
d for the error |
| 23245 */ | 23289 */ |
| 23246 const ResolverErrorCode.con2(String name, int ordinal, this.type, this.message
, this.correction) : super(name, ordinal); | 23290 const ResolverErrorCode.con2(String name, int ordinal, this.type, this.message
, this.correction) : super(name, ordinal); |
| 23247 | 23291 |
| 23248 @override | 23292 @override |
| 23249 ErrorSeverity get errorSeverity => type.severity; | 23293 ErrorSeverity get errorSeverity => type.severity; |
| 23250 } | 23294 } |
| OLD | NEW |