| Index: pkg/analyzer/lib/src/generated/resolver.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
|
| index 952323dd1197c80bce047e67d39dc7d70ba9e964..39f96eeff4efdeab96c2a6ac8452553e55d925a1 100644
|
| --- a/pkg/analyzer/lib/src/generated/resolver.dart
|
| +++ b/pkg/analyzer/lib/src/generated/resolver.dart
|
| @@ -39,676 +39,6 @@ typedef void ImplicitConstructorBuilderCallback(ClassElement classElement,
|
| typedef void VoidFunction();
|
|
|
| /**
|
| - * Instances of the class `AngularCompilationUnitBuilder` build an Angular specific element
|
| - * model for a single compilation unit.
|
| - */
|
| -class AngularCompilationUnitBuilder {
|
| - static String _NG_COMPONENT = "Component";
|
| -
|
| - static String _NG_CONTROLLER = "Controller";
|
| -
|
| - static String _NG_DECORATOR = "Decorator";
|
| -
|
| - static String _NG_FORMATTER = "Formatter";
|
| -
|
| - static String _NAME = "name";
|
| -
|
| - static String _SELECTOR = "selector";
|
| -
|
| - static String _PUBLISH_AS = "publishAs";
|
| -
|
| - static String _TEMPLATE_URL = "templateUrl";
|
| -
|
| - static String _CSS_URL = "cssUrl";
|
| -
|
| - static String _NG_ATTR = "NgAttr";
|
| -
|
| - static String _NG_CALLBACK = "NgCallback";
|
| -
|
| - static String _NG_ONE_WAY = "NgOneWay";
|
| -
|
| - static String _NG_ONE_WAY_ONE_TIME = "NgOneWayOneTime";
|
| -
|
| - static String _NG_TWO_WAY = "NgTwoWay";
|
| -
|
| - /**
|
| - * The listener to which errors will be reported.
|
| - */
|
| - final AnalysisErrorListener _errorListener;
|
| -
|
| - /**
|
| - * The source containing the unit that will be analyzed.
|
| - */
|
| - final Source _source;
|
| -
|
| - /**
|
| - * The compilation unit with built Dart element models.
|
| - */
|
| - final CompilationUnit _unit;
|
| -
|
| - /**
|
| - * The [ClassDeclaration] that is currently being analyzed.
|
| - */
|
| - ClassDeclaration _classDeclaration;
|
| -
|
| - /**
|
| - * The [ClassElementImpl] that is currently being analyzed.
|
| - */
|
| - ClassElementImpl _classElement;
|
| -
|
| - /**
|
| - * The [Annotation] that is currently being analyzed.
|
| - */
|
| - Annotation _annotation;
|
| -
|
| - /**
|
| - * Initialize a newly created compilation unit element builder.
|
| - *
|
| - * @param errorListener the listener to which errors will be reported.
|
| - * @param source the source containing the unit that will be analyzed
|
| - * @param unit the compilation unit with built Dart element models
|
| - */
|
| - AngularCompilationUnitBuilder(this._errorListener, this._source, this._unit);
|
| -
|
| - /**
|
| - * Builds Angular specific element models and adds them to the existing Dart elements.
|
| - */
|
| - void build() {
|
| - _parseViews();
|
| - // process classes
|
| - for (CompilationUnitMember unitMember in _unit.declarations) {
|
| - if (unitMember is ClassDeclaration) {
|
| - this._classDeclaration = unitMember;
|
| - this._classElement = _classDeclaration.element as ClassElementImpl;
|
| - // process annotations
|
| - NodeList<Annotation> annotations = _classDeclaration.metadata;
|
| - for (Annotation annotation in annotations) {
|
| - // verify annotation
|
| - if (annotation.arguments == null) {
|
| - continue;
|
| - }
|
| - this._annotation = annotation;
|
| - // @Formatter
|
| - if (_isAngularAnnotation(annotation, _NG_FORMATTER)) {
|
| - _parseFormatter();
|
| - continue;
|
| - }
|
| - // @Component
|
| - if (_isAngularAnnotation(annotation, _NG_COMPONENT)) {
|
| - _parseComponent();
|
| - continue;
|
| - }
|
| - // @Controller
|
| - if (_isAngularAnnotation(annotation, _NG_CONTROLLER)) {
|
| - _parseController();
|
| - continue;
|
| - }
|
| - // @Decorator
|
| - if (_isAngularAnnotation(annotation, _NG_DECORATOR)) {
|
| - _parseDecorator();
|
| - continue;
|
| - }
|
| - }
|
| - }
|
| - }
|
| - }
|
| -
|
| - /**
|
| - * @return the argument [Expression] with given name form [annotation], may be
|
| - * `null` if not found.
|
| - */
|
| - Expression _getArgument(String name) {
|
| - List<Expression> arguments = _annotation.arguments.arguments;
|
| - for (Expression argument in arguments) {
|
| - if (argument is NamedExpression) {
|
| - NamedExpression namedExpression = argument;
|
| - String argumentName = namedExpression.name.label.name;
|
| - if (name == argumentName) {
|
| - return namedExpression.expression;
|
| - }
|
| - }
|
| - }
|
| - return null;
|
| - }
|
| -
|
| - /**
|
| - * @return the [String] value of the named argument.
|
| - */
|
| - String _getStringArgument(String name) => _getStringLiteral(name).value;
|
| -
|
| - /**
|
| - * @return the offset of the value of the named argument.
|
| - */
|
| - int _getStringArgumentOffset(String name) {
|
| - Expression argument = _getArgument(name);
|
| - return (argument as SimpleStringLiteral).contentsOffset;
|
| - }
|
| -
|
| - /**
|
| - * @return the [SimpleStringLiteral] of the named argument.
|
| - */
|
| - SimpleStringLiteral _getStringLiteral(String name) {
|
| - Expression argument = _getArgument(name);
|
| - return argument as SimpleStringLiteral;
|
| - }
|
| -
|
| - /**
|
| - * Checks if [namedArguments] has string value for the argument with the given name.
|
| - */
|
| - bool _hasStringArgument(String name) {
|
| - Expression argument = _getArgument(name);
|
| - return argument is SimpleStringLiteral;
|
| - }
|
| -
|
| - /**
|
| - * Checks if given [Annotation] is an annotation with required name.
|
| - */
|
| - bool _isAngularAnnotation(Annotation annotation, String name) {
|
| - Element element = annotation.element;
|
| - if (element is ConstructorElement) {
|
| - ConstructorElement constructorElement = element;
|
| - if (constructorElement.returnType.displayName != name) {
|
| - return false;
|
| - }
|
| - return _isAngularLibraryElement(constructorElement);
|
| - }
|
| - return false;
|
| - }
|
| -
|
| - /**
|
| - * Checks if the given [Element] is a part of the Angular library.
|
| - */
|
| - bool _isAngularLibraryElement(Element element) {
|
| - LibraryElement library = element.library;
|
| - return library != null &&
|
| - library.name != null &&
|
| - library.name.startsWith("angular");
|
| - }
|
| -
|
| - void _parseComponent() {
|
| - bool isValid = true;
|
| - // publishAs
|
| - String name = null;
|
| - int nameOffset = -1;
|
| - if (_hasStringArgument(_PUBLISH_AS)) {
|
| - name = _getStringArgument(_PUBLISH_AS);
|
| - nameOffset = _getStringArgumentOffset(_PUBLISH_AS);
|
| - }
|
| - // selector
|
| - AngularSelectorElement selector = null;
|
| - if (!_hasStringArgument(_SELECTOR)) {
|
| - _reportErrorForAnnotation(AngularCode.MISSING_SELECTOR);
|
| - isValid = false;
|
| - } else {
|
| - SimpleStringLiteral selectorLiteral = _getStringLiteral(_SELECTOR);
|
| - selector = _parseSelectorFromString(selectorLiteral);
|
| - if (selector == null) {
|
| - _reportErrorForArgument(
|
| - _SELECTOR,
|
| - AngularCode.CANNOT_PARSE_SELECTOR,
|
| - [selectorLiteral]);
|
| - isValid = false;
|
| - }
|
| - }
|
| - // templateUrl
|
| - String templateUri = null;
|
| - int templateUriOffset = -1;
|
| - if (_hasStringArgument(_TEMPLATE_URL)) {
|
| - templateUri = _getStringArgument(_TEMPLATE_URL);
|
| - templateUriOffset = _getStringArgumentOffset(_TEMPLATE_URL);
|
| - }
|
| - // cssUrl
|
| - String styleUri = null;
|
| - int styleUriOffset = -1;
|
| - if (_hasStringArgument(_CSS_URL)) {
|
| - styleUri = _getStringArgument(_CSS_URL);
|
| - styleUriOffset = _getStringArgumentOffset(_CSS_URL);
|
| - }
|
| - // create
|
| - if (isValid) {
|
| - AngularComponentElementImpl element =
|
| - new AngularComponentElementImpl(name, nameOffset, _annotation.offset);
|
| - element.selector = selector;
|
| - element.templateUri = templateUri;
|
| - element.templateUriOffset = templateUriOffset;
|
| - element.styleUri = styleUri;
|
| - element.styleUriOffset = styleUriOffset;
|
| - element.properties = _parseComponentProperties();
|
| - element.scopeProperties = _parseScopeProperties();
|
| - _classElement.addToolkitObjects(element);
|
| - }
|
| - }
|
| -
|
| - /**
|
| - * Parses [AngularPropertyElement]s from [annotation] and [classDeclaration].
|
| - */
|
| - List<AngularPropertyElement> _parseComponentProperties() {
|
| - List<AngularPropertyElement> properties = <AngularPropertyElement>[];
|
| - _parseComponentProperties_fromMap(properties);
|
| - _parseComponentProperties_fromFields(properties);
|
| - return properties;
|
| - }
|
| -
|
| - /**
|
| - * Parses [AngularPropertyElement]s from [annotation].
|
| - */
|
| - void
|
| - _parseComponentProperties_fromFields(List<AngularPropertyElement> properties) {
|
| - NodeList<ClassMember> members = _classDeclaration.members;
|
| - for (ClassMember member in members) {
|
| - if (member is FieldDeclaration) {
|
| - FieldDeclaration fieldDeclaration = member;
|
| - for (Annotation annotation in fieldDeclaration.metadata) {
|
| - // prepare property kind (if property annotation at all)
|
| - AngularPropertyKind kind = null;
|
| - if (_isAngularAnnotation(annotation, _NG_ATTR)) {
|
| - kind = AngularPropertyKind.ATTR;
|
| - } else if (_isAngularAnnotation(annotation, _NG_CALLBACK)) {
|
| - kind = AngularPropertyKind.CALLBACK;
|
| - } else if (_isAngularAnnotation(annotation, _NG_ONE_WAY)) {
|
| - kind = AngularPropertyKind.ONE_WAY;
|
| - } else if (_isAngularAnnotation(annotation, _NG_ONE_WAY_ONE_TIME)) {
|
| - kind = AngularPropertyKind.ONE_WAY_ONE_TIME;
|
| - } else if (_isAngularAnnotation(annotation, _NG_TWO_WAY)) {
|
| - kind = AngularPropertyKind.TWO_WAY;
|
| - }
|
| - // add property
|
| - if (kind != null) {
|
| - SimpleStringLiteral nameLiteral =
|
| - _getOnlySimpleStringLiteralArgument(annotation);
|
| - FieldElement field = _getOnlyFieldElement(fieldDeclaration);
|
| - if (nameLiteral != null && field != null) {
|
| - AngularPropertyElementImpl property =
|
| - new AngularPropertyElementImpl(nameLiteral.value, nameLiteral.contentsOffset);
|
| - property.field = field;
|
| - property.propertyKind = kind;
|
| - properties.add(property);
|
| - }
|
| - }
|
| - }
|
| - }
|
| - }
|
| - }
|
| -
|
| - /**
|
| - * Parses [AngularPropertyElement]s from [annotation].
|
| - */
|
| - void
|
| - _parseComponentProperties_fromMap(List<AngularPropertyElement> properties) {
|
| - Expression mapExpression = _getArgument("map");
|
| - // may be not properties
|
| - if (mapExpression == null) {
|
| - return;
|
| - }
|
| - // prepare map literal
|
| - if (mapExpression is! MapLiteral) {
|
| - _reportErrorForNode(AngularCode.INVALID_PROPERTY_MAP, mapExpression);
|
| - return;
|
| - }
|
| - MapLiteral mapLiteral = mapExpression as MapLiteral;
|
| - // analyze map entries
|
| - for (MapLiteralEntry entry in mapLiteral.entries) {
|
| - // prepare property name
|
| - Expression nameExpression = entry.key;
|
| - if (nameExpression is! SimpleStringLiteral) {
|
| - _reportErrorForNode(AngularCode.INVALID_PROPERTY_NAME, nameExpression);
|
| - continue;
|
| - }
|
| - SimpleStringLiteral nameLiteral = nameExpression as SimpleStringLiteral;
|
| - String name = nameLiteral.value;
|
| - int nameOffset = nameLiteral.contentsOffset;
|
| - // prepare field specification
|
| - Expression specExpression = entry.value;
|
| - if (specExpression is! SimpleStringLiteral) {
|
| - _reportErrorForNode(AngularCode.INVALID_PROPERTY_SPEC, specExpression);
|
| - continue;
|
| - }
|
| - SimpleStringLiteral specLiteral = specExpression as SimpleStringLiteral;
|
| - String spec = specLiteral.value;
|
| - // parse binding kind and field name
|
| - AngularPropertyKind kind;
|
| - int fieldNameOffset;
|
| - if (StringUtilities.startsWithChar(spec, 0x40)) {
|
| - kind = AngularPropertyKind.ATTR;
|
| - fieldNameOffset = 1;
|
| - } else if (StringUtilities.startsWithChar(spec, 0x26)) {
|
| - kind = AngularPropertyKind.CALLBACK;
|
| - fieldNameOffset = 1;
|
| - } else if (StringUtilities.startsWith3(spec, 0, 0x3D, 0x3E, 0x21)) {
|
| - kind = AngularPropertyKind.ONE_WAY_ONE_TIME;
|
| - fieldNameOffset = 3;
|
| - } else if (StringUtilities.startsWith2(spec, 0, 0x3D, 0x3E)) {
|
| - kind = AngularPropertyKind.ONE_WAY;
|
| - fieldNameOffset = 2;
|
| - } else if (StringUtilities.startsWith3(spec, 0, 0x3C, 0x3D, 0x3E)) {
|
| - kind = AngularPropertyKind.TWO_WAY;
|
| - fieldNameOffset = 3;
|
| - } else {
|
| - _reportErrorForNode(
|
| - AngularCode.INVALID_PROPERTY_KIND,
|
| - specLiteral,
|
| - [spec]);
|
| - continue;
|
| - }
|
| - String fieldName = spec.substring(fieldNameOffset);
|
| - fieldNameOffset += specLiteral.contentsOffset;
|
| - // prepare field
|
| - PropertyAccessorElement setter =
|
| - _classElement.type.lookUpSetter(fieldName, _classElement.library);
|
| - if (setter == null) {
|
| - _reportErrorForOffset(
|
| - AngularCode.INVALID_PROPERTY_FIELD,
|
| - fieldNameOffset,
|
| - fieldName.length,
|
| - [fieldName]);
|
| - continue;
|
| - }
|
| - FieldElement field = setter.variable as FieldElement;
|
| - // add property
|
| - AngularPropertyElementImpl property =
|
| - new AngularPropertyElementImpl(name, nameOffset);
|
| - property.field = field;
|
| - property.propertyKind = kind;
|
| - property.fieldNameOffset = fieldNameOffset;
|
| - properties.add(property);
|
| - }
|
| - }
|
| -
|
| - void _parseController() {
|
| - bool isValid = true;
|
| - // publishAs
|
| - if (!_hasStringArgument(_PUBLISH_AS)) {
|
| - _reportErrorForAnnotation(AngularCode.MISSING_PUBLISH_AS);
|
| - isValid = false;
|
| - }
|
| - // selector
|
| - AngularSelectorElement selector = null;
|
| - if (!_hasStringArgument(_SELECTOR)) {
|
| - _reportErrorForAnnotation(AngularCode.MISSING_SELECTOR);
|
| - isValid = false;
|
| - } else {
|
| - SimpleStringLiteral selectorLiteral = _getStringLiteral(_SELECTOR);
|
| - selector = _parseSelectorFromString(selectorLiteral);
|
| - if (selector == null) {
|
| - _reportErrorForArgument(
|
| - _SELECTOR,
|
| - AngularCode.CANNOT_PARSE_SELECTOR,
|
| - [selectorLiteral]);
|
| - isValid = false;
|
| - }
|
| - }
|
| - // create
|
| - if (isValid) {
|
| - String name = _getStringArgument(_PUBLISH_AS);
|
| - int nameOffset = _getStringArgumentOffset(_PUBLISH_AS);
|
| - AngularControllerElementImpl element =
|
| - new AngularControllerElementImpl(name, nameOffset);
|
| - element.selector = selector;
|
| - _classElement.addToolkitObjects(element);
|
| - }
|
| - }
|
| -
|
| - void _parseDecorator() {
|
| - bool isValid = true;
|
| - // selector
|
| - AngularSelectorElement selector = null;
|
| - if (!_hasStringArgument(_SELECTOR)) {
|
| - _reportErrorForAnnotation(AngularCode.MISSING_SELECTOR);
|
| - isValid = false;
|
| - } else {
|
| - SimpleStringLiteral selectorLiteral = _getStringLiteral(_SELECTOR);
|
| - selector = _parseSelectorFromString(selectorLiteral);
|
| - if (selector == null) {
|
| - _reportErrorForArgument(
|
| - _SELECTOR,
|
| - AngularCode.CANNOT_PARSE_SELECTOR,
|
| - [selectorLiteral]);
|
| - isValid = false;
|
| - }
|
| - }
|
| - // create
|
| - if (isValid) {
|
| - int offset = _annotation.offset;
|
| - AngularDecoratorElementImpl element =
|
| - new AngularDecoratorElementImpl(offset);
|
| - element.selector = selector;
|
| - element.properties = _parseComponentProperties();
|
| - _classElement.addToolkitObjects(element);
|
| - }
|
| - }
|
| -
|
| - void _parseFormatter() {
|
| - bool isValid = true;
|
| - // name
|
| - if (!_hasStringArgument(_NAME)) {
|
| - _reportErrorForAnnotation(AngularCode.MISSING_NAME);
|
| - isValid = false;
|
| - }
|
| - // create
|
| - if (isValid) {
|
| - String name = _getStringArgument(_NAME);
|
| - int nameOffset = _getStringArgumentOffset(_NAME);
|
| - _classElement.addToolkitObjects(
|
| - new AngularFormatterElementImpl(name, nameOffset));
|
| - }
|
| - }
|
| -
|
| - List<AngularScopePropertyElement> _parseScopeProperties() {
|
| - List<AngularScopePropertyElement> properties =
|
| - <AngularScopePropertyElement>[
|
| - ];
|
| - _classDeclaration.accept(
|
| - new _AngularCompilationUnitBuilder_parseScopeProperties(properties));
|
| - return properties;
|
| - }
|
| -
|
| - /**
|
| - * Create [AngularViewElement] for each valid <code>view('template.html')</code> invocation,
|
| - * where <code>view</code> is <code>ViewFactory</code>.
|
| - */
|
| - void _parseViews() {
|
| - List<AngularViewElement> views = <AngularViewElement>[];
|
| - _unit.accept(
|
| - new RecursiveAstVisitor_AngularCompilationUnitBuilder_parseViews(views));
|
| - if (!views.isEmpty) {
|
| - List<AngularViewElement> viewArray = views;
|
| - (_unit.element as CompilationUnitElementImpl).angularViews = viewArray;
|
| - }
|
| - }
|
| -
|
| - void _reportErrorForAnnotation(ErrorCode errorCode,
|
| - [List<Object> arguments]) {
|
| - _reportErrorForNode(errorCode, _annotation, arguments);
|
| - }
|
| -
|
| - void _reportErrorForArgument(String argumentName, ErrorCode errorCode,
|
| - [List<Object> arguments]) {
|
| - Expression argument = _getArgument(argumentName);
|
| - _reportErrorForNode(errorCode, argument, arguments);
|
| - }
|
| -
|
| - void _reportErrorForNode(ErrorCode errorCode, AstNode node,
|
| - [List<Object> arguments]) {
|
| - int offset = node.offset;
|
| - int length = node.length;
|
| - _reportErrorForOffset(errorCode, offset, length, arguments);
|
| - }
|
| -
|
| - void _reportErrorForOffset(ErrorCode errorCode, int offset, int length,
|
| - [List<Object> arguments]) {
|
| - _errorListener.onError(
|
| - new AnalysisError.con2(_source, offset, length, errorCode, arguments));
|
| - }
|
| -
|
| - static Element getElement(AstNode node, int offset) {
|
| - // maybe node is not SimpleStringLiteral
|
| - if (node is! SimpleStringLiteral) {
|
| - return null;
|
| - }
|
| - SimpleStringLiteral literal = node as SimpleStringLiteral;
|
| - // maybe has AngularElement
|
| - {
|
| - Element element = literal.toolkitElement;
|
| - if (element is AngularElement) {
|
| - return element;
|
| - }
|
| - }
|
| - // prepare enclosing ClassDeclaration
|
| - ClassDeclaration classDeclaration =
|
| - node.getAncestor((node) => node is ClassDeclaration);
|
| - if (classDeclaration == null) {
|
| - return null;
|
| - }
|
| - // prepare ClassElement
|
| - ClassElement classElement = classDeclaration.element;
|
| - if (classElement == null) {
|
| - return null;
|
| - }
|
| - // check toolkit objects
|
| - for (ToolkitObjectElement toolkitObject in classElement.toolkitObjects) {
|
| - List<AngularPropertyElement> properties =
|
| - AngularPropertyElement.EMPTY_ARRAY;
|
| - // maybe name
|
| - if (toolkitObject is AngularElement) {
|
| - if (_isNameCoveredByLiteral(toolkitObject, node)) {
|
| - return toolkitObject;
|
| - }
|
| - }
|
| - // try selector
|
| - if (toolkitObject is AngularHasSelectorElement) {
|
| - AngularHasSelectorElement hasSelector = toolkitObject;
|
| - AngularSelectorElement selector = hasSelector.selector;
|
| - if (_isNameCoveredByLiteral(selector, node)) {
|
| - return selector;
|
| - }
|
| - }
|
| - // try properties of AngularComponentElement
|
| - if (toolkitObject is AngularComponentElement) {
|
| - AngularComponentElement component = toolkitObject;
|
| - properties = component.properties;
|
| - }
|
| - // try properties of AngularDirectiveElement
|
| - if (toolkitObject is AngularDecoratorElement) {
|
| - AngularDecoratorElement directive = toolkitObject;
|
| - properties = directive.properties;
|
| - }
|
| - // check properties
|
| - for (AngularPropertyElement property in properties) {
|
| - // property name (use complete node range)
|
| - if (_isNameCoveredByLiteral(property, node)) {
|
| - return property;
|
| - }
|
| - // field name (use complete node range, including @, => and <=>)
|
| - FieldElement field = property.field;
|
| - if (field != null) {
|
| - int fieldOffset = property.fieldNameOffset;
|
| - int fieldEnd = fieldOffset + field.name.length;
|
| - if (node.offset <= fieldOffset && fieldEnd < node.end) {
|
| - return field;
|
| - }
|
| - }
|
| - }
|
| - }
|
| - // no Element
|
| - return null;
|
| - }
|
| -
|
| - /**
|
| - * Parses given selector text and returns [AngularSelectorElement]. May be `null` if
|
| - * cannot parse.
|
| - */
|
| - static AngularSelectorElement parseSelector(int offset, String text) {
|
| - // [attribute]
|
| - if (StringUtilities.startsWithChar(text, 0x5B) &&
|
| - StringUtilities.endsWithChar(text, 0x5D)) {
|
| - int nameOffset = offset + 1;
|
| - String attributeName = text.substring(1, text.length - 1);
|
| - // TODO(scheglov) report warning if there are spaces between
|
| - // [ and identifier
|
| - return new HasAttributeSelectorElementImpl(attributeName, nameOffset);
|
| - }
|
| - // .class
|
| - if (StringUtilities.startsWithChar(text, 0x2E)) {
|
| - int nameOffset = offset + 1;
|
| - String className = text.substring(1, text.length);
|
| - return new AngularHasClassSelectorElementImpl(className, nameOffset);
|
| - }
|
| - // tag[attribute]
|
| - if (StringUtilities.endsWithChar(text, 0x5D)) {
|
| - int index = StringUtilities.indexOf1(text, 0, 0x5B);
|
| - if (index != -1) {
|
| - String tagName = text.substring(0, index);
|
| - String attributeName = text.substring(index + 1, text.length - 1);
|
| - if (StringUtilities.isTagName(tagName)) {
|
| - return new IsTagHasAttributeSelectorElementImpl(
|
| - tagName,
|
| - attributeName);
|
| - }
|
| - }
|
| - }
|
| - // tag
|
| - if (StringUtilities.isTagName(text)) {
|
| - return new AngularTagSelectorElementImpl(text, offset);
|
| - }
|
| - return null;
|
| - }
|
| -
|
| - /**
|
| - * Returns the [FieldElement] of the first field in the given [FieldDeclaration].
|
| - */
|
| - static FieldElement _getOnlyFieldElement(FieldDeclaration fieldDeclaration) {
|
| - NodeList<VariableDeclaration> fields = fieldDeclaration.fields.variables;
|
| - return fields[0].element as FieldElement;
|
| - }
|
| -
|
| - /**
|
| - * If given [Annotation] has one argument and it is [SimpleStringLiteral], returns it,
|
| - * otherwise returns `null`.
|
| - */
|
| - static SimpleStringLiteral
|
| - _getOnlySimpleStringLiteralArgument(Annotation annotation) {
|
| - SimpleStringLiteral nameLiteral = null;
|
| - ArgumentList argsNode = annotation.arguments;
|
| - if (argsNode != null) {
|
| - NodeList<Expression> args = argsNode.arguments;
|
| - if (args.length == 1) {
|
| - Expression arg = args[0];
|
| - if (arg is SimpleStringLiteral) {
|
| - nameLiteral = arg;
|
| - }
|
| - }
|
| - }
|
| - return nameLiteral;
|
| - }
|
| -
|
| - /**
|
| - * Checks if the name range of the given [Element] is completely covered by the given
|
| - * [SimpleStringLiteral].
|
| - */
|
| - static bool _isNameCoveredByLiteral(Element element, AstNode node) {
|
| - if (element != null) {
|
| - String name = element.name;
|
| - if (name != null) {
|
| - int nameOffset = element.nameOffset;
|
| - int nameEnd = nameOffset + name.length;
|
| - return node.offset <= nameOffset && nameEnd < node.end;
|
| - }
|
| - }
|
| - return false;
|
| - }
|
| -
|
| - /**
|
| - * Parses given [SimpleStringLiteral] using [parseSelector].
|
| - */
|
| - static AngularSelectorElement
|
| - _parseSelectorFromString(SimpleStringLiteral literal) {
|
| - int offset = literal.contentsOffset;
|
| - String text = literal.stringValue;
|
| - return parseSelector(offset, text);
|
| - }
|
| -}
|
| -
|
| -/**
|
| * Instances of the class `BestPracticesVerifier` traverse an AST structure looking for
|
| * violations of Dart best practices.
|
| */
|
| @@ -9180,16 +8510,6 @@ class LibraryResolver {
|
| } finally {
|
| timeCounter.stop();
|
| }
|
| - // Angular
|
| - timeCounter = PerformanceStatistics.angular.start();
|
| - try {
|
| - for (Source source in library.compilationUnitSources) {
|
| - CompilationUnit ast = library.getAST(source);
|
| - new AngularCompilationUnitBuilder(_errorListener, source, ast).build();
|
| - }
|
| - } finally {
|
| - timeCounter.stop();
|
| - }
|
| // Polymer
|
| timeCounter = PerformanceStatistics.polymer.start();
|
| try {
|
| @@ -9753,18 +9073,6 @@ class LibraryResolver2 {
|
| } finally {
|
| timeCounter.stop();
|
| }
|
| - // Angular
|
| - timeCounter = PerformanceStatistics.angular.start();
|
| - try {
|
| - for (ResolvableCompilationUnit unit in library.resolvableCompilationUnits)
|
| - {
|
| - Source source = unit.source;
|
| - CompilationUnit ast = unit.compilationUnit;
|
| - new AngularCompilationUnitBuilder(_errorListener, source, ast).build();
|
| - }
|
| - } finally {
|
| - timeCounter.stop();
|
| - }
|
| // Polymer
|
| timeCounter = PerformanceStatistics.polymer.start();
|
| try {
|
| @@ -10753,62 +10061,6 @@ class PubVerifier extends RecursiveAstVisitor<Object> {
|
| // }
|
| }
|
|
|
| -class RecursiveAstVisitor_AngularCompilationUnitBuilder_parseViews extends
|
| - RecursiveAstVisitor<Object> {
|
| - List<AngularViewElement> views;
|
| -
|
| - RecursiveAstVisitor_AngularCompilationUnitBuilder_parseViews(this.views)
|
| - : super();
|
| -
|
| - @override
|
| - Object visitMethodInvocation(MethodInvocation node) {
|
| - _addView(node);
|
| - return super.visitMethodInvocation(node);
|
| - }
|
| -
|
| - void _addView(MethodInvocation node) {
|
| - // only one argument
|
| - List<Expression> arguments = node.argumentList.arguments;
|
| - if (arguments.length != 1) {
|
| - return;
|
| - }
|
| - // String literal
|
| - Expression argument = arguments[0];
|
| - if (argument is! SimpleStringLiteral) {
|
| - return;
|
| - }
|
| - SimpleStringLiteral literal = argument as SimpleStringLiteral;
|
| - // just view('template')
|
| - if (node.realTarget != null) {
|
| - return;
|
| - }
|
| - // should be ViewFactory
|
| - if (!_isViewFactory(node.methodName)) {
|
| - return;
|
| - }
|
| - // add AngularViewElement
|
| - String templateUri = literal.stringValue;
|
| - int templateUriOffset = literal.contentsOffset;
|
| - views.add(new AngularViewElementImpl(templateUri, templateUriOffset));
|
| - }
|
| -
|
| - bool _isViewFactory(Expression target) {
|
| - if (target is SimpleIdentifier) {
|
| - SimpleIdentifier identifier = target;
|
| - Element element = identifier.staticElement;
|
| - if (element is VariableElement) {
|
| - VariableElement variable = element;
|
| - DartType type = variable.type;
|
| - if (type is InterfaceType) {
|
| - InterfaceType interfaceType = type;
|
| - return interfaceType.name == "ViewFactory";
|
| - }
|
| - }
|
| - }
|
| - return false;
|
| - }
|
| -}
|
| -
|
| /**
|
| * Kind of the redirecting constructor.
|
| */
|
| @@ -15838,83 +15090,6 @@ class VariableResolverVisitor extends ScopedVisitor {
|
| }
|
| }
|
|
|
| -class _AngularCompilationUnitBuilder_parseScopeProperties extends
|
| - RecursiveAstVisitor<Object> {
|
| - List<AngularScopePropertyElement> properties;
|
| -
|
| - _AngularCompilationUnitBuilder_parseScopeProperties(this.properties)
|
| - : super();
|
| -
|
| - @override
|
| - Object visitAssignmentExpression(AssignmentExpression node) {
|
| - _addProperty(node);
|
| - return super.visitAssignmentExpression(node);
|
| - }
|
| -
|
| - void _addProperty(AssignmentExpression node) {
|
| - // try to find "name" in scope[name]
|
| - SimpleStringLiteral nameNode = _getNameNode(node.leftHandSide);
|
| - if (nameNode == null) {
|
| - return;
|
| - }
|
| - // prepare unique
|
| - String name = nameNode.stringValue;
|
| - if (_hasPropertyWithName(name)) {
|
| - return;
|
| - }
|
| - // do add property
|
| - int nameOffset = nameNode.contentsOffset;
|
| - AngularScopePropertyElement property = new AngularScopePropertyElementImpl(
|
| - name,
|
| - nameOffset,
|
| - node.rightHandSide.bestType);
|
| - nameNode.toolkitElement = property;
|
| - properties.add(property);
|
| - }
|
| -
|
| - SimpleStringLiteral _getNameNode(Expression node) {
|
| - if (node is IndexExpression) {
|
| - IndexExpression indexExpression = node;
|
| - Expression target = indexExpression.target;
|
| - Expression index = indexExpression.index;
|
| - if (index is SimpleStringLiteral && _isContext(target)) {
|
| - return index;
|
| - }
|
| - }
|
| - return null;
|
| - }
|
| -
|
| - bool _hasPropertyWithName(String name) {
|
| - for (AngularScopePropertyElement property in properties) {
|
| - if (property.name == name) {
|
| - return true;
|
| - }
|
| - }
|
| - return false;
|
| - }
|
| -
|
| - bool _isContext(Expression target) {
|
| - if (target is PrefixedIdentifier) {
|
| - PrefixedIdentifier prefixed = target;
|
| - SimpleIdentifier prefix = prefixed.prefix;
|
| - SimpleIdentifier identifier = prefixed.identifier;
|
| - return (identifier.name == "context") && _isScope(prefix);
|
| - }
|
| - return false;
|
| - }
|
| -
|
| - bool _isScope(Expression target) {
|
| - if (target != null) {
|
| - DartType type = target.bestType;
|
| - if (type is InterfaceType) {
|
| - InterfaceType interfaceType = type;
|
| - return interfaceType.name == "Scope";
|
| - }
|
| - }
|
| - return false;
|
| - }
|
| -}
|
| -
|
| class _ConstantVerifier_validateInitializerExpression extends ConstantVisitor {
|
| final ConstantVerifier verifier;
|
|
|
|
|