Package com.google.gwt.libideas.resources.css.ast

Examples of com.google.gwt.libideas.resources.css.ast.CssDef


          // Don't try to substitute into anything other than idents
          continue;
        }

        String value = v.getIdent();
        CssDef def = substitutions.get(value);

        if (def == null) {
          continue;
        } else if (def instanceof CssUrl) {
          assert def.getValues().size() == 1;
          assert def.getValues().get(0).isIdentValue() != null;
          String functionName = def.getValues().get(0).isIdentValue().getIdent();

          // Find the method
          JMethod method = context.getResourceBundleType().findMethod(
              functionName, new JType[0]);

          if (method == null) {
            logger.log(TreeLogger.ERROR, "Unable to find DataResource method "
                + functionName + " in "
                + context.getResourceBundleType().getQualifiedSourceName());
            throw new CssCompilerException("Cannot find data function");
          }

          String instance = "((" + DataResource.class.getName() + ")("
              + context.getImplementationSimpleSourceName() + ".this."
              + functionName + "()))";

          StringBuilder expression = new StringBuilder();
          expression.append("\"url('\" + ");
          expression.append(instance).append(".getUrl()");
          expression.append(" + \"')\"");
          i.set(new ExpressionValue(expression.toString()));

        } else {
          i.remove();
          for (Value defValue : def.getValues()) {
            i.add(defValue);
          }
        }
      }
View Full Code Here


    collector.accept(cssStylesheet);

    String name = toImplement.getName();
    // TODO: Annotation for override

    CssDef def = collector.substitutions.get(name);
    if (def == null) {
      logger.log(TreeLogger.ERROR, "No @def rule for name " + name);
      throw new UnableToCompleteException();
    }

    // TODO: Allow returning an array of values
    if (def.getValues().size() != 1) {
      logger.log(TreeLogger.ERROR, "@def rule " + name
          + " must define exactly one value");
      throw new UnableToCompleteException();
    }

    NumberValue numberValue = def.getValues().get(0).isNumberValue();

    if (numberValue == null) {
      logger.log(TreeLogger.ERROR, "The define named " + name
          + " does not define a numeric value");
      throw new UnableToCompleteException();
View Full Code Here

       * expansion up-front to prevent the need for cycle-detection later.
       */
      for (ListIterator<Value> it = values.listIterator(1); it.hasNext();) {
        IdentValue maybeDefReference = it.next().isIdentValue();
        if (maybeDefReference != null) {
          CssDef previousDef = defs.get(maybeDefReference.getIdent());
          if (previousDef != null) {
            it.remove();
            for (Value previousValue : previousDef.getValues()) {
              it.add(previousValue);
            }
          }
        }
      }

      CssDef def = new CssDef(defName.getIdent());
      def.getValues().addAll(values.subList(1, values.size()));
      addNode(def);

      defs.put(defName.getIdent(), def);
    }
View Full Code Here

TOP

Related Classes of com.google.gwt.libideas.resources.css.ast.CssDef

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.