Package com.github.sommeri.less4j.core.ast

Examples of com.github.sommeri.less4j.core.ast.Declaration


    Iterator<HiddenTokenAwareTree> iterator = token.getChildren().iterator();
    HiddenTokenAwareTree nameToken = iterator.next();
    InterpolableName name = toInterpolableName(nameToken, nameToken.getChildren());

    if (!iterator.hasNext())
      return new Declaration(token, name);

    HiddenTokenAwareTree expressionToken = iterator.next();
    ListExpressionOperator.Operator mergeOperator = null;
    if (expressionToken.getType() == LessLexer.PLUS) {
      expressionToken = iterator.next();
      mergeOperator = ListExpressionOperator.Operator.COMMA;
      if (expressionToken.getType() == LessLexer.UNDERSCORE) {
        expressionToken = iterator.next();
        mergeOperator = ListExpressionOperator.Operator.EMPTY_OPERATOR;
      }
    }

    if (expressionToken.getType() == LessLexer.IMPORTANT_SYM)
      return new Declaration(token, name, null, true, mergeOperator);

    Expression expression = (Expression) switchOn(expressionToken);
    if (!iterator.hasNext())
      return new Declaration(token, name, expression, mergeOperator);

    HiddenTokenAwareTree importantToken = iterator.next();
    if (importantToken.getType() == LessLexer.IMPORTANT_SYM)
      return new Declaration(token, name, expression, true, mergeOperator);

    throw new BugHappened(GRAMMAR_MISMATCH, token);
  }
View Full Code Here


  }

  public SupportsCondition handleSupportsQuery(HiddenTokenAwareTree token) {
    Iterator<HiddenTokenAwareTree> children = token.getChildren().iterator();
    SyntaxOnlyElement openingParentheses = toSyntaxOnlyElement(children.next());
    Declaration declaration = (Declaration) switchOn(children.next());
    SyntaxOnlyElement closingParentheses = toSyntaxOnlyElement(children.next());
    SupportsQuery result = new SupportsQuery(token, openingParentheses, closingParentheses, declaration);
    return result;
  }
View Full Code Here

  @SuppressWarnings("rawtypes")
  private void declarationsAreImportant(Body result) {
    for (ASTCssNode kid : result.getMembers()) {
      if (kid instanceof Declaration) {
        Declaration declaration = (Declaration) kid;
        declaration.setImportant(true);
      } else if (kid instanceof BodyOwner<?>) {
        BodyOwner owner = (BodyOwner) kid;
        declarationsAreImportant(owner.getBody());
      }
    }
View Full Code Here

    List<? extends ASTCssNode> childs = node.getChilds();
    for (ASTCssNode kid : childs) {
      switch (kid.getType()) {
      case DECLARATION:
        Declaration declaration = (Declaration) kid;
        if (declaration.isMerging())
          addToPrevious(declaration);
        break;

      default:
        mergeKidsProperties(kid);
View Full Code Here

  private void addToPrevious(Declaration declaration) {
    if (declaration.getExpression() == null)
      return;
    String key = toMergingPropertiesKey(declaration);
    if (mergingProperties.containsKey(key)) {
      Declaration previousDeclaration = mergingProperties.get(key);
      Expression previousExpression = previousDeclaration.getExpression();
     
      ListExpressionOperator.Operator mergeOperator = declaration.getMergeOperator();
      Expression mergedExpression = mergeWithPrevious(declaration.getUnderlyingStructure(), previousExpression, mergeOperator, declaration.getExpression());
     
      previousDeclaration.setExpression(mergedExpression);
      mergedExpression.setParent(previousDeclaration);
      manipulator.removeFromBody(declaration);
    } else {
      mergingProperties.put(key, declaration);
    }
View Full Code Here

TOP

Related Classes of com.github.sommeri.less4j.core.ast.Declaration

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.