| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /** | 5 /** |
| 6 * Datatypes holding information extracted by the analyzer and used by later | 6 * Datatypes holding information extracted by the analyzer and used by later |
| 7 * phases of the compiler. | 7 * phases of the compiler. |
| 8 */ | 8 */ |
| 9 library web_ui.src.info; | 9 library web_ui.src.info; |
| 10 | 10 |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 * Collected information about `data-value="name:value"` expressions. | 367 * Collected information about `data-value="name:value"` expressions. |
| 368 * Note: this feature is deprecated and should be removed after grace period. | 368 * Note: this feature is deprecated and should be removed after grace period. |
| 369 */ | 369 */ |
| 370 final Map<String, String> values = new SplayTreeMap<String, String>(); | 370 final Map<String, String> values = new SplayTreeMap<String, String>(); |
| 371 | 371 |
| 372 // TODO(jmesserly): we could keep this local to the analyzer. | 372 // TODO(jmesserly): we could keep this local to the analyzer. |
| 373 /** Attribute names to remove in cleanup phase. */ | 373 /** Attribute names to remove in cleanup phase. */ |
| 374 final Set<String> removeAttributes = new Set<String>(); | 374 final Set<String> removeAttributes = new Set<String>(); |
| 375 | 375 |
| 376 /** Whether the template element has `iterate="... in ...". */ | 376 /** Whether the template element has `iterate="... in ...". */ |
| 377 bool get hasIterate => false; | 377 bool get hasLoop => false; |
| 378 | 378 |
| 379 /** Whether the template element has an `if="..."` conditional. */ | 379 /** Whether the template element has an `if="..."` conditional. */ |
| 380 bool get hasIfCondition => false; | 380 bool get hasCondition => false; |
| 381 | 381 |
| 382 bool get isTemplateElement => false; | 382 bool get isTemplateElement => false; |
| 383 | 383 |
| 384 /** | 384 /** |
| 385 * For a builtin HTML element this returns the [node.tagName], otherwise it | 385 * For a builtin HTML element this returns the [node.tagName], otherwise it |
| 386 * returns [component.baseExtendsTag]. This is useful when looking up which | 386 * returns [component.baseExtendsTag]. This is useful when looking up which |
| 387 * DOM property this element supports. | 387 * DOM property this element supports. |
| 388 */ | 388 */ |
| 389 String get baseTagName => | 389 String get baseTagName => |
| 390 component != null ? component.baseExtendsTag : node.tagName; | 390 component != null ? component.baseExtendsTag : node.tagName; |
| 391 | 391 |
| 392 ElementInfo(Element node, ElementInfo parent, [this.component]) | 392 ElementInfo(Element node, ElementInfo parent, [this.component]) |
| 393 : super(node, parent); | 393 : super(node, parent); |
| 394 | 394 |
| 395 String toString() => '#<ElementInfo ' | 395 String toString() => '#<ElementInfo ' |
| 396 'identifier: $identifier, ' | 396 'identifier: $identifier, ' |
| 397 'childrenCreatedInCode: $childrenCreatedInCode, ' | 397 'childrenCreatedInCode: $childrenCreatedInCode, ' |
| 398 'component: $component, ' | 398 'component: $component, ' |
| 399 'descendantHasBinding: $descendantHasBinding, ' | 399 'descendantHasBinding: $descendantHasBinding, ' |
| 400 'hasIterate: $hasIterate, ' | 400 'hasLoop: $hasLoop, ' |
| 401 'hasIfCondition: $hasIfCondition, ' | 401 'hasCondition: $hasCondition, ' |
| 402 'attributes: $attributes, ' | 402 'attributes: $attributes, ' |
| 403 'events: $events>'; | 403 'events: $events>'; |
| 404 } | 404 } |
| 405 | 405 |
| 406 /** | 406 /** |
| 407 * Information for a single text node created programatically. We create a | 407 * Information for a single text node created programatically. We create a |
| 408 * [TextInfo] for data bindings that occur in content nodes, and for each | 408 * [TextInfo] for data bindings that occur in content nodes, and for each |
| 409 * text node that is created programatically in code. Note that the analyzer | 409 * text node that is created programatically in code. Note that the analyzer |
| 410 * splits HTML text nodes, so that each data-binding has its own node (and | 410 * splits HTML text nodes, so that each data-binding has its own node (and |
| 411 * [TextInfo]). | 411 * [TextInfo]). |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 */ | 539 */ |
| 540 final String loopVariable; | 540 final String loopVariable; |
| 541 | 541 |
| 542 /** | 542 /** |
| 543 * If this is a `<template iterate="item in items">`, this is the expression | 543 * If this is a `<template iterate="item in items">`, this is the expression |
| 544 * to get the items to iterate over, e.g. `items`. This will be null if it is | 544 * to get the items to iterate over, e.g. `items`. This will be null if it is |
| 545 * not a `<template iterate="...">`. | 545 * not a `<template iterate="...">`. |
| 546 */ | 546 */ |
| 547 final String loopItems; | 547 final String loopItems; |
| 548 | 548 |
| 549 /** |
| 550 * If [hasLoop] is true, this indicates if the attribute was "repeat" instead |
| 551 * of "iterate". |
| 552 * |
| 553 * For template elements, the two are equivalent, but for template attributes |
| 554 * repeat causes that node to repeat in place, instead of iterating its |
| 555 * children. |
| 556 */ |
| 557 final bool isRepeat; |
| 558 |
| 549 TemplateInfo(Node node, ElementInfo parent, | 559 TemplateInfo(Node node, ElementInfo parent, |
| 550 {this.ifCondition, this.loopVariable, this.loopItems}) | 560 {this.ifCondition, this.loopVariable, this.loopItems, this.isRepeat}) |
| 551 : super(node, parent) { | 561 : super(node, parent) { |
| 552 childrenCreatedInCode = hasIfCondition || hasIterate; | 562 childrenCreatedInCode = hasCondition || hasLoop; |
| 553 } | 563 } |
| 554 | 564 |
| 555 /** | 565 /** |
| 556 * True when [node] is a '<template>' tag. False when [node] is any other | 566 * True when [node] is a '<template>' tag. False when [node] is any other |
| 557 * element type and the template information is attached as an attribute. | 567 * element type and the template information is attached as an attribute. |
| 558 */ | 568 */ |
| 559 bool get isTemplateElement => node.tagName == 'template'; | 569 bool get isTemplateElement => node.tagName == 'template'; |
| 560 | 570 |
| 561 bool get hasIfCondition => ifCondition != null; | 571 bool get hasCondition => ifCondition != null; |
| 562 | 572 |
| 563 bool get hasIterate => loopVariable != null; | 573 bool get hasLoop => loopVariable != null; |
| 564 | 574 |
| 565 String toString() => '#<TemplateInfo ${super.toString()}' | 575 String toString() => '#<TemplateInfo ${super.toString()}' |
| 566 'ifCondition: $ifCondition, ' | 576 'ifCondition: $ifCondition, ' |
| 567 'loopVariable: $ifCondition, ' | 577 'loopVariable: $ifCondition, ' |
| 568 'loopItems: $ifCondition>'; | 578 'loopItems: $ifCondition>'; |
| 569 } | 579 } |
| 570 | 580 |
| 571 /** | 581 /** |
| 572 * Specifies the action to take on a particular event. Some actions need to read | 582 * Specifies the action to take on a particular event. Some actions need to read |
| 573 * attributes from the DOM element that has the event listener (e.g. two way | 583 * attributes from the DOM element that has the event listener (e.g. two way |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 */ | 621 */ |
| 612 class UrlInfo { | 622 class UrlInfo { |
| 613 /** Path that the URL points to. */ | 623 /** Path that the URL points to. */ |
| 614 final String resolvedPath; | 624 final String resolvedPath; |
| 615 | 625 |
| 616 /** Original source location where the URL was extracted from. */ | 626 /** Original source location where the URL was extracted from. */ |
| 617 final Span sourceSpan; | 627 final Span sourceSpan; |
| 618 | 628 |
| 619 UrlInfo(this.resolvedPath, this.sourceSpan); | 629 UrlInfo(this.resolvedPath, this.sourceSpan); |
| 620 } | 630 } |
| OLD | NEW |