Package com.google.dart.engine.html.ast

Examples of com.google.dart.engine.html.ast.XmlAttributeNode


    super(name, offset);
  }

  @Override
  public boolean apply(XmlTagNode node) {
    XmlAttributeNode attribute = node.getAttribute("class");
    if (attribute != null) {
      String text = attribute.getText();
      if (text != null) {
        String name = getName();
        for (String className : StringUtils.split(text)) {
          if (className.equals(name)) {
            return true;
View Full Code Here


      return reportCircularity(node);
    }
    parentNodes.add(node);
    try {
      Source htmlSource = htmlElement.getSource();
      XmlAttributeNode scriptAttribute = getScriptSourcePath(node);
      String scriptSourcePath = scriptAttribute == null ? null : scriptAttribute.getText();
      if (node.getAttributeEnd().getType() == TokenType.GT && scriptSourcePath == null) {
        EmbeddedHtmlScriptElementImpl script = new EmbeddedHtmlScriptElementImpl(node);
        try {
          LibraryResolver resolver = new LibraryResolver(context);
          LibraryElementImpl library = (LibraryElementImpl) resolver.resolveEmbeddedLibrary(
View Full Code Here

    return new HtmlUnit(token, tagNodes, getCurrentToken());
  }

  @Override
  protected XmlAttributeNode createAttributeNode(Token name, Token equals, Token value) {
    return new XmlAttributeNode(name, equals, value);
  }
View Full Code Here

   * @param equals the equals sign, or {@code null} if there is no value
   * @param value the value of the attribute
   * @return the node that was created
   */
  protected XmlAttributeNode createAttributeNode(Token name, Token equals, Token value) {
    return new XmlAttributeNode(name, equals, value);
  }
View Full Code Here

  private NgModelProcessor() {
  }

  @Override
  public void apply(AngularHtmlUnitResolver resolver, XmlTagNode node) {
    XmlAttributeNode attribute = node.getAttribute(NG_MODEL);
    Expression expression = parseDartExpression(resolver, attribute);
    // identifiers have been already handled by "apply top"
    if (expression instanceof SimpleIdentifier) {
      return;
    }
View Full Code Here

  /**
   * This method is used to define top-level {@link VariableElement}s for each "ng-model" with
   * simple identifier model.
   */
  void applyTopDeclarations(AngularHtmlUnitResolver resolver, XmlTagNode node) {
    XmlAttributeNode attribute = node.getAttribute(NG_MODEL);
    Expression expression = parseDartExpression(resolver, attribute);
    // if not identifier, then not a top-level model, delay until "apply"
    if (!(expression instanceof SimpleIdentifier)) {
      return;
    }
View Full Code Here

  private Source[] getLibrarySources() {
    final ArrayList<Source> libraries = new ArrayList<Source>();
    unit.accept(new RecursiveXmlVisitor<Void>() {
      @Override
      public Void visitHtmlScriptTagNode(HtmlScriptTagNode node) {
        XmlAttributeNode scriptAttribute = null;
        for (XmlAttributeNode attribute : node.getAttributes()) {
          if (attribute.getName().equalsIgnoreCase(ATTRIBUTE_SRC)) {
            scriptAttribute = attribute;
          }
        }
        if (scriptAttribute != null) {
          try {
            URI uri = new URI(null, null, scriptAttribute.getText(), null);
            String fileName = uri.getPath();
            Source librarySource = getContext().getSourceFactory().resolveUri(source, fileName);
            if (getContext().exists(librarySource)) {
              libraries.add(librarySource);
            }
View Full Code Here

  @Override
  public void apply(AngularHtmlUnitResolver resolver, XmlTagNode node) {
    node.setElement(element.getSelector());
    for (AngularPropertyElement property : element.getProperties()) {
      String name = property.getName();
      XmlAttributeNode attribute = node.getAttribute(name);
      if (attribute != null) {
        attribute.setElement(property);
        // resolve if binding
        if (property.getPropertyKind() != AngularPropertyKind.ATTR) {
          AngularExpression expression = parseAngularExpression(resolver, attribute);
          resolver.resolveExpression(expression);
          setAngularExpression(attribute, expression);
View Full Code Here

    return super.visitXmlTagNode(node);
  }

  private void createAttributeElements() {
    // prepare "attributes" attribute
    XmlAttributeNode attributesAttribute = elementNode.getAttribute("attributes");
    if (attributesAttribute == null) {
      return;
    }
    // check if there is a Dart part to resolve against it
    if (dartElement == null) {
      // TODO(scheglov) maybe report error (if it is allowed at all to have element without Dart part)
      return;
    }
    // prepare value of the "attributes" attribute
    String attributesText = attributesAttribute.getText();
    if (attributesText.trim().isEmpty()) {
      reportErrorForAttribute(attributesAttribute, PolymerCode.EMPTY_ATTRIBUTES);
      return;
    }
    // prepare attribute name tokens
    List<NameToken> nameTokens = Lists.newArrayList();
    {
      int index = 0;
      int textOffset = attributesAttribute.getTextOffset();
      int nameOffset = -1;
      StringBuilder nameBuilder = new StringBuilder();
      while (index < attributesText.length()) {
        char c = attributesText.charAt(index++);
        if (Character.isWhitespace(c)) {
View Full Code Here

    this.elementNode = node;
    this.elementName = null;
    this.htmlElement = null;
    this.dartElement = null;
    // prepare 'name' attribute
    XmlAttributeNode nameAttribute = node.getAttribute("name");
    if (nameAttribute == null) {
      reportErrorForToken(node.getTagToken(), PolymerCode.MISSING_TAG_NAME);
      return;
    }
    // prepare name
    elementName = nameAttribute.getText();
    if (!isValidTagName(elementName)) {
      reportErrorForAttributeValue(nameAttribute, PolymerCode.INVALID_TAG_NAME, elementName);
      return;
    }
    // TODO(scheglov) Maybe check that at least one of "template" or "script" children.
    // TODO(scheglov) Maybe check if more than one top-level "template".
    // create HTML element
    int nameOffset = nameAttribute.getTextOffset();
    htmlElement = new PolymerTagHtmlElementImpl(elementName, nameOffset);
    // bind to the corresponding Dart element
    dartElement = findTagDartElement();
    if (dartElement != null) {
      htmlElement.setDartElement(dartElement);
View Full Code Here

TOP

Related Classes of com.google.dart.engine.html.ast.XmlAttributeNode

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.