Package com.google.dart.engine.ast

Examples of com.google.dart.engine.ast.SimpleStringLiteral


          } 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.getValue(),
                  nameLiteral.getValueOffset());
              property.setField(field);
              property.setPropertyKind(kind);
              properties.add(property);
            }
          }
View Full Code Here


      Expression nameExpression = entry.getKey();
      if (!(nameExpression instanceof SimpleStringLiteral)) {
        reportErrorForNode(AngularCode.INVALID_PROPERTY_NAME, nameExpression);
        continue;
      }
      SimpleStringLiteral nameLiteral = (SimpleStringLiteral) nameExpression;
      String name = nameLiteral.getValue();
      int nameOffset = nameLiteral.getValueOffset();
      // prepare field specification
      Expression specExpression = entry.getValue();
      if (!(specExpression instanceof SimpleStringLiteral)) {
        reportErrorForNode(AngularCode.INVALID_PROPERTY_SPEC, specExpression);
        continue;
      }
      SimpleStringLiteral specLiteral = (SimpleStringLiteral) specExpression;
      String spec = specLiteral.getValue();
      // parse binding kind and field name
      AngularPropertyKind kind;
      int fieldNameOffset;
      if (StringUtilities.startsWithChar(spec, '@')) {
        kind = AngularPropertyKind.ATTR;
        fieldNameOffset = 1;
      } else if (StringUtilities.startsWithChar(spec, '&')) {
        kind = AngularPropertyKind.CALLBACK;
        fieldNameOffset = 1;
      } else if (StringUtilities.startsWith3(spec, 0, '=', '>', '!')) {
        kind = AngularPropertyKind.ONE_WAY_ONE_TIME;
        fieldNameOffset = 3;
      } else if (StringUtilities.startsWith2(spec, 0, '=', '>')) {
        kind = AngularPropertyKind.ONE_WAY;
        fieldNameOffset = 2;
      } else if (StringUtilities.startsWith3(spec, 0, '<', '=', '>')) {
        kind = AngularPropertyKind.TWO_WAY;
        fieldNameOffset = 3;
      } else {
        reportErrorForNode(AngularCode.INVALID_PROPERTY_KIND, specLiteral, spec);
        continue;
      }
      String fieldName = spec.substring(fieldNameOffset);
      fieldNameOffset += specLiteral.getValueOffset();
      // prepare field
      PropertyAccessorElement setter = classElement.getType().lookUpSetter(
          fieldName,
          classElement.getLibrary());
      if (setter == null) {
View Full Code Here

    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;
      }
View Full Code Here

    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;
      }
View Full Code Here

        return super.visitAssignmentExpression(node);
      }

      private void addProperty(AssignmentExpression node) {
        // try to find "name" in scope[name]
        SimpleStringLiteral nameNode = getNameNode(node.getLeftHandSide());
        if (nameNode == null) {
          return;
        }
        // prepare unique
        String name = nameNode.getStringValue();
        if (hasPropertyWithName(name)) {
          return;
        }
        // do add property
        int nameOffset = nameNode.getValueOffset();
        AngularScopePropertyElement property = new AngularScopePropertyElementImpl(
            name,
            nameOffset,
            node.getRightHandSide().getBestType());
        nameNode.setToolkitElement(property);
        properties.add(property);
      }

      private SimpleStringLiteral getNameNode(Expression node) {
        if (node instanceof IndexExpression) {
View Full Code Here

        // String literal
        Expression argument = arguments.get(0);
        if (!(argument instanceof SimpleStringLiteral)) {
          return;
        }
        SimpleStringLiteral literal = (SimpleStringLiteral) argument;
        // just view('template')
        if (node.getRealTarget() != null) {
          return;
        }
        // should be ViewFactory
        if (!isViewFactory(node.getMethodName())) {
          return;
        }
        // add AngularViewElement
        String templateUri = literal.getStringValue();
        int templateUriOffset = literal.getValueOffset();
        views.add(new AngularViewElementImpl(templateUri, templateUriOffset));
      }

      private boolean isViewFactory(Expression target) {
        if (target instanceof SimpleIdentifier) {
View Full Code Here

  public static Element getElement(AstNode node, int offset) {
    // maybe node is not SimpleStringLiteral
    if (!(node instanceof SimpleStringLiteral)) {
      return null;
    }
    SimpleStringLiteral literal = (SimpleStringLiteral) node;
    // maybe has AngularElement
    {
      Element element = literal.getToolkitElement();
      if (element instanceof AngularElement) {
        return element;
      }
    }
    // prepare enclosing ClassDeclaration
View Full Code Here

  /**
   * If given {@link Annotation} has one argument and it is {@link SimpleStringLiteral}, returns it,
   * otherwise returns {@code null}.
   */
  private static SimpleStringLiteral getOnlySimpleStringLiteralArgument(Annotation annotation) {
    SimpleStringLiteral nameLiteral = null;
    ArgumentList argsNode = annotation.getArguments();
    if (argsNode != null) {
      NodeList<Expression> args = argsNode.getArguments();
      if (args.size() == 1) {
        Expression arg = args.get(0);
View Full Code Here

    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;
      }
View Full Code Here

  public static Element getElement(AstNode node, int offset) {
    // maybe node is not SimpleStringLiteral
    if (!(node instanceof SimpleStringLiteral)) {
      return null;
    }
    SimpleStringLiteral literal = (SimpleStringLiteral) node;
    // maybe has PolymerElement
    {
      Element element = literal.getToolkitElement();
      if (element instanceof PolymerElement) {
        return element;
      }
    }
    // no Element
View Full Code Here

TOP

Related Classes of com.google.dart.engine.ast.SimpleStringLiteral

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.