| Index: pkg/analyzer/test/generated/all_the_rest_test.dart
|
| diff --git a/pkg/analyzer/test/generated/all_the_rest_test.dart b/pkg/analyzer/test/generated/all_the_rest_test.dart
|
| index ecd06ad40b7ae601187e887653f1dbb6597a6350..0d7d7ff2cb484baeb214007b8c3e88d2e5c3b9cf 100644
|
| --- a/pkg/analyzer/test/generated/all_the_rest_test.dart
|
| +++ b/pkg/analyzer/test/generated/all_the_rest_test.dart
|
| @@ -40,9 +40,6 @@ import 'test_support.dart';
|
|
|
| main() {
|
| groupSep = ' | ';
|
| - runReflectiveTests(AngularCompilationUnitBuilderTest);
|
| - runReflectiveTests(AngularHtmlUnitResolverTest);
|
| - runReflectiveTests(AngularHtmlUnitUtilsTest);
|
| runReflectiveTests(ConstantEvaluatorTest);
|
| runReflectiveTests(ConstantFinderTest);
|
| runReflectiveTests(ConstantValueComputerTest);
|
| @@ -453,2549 +450,6 @@ abstract class AbstractScannerTest {
|
|
|
|
|
| @ReflectiveTestCase()
|
| -class AngularCompilationUnitBuilderTest extends AngularTest {
|
| - void test_bad_notConstructorAnnotation() {
|
| - String mainContent = r'''
|
| -const MY_ANNOTATION = null;
|
| -@MY_ANNOTATION()
|
| -class MyFilter {
|
| -}''';
|
| - resolveMainSource(mainContent);
|
| - // prepare AngularFilterElement
|
| - ClassElement classElement = mainUnitElement.getType("MyFilter");
|
| - AngularFormatterElement filter =
|
| - getAngularElement(classElement, (e) => e is AngularFormatterElement);
|
| - expect(filter, isNull);
|
| - }
|
| -
|
| - void test_Decorator() {
|
| - String mainContent = _createAngularSource(r'''
|
| -@Decorator(selector: '[my-dir]',
|
| - map: const {
|
| - 'my-dir' : '=>myPropA',
|
| - '.' : '&myPropB',
|
| - })
|
| -class MyDirective {
|
| - set myPropA(value) {}
|
| - set myPropB(value) {}
|
| - @NgTwoWay('my-prop-c')
|
| - String myPropC;
|
| -}''');
|
| - resolveMainSourceNoErrors(mainContent);
|
| - // prepare AngularDirectiveElement
|
| - ClassElement classElement = mainUnitElement.getType("MyDirective");
|
| - AngularDecoratorElement directive =
|
| - getAngularElement(classElement, (e) => e is AngularDecoratorElement);
|
| - expect(directive, isNotNull);
|
| - // verify
|
| - expect(directive.name, null);
|
| - expect(directive.nameOffset, -1);
|
| - _assertHasAttributeSelector(directive.selector, "my-dir");
|
| - // verify properties
|
| - List<AngularPropertyElement> properties = directive.properties;
|
| - expect(properties, hasLength(3));
|
| - _assertProperty(
|
| - properties[0],
|
| - "my-dir",
|
| - findMainOffset("my-dir' :"),
|
| - AngularPropertyKind.ONE_WAY,
|
| - "myPropA",
|
| - findMainOffset("myPropA'"));
|
| - _assertProperty(
|
| - properties[1],
|
| - ".",
|
| - findMainOffset(".' :"),
|
| - AngularPropertyKind.CALLBACK,
|
| - "myPropB",
|
| - findMainOffset("myPropB'"));
|
| - _assertProperty(
|
| - properties[2],
|
| - "my-prop-c",
|
| - findMainOffset("my-prop-c'"),
|
| - AngularPropertyKind.TWO_WAY,
|
| - "myPropC",
|
| - -1);
|
| - }
|
| -
|
| - void test_Decorator_bad_cannotParseSelector() {
|
| - String mainContent = _createAngularSource(r'''
|
| -@Decorator(selector: '~bad-selector',
|
| - map: const {
|
| - 'my-dir' : '=>myPropA',
|
| - '.' : '&myPropB',
|
| - })
|
| -class MyDirective {
|
| - set myPropA(value) {}
|
| - set myPropB(value) {}
|
| -}''');
|
| - resolveMainSource(mainContent);
|
| - // has error
|
| - assertMainErrors([AngularCode.CANNOT_PARSE_SELECTOR]);
|
| - }
|
| -
|
| - void test_Decorator_bad_missingSelector() {
|
| - String mainContent = _createAngularSource(r'''
|
| -@Decorator(/*selector: '[my-dir]',*/
|
| - map: const {
|
| - 'my-dir' : '=>myPropA',
|
| - '.' : '&myPropB',
|
| - })
|
| -class MyDirective {
|
| - set myPropA(value) {}
|
| - set myPropB(value) {}
|
| -}''');
|
| - resolveMainSource(mainContent);
|
| - // has error
|
| - assertMainErrors([AngularCode.MISSING_SELECTOR]);
|
| - }
|
| -
|
| - void test_Formatter() {
|
| - String mainContent = _createAngularSource(r'''
|
| -@Formatter(name: 'myFilter')
|
| -class MyFilter {
|
| - call(p1, p2) {}
|
| -}''');
|
| - resolveMainSourceNoErrors(mainContent);
|
| - // prepare AngularFilterElement
|
| - ClassElement classElement = mainUnitElement.getType("MyFilter");
|
| - AngularFormatterElement filter =
|
| - getAngularElement(classElement, (e) => e is AngularFormatterElement);
|
| - expect(filter, isNotNull);
|
| - // verify
|
| - expect(filter.name, "myFilter");
|
| - expect(filter.nameOffset, AngularTest.findOffset(mainContent, "myFilter'"));
|
| - }
|
| -
|
| - void test_Formatter_missingName() {
|
| - String mainContent = _createAngularSource(r'''
|
| -@Formatter()
|
| -class MyFilter {
|
| - call(p1, p2) {}
|
| -}''');
|
| - resolveMainSource(mainContent);
|
| - // has error
|
| - assertMainErrors([AngularCode.MISSING_NAME]);
|
| - // no filter
|
| - ClassElement classElement = mainUnitElement.getType("MyFilter");
|
| - AngularFormatterElement filter =
|
| - getAngularElement(classElement, (e) => e is AngularFormatterElement);
|
| - expect(filter, isNull);
|
| - }
|
| -
|
| - void test_getElement_component_name() {
|
| - resolveMainSource(_createAngularSource(r'''
|
| -@Component(publishAs: 'ctrl', selector: 'myComp',
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css')
|
| -class MyComponent {}'''));
|
| - SimpleStringLiteral node =
|
| - _findMainNode("ctrl'", (n) => n is SimpleStringLiteral);
|
| - int offset = node.offset;
|
| - // find AngularComponentElement
|
| - Element element = AngularCompilationUnitBuilder.getElement(node, offset);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is AngularComponentElement,
|
| - AngularComponentElement,
|
| - element);
|
| - }
|
| -
|
| - void test_getElement_component_property_fromFieldAnnotation() {
|
| - resolveMainSource(_createAngularSource(r'''
|
| -@Component(publishAs: 'ctrl', selector: 'myComp',
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css')
|
| -class MyComponent {
|
| - @NgOneWay('prop')
|
| - var field;
|
| -}'''));
|
| - // prepare node
|
| - SimpleStringLiteral node =
|
| - _findMainNode("prop'", (n) => n is SimpleStringLiteral);
|
| - int offset = node.offset;
|
| - // prepare Element
|
| - Element element = AngularCompilationUnitBuilder.getElement(node, offset);
|
| - expect(element, isNotNull);
|
| - // check AngularPropertyElement
|
| - AngularPropertyElement property = element as AngularPropertyElement;
|
| - expect(property.name, "prop");
|
| - }
|
| -
|
| - void test_getElement_component_property_fromMap() {
|
| - resolveMainSource(_createAngularSource(r'''
|
| -@Component(publishAs: 'ctrl', selector: 'myComp',
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css',
|
| - map: const {
|
| - 'prop' : '@field',
|
| - })
|
| -class MyComponent {
|
| - var field;
|
| -}'''));
|
| - // AngularPropertyElement
|
| - {
|
| - SimpleStringLiteral node =
|
| - _findMainNode("prop'", (n) => n is SimpleStringLiteral);
|
| - int offset = node.offset;
|
| - // prepare Element
|
| - Element element = AngularCompilationUnitBuilder.getElement(node, offset);
|
| - expect(element, isNotNull);
|
| - // check AngularPropertyElement
|
| - AngularPropertyElement property = element as AngularPropertyElement;
|
| - expect(property.name, "prop");
|
| - }
|
| - // FieldElement
|
| - {
|
| - SimpleStringLiteral node =
|
| - _findMainNode("@field'", (n) => n is SimpleStringLiteral);
|
| - int offset = node.offset;
|
| - // prepare Element
|
| - Element element = AngularCompilationUnitBuilder.getElement(node, offset);
|
| - expect(element, isNotNull);
|
| - // check FieldElement
|
| - FieldElement field = element as FieldElement;
|
| - expect(field.name, "field");
|
| - }
|
| - }
|
| -
|
| - void test_getElement_component_selector() {
|
| - resolveMainSource(_createAngularSource(r'''
|
| -@Component(publishAs: 'ctrl', selector: 'myComp',
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css')
|
| -class MyComponent {}'''));
|
| - SimpleStringLiteral node =
|
| - _findMainNode("myComp'", (n) => n is SimpleStringLiteral);
|
| - int offset = node.offset;
|
| - // find AngularSelectorElement
|
| - Element element = AngularCompilationUnitBuilder.getElement(node, offset);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is AngularSelectorElement,
|
| - AngularSelectorElement,
|
| - element);
|
| - }
|
| -
|
| - void test_getElement_controller_name() {
|
| - resolveMainSource(_createAngularSource(r'''
|
| -@Controller(publishAs: 'ctrl', selector: '[myApp]')
|
| -class MyController {
|
| -}'''));
|
| - SimpleStringLiteral node =
|
| - _findMainNode("ctrl'", (n) => n is SimpleStringLiteral);
|
| - int offset = node.offset;
|
| - // find AngularControllerElement
|
| - Element element = AngularCompilationUnitBuilder.getElement(node, offset);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is AngularControllerElement,
|
| - AngularControllerElement,
|
| - element);
|
| - }
|
| -
|
| - void test_getElement_directive_property() {
|
| - resolveMainSource(_createAngularSource(r'''
|
| -@Decorator(selector: '[my-dir]',
|
| - map: const {
|
| - 'my-dir' : '=>field'
|
| - })
|
| -class MyDirective {
|
| - set field(value) {}
|
| -}'''));
|
| - // prepare node
|
| - SimpleStringLiteral node =
|
| - _findMainNode("my-dir'", (n) => n is SimpleStringLiteral);
|
| - int offset = node.offset;
|
| - // prepare Element
|
| - Element element = AngularCompilationUnitBuilder.getElement(node, offset);
|
| - expect(element, isNotNull);
|
| - // check AngularPropertyElement
|
| - AngularPropertyElement property = element as AngularPropertyElement;
|
| - expect(property.name, "my-dir");
|
| - }
|
| -
|
| - void test_getElement_directive_selector() {
|
| - resolveMainSource(_createAngularSource(r'''
|
| -@Decorator(selector: '[my-dir]')
|
| -class MyDirective {}'''));
|
| - SimpleStringLiteral node =
|
| - _findMainNode("my-dir]'", (n) => n is SimpleStringLiteral);
|
| - int offset = node.offset;
|
| - // find AngularSelectorElement
|
| - Element element = AngularCompilationUnitBuilder.getElement(node, offset);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is AngularSelectorElement,
|
| - AngularSelectorElement,
|
| - element);
|
| - }
|
| -
|
| - void test_getElement_filter_name() {
|
| - resolveMainSource(_createAngularSource(r'''
|
| -@Formatter(name: 'myFilter')
|
| -class MyFilter {
|
| - call(p1, p2) {}
|
| -}'''));
|
| - SimpleStringLiteral node =
|
| - _findMainNode("myFilter'", (n) => n is SimpleStringLiteral);
|
| - int offset = node.offset;
|
| - // find FilterElement
|
| - Element element = AngularCompilationUnitBuilder.getElement(node, offset);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is AngularFormatterElement,
|
| - AngularFormatterElement,
|
| - element);
|
| - }
|
| -
|
| - void test_getElement_noClassDeclaration() {
|
| - resolveMainSource("var foo = 'bar';");
|
| - SimpleStringLiteral node =
|
| - _findMainNode("bar'", (n) => n is SimpleStringLiteral);
|
| - Element element = AngularCompilationUnitBuilder.getElement(node, 0);
|
| - expect(element, isNull);
|
| - }
|
| -
|
| - void test_getElement_noClassElement() {
|
| - resolveMainSource(r'''
|
| -class A {
|
| - const A(p);
|
| -}
|
| -
|
| -@A('bar')
|
| -class B {}''');
|
| - SimpleStringLiteral node =
|
| - _findMainNode("bar'", (n) => n is SimpleStringLiteral);
|
| - // reset B element
|
| - ClassDeclaration classDeclaration =
|
| - node.getAncestor((node) => node is ClassDeclaration);
|
| - classDeclaration.name.staticElement = null;
|
| - // class is not resolved - no element
|
| - Element element = AngularCompilationUnitBuilder.getElement(node, 0);
|
| - expect(element, isNull);
|
| - }
|
| -
|
| - void test_getElement_noNode() {
|
| - Element element = AngularCompilationUnitBuilder.getElement(null, 0);
|
| - expect(element, isNull);
|
| - }
|
| -
|
| - void test_getElement_notFound() {
|
| - resolveMainSource(r'''
|
| -class MyComponent {
|
| - var str = 'some string';
|
| -}''');
|
| - // prepare node
|
| - SimpleStringLiteral node =
|
| - _findMainNode("some string'", (n) => n is SimpleStringLiteral);
|
| - int offset = node.offset;
|
| - // no Element
|
| - Element element = AngularCompilationUnitBuilder.getElement(node, offset);
|
| - expect(element, isNull);
|
| - }
|
| -
|
| - void test_getElement_SimpleStringLiteral_withToolkitElement() {
|
| - SimpleStringLiteral literal = AstFactory.string2("foo");
|
| - Element element = new AngularScopePropertyElementImpl("foo", 0, null);
|
| - literal.toolkitElement = element;
|
| - expect(
|
| - AngularCompilationUnitBuilder.getElement(literal, -1),
|
| - same(element));
|
| - }
|
| -
|
| - void test_NgComponent_bad_cannotParseSelector() {
|
| - contextHelper.addSource("/my_template.html", "");
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - String mainContent = _createAngularSource(r'''
|
| -@Component(publishAs: 'ctrl', selector: '~myComp',
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css')
|
| -class MyComponent {
|
| -}''');
|
| - resolveMainSource(mainContent);
|
| - // has error
|
| - assertMainErrors([AngularCode.CANNOT_PARSE_SELECTOR]);
|
| - }
|
| -
|
| - void test_NgComponent_bad_missingSelector() {
|
| - contextHelper.addSource("/my_template.html", "");
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - String mainContent = _createAngularSource(r'''
|
| -@Component(publishAs: 'ctrl', /*selector: 'myComp',*/
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css')
|
| -class MyComponent {
|
| -}''');
|
| - resolveMainSource(mainContent);
|
| - // has error
|
| - assertMainErrors([AngularCode.MISSING_SELECTOR]);
|
| - }
|
| -
|
| - /**
|
| - *
|
| - * https://code.google.com/p/dart/issues/detail?id=16346
|
| - */
|
| - void test_NgComponent_bad_notHtmlTemplate() {
|
| - contextHelper.addSource("/my_template", "");
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - addMainSource(_createAngularSource(r'''
|
| -@NgComponent(publishAs: 'ctrl', selector: 'myComp',
|
| - templateUrl: 'my_template', cssUrl: 'my_styles.css')
|
| -class MyComponent {
|
| -}'''));
|
| - contextHelper.runTasks();
|
| - }
|
| -
|
| - void test_NgComponent_bad_properties_invalidBinding() {
|
| - contextHelper.addSource("/my_template.html", "");
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - String mainContent = _createAngularSource(r'''
|
| -@Component(publishAs: 'ctrl', selector: 'myComp',
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css',
|
| - map: const {'name' : '?field'})
|
| -class MyComponent {
|
| -}''');
|
| - resolveMainSource(mainContent);
|
| - // has error
|
| - assertMainErrors([AngularCode.INVALID_PROPERTY_KIND]);
|
| - }
|
| -
|
| - void test_NgComponent_bad_properties_nameNotStringLiteral() {
|
| - contextHelper.addSource("/my_template.html", "");
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - String mainContent = _createAngularSource(r'''
|
| -@Component(publishAs: 'ctrl', selector: 'myComp',
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css',
|
| - map: const {null : 'field'})
|
| -class MyComponent {
|
| -}''');
|
| - resolveMainSource(mainContent);
|
| - // has error
|
| - assertMainErrors([AngularCode.INVALID_PROPERTY_NAME]);
|
| - }
|
| -
|
| - void test_NgComponent_bad_properties_noSuchField() {
|
| - contextHelper.addSource("/my_template.html", "");
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - String mainContent = _createAngularSource(r'''
|
| -@Component(publishAs: 'ctrl', selector: 'myComp',
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css',
|
| - map: const {'name' : '=>field'})
|
| -class MyComponent {
|
| -}''');
|
| - resolveMainSource(mainContent);
|
| - // has error
|
| - assertMainErrors([AngularCode.INVALID_PROPERTY_FIELD]);
|
| - }
|
| -
|
| - void test_NgComponent_bad_properties_notMapLiteral() {
|
| - contextHelper.addSource("/my_template.html", "");
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - String mainContent = _createAngularSource(r'''
|
| -@Component(publishAs: 'ctrl', selector: 'myComp',
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css',
|
| - map: null)
|
| -class MyComponent {
|
| -}''');
|
| - resolveMainSource(mainContent);
|
| - // has error
|
| - assertMainErrors([AngularCode.INVALID_PROPERTY_MAP]);
|
| - }
|
| -
|
| - void test_NgComponent_bad_properties_specNotStringLiteral() {
|
| - contextHelper.addSource("/my_template.html", "");
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - String mainContent = _createAngularSource(r'''
|
| -@Component(publishAs: 'ctrl', selector: 'myComp',
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css',
|
| - map: const {'name' : null})
|
| -class MyComponent {
|
| -}''');
|
| - resolveMainSource(mainContent);
|
| - // has error
|
| - assertMainErrors([AngularCode.INVALID_PROPERTY_SPEC]);
|
| - }
|
| -
|
| - void test_NgComponent_no_cssUrl() {
|
| - contextHelper.addSource("/my_template.html", "");
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - String mainContent = _createAngularSource(r'''
|
| -@Component(publishAs: 'ctrl', selector: 'myComp',
|
| - templateUrl: 'my_template.html'/*, cssUrl: 'my_styles.css'*/)
|
| -class MyComponent {
|
| -}''');
|
| - resolveMainSource(mainContent);
|
| - // prepare AngularComponentElement
|
| - ClassElement classElement = mainUnitElement.getType("MyComponent");
|
| - AngularComponentElement component =
|
| - getAngularElement(classElement, (e) => e is AngularComponentElement);
|
| - expect(component, isNotNull);
|
| - // no CSS
|
| - expect(component.styleUri, null);
|
| - expect(component.styleUriOffset, -1);
|
| - }
|
| -
|
| - void test_NgComponent_no_publishAs() {
|
| - contextHelper.addSource("/my_template.html", "");
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - String mainContent = _createAngularSource(r'''
|
| -@Component(/*publishAs: 'ctrl',*/ selector: 'myComp',
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css')
|
| -class MyComponent {
|
| -}''');
|
| - resolveMainSource(mainContent);
|
| - // prepare AngularComponentElement
|
| - ClassElement classElement = mainUnitElement.getType("MyComponent");
|
| - AngularComponentElement component =
|
| - getAngularElement(classElement, (e) => e is AngularComponentElement);
|
| - expect(component, isNotNull);
|
| - // no name
|
| - expect(component.name, null);
|
| - expect(component.nameOffset, -1);
|
| - }
|
| -
|
| - void test_NgComponent_no_templateUrl() {
|
| - contextHelper.addSource("/my_template.html", "");
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - String mainContent = _createAngularSource(r'''
|
| -@Component(publishAs: 'ctrl', selector: 'myComp',
|
| - /*templateUrl: 'my_template.html',*/ cssUrl: 'my_styles.css')
|
| -class MyComponent {
|
| -}''');
|
| - resolveMainSource(mainContent);
|
| - // prepare AngularComponentElement
|
| - ClassElement classElement = mainUnitElement.getType("MyComponent");
|
| - AngularComponentElement component =
|
| - getAngularElement(classElement, (e) => e is AngularComponentElement);
|
| - expect(component, isNotNull);
|
| - // no template
|
| - expect(component.templateUri, null);
|
| - expect(component.templateSource, null);
|
| - expect(component.templateUriOffset, -1);
|
| - }
|
| -
|
| - /**
|
| - * https://code.google.com/p/dart/issues/detail?id=19023
|
| - */
|
| - void test_NgComponent_notAngular() {
|
| - contextHelper.addSource("/my_template.html", "");
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - String mainContent = r'''
|
| -class Component {
|
| - const Component(a, b);
|
| -}
|
| -
|
| -@Component('foo', 42)
|
| -class MyComponent {
|
| -}''';
|
| - resolveMainSource(mainContent);
|
| - assertNoMainErrors();
|
| - }
|
| -
|
| - void test_NgComponent_properties_fieldFromSuper() {
|
| - contextHelper.addSource("/my_template.html", "");
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - resolveMainSourceNoErrors(_createAngularSource(r'''
|
| -class MySuper {
|
| - var myPropA;
|
| -}
|
| -
|
| -
|
| -
|
| -@Component(publishAs: 'ctrl', selector: 'myComp',
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css',
|
| - map: const {
|
| - 'prop-a' : '@myPropA'
|
| - })
|
| -class MyComponent extends MySuper {
|
| -}'''));
|
| - // prepare AngularComponentElement
|
| - ClassElement classElement = mainUnitElement.getType("MyComponent");
|
| - AngularComponentElement component =
|
| - getAngularElement(classElement, (e) => e is AngularComponentElement);
|
| - expect(component, isNotNull);
|
| - // verify
|
| - List<AngularPropertyElement> properties = component.properties;
|
| - expect(properties, hasLength(1));
|
| - _assertProperty(
|
| - properties[0],
|
| - "prop-a",
|
| - findMainOffset("prop-a' :"),
|
| - AngularPropertyKind.ATTR,
|
| - "myPropA",
|
| - findMainOffset("myPropA'"));
|
| - }
|
| -
|
| - void test_NgComponent_properties_fromFields() {
|
| - contextHelper.addSource("/my_template.html", "");
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - resolveMainSourceNoErrors(_createAngularSource(r'''
|
| -@Component(publishAs: 'ctrl', selector: 'myComp',
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css')
|
| -class MyComponent {
|
| - @NgAttr('prop-a')
|
| - var myPropA;
|
| - @NgCallback('prop-b')
|
| - var myPropB;
|
| - @NgOneWay('prop-c')
|
| - var myPropC;
|
| - @NgOneWayOneTime('prop-d')
|
| - var myPropD;
|
| - @NgTwoWay('prop-e')
|
| - var myPropE;
|
| -}'''));
|
| - // prepare AngularComponentElement
|
| - ClassElement classElement = mainUnitElement.getType("MyComponent");
|
| - AngularComponentElement component =
|
| - getAngularElement(classElement, (e) => e is AngularComponentElement);
|
| - expect(component, isNotNull);
|
| - // verify
|
| - List<AngularPropertyElement> properties = component.properties;
|
| - expect(properties, hasLength(5));
|
| - _assertProperty(
|
| - properties[0],
|
| - "prop-a",
|
| - findMainOffset("prop-a')"),
|
| - AngularPropertyKind.ATTR,
|
| - "myPropA",
|
| - -1);
|
| - _assertProperty(
|
| - properties[1],
|
| - "prop-b",
|
| - findMainOffset("prop-b')"),
|
| - AngularPropertyKind.CALLBACK,
|
| - "myPropB",
|
| - -1);
|
| - _assertProperty(
|
| - properties[2],
|
| - "prop-c",
|
| - findMainOffset("prop-c')"),
|
| - AngularPropertyKind.ONE_WAY,
|
| - "myPropC",
|
| - -1);
|
| - _assertProperty(
|
| - properties[3],
|
| - "prop-d",
|
| - findMainOffset("prop-d')"),
|
| - AngularPropertyKind.ONE_WAY_ONE_TIME,
|
| - "myPropD",
|
| - -1);
|
| - _assertProperty(
|
| - properties[4],
|
| - "prop-e",
|
| - findMainOffset("prop-e')"),
|
| - AngularPropertyKind.TWO_WAY,
|
| - "myPropE",
|
| - -1);
|
| - }
|
| -
|
| - void test_NgComponent_properties_fromMap() {
|
| - contextHelper.addSource("/my_template.html", "");
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - resolveMainSourceNoErrors(_createAngularSource(r'''
|
| -@Component(publishAs: 'ctrl', selector: 'myComp',
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css',
|
| - map: const {
|
| - 'prop-a' : '@myPropA',
|
| - 'prop-b' : '&myPropB',
|
| - 'prop-c' : '=>myPropC',
|
| - 'prop-d' : '=>!myPropD',
|
| - 'prop-e' : '<=>myPropE'
|
| - })
|
| -class MyComponent {
|
| - var myPropA;
|
| - var myPropB;
|
| - var myPropC;
|
| - var myPropD;
|
| - var myPropE;
|
| -}'''));
|
| - // prepare AngularComponentElement
|
| - ClassElement classElement = mainUnitElement.getType("MyComponent");
|
| - AngularComponentElement component =
|
| - getAngularElement(classElement, (e) => e is AngularComponentElement);
|
| - expect(component, isNotNull);
|
| - // verify
|
| - List<AngularPropertyElement> properties = component.properties;
|
| - expect(properties, hasLength(5));
|
| - _assertProperty(
|
| - properties[0],
|
| - "prop-a",
|
| - findMainOffset("prop-a' :"),
|
| - AngularPropertyKind.ATTR,
|
| - "myPropA",
|
| - findMainOffset("myPropA'"));
|
| - _assertProperty(
|
| - properties[1],
|
| - "prop-b",
|
| - findMainOffset("prop-b' :"),
|
| - AngularPropertyKind.CALLBACK,
|
| - "myPropB",
|
| - findMainOffset("myPropB'"));
|
| - _assertProperty(
|
| - properties[2],
|
| - "prop-c",
|
| - findMainOffset("prop-c' :"),
|
| - AngularPropertyKind.ONE_WAY,
|
| - "myPropC",
|
| - findMainOffset("myPropC'"));
|
| - _assertProperty(
|
| - properties[3],
|
| - "prop-d",
|
| - findMainOffset("prop-d' :"),
|
| - AngularPropertyKind.ONE_WAY_ONE_TIME,
|
| - "myPropD",
|
| - findMainOffset("myPropD'"));
|
| - _assertProperty(
|
| - properties[4],
|
| - "prop-e",
|
| - findMainOffset("prop-e' :"),
|
| - AngularPropertyKind.TWO_WAY,
|
| - "myPropE",
|
| - findMainOffset("myPropE'"));
|
| - }
|
| -
|
| - void test_NgComponent_properties_no() {
|
| - contextHelper.addSource("/my_template.html", "");
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - String mainContent = _createAngularSource(r'''
|
| -@Component(publishAs: 'ctrl', selector: 'myComp',
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css')
|
| -class MyComponent {
|
| -}''');
|
| - resolveMainSourceNoErrors(mainContent);
|
| - // prepare AngularComponentElement
|
| - ClassElement classElement = mainUnitElement.getType("MyComponent");
|
| - AngularComponentElement component =
|
| - getAngularElement(classElement, (e) => e is AngularComponentElement);
|
| - expect(component, isNotNull);
|
| - // verify
|
| - expect(component.name, "ctrl");
|
| - expect(component.nameOffset, AngularTest.findOffset(mainContent, "ctrl'"));
|
| - _assertIsTagSelector(component.selector, "myComp");
|
| - expect(component.templateUri, "my_template.html");
|
| - expect(
|
| - component.templateUriOffset,
|
| - AngularTest.findOffset(mainContent, "my_template.html'"));
|
| - expect(component.styleUri, "my_styles.css");
|
| - expect(
|
| - component.styleUriOffset,
|
| - AngularTest.findOffset(mainContent, "my_styles.css'"));
|
| - expect(component.properties, hasLength(0));
|
| - }
|
| -
|
| - void test_NgComponent_scopeProperties() {
|
| - contextHelper.addSource("/my_template.html", "");
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - String mainContent = _createAngularSource(r'''
|
| -@Component(publishAs: 'ctrl', selector: 'myComp',
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css')
|
| -class MyComponent {
|
| - MyComponent(Scope scope) {
|
| - scope.context['boolProp'] = true;
|
| - scope.context['intProp'] = 42;
|
| - scope.context['stringProp'] = 'foo';
|
| - // duplicate is ignored
|
| - scope.context['boolProp'] = true;
|
| - // LHS is not an IndexExpression
|
| - var v1;
|
| - v1 = 1;
|
| - // LHS is not a Scope access
|
| - var v2;
|
| - v2['name'] = 2;
|
| - }
|
| -}''');
|
| - resolveMainSourceNoErrors(mainContent);
|
| - // prepare AngularComponentElement
|
| - ClassElement classElement = mainUnitElement.getType("MyComponent");
|
| - AngularComponentElement component =
|
| - getAngularElement(classElement, (e) => e is AngularComponentElement);
|
| - expect(component, isNotNull);
|
| - // verify
|
| - List<AngularScopePropertyElement> scopeProperties =
|
| - component.scopeProperties;
|
| - expect(scopeProperties, hasLength(3));
|
| - {
|
| - AngularScopePropertyElement property = scopeProperties[0];
|
| - expect(findMainElement2("boolProp"), same(property));
|
| - expect(property.name, "boolProp");
|
| - expect(
|
| - property.nameOffset,
|
| - AngularTest.findOffset(mainContent, "boolProp'"));
|
| - expect(property.type.name, "bool");
|
| - }
|
| - {
|
| - AngularScopePropertyElement property = scopeProperties[1];
|
| - expect(findMainElement2("intProp"), same(property));
|
| - expect(property.name, "intProp");
|
| - expect(
|
| - property.nameOffset,
|
| - AngularTest.findOffset(mainContent, "intProp'"));
|
| - expect(property.type.name, "int");
|
| - }
|
| - {
|
| - AngularScopePropertyElement property = scopeProperties[2];
|
| - expect(findMainElement2("stringProp"), same(property));
|
| - expect(property.name, "stringProp");
|
| - expect(
|
| - property.nameOffset,
|
| - AngularTest.findOffset(mainContent, "stringProp'"));
|
| - expect(property.type.name, "String");
|
| - }
|
| - }
|
| -
|
| - void test_NgController() {
|
| - String mainContent = _createAngularSource(r'''
|
| -@Controller(publishAs: 'ctrl', selector: '[myApp]')
|
| -class MyController {
|
| -}''');
|
| - resolveMainSourceNoErrors(mainContent);
|
| - // prepare AngularControllerElement
|
| - ClassElement classElement = mainUnitElement.getType("MyController");
|
| - AngularControllerElement controller =
|
| - getAngularElement(classElement, (e) => e is AngularControllerElement);
|
| - expect(controller, isNotNull);
|
| - // verify
|
| - expect(controller.name, "ctrl");
|
| - expect(controller.nameOffset, AngularTest.findOffset(mainContent, "ctrl'"));
|
| - _assertHasAttributeSelector(controller.selector, "myApp");
|
| - }
|
| -
|
| - void test_NgController_cannotParseSelector() {
|
| - String mainContent = _createAngularSource(r'''
|
| -@Controller(publishAs: 'ctrl', selector: '~unknown')
|
| -class MyController {
|
| -}''');
|
| - resolveMainSource(mainContent);
|
| - // has error
|
| - assertMainErrors([AngularCode.CANNOT_PARSE_SELECTOR]);
|
| - }
|
| -
|
| - void test_NgController_missingPublishAs() {
|
| - String mainContent = _createAngularSource(r'''
|
| -@Controller(selector: '[myApp]')
|
| -class MyController {
|
| -}''');
|
| - resolveMainSource(mainContent);
|
| - // has error
|
| - assertMainErrors([AngularCode.MISSING_PUBLISH_AS]);
|
| - }
|
| -
|
| - void test_NgController_missingSelector() {
|
| - String mainContent = _createAngularSource(r'''
|
| -@Controller(publishAs: 'ctrl')
|
| -class MyController {
|
| -}''');
|
| - resolveMainSource(mainContent);
|
| - // has error
|
| - assertMainErrors([AngularCode.MISSING_SELECTOR]);
|
| - }
|
| -
|
| - void test_NgController_noAnnotationArguments() {
|
| - String mainContent = _createAngularSource(r'''
|
| -@NgController
|
| -class MyController {
|
| -}''');
|
| - resolveMainSource(mainContent);
|
| - }
|
| -
|
| - void test_parseSelector_hasAttribute() {
|
| - AngularSelectorElement selector =
|
| - AngularCompilationUnitBuilder.parseSelector(42, "[name]");
|
| - _assertHasAttributeSelector(selector, "name");
|
| - expect(selector.nameOffset, 42 + 1);
|
| - }
|
| -
|
| - void test_parseSelector_hasClass() {
|
| - AngularSelectorElement selector =
|
| - AngularCompilationUnitBuilder.parseSelector(42, ".my-class");
|
| - AngularHasClassSelectorElementImpl classSelector =
|
| - selector as AngularHasClassSelectorElementImpl;
|
| - expect(classSelector.name, "my-class");
|
| - expect(classSelector.toString(), ".my-class");
|
| - expect(selector.nameOffset, 42 + 1);
|
| - // test apply()
|
| - {
|
| - ht.XmlTagNode node =
|
| - HtmlFactory.tagNode("div", [HtmlFactory.attribute("class", "one two")]);
|
| - expect(classSelector.apply(node), isFalse);
|
| - }
|
| - {
|
| - ht.XmlTagNode node = HtmlFactory.tagNode(
|
| - "div",
|
| - [HtmlFactory.attribute("class", "one my-class two")]);
|
| - expect(classSelector.apply(node), isTrue);
|
| - }
|
| - }
|
| -
|
| - void test_parseSelector_isTag() {
|
| - AngularSelectorElement selector =
|
| - AngularCompilationUnitBuilder.parseSelector(42, "name");
|
| - _assertIsTagSelector(selector, "name");
|
| - expect(selector.nameOffset, 42);
|
| - }
|
| -
|
| - void test_parseSelector_isTag_hasAttribute() {
|
| - AngularSelectorElement selector =
|
| - AngularCompilationUnitBuilder.parseSelector(42, "tag[attr]");
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is IsTagHasAttributeSelectorElementImpl,
|
| - IsTagHasAttributeSelectorElementImpl,
|
| - selector);
|
| - expect(selector.name, "tag[attr]");
|
| - expect(selector.nameOffset, -1);
|
| - expect((selector as IsTagHasAttributeSelectorElementImpl).tagName, "tag");
|
| - expect(
|
| - (selector as IsTagHasAttributeSelectorElementImpl).attributeName,
|
| - "attr");
|
| - }
|
| -
|
| - void test_parseSelector_unknown() {
|
| - AngularSelectorElement selector =
|
| - AngularCompilationUnitBuilder.parseSelector(0, "~unknown");
|
| - expect(selector, isNull);
|
| - }
|
| -
|
| - void test_view() {
|
| - contextHelper.addSource("/wrong.html", "");
|
| - contextHelper.addSource("/my_templateA.html", "");
|
| - contextHelper.addSource("/my_templateB.html", "");
|
| - String mainContent = _createAngularSource(r'''
|
| -class MyRouteInitializer {
|
| - init(ViewFactory view, foo) {
|
| - foo.view('wrong.html'); // has target
|
| - foo(); // less than one argument
|
| - foo('wrong.html', 'bar'); // more than one argument
|
| - foo('wrong' + '.html'); // not literal
|
| - foo('wrong.html'); // not ViewFactory
|
| - view('my_templateA.html');
|
| - view('my_templateB.html');
|
| - }
|
| -}''');
|
| - resolveMainSourceNoErrors(mainContent);
|
| - // prepare AngularViewElement(s)
|
| - List<AngularViewElement> views = mainUnitElement.angularViews;
|
| - expect(views, hasLength(2));
|
| - {
|
| - AngularViewElement view = views[0];
|
| - expect(view.templateUri, "my_templateA.html");
|
| - expect(view.name, null);
|
| - expect(view.nameOffset, -1);
|
| - expect(
|
| - view.templateUriOffset,
|
| - AngularTest.findOffset(mainContent, "my_templateA.html'"));
|
| - }
|
| - {
|
| - AngularViewElement view = views[1];
|
| - expect(view.templateUri, "my_templateB.html");
|
| - expect(view.name, null);
|
| - expect(view.nameOffset, -1);
|
| - expect(
|
| - view.templateUriOffset,
|
| - AngularTest.findOffset(mainContent, "my_templateB.html'"));
|
| - }
|
| - }
|
| -
|
| - void _assertProperty(AngularPropertyElement property, String expectedName,
|
| - int expectedNameOffset, AngularPropertyKind expectedKind,
|
| - String expectedFieldName, int expectedFieldOffset) {
|
| - expect(property.name, expectedName);
|
| - expect(property.nameOffset, expectedNameOffset);
|
| - expect(property.propertyKind, same(expectedKind));
|
| - expect(property.field.name, expectedFieldName);
|
| - expect(property.fieldNameOffset, expectedFieldOffset);
|
| - }
|
| -
|
| - /**
|
| - * Find [AstNode] of the given type in [mainUnit].
|
| - */
|
| - AstNode _findMainNode(String search, Predicate<AstNode> predicate) {
|
| - return EngineTestCase.findNode(mainUnit, mainContent, search, predicate);
|
| - }
|
| -
|
| - static AngularElement getAngularElement(Element element,
|
| - Predicate<Element> predicate) {
|
| - List<ToolkitObjectElement> toolkitObjects = null;
|
| - if (element is ClassElement) {
|
| - ClassElement classElement = element;
|
| - toolkitObjects = classElement.toolkitObjects;
|
| - }
|
| - if (element is LocalVariableElement) {
|
| - LocalVariableElement variableElement = element;
|
| - toolkitObjects = variableElement.toolkitObjects;
|
| - }
|
| - if (toolkitObjects != null) {
|
| - for (ToolkitObjectElement toolkitObject in toolkitObjects) {
|
| - if (predicate(toolkitObject)) {
|
| - return toolkitObject as AngularElement;
|
| - }
|
| - }
|
| - }
|
| - return null;
|
| - }
|
| -
|
| - static void _assertHasAttributeSelector(AngularSelectorElement selector,
|
| - String name) {
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is HasAttributeSelectorElementImpl,
|
| - HasAttributeSelectorElementImpl,
|
| - selector);
|
| - expect((selector as HasAttributeSelectorElementImpl).name, name);
|
| - }
|
| -
|
| - static void _assertIsTagSelector(AngularSelectorElement selector,
|
| - String name) {
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is AngularTagSelectorElementImpl,
|
| - AngularTagSelectorElementImpl,
|
| - selector);
|
| - expect((selector as AngularTagSelectorElementImpl).name, name);
|
| - }
|
| -
|
| - static String _createAngularSource(String code) {
|
| - return "import 'angular.dart';\n" + code;
|
| - }
|
| -}
|
| -
|
| -
|
| -@ReflectiveTestCase()
|
| -class AngularHtmlUnitResolverTest extends AngularTest {
|
| - void fail_analysisContext_changeDart_invalidateApplication() {
|
| - addMainSource(r'''
|
| -
|
| -import 'angular.dart';
|
| -
|
| -@Component(
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css',
|
| - publishAs: 'ctrl',
|
| - selector: 'myComponent')
|
| -class MyComponent {
|
| -}''');
|
| - contextHelper.addSource(
|
| - "/entry-point.html",
|
| - AngularTest.createHtmlWithAngular(''));
|
| - addIndexSource2("/my_template.html", r'''
|
| -<div>
|
| - {{ctrl.noMethod()}}
|
| -</div>''');
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - contextHelper.runTasks();
|
| - // there are some errors in my_template.html
|
| - {
|
| - List<AnalysisError> errors = context.getErrors(indexSource).errors;
|
| - expect(errors.length != 0, isTrue);
|
| - }
|
| - // change main.dart, there are no MyComponent anymore
|
| - context.setContents(mainSource, "");
|
| - // ...errors in my_template.html should be removed
|
| - {
|
| - List<AnalysisError> errors = context.getErrors(indexSource).errors;
|
| - expect(errors, isEmpty);
|
| - expect(errors.length == 0, isTrue);
|
| - }
|
| - }
|
| -
|
| - void fail_ngRepeat_additionalVariables() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<li ng-repeat='name in ctrl.names'>
|
| - {{$index}} {{$first}} {{$middle}} {{$last}} {{$even}} {{$odd}}
|
| -</li>'''));
|
| - assertResolvedIdentifier2("\$index", "int");
|
| - assertResolvedIdentifier2("\$first", "bool");
|
| - assertResolvedIdentifier2("\$middle", "bool");
|
| - assertResolvedIdentifier2("\$last", "bool");
|
| - assertResolvedIdentifier2("\$even", "bool");
|
| - assertResolvedIdentifier2("\$odd", "bool");
|
| - }
|
| -
|
| - void fail_ngRepeat_bad_expectedIdentifier() {
|
| - addMyController();
|
| - resolveIndex2(AngularTest.createHtmlWithMyController(r'''
|
| -<li ng-repeat='name + 42 in ctrl.names'>
|
| -</li>'''));
|
| - assertErrors(indexSource, [AngularCode.INVALID_REPEAT_ITEM_SYNTAX]);
|
| - }
|
| -
|
| - void fail_ngRepeat_bad_expectedIn() {
|
| - addMyController();
|
| - resolveIndex2(AngularTest.createHtmlWithMyController(r'''
|
| -<li ng-repeat='name : ctrl.names'>
|
| -</li>'''));
|
| - assertErrors(indexSource, [AngularCode.INVALID_REPEAT_SYNTAX]);
|
| - }
|
| -
|
| - void fail_ngRepeat_filters_filter_literal() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<li ng-repeat='item in ctrl.items | filter:42:null'/>
|
| -</li>'''));
|
| - // filter "filter" is resolved
|
| - Element filterElement = assertResolvedIdentifier("filter");
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is AngularFormatterElement,
|
| - AngularFormatterElement,
|
| - filterElement);
|
| - }
|
| -
|
| - void fail_ngRepeat_filters_filter_propertyMap() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<li ng-repeat='item in ctrl.items | filter:{name:null, done:false}'/>
|
| -</li>'''));
|
| - assertResolvedIdentifier2("name:", "String");
|
| - assertResolvedIdentifier2("done:", "bool");
|
| - }
|
| -
|
| - void fail_ngRepeat_filters_missingColon() {
|
| - addMyController();
|
| - resolveIndex2(AngularTest.createHtmlWithMyController(r'''
|
| -<li ng-repeat="item in ctrl.items | orderBy:'' true"/>
|
| -</li>'''));
|
| - assertErrors(indexSource, [AngularCode.MISSING_FORMATTER_COLON]);
|
| - }
|
| -
|
| - void fail_ngRepeat_filters_noArgs() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<li ng-repeat="item in ctrl.items | orderBy"/>
|
| -</li>'''));
|
| - // filter "orderBy" is resolved
|
| - Element filterElement = assertResolvedIdentifier("orderBy");
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is AngularFormatterElement,
|
| - AngularFormatterElement,
|
| - filterElement);
|
| - }
|
| -
|
| - void fail_ngRepeat_filters_orderBy_emptyString() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<li ng-repeat="item in ctrl.items | orderBy:'':true"/>
|
| -</li>'''));
|
| - // filter "orderBy" is resolved
|
| - Element filterElement = assertResolvedIdentifier("orderBy");
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is AngularFormatterElement,
|
| - AngularFormatterElement,
|
| - filterElement);
|
| - }
|
| -
|
| - void fail_ngRepeat_filters_orderBy_propertyList() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<li ng-repeat="item in ctrl.items | orderBy:['name', 'done']"/>
|
| -</li>'''));
|
| - assertResolvedIdentifier2("name'", "String");
|
| - assertResolvedIdentifier2("done'", "bool");
|
| - }
|
| -
|
| - void fail_ngRepeat_filters_orderBy_propertyName() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<li ng-repeat="item in ctrl.items | orderBy:'name'"/>
|
| -</li>'''));
|
| - assertResolvedIdentifier2("name'", "String");
|
| - }
|
| -
|
| - void fail_ngRepeat_filters_orderBy_propertyName_minus() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<li ng-repeat="item in ctrl.items | orderBy:'-name'"/>
|
| -</li>'''));
|
| - assertResolvedIdentifier2("name'", "String");
|
| - }
|
| -
|
| - void fail_ngRepeat_filters_orderBy_propertyName_plus() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<li ng-repeat="item in ctrl.items | orderBy:'+name'"/>
|
| -</li>'''));
|
| - assertResolvedIdentifier2("name'", "String");
|
| - }
|
| -
|
| - void fail_ngRepeat_filters_orderBy_propertyName_untypedItems() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<li ng-repeat="item in ctrl.untypedItems | orderBy:'name'"/>
|
| -</li>'''));
|
| - assertResolvedIdentifier2("name'", "dynamic");
|
| - }
|
| -
|
| - void fail_ngRepeat_filters_two() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<li ng-repeat="item in ctrl.items | orderBy:'+' | orderBy:'-'"/>
|
| -</li>'''));
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is AngularFormatterElement,
|
| - AngularFormatterElement,
|
| - assertResolvedIdentifier("orderBy:'+'"));
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is AngularFormatterElement,
|
| - AngularFormatterElement,
|
| - assertResolvedIdentifier("orderBy:'-'"));
|
| - }
|
| -
|
| - void fail_ngRepeat_resolvedExpressions() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<li ng-repeat='name in ctrl.names'>
|
| - {{name}}
|
| -</li>'''));
|
| - assertResolvedIdentifier2("name in", "String");
|
| - assertResolvedIdentifier2("ctrl.", "MyController");
|
| - assertResolvedIdentifier2("names'", "List<String>");
|
| - assertResolvedIdentifier2("name}}", "String");
|
| - }
|
| -
|
| - void fail_ngRepeat_trackBy() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<li ng-repeat='name in ctrl.names track by name.length'/>
|
| -</li>'''));
|
| - assertResolvedIdentifier2("length'", "int");
|
| - }
|
| -
|
| - void test_analysisContext_changeEntryPoint_clearAngularErrors_inDart() {
|
| - addMainSource(r'''
|
| -
|
| -import 'angular.dart';
|
| -
|
| -@Component(
|
| - templateUrl: 'no-such-template.html', cssUrl: 'my_styles.css',
|
| - publishAs: 'ctrl',
|
| - selector: 'myComponent')
|
| -class MyComponent {
|
| -}''');
|
| - Source entrySource = contextHelper.addSource(
|
| - "/entry-point.html",
|
| - AngularTest.createHtmlWithAngular(''));
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - contextHelper.runTasks();
|
| - // there are some errors in MyComponent
|
| - {
|
| - List<AnalysisError> errors = context.getErrors(mainSource).errors;
|
| - expect(errors.length != 0, isTrue);
|
| - }
|
| - // make entry-point.html non-Angular
|
| - context.setContents(entrySource, "<html/>");
|
| - // ...errors in MyComponent should be removed
|
| - {
|
| - List<AnalysisError> errors = context.getErrors(mainSource).errors;
|
| - expect(errors.length == 0, isTrue);
|
| - }
|
| - }
|
| -
|
| - void test_analysisContext_changeEntryPoint_clearAngularErrors_inTemplate() {
|
| - addMainSource(r'''
|
| -
|
| -import 'angular.dart';
|
| -
|
| -@Component(
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css',
|
| - publishAs: 'ctrl',
|
| - selector: 'myComponent')
|
| -class MyComponent {
|
| -}''');
|
| - Source entrySource = contextHelper.addSource(
|
| - "/entry-point.html",
|
| - AngularTest.createHtmlWithAngular(''));
|
| - addIndexSource2("/my_template.html", r'''
|
| -<div>
|
| - {{ctrl.noMethod()}}
|
| -</div>''');
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - contextHelper.runTasks();
|
| - // there are some errors in my_template.html
|
| - {
|
| - List<AnalysisError> errors = context.getErrors(indexSource).errors;
|
| - expect(errors.length != 0, isTrue);
|
| - }
|
| - // make entry-point.html non-Angular
|
| - context.setContents(entrySource, "<html/>");
|
| - // ...errors in my_template.html should be removed
|
| - {
|
| - List<AnalysisError> errors = context.getErrors(indexSource).errors;
|
| - expect(errors.length == 0, isTrue);
|
| - }
|
| - }
|
| -
|
| - void test_analysisContext_removeEntryPoint_clearAngularErrors_inDart() {
|
| - addMainSource(r'''
|
| -
|
| -import 'angular.dart';
|
| -
|
| -@Component(
|
| - templateUrl: 'no-such-template.html', cssUrl: 'my_styles.css',
|
| - publishAs: 'ctrl',
|
| - selector: 'myComponent')
|
| -class MyComponent {
|
| -}''');
|
| - Source entrySource = contextHelper.addSource(
|
| - "/entry-point.html",
|
| - AngularTest.createHtmlWithAngular(''));
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - contextHelper.runTasks();
|
| - // there are some errors in MyComponent
|
| - {
|
| - List<AnalysisError> errors = context.getErrors(mainSource).errors;
|
| - expect(errors.length != 0, isTrue);
|
| - }
|
| - // remove entry-point.html
|
| - {
|
| - ChangeSet changeSet = new ChangeSet();
|
| - changeSet.removedSource(entrySource);
|
| - context.applyChanges(changeSet);
|
| - }
|
| - // ...errors in MyComponent should be removed
|
| - {
|
| - List<AnalysisError> errors = context.getErrors(mainSource).errors;
|
| - expect(errors.length == 0, isTrue);
|
| - }
|
| - }
|
| -
|
| - void test_contextProperties() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithAngular(r'''
|
| -<div>
|
| - {{$id}}
|
| - {{$parent}}
|
| - {{$root}}
|
| -</div>'''));
|
| - assertResolvedIdentifier("\$id");
|
| - assertResolvedIdentifier("\$parent");
|
| - assertResolvedIdentifier("\$root");
|
| - }
|
| -
|
| - void test_getAngularElement_isAngular() {
|
| - // prepare local variable "name" in compilation unit
|
| - CompilationUnitElementImpl unit =
|
| - ElementFactory.compilationUnit("test.dart");
|
| - FunctionElementImpl function = ElementFactory.functionElement("main");
|
| - unit.functions = <FunctionElement>[function];
|
| - LocalVariableElementImpl local =
|
| - ElementFactory.localVariableElement2("name");
|
| - function.localVariables = <LocalVariableElement>[local];
|
| - // set AngularElement
|
| - AngularElement angularElement = new AngularControllerElementImpl("ctrl", 0);
|
| - local.toolkitObjects = <AngularElement>[angularElement];
|
| - expect(
|
| - AngularHtmlUnitResolver.getAngularElement(local),
|
| - same(angularElement));
|
| - }
|
| -
|
| - void test_getAngularElement_notAngular() {
|
| - Element element = ElementFactory.localVariableElement2("name");
|
| - expect(AngularHtmlUnitResolver.getAngularElement(element), isNull);
|
| - }
|
| -
|
| - void test_getAngularElement_notLocal() {
|
| - Element element = ElementFactory.classElement2("Test");
|
| - expect(AngularHtmlUnitResolver.getAngularElement(element), isNull);
|
| - }
|
| -
|
| - /**
|
| - * Test that we resolve "ng-click" expression.
|
| - */
|
| - void test_ngClick() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(
|
| - AngularTest.createHtmlWithMyController(
|
| - r"<button ng-click='ctrl.doSomething($event)'/>"));
|
| - assertResolvedIdentifier("doSomething");
|
| - }
|
| -
|
| - void test_NgComponent_resolveTemplateFile() {
|
| - addMainSource(r'''
|
| -import 'angular.dart';
|
| -
|
| -@Component(
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css',
|
| - publishAs: 'ctrl',
|
| - selector: 'myComponent')
|
| -class MyComponent {
|
| - String field;
|
| -}''');
|
| - contextHelper.addSource(
|
| - "/entry-point.html",
|
| - AngularTest.createHtmlWithAngular(''));
|
| - addIndexSource2("/my_template.html", r'''
|
| -<div>
|
| - {{ctrl.field}}
|
| -</div>''');
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - contextHelper.runTasks();
|
| - resolveIndex();
|
| - assertNoErrors();
|
| - assertResolvedIdentifier2("ctrl.", "MyComponent");
|
| - assertResolvedIdentifier2("field}}", "String");
|
| - }
|
| -
|
| - void test_NgComponent_updateDartFile() {
|
| - Source componentSource = contextHelper.addSource("/my_component.dart", r'''
|
| -library my.component;
|
| -import 'angular.dart';
|
| -@Component(selector: 'myComponent')
|
| -class MyComponent {
|
| -}''');
|
| - contextHelper.addSource("/my_module.dart", r'''
|
| -library my.module;
|
| -import 'my_component.dart';''');
|
| - addMainSource(r'''
|
| -library main;
|
| -import 'my_module.dart';''');
|
| - _resolveIndexNoErrors(
|
| - AngularTest.createHtmlWithMyController("<myComponent/>"));
|
| - // "myComponent" tag was resolved
|
| - {
|
| - ht.XmlTagNode tagNode =
|
| - ht.HtmlUnitUtils.getTagNode(indexUnit, findOffset2("myComponent"));
|
| - AngularSelectorElement tagElement =
|
| - tagNode.element as AngularSelectorElement;
|
| - expect(tagElement, isNotNull);
|
| - expect(tagElement.name, "myComponent");
|
| - }
|
| - // replace "myComponent" with "myComponent2"
|
| - // in my_component.dart and index.html
|
| - {
|
| - context.setContents(
|
| - componentSource,
|
| - _getSourceContent(componentSource).replaceAll("myComponent", "myComponent2"));
|
| - indexContent =
|
| - _getSourceContent(indexSource).replaceAll("myComponent", "myComponent2");
|
| - context.setContents(indexSource, indexContent);
|
| - }
|
| - contextHelper.runTasks();
|
| - resolveIndex();
|
| - // "myComponent2" tag should be resolved
|
| - {
|
| - ht.XmlTagNode tagNode =
|
| - ht.HtmlUnitUtils.getTagNode(indexUnit, findOffset2("myComponent2"));
|
| - AngularSelectorElement tagElement =
|
| - tagNode.element as AngularSelectorElement;
|
| - expect(tagElement, isNotNull);
|
| - expect(tagElement.name, "myComponent2");
|
| - }
|
| - }
|
| -
|
| - void test_NgComponent_use_resolveAttributes() {
|
| - contextHelper.addSource("/my_template.html", r'''
|
| - <div>
|
| - {{ctrl.field}}
|
| - </div>''');
|
| - addMainSource(r'''
|
| -
|
| -import 'angular.dart';
|
| -
|
| -@Component(
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css',
|
| - publishAs: 'ctrl',
|
| - selector: 'myComponent', // selector
|
| - map: const {'attrA' : '=>setA', 'attrB' : '@setB'})
|
| -class MyComponent {
|
| - set setA(value) {}
|
| - set setB(value) {}
|
| -}''');
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<input type='text' ng-model='someModel'/>
|
| -<myComponent attrA='someModel' attrB='bbb'/>'''));
|
| - // "attrA" attribute expression was resolved
|
| - expect(findIdentifier("someModel"), isNotNull);
|
| - // "myComponent" tag was resolved
|
| - ht.XmlTagNode tagNode =
|
| - ht.HtmlUnitUtils.getTagNode(indexUnit, findOffset2("myComponent"));
|
| - AngularSelectorElement tagElement =
|
| - tagNode.element as AngularSelectorElement;
|
| - expect(tagElement, isNotNull);
|
| - expect(tagElement.name, "myComponent");
|
| - expect(tagElement.nameOffset, findMainOffset("myComponent', // selector"));
|
| - // "attrA" attribute was resolved
|
| - {
|
| - ht.XmlAttributeNode node =
|
| - ht.HtmlUnitUtils.getAttributeNode(indexUnit, findOffset2("attrA='"));
|
| - AngularPropertyElement element = node.element as AngularPropertyElement;
|
| - expect(element, isNotNull);
|
| - expect(element.name, "attrA");
|
| - expect(element.field.name, "setA");
|
| - }
|
| - // "attrB" attribute was resolved, even if it @binding
|
| - {
|
| - ht.XmlAttributeNode node =
|
| - ht.HtmlUnitUtils.getAttributeNode(indexUnit, findOffset2("attrB='"));
|
| - AngularPropertyElement element = node.element as AngularPropertyElement;
|
| - expect(element, isNotNull);
|
| - expect(element.name, "attrB");
|
| - expect(element.field.name, "setB");
|
| - }
|
| - }
|
| -
|
| - void test_NgDirective_noAttribute() {
|
| - addMainSource(r'''
|
| -
|
| -import 'angular.dart';
|
| -
|
| -@NgDirective(selector: '[my-directive]', map: const {'foo': '=>input'})
|
| -class MyDirective {
|
| - set input(value) {}
|
| -}''');
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<div my-directive>
|
| -</div>'''));
|
| - }
|
| -
|
| - void test_NgDirective_noExpression() {
|
| - addMainSource(r'''
|
| -
|
| -import 'angular.dart';
|
| -
|
| -@NgDirective(selector: '[my-directive]', map: const {'.': '=>input'})
|
| -class MyDirective {
|
| - set input(value) {}
|
| -}''');
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<div my-directive>
|
| -</div>'''));
|
| - }
|
| -
|
| - void test_NgDirective_resolvedExpression() {
|
| - addMainSource(r'''
|
| -
|
| -import 'angular.dart';
|
| -
|
| -@Decorator(selector: '[my-directive]')
|
| -class MyDirective {
|
| - @NgOneWay('my-property')
|
| - String condition;
|
| -}''');
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<input type='text' ng-model='name'>
|
| -<div my-directive my-property='name != null'>
|
| -</div>'''));
|
| - resolveMainNoErrors();
|
| - // "my-directive" attribute was resolved
|
| - {
|
| - AngularSelectorElement selector =
|
| - findMainElement(ElementKind.ANGULAR_SELECTOR, "my-directive");
|
| - ht.XmlAttributeNode attrNodeSelector =
|
| - ht.HtmlUnitUtils.getAttributeNode(indexUnit, findOffset2("my-directive"));
|
| - expect(attrNodeSelector, isNotNull);
|
| - expect(attrNodeSelector.element, same(selector));
|
| - }
|
| - // "my-property" attribute was resolved
|
| - {
|
| - ht.XmlAttributeNode attrNodeProperty =
|
| - ht.HtmlUnitUtils.getAttributeNode(indexUnit, findOffset2("my-property='"));
|
| - AngularPropertyElement propertyElement =
|
| - attrNodeProperty.element as AngularPropertyElement;
|
| - expect(propertyElement, isNotNull);
|
| - expect(propertyElement.propertyKind, same(AngularPropertyKind.ONE_WAY));
|
| - expect(propertyElement.field.name, "condition");
|
| - }
|
| - // "name" expression was resolved
|
| - expect(findIdentifier("name != null"), isNotNull);
|
| - }
|
| -
|
| - void test_NgDirective_resolvedExpression_attrString() {
|
| - addMainSource(r'''
|
| -
|
| -import 'angular.dart';
|
| -
|
| -@NgDirective(selector: '[my-directive])
|
| -class MyDirective {
|
| - @NgAttr('my-property')
|
| - String property;
|
| -}''');
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<input type='text' ng-model='name'>
|
| -<div my-directive my-property='name != null'>
|
| -</div>'''));
|
| - resolveMain();
|
| - // @NgAttr means "string attribute", which we don't parse
|
| - expect(findIdentifierMaybe("name != null"), isNull);
|
| - }
|
| -
|
| - void test_NgDirective_resolvedExpression_dotAsName() {
|
| - addMainSource(r'''
|
| -
|
| -import 'angular.dart';
|
| -
|
| -@Decorator(
|
| - selector: '[my-directive]',
|
| - map: const {'.' : '=>condition'})
|
| -class MyDirective {
|
| - set condition(value) {}
|
| -}''');
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<input type='text' ng-model='name'>
|
| -<div my-directive='name != null'>
|
| -</div>'''));
|
| - // "name" attribute was resolved
|
| - expect(findIdentifier("name != null"), isNotNull);
|
| - }
|
| -
|
| - /**
|
| - * Test that we resolve "ng-if" expression.
|
| - */
|
| - void test_ngIf() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(
|
| - AngularTest.createHtmlWithMyController("<div ng-if='ctrl.field != null'/>"));
|
| - assertResolvedIdentifier("field");
|
| - }
|
| -
|
| - void test_ngModel_modelAfterUsage() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<h3>Hello {{name}}!</h3>
|
| -<input type='text' ng-model='name'>'''));
|
| - assertResolvedIdentifier2("name}}!", "String");
|
| - assertResolvedIdentifier2("name'>", "String");
|
| - }
|
| -
|
| - void test_ngModel_modelBeforeUsage() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(AngularTest.createHtmlWithMyController(r'''
|
| -<input type='text' ng-model='name'>
|
| -<h3>Hello {{name}}!</h3>'''));
|
| - assertResolvedIdentifier2("name}}!", "String");
|
| - Element element = assertResolvedIdentifier2("name'>", "String");
|
| - expect(element.name, "name");
|
| - expect(element.nameOffset, findOffset2("name'>"));
|
| - }
|
| -
|
| - void test_ngModel_notIdentifier() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(
|
| - AngularTest.createHtmlWithMyController(
|
| - "<input type='text' ng-model='ctrl.field'>"));
|
| - assertResolvedIdentifier2("field'>", "String");
|
| - }
|
| -
|
| - /**
|
| - * Test that we resolve "ng-mouseout" expression.
|
| - */
|
| - void test_ngMouseOut() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(
|
| - AngularTest.createHtmlWithMyController(
|
| - r"<button ng-mouseout='ctrl.doSomething($event)'/>"));
|
| - assertResolvedIdentifier("doSomething");
|
| - }
|
| -
|
| - /**
|
| - * Test that we resolve "ng-show" expression.
|
| - */
|
| - void test_ngShow() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(
|
| - AngularTest.createHtmlWithMyController("<div ng-show='ctrl.field != null'/>"));
|
| - assertResolvedIdentifier("field");
|
| - }
|
| -
|
| - void test_notResolved_noDartScript() {
|
| - resolveIndex2(r'''
|
| -<html ng-app>
|
| - <body>
|
| - <div my-marker>
|
| - {{ctrl.field}}
|
| - </div>
|
| - </body>
|
| -</html>''');
|
| - assertNoErrors();
|
| - // Angular is not initialized, so "ctrl" is not parsed
|
| - Expression expression =
|
| - ht.HtmlUnitUtils.getExpression(indexUnit, findOffset2("ctrl"));
|
| - expect(expression, isNull);
|
| - }
|
| -
|
| - void test_notResolved_notAngular() {
|
| - resolveIndex2(r'''
|
| -<html no-ng-app>
|
| - <body>
|
| - <div my-marker>
|
| - {{ctrl.field}}
|
| - </div>
|
| - </body>
|
| -</html>''');
|
| - assertNoErrors();
|
| - // Angular is not initialized, so "ctrl" is not parsed
|
| - Expression expression =
|
| - ht.HtmlUnitUtils.getExpression(indexUnit, findOffset2("ctrl"));
|
| - expect(expression, isNull);
|
| - }
|
| -
|
| - void test_notResolved_wrongControllerMarker() {
|
| - addMyController();
|
| - addIndexSource(r'''
|
| -<html ng-app>
|
| - <body>
|
| - <div not-my-marker>
|
| - {{ctrl.field}}
|
| - </div>
|
| - <script type='application/dart' src='main.dart'></script>
|
| - </body>
|
| -</html>''');
|
| - contextHelper.runTasks();
|
| - resolveIndex();
|
| - // no errors, because we decided to ignore them at the moment
|
| - assertNoErrors();
|
| - // "ctrl" is not resolved
|
| - SimpleIdentifier identifier = findIdentifier("ctrl");
|
| - expect(identifier.bestElement, isNull);
|
| - }
|
| -
|
| - void test_resolveExpression_evenWithout_ngBootstrap() {
|
| - resolveMainSource(r'''
|
| -
|
| -import 'angular.dart';
|
| -
|
| -@Controller(
|
| - selector: '[my-controller]',
|
| - publishAs: 'ctrl')
|
| -class MyController {
|
| - String field;
|
| -}''');
|
| - _resolveIndexNoErrors(r'''
|
| -<html ng-app>
|
| - <body>
|
| - <div my-controller>
|
| - {{ctrl.field}}
|
| - </div>
|
| - <script type='application/dart' src='main.dart'></script>
|
| - </body>
|
| -</html>''');
|
| - assertResolvedIdentifier2("ctrl.", "MyController");
|
| - }
|
| -
|
| - void test_resolveExpression_ignoreUnresolved() {
|
| - resolveMainSource(r'''
|
| -
|
| -import 'angular.dart';
|
| -
|
| -@Controller(
|
| - selector: '[my-controller]',
|
| - publishAs: 'ctrl')
|
| -class MyController {
|
| - Map map;
|
| - Object obj;
|
| -}''');
|
| - resolveIndex2(r'''
|
| -<html ng-app>
|
| - <body>
|
| - <div my-controller>
|
| - {{ctrl.map.property}}
|
| - {{ctrl.obj.property}}
|
| - {{invisibleScopeProperty}}
|
| - </div>
|
| - <script type='application/dart' src='main.dart'></script>
|
| - </body>
|
| -</html>''');
|
| - assertNoErrors();
|
| - // "ctrl.map" and "ctrl.obj" are resolved
|
| - assertResolvedIdentifier2("map", "Map<dynamic, dynamic>");
|
| - assertResolvedIdentifier2("obj", "Object");
|
| - // ...but not "invisibleScopeProperty"
|
| - {
|
| - SimpleIdentifier identifier = findIdentifier("invisibleScopeProperty");
|
| - expect(identifier.bestElement, isNull);
|
| - }
|
| - }
|
| -
|
| - void test_resolveExpression_inAttribute() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(
|
| - AngularTest.createHtmlWithMyController(
|
| - "<button title='{{ctrl.field}}'></button>"));
|
| - assertResolvedIdentifier2("ctrl", "MyController");
|
| - }
|
| -
|
| - void test_resolveExpression_ngApp_onBody() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(r'''
|
| -<html>
|
| - <body ng-app>
|
| - <div my-controller>
|
| - {{ctrl.field}}
|
| - </div>
|
| - <script type='application/dart' src='main.dart'></script>
|
| - </body>
|
| -</html>''');
|
| - assertResolvedIdentifier2("ctrl", "MyController");
|
| - }
|
| -
|
| - void test_resolveExpression_withFormatter() {
|
| - addMyController();
|
| - _resolveIndexNoErrors(
|
| - AngularTest.createHtmlWithMyController("{{ctrl.field | uppercase}}"));
|
| - assertResolvedIdentifier2("ctrl", "MyController");
|
| - assertResolvedIdentifier("uppercase");
|
| - }
|
| -
|
| - void test_resolveExpression_withFormatter_missingColon() {
|
| - addMyController();
|
| - resolveIndex2(
|
| - AngularTest.createHtmlWithMyController(
|
| - "{{ctrl.field | uppercase, lowercase}}"));
|
| - assertErrors(indexSource, [AngularCode.MISSING_FORMATTER_COLON]);
|
| - }
|
| -
|
| - void test_resolveExpression_withFormatter_notSimpleIdentifier() {
|
| - addMyController();
|
| - resolveIndex2(
|
| - AngularTest.createHtmlWithMyController("{{ctrl.field | not.supported}}"));
|
| - assertErrors(indexSource, [AngularCode.INVALID_FORMATTER_NAME]);
|
| - }
|
| -
|
| - void test_scopeProperties() {
|
| - addMainSource(r'''
|
| -
|
| -import 'angular.dart';
|
| -
|
| -@Component(
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css',
|
| - publishAs: 'ctrl',
|
| - selector: 'myComponent')
|
| -class MyComponent {
|
| - String field;
|
| - MyComponent(Scope scope) {
|
| - scope.context['scopeProperty'] = 'abc';
|
| - }
|
| -}
|
| -''');
|
| - contextHelper.addSource(
|
| - "/entry-point.html",
|
| - AngularTest.createHtmlWithAngular(''));
|
| - addIndexSource2("/my_template.html", r'''
|
| -<div>
|
| - {{scopeProperty}}
|
| -</div>''');
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - contextHelper.runTasks();
|
| - resolveIndex();
|
| - assertNoErrors();
|
| - // "scopeProperty" is resolved
|
| - Element element = assertResolvedIdentifier2("scopeProperty}}", "String");
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is AngularScopePropertyElement,
|
| - AngularScopePropertyElement,
|
| - AngularHtmlUnitResolver.getAngularElement(element));
|
| - }
|
| -
|
| - void test_scopeProperties_hideWithComponent() {
|
| - addMainSource(r'''
|
| -
|
| -import 'angular.dart';
|
| -
|
| -@Component(
|
| - templateUrl: 'my_template.html', cssUrl: 'my_styles.css',
|
| - publishAs: 'ctrl',
|
| - selector: 'myComponent')
|
| -class MyComponent {
|
| -}
|
| -
|
| -void setScopeProperties(Scope scope) {
|
| - scope.context['ctrl'] = 1;
|
| -}
|
| -''');
|
| - contextHelper.addSource(
|
| - "/entry-point.html",
|
| - AngularTest.createHtmlWithAngular(''));
|
| - addIndexSource2("/my_template.html", r'''
|
| -<div>
|
| - {{ctrl}}
|
| -</div>''');
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - contextHelper.runTasks();
|
| - resolveIndex();
|
| - assertNoErrors();
|
| - // "ctrl" is resolved
|
| - LocalVariableElement element =
|
| - assertResolvedIdentifier("ctrl}}") as LocalVariableElement;
|
| - List<ToolkitObjectElement> toolkitObjects = element.toolkitObjects;
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is AngularComponentElement,
|
| - AngularComponentElement,
|
| - toolkitObjects[0]);
|
| - }
|
| -
|
| - void test_view_resolveTemplateFile() {
|
| - addMainSource(r'''
|
| -
|
| -import 'angular.dart';
|
| -
|
| -@Controller(
|
| - selector: '[my-controller]',
|
| - publishAs: 'ctrl')
|
| -class MyController {
|
| - String field;
|
| -}
|
| -
|
| -class MyRouteInitializer {
|
| - init(ViewFactory view) {
|
| - view('my_template.html');
|
| - }
|
| -}''');
|
| - contextHelper.addSource(
|
| - "/entry-point.html",
|
| - AngularTest.createHtmlWithAngular(''));
|
| - addIndexSource2("/my_template.html", r'''
|
| -<div my-controller>
|
| - {{ctrl.field}}
|
| -</div>''');
|
| - contextHelper.addSource("/my_styles.css", "");
|
| - contextHelper.runTasks();
|
| - resolveIndex();
|
| - assertNoErrors();
|
| - assertResolvedIdentifier2("ctrl.", "MyController");
|
| - assertResolvedIdentifier2("field}}", "String");
|
| - }
|
| -
|
| - String _getSourceContent(Source source) {
|
| - return context.getContents(source).data.toString();
|
| - }
|
| -
|
| - void _resolveIndexNoErrors(String content) {
|
| - resolveIndex2(content);
|
| - assertNoErrors();
|
| - verify([indexSource]);
|
| - }
|
| -}
|
| -
|
| -
|
| -/**
|
| - * Tests for [HtmlUnitUtils] for Angular HTMLs.
|
| - */
|
| -@ReflectiveTestCase()
|
| -class AngularHtmlUnitUtilsTest extends AngularTest {
|
| - void test_getElement_forExpression() {
|
| - addMyController();
|
| - _resolveSimpleCtrlFieldHtml();
|
| - // prepare expression
|
| - int offset = indexContent.indexOf("ctrl");
|
| - Expression expression = ht.HtmlUnitUtils.getExpression(indexUnit, offset);
|
| - // get element
|
| - Element element = ht.HtmlUnitUtils.getElement(expression);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is VariableElement,
|
| - VariableElement,
|
| - element);
|
| - expect(element.name, "ctrl");
|
| - }
|
| -
|
| - void test_getElement_forExpression_null() {
|
| - Element element = ht.HtmlUnitUtils.getElement(null);
|
| - expect(element, isNull);
|
| - }
|
| -
|
| - void test_getElement_forOffset() {
|
| - addMyController();
|
| - _resolveSimpleCtrlFieldHtml();
|
| - // no expression
|
| - {
|
| - Element element = ht.HtmlUnitUtils.getElementAtOffset(indexUnit, 0);
|
| - expect(element, isNull);
|
| - }
|
| - // has expression at offset
|
| - {
|
| - int offset = indexContent.indexOf("field");
|
| - Element element = ht.HtmlUnitUtils.getElementAtOffset(indexUnit, offset);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is PropertyAccessorElement,
|
| - PropertyAccessorElement,
|
| - element);
|
| - expect(element.name, "field");
|
| - }
|
| - }
|
| -
|
| - void test_getElementToOpen_controller() {
|
| - addMyController();
|
| - _resolveSimpleCtrlFieldHtml();
|
| - // prepare expression
|
| - int offset = indexContent.indexOf("ctrl");
|
| - Expression expression = ht.HtmlUnitUtils.getExpression(indexUnit, offset);
|
| - // get element
|
| - Element element = ht.HtmlUnitUtils.getElementToOpen(indexUnit, expression);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is AngularControllerElement,
|
| - AngularControllerElement,
|
| - element);
|
| - expect(element.name, "ctrl");
|
| - }
|
| -
|
| - void test_getElementToOpen_field() {
|
| - addMyController();
|
| - _resolveSimpleCtrlFieldHtml();
|
| - // prepare expression
|
| - int offset = indexContent.indexOf("field");
|
| - Expression expression = ht.HtmlUnitUtils.getExpression(indexUnit, offset);
|
| - // get element
|
| - Element element = ht.HtmlUnitUtils.getElementToOpen(indexUnit, expression);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is PropertyAccessorElement,
|
| - PropertyAccessorElement,
|
| - element);
|
| - expect(element.name, "field");
|
| - }
|
| -
|
| - void test_getEnclosingTagNode() {
|
| - resolveIndex2(r'''
|
| -<html>
|
| - <body ng-app>
|
| - <badge name='abc'> 123 </badge>
|
| - </body>
|
| -</html>''');
|
| - // no unit
|
| - expect(ht.HtmlUnitUtils.getEnclosingTagNode(null, 0), isNull);
|
| - // wrong offset
|
| - expect(ht.HtmlUnitUtils.getEnclosingTagNode(indexUnit, -1), isNull);
|
| - // valid offset
|
| - ht.XmlTagNode expected = _getEnclosingTagNode("<badge");
|
| - expect(expected, isNotNull);
|
| - expect(expected.tag, "badge");
|
| - expect(_getEnclosingTagNode("badge"), same(expected));
|
| - expect(_getEnclosingTagNode("name="), same(expected));
|
| - expect(_getEnclosingTagNode("123"), same(expected));
|
| - expect(_getEnclosingTagNode("/badge"), same(expected));
|
| - }
|
| -
|
| - void test_getExpression() {
|
| - addMyController();
|
| - _resolveSimpleCtrlFieldHtml();
|
| - // try offset without expression
|
| - expect(ht.HtmlUnitUtils.getExpression(indexUnit, 0), isNull);
|
| - // try offset with expression
|
| - int offset = indexContent.indexOf("ctrl");
|
| - expect(ht.HtmlUnitUtils.getExpression(indexUnit, offset), isNotNull);
|
| - expect(ht.HtmlUnitUtils.getExpression(indexUnit, offset + 1), isNotNull);
|
| - expect(ht.HtmlUnitUtils.getExpression(indexUnit, offset + 2), isNotNull);
|
| - expect(
|
| - ht.HtmlUnitUtils.getExpression(indexUnit, offset + "ctrl.field".length),
|
| - isNotNull);
|
| - // try without unit
|
| - expect(ht.HtmlUnitUtils.getExpression(null, offset), isNull);
|
| - }
|
| -
|
| - void test_getTagNode() {
|
| - resolveIndex2(r'''
|
| -<html>
|
| - <body ng-app>
|
| - <badge name='abc'> 123 </badge> done
|
| - </body>
|
| -</html>''');
|
| - // no unit
|
| - expect(ht.HtmlUnitUtils.getTagNode(null, 0), isNull);
|
| - // wrong offset
|
| - expect(ht.HtmlUnitUtils.getTagNode(indexUnit, -1), isNull);
|
| - // on tag name
|
| - ht.XmlTagNode expected = _getTagNode("badge name=");
|
| - expect(expected, isNotNull);
|
| - expect(expected.tag, "badge");
|
| - expect(_getTagNode("badge"), same(expected));
|
| - expect(_getTagNode(" name="), same(expected));
|
| - expect(_getTagNode("adge name="), same(expected));
|
| - expect(_getTagNode("badge>"), same(expected));
|
| - expect(_getTagNode("adge>"), same(expected));
|
| - expect(_getTagNode("> done"), same(expected));
|
| - // in tag node, but not on the name token
|
| - expect(_getTagNode("name="), isNull);
|
| - expect(_getTagNode("123"), isNull);
|
| - }
|
| -
|
| - ht.XmlTagNode _getEnclosingTagNode(String search) {
|
| - return ht.HtmlUnitUtils.getEnclosingTagNode(
|
| - indexUnit,
|
| - indexContent.indexOf(search));
|
| - }
|
| -
|
| - ht.XmlTagNode _getTagNode(String search) {
|
| - return ht.HtmlUnitUtils.getTagNode(indexUnit, indexContent.indexOf(search));
|
| - }
|
| -
|
| - void _resolveSimpleCtrlFieldHtml() {
|
| - resolveIndex2(r'''
|
| -<html>
|
| - <body ng-app>
|
| - <div my-controller>
|
| - {{ctrl.field}}
|
| - </div>
|
| - <script type='application/dart' src='main.dart'></script>
|
| - </body>
|
| -</html>''');
|
| - }
|
| -}
|
| -
|
| -
|
| -abstract class AngularTest extends EngineTestCase {
|
| - AnalysisContextHelper contextHelper = new AnalysisContextHelper();
|
| -
|
| - AnalysisContext context;
|
| -
|
| - String mainContent;
|
| -
|
| - Source mainSource;
|
| -
|
| - CompilationUnit mainUnit;
|
| -
|
| - CompilationUnitElement mainUnitElement;
|
| - String indexContent;
|
| - Source indexSource;
|
| - ht.HtmlUnit indexUnit;
|
| - HtmlElement indexHtmlUnit;
|
| - CompilationUnitElement indexDartUnitElement;
|
| - /**
|
| - * Fills [indexContent] and [indexSource].
|
| - */
|
| - void addIndexSource(String content) {
|
| - addIndexSource2("/index.html", content);
|
| - }
|
| - /**
|
| - * Fills [indexContent] and [indexSource].
|
| - */
|
| - void addIndexSource2(String name, String content) {
|
| - indexContent = content;
|
| - indexSource = contextHelper.addSource(name, indexContent);
|
| - }
|
| - /**
|
| - * Fills [mainContent] and [mainSource].
|
| - */
|
| - void addMainSource(String content) {
|
| - mainContent = content;
|
| - mainSource = contextHelper.addSource("/main.dart", content);
|
| - }
|
| - void addMyController() {
|
| - resolveMainSource(r'''
|
| -
|
| -import 'angular.dart';
|
| -
|
| -class Item {
|
| - String name;
|
| - bool done;
|
| -}
|
| -
|
| -@Controller(
|
| - selector: '[my-controller]',
|
| - publishAs: 'ctrl')
|
| -class MyController {
|
| - String field;
|
| - List<String> names;
|
| - List<Item> items;
|
| - var untypedItems;
|
| - doSomething(event) {}
|
| -}''');
|
| - }
|
| - /**
|
| - * Assert that the number of errors reported against the given source matches the number of errors
|
| - * that are given and that they have the expected error codes. The order in which the errors were
|
| - * gathered is ignored.
|
| - *
|
| - * @param source the source against which the errors should have been reported
|
| - * @param expectedErrorCodes the error codes of the errors that should have been reported
|
| - * @throws AnalysisException if the reported errors could not be computed
|
| - * @throws AssertionFailedError if a different number of errors have been reported than were
|
| - * expected
|
| - */
|
| - void assertErrors(Source source, [List<ErrorCode> expectedErrorCodes =
|
| - ErrorCode.EMPTY_LIST]) {
|
| - GatheringErrorListener errorListener = new GatheringErrorListener();
|
| - AnalysisErrorInfo errorsInfo = context.getErrors(source);
|
| - for (AnalysisError error in errorsInfo.errors) {
|
| - errorListener.onError(error);
|
| - }
|
| - errorListener.assertErrorsWithCodes(expectedErrorCodes);
|
| - }
|
| -
|
| - void assertMainErrors(List<ErrorCode> expectedErrorCodes) {
|
| - assertErrors(mainSource, expectedErrorCodes);
|
| - }
|
| -
|
| - /**
|
| - * Assert that no errors have been reported against the [indexSource].
|
| - */
|
| - void assertNoErrors() {
|
| - assertErrors(indexSource);
|
| - }
|
| -
|
| - void assertNoErrors2(Source source) {
|
| - assertErrors(source);
|
| - }
|
| -
|
| - /**
|
| - * Assert that no errors have been reported against the [mainSource].
|
| - */
|
| - void assertNoMainErrors() {
|
| - assertErrors(mainSource);
|
| - }
|
| -
|
| - /**
|
| - * Checks that [indexHtmlUnit] has [SimpleIdentifier] with given name, resolved to
|
| - * not `null` [Element].
|
| - */
|
| - Element assertResolvedIdentifier(String name) {
|
| - SimpleIdentifier identifier = findIdentifier(name);
|
| - // check Element
|
| - Element element = identifier.bestElement;
|
| - expect(element, isNotNull);
|
| - // return Element for further analysis
|
| - return element;
|
| - }
|
| -
|
| - Element assertResolvedIdentifier2(String name, String expectedTypeName) {
|
| - SimpleIdentifier identifier = findIdentifier(name);
|
| - // check Element
|
| - Element element = identifier.bestElement;
|
| - expect(element, isNotNull);
|
| - // check Type
|
| - DartType type = identifier.bestType;
|
| - expect(type, isNotNull);
|
| - expect(type.toString(), expectedTypeName);
|
| - // return Element for further analysis
|
| - return element;
|
| - }
|
| -
|
| - /**
|
| - * @return [AstNode] which has required offset and type.
|
| - */
|
| - AstNode findExpression(int offset, Predicate<AstNode> predicate) {
|
| - Expression expression = ht.HtmlUnitUtils.getExpression(indexUnit, offset);
|
| - return expression != null ? expression.getAncestor(predicate) : null;
|
| - }
|
| -
|
| - /**
|
| - * Returns the [SimpleIdentifier] at the given search pattern. Fails if not found.
|
| - */
|
| - SimpleIdentifier findIdentifier(String search) {
|
| - SimpleIdentifier identifier = findIdentifierMaybe(search);
|
| - expect(identifier, isNotNull, reason: "$search in $indexContent");
|
| - // check that offset/length of the identifier is valid
|
| - {
|
| - int offset = identifier.offset;
|
| - int end = identifier.end;
|
| - String contentStr = indexContent.substring(offset, end);
|
| - expect(contentStr, identifier.name);
|
| - }
|
| - // done
|
| - return identifier;
|
| - }
|
| -
|
| - /**
|
| - * Returns the [SimpleIdentifier] at the given search pattern, or `null` if not found.
|
| - */
|
| - SimpleIdentifier findIdentifierMaybe(String search) {
|
| - return findExpression(
|
| - findOffset2(search),
|
| - (node) => node is SimpleIdentifier);
|
| - }
|
| -
|
| - /**
|
| - * Returns [Element] from [indexDartUnitElement].
|
| - */
|
| - Element findIndexElement(String name) {
|
| - return findElement2(indexDartUnitElement, name);
|
| - }
|
| -
|
| - /**
|
| - * Returns [Element] from [mainUnitElement].
|
| - */
|
| - Element findMainElement(ElementKind kind, String name) {
|
| - return findElement(mainUnitElement, kind, name);
|
| - }
|
| -
|
| - /**
|
| - * Returns [Element] from [mainUnitElement].
|
| - */
|
| - Element findMainElement2(String name) => findElement2(mainUnitElement, name);
|
| -
|
| - /**
|
| - * @return the offset of given <code>search</code> string in [mainContent]. Fails test if
|
| - * not found.
|
| - */
|
| - int findMainOffset(String search) => findOffset(mainContent, search);
|
| -
|
| - /**
|
| - * @return the offset of given <code>search</code> string in [indexContent]. Fails test if
|
| - * not found.
|
| - */
|
| - int findOffset2(String search) => findOffset(indexContent, search);
|
| -
|
| - /**
|
| - * Resolves [indexSource].
|
| - */
|
| - void resolveIndex() {
|
| - indexUnit = context.resolveHtmlUnit(indexSource);
|
| - indexHtmlUnit = indexUnit.element;
|
| - indexDartUnitElement = indexHtmlUnit.angularCompilationUnit;
|
| - }
|
| -
|
| - void resolveIndex2(String content) {
|
| - addIndexSource(content);
|
| - contextHelper.runTasks();
|
| - resolveIndex();
|
| - }
|
| -
|
| - /**
|
| - * Resolves [mainSource].
|
| - */
|
| - void resolveMain() {
|
| - mainUnit = contextHelper.resolveDefiningUnit(mainSource);
|
| - mainUnitElement = mainUnit.element;
|
| - }
|
| -
|
| - /**
|
| - * Resolves [mainSource].
|
| - */
|
| - void resolveMainNoErrors() {
|
| - resolveMain();
|
| - assertNoErrors2(mainSource);
|
| - }
|
| -
|
| - void resolveMainSource(String content) {
|
| - addMainSource(content);
|
| - resolveMain();
|
| - }
|
| -
|
| - void resolveMainSourceNoErrors(String content) {
|
| - resolveMainSource(content);
|
| - assertNoErrors2(mainSource);
|
| - }
|
| -
|
| - @override
|
| - void setUp() {
|
| - super.setUp();
|
| - _configureForAngular(contextHelper);
|
| - context = contextHelper.context;
|
| - }
|
| -
|
| - @override
|
| - void tearDown() {
|
| - contextHelper = null;
|
| - context = null;
|
| - // main
|
| - mainContent = null;
|
| - mainSource = null;
|
| - mainUnit = null;
|
| - mainUnitElement = null;
|
| - // index
|
| - indexContent = null;
|
| - indexSource = null;
|
| - indexUnit = null;
|
| - indexHtmlUnit = null;
|
| - indexDartUnitElement = null;
|
| - // super
|
| - super.tearDown();
|
| - }
|
| -
|
| - /**
|
| - * Verify that all of the identifiers in the HTML units associated with the given sources have
|
| - * been resolved.
|
| - *
|
| - * @param sources the sources identifying the compilation units to be verified
|
| - * @throws Exception if the contents of the compilation unit cannot be accessed
|
| - */
|
| - void verify(List<Source> sources) {
|
| - ResolutionVerifier verifier = new ResolutionVerifier();
|
| - for (Source source in sources) {
|
| - ht.HtmlUnit htmlUnit = context.getResolvedHtmlUnit(source);
|
| - htmlUnit.accept(new ExpressionVisitor_AngularTest_verify(verifier));
|
| - }
|
| - verifier.assertResolved();
|
| - }
|
| -
|
| - void _configureForAngular(AnalysisContextHelper contextHelper) {
|
| - contextHelper.addSource("/angular.dart", r'''
|
| -library angular;
|
| -
|
| -class Scope {
|
| - Map context;
|
| -}
|
| -
|
| -class Formatter {
|
| - final String name;
|
| - const Formatter({this.name});
|
| -}
|
| -
|
| -class Directive {
|
| - const Directive({
|
| - selector,
|
| - children,
|
| - visibility,
|
| - module,
|
| - map,
|
| - exportedExpressions,
|
| - exportedExpressionAttrs
|
| - });
|
| -}
|
| -
|
| -class Decorator {
|
| - const Decorator({
|
| - children/*: Directive.COMPILE_CHILDREN*/,
|
| - map,
|
| - selector,
|
| - module,
|
| - visibility,
|
| - exportedExpressions,
|
| - exportedExpressionAttrs
|
| - });
|
| -}
|
| -
|
| -class Controller {
|
| - const Controller({
|
| - children,
|
| - publishAs,
|
| - map,
|
| - selector,
|
| - visibility,
|
| - publishTypes,
|
| - exportedExpressions,
|
| - exportedExpressionAttrs
|
| - });
|
| -}
|
| -
|
| -class NgAttr {
|
| - const NgAttr(String name);
|
| -}
|
| -class NgCallback {
|
| - const NgCallback(String name);
|
| -}
|
| -class NgOneWay {
|
| - const NgOneWay(String name);
|
| -}
|
| -class NgOneWayOneTime {
|
| - const NgOneWayOneTime(String name);
|
| -}
|
| -class NgTwoWay {
|
| - const NgTwoWay(String name);
|
| -}
|
| -
|
| -class Component extends Directive {
|
| - const Component({
|
| - this.template,
|
| - this.templateUrl,
|
| - this.cssUrl,
|
| - this.applyAuthorStyles,
|
| - this.resetStyleInheritance,
|
| - publishAs,
|
| - module,
|
| - map,
|
| - selector,
|
| - visibility,
|
| - exportExpressions,
|
| - exportExpressionAttrs
|
| - }) : super(selector: selector,
|
| - children: null/*NgAnnotation.COMPILE_CHILDREN*/,
|
| - visibility: visibility,
|
| - map: map,
|
| - module: module,
|
| - exportExpressions: exportExpressions,
|
| - exportExpressionAttrs: exportExpressionAttrs);
|
| -}
|
| -
|
| -@Decorator(selector: '[ng-click]', map: const {'ng-click': '&onEvent'})
|
| -@Decorator(selector: '[ng-mouseout]', map: const {'ng-mouseout': '&onEvent'})
|
| -class NgEventDirective {
|
| - set onEvent(value) {}
|
| -}
|
| -
|
| -@Decorator(selector: '[ng-if]', map: const {'ng-if': '=>condition'})
|
| -class NgIfDirective {
|
| - set condition(value) {}
|
| -}
|
| -
|
| -@Decorator(selector: '[ng-show]', map: const {'ng-show': '=>show'})
|
| -class NgShowDirective {
|
| - set show(value) {}
|
| -}
|
| -
|
| -@Formatter(name: 'filter')
|
| -class FilterFormatter {}
|
| -
|
| -@Formatter(name: 'orderBy')
|
| -class OrderByFilter {}
|
| -
|
| -@Formatter(name: 'uppercase')
|
| -class UppercaseFilter {}
|
| -
|
| -class ViewFactory {
|
| - call(String templateUrl) => null;
|
| -}
|
| -
|
| -class Module {
|
| - install(Module m) {}
|
| - type(Type t) {}
|
| - value(Type t, value) {}
|
| -}
|
| -
|
| -class Injector {}
|
| -
|
| -Injector ngBootstrap({
|
| - Module module: null,
|
| - List<Module> modules: null,
|
| - /*dom.Element*/ element: null,
|
| - String selector: '[ng-app]',
|
| - /*Injector*/ injectorFactory/*(List<Module> modules): _defaultInjectorFactory*/}) {}
|
| -''');
|
| - }
|
| -
|
| - /**
|
| - * Creates an HTML content that has Angular marker and script with
|
| - * the "main.dart" reference.
|
| - */
|
| - static String createHtmlWithAngular(String innerCode) {
|
| - String source = '''
|
| -<html ng-app>
|
| - <body>
|
| -$innerCode
|
| - <script type='application/dart' src='main.dart'></script>
|
| - </body>
|
| -</html>''';
|
| - return source;
|
| - }
|
| -
|
| - /**
|
| - * Creates an HTML content that has Angular marker, script with "main.dart" reference and
|
| - * "MyController" injected.
|
| - */
|
| - static String createHtmlWithMyController(String innerHtml) {
|
| - String source = '''
|
| -<html ng-app>
|
| - <body>
|
| - <div my-controller>
|
| -$innerHtml
|
| - </div>
|
| - <script type='application/dart' src='main.dart'></script>
|
| - </body>
|
| -</html>''';
|
| - return source;
|
| - }
|
| -
|
| - /**
|
| - * Finds an [Element] with the given names inside of the given root [Element].
|
| - *
|
| - * TODO(scheglov) maybe move this method to Element
|
| - *
|
| - * @param root the root [Element] to start searching from
|
| - * @param kind the kind of the [Element] to find, if `null` then any kind
|
| - * @param name the name of an [Element] to find
|
| - * @return the found [Element] or `null` if not found
|
| - */
|
| - static Element findElement(Element root, ElementKind kind, String name) {
|
| - _AngularTest_findElement visitor = new _AngularTest_findElement(kind, name);
|
| - root.accept(visitor);
|
| - return visitor.result;
|
| - }
|
| -
|
| - /**
|
| - * Finds an [Element] with the given names inside of the given root [Element].
|
| - *
|
| - * @param root the root [Element] to start searching from
|
| - * @param name the name of an [Element] to find
|
| - * @return the found [Element] or `null` if not found
|
| - */
|
| - static Element findElement2(Element root, String name) {
|
| - return findElement(root, null, name);
|
| - }
|
| -
|
| - /**
|
| - * @return the offset of given <code>search</code> string in <code>content</code>. Fails test if
|
| - * not found.
|
| - */
|
| - static int findOffset(String content, String search) {
|
| - int offset = content.indexOf(search);
|
| - expect(offset, isNot(-1));
|
| - return offset;
|
| - }
|
| -}
|
| -
|
| -
|
| -@ReflectiveTestCase()
|
| class ConstantEvaluatorTest extends ResolverTestCase {
|
| void fail_constructor() {
|
| EvaluationResult result = _getExpressionValue("?");
|
| @@ -9884,18 +7338,6 @@ class ExitDetectorTest extends ParserTestCase {
|
| }
|
|
|
|
|
| -class ExpressionVisitor_AngularTest_verify extends ExpressionVisitor {
|
| - ResolutionVerifier verifier;
|
| -
|
| - ExpressionVisitor_AngularTest_verify(this.verifier);
|
| -
|
| - @override
|
| - void visitExpression(Expression expression) {
|
| - expression.accept(verifier);
|
| - }
|
| -}
|
| -
|
| -
|
| @ReflectiveTestCase()
|
| class FileBasedSourceTest {
|
| void test_equals_false_differentFiles() {
|
| @@ -11343,25 +8785,6 @@ class XmlValidator_Tag {
|
| }
|
|
|
|
|
| -class _AngularTest_findElement extends GeneralizingElementVisitor<Object> {
|
| - final ElementKind kind;
|
| -
|
| - final String name;
|
| -
|
| - Element result;
|
| -
|
| - _AngularTest_findElement(this.kind, this.name);
|
| -
|
| - @override
|
| - Object visitElement(Element element) {
|
| - if ((kind == null || element.kind == kind) && name == element.name) {
|
| - result = element;
|
| - }
|
| - return super.visitElement(element);
|
| - }
|
| -}
|
| -
|
| -
|
| class _ExpectedScript {
|
| String _expectedExternalScriptName;
|
| HtmlUnitBuilderTest_ExpectedLibrary _expectedLibrary;
|
|
|