Package com.github.sommeri.less4j.core.problems

Examples of com.github.sommeri.less4j.core.problems.BugHappened


  }

  public void validateGuardAnd(HiddenTokenAwareTree token) {
    String operator = token.getText().trim();
    if (!"and".equals(operator))
      throw new BugHappened(GRAMMAR_MISMATCH, token);
  }
View Full Code Here


  }

  public SelectorAttribute handleSelectorAttribute(HiddenTokenAwareTree token) {
    List<HiddenTokenAwareTree> children = token.getChildren();
    if (children.size() == 0)
      throw new BugHappened(GRAMMAR_MISMATCH, token);

    if (children.size() == 1)
      return new SelectorAttribute(token, children.get(0).getText());

    if (children.size() < 3)
      throw new BugHappened(GRAMMAR_MISMATCH, token);

    Expression value = handleTerm(children.get(2));
    switch (value.getType()) {
    case IDENTIFIER_EXPRESSION:
    case STRING_EXPRESSION:
View Full Code Here

    default:
      break;
    }

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

  }

  public Pseudo handlePseudo(HiddenTokenAwareTree token) {
    List<HiddenTokenAwareTree> children = token.getChildren();
    if (children.size() == 0 || children.size() == 1)
      throw new BugHappened(GRAMMAR_MISMATCH, token);

    // the child number 0 is a :
    HiddenTokenAwareTree t = children.get(1);
    if (t.getType() == LessLexer.COLON) {
      return createPseudoElement(token, 2, false);
    }

    if (COLONLESS_PSEUDOELEMENTS.contains(t.getText().toLowerCase())) {
      return createPseudoElement(token, 1, true);
    }

    if (children.size() == 2)
      return new PseudoClass(token, children.get(1).getText());

    if (children.size() == 3) {
      HiddenTokenAwareTree parameter = children.get(2);
      //FIXME: this is not really sufficient for all cases less.js supports (1@{num}n+3)
      if (parameter.getType() == LessLexer.INTERPOLATED_VARIABLE)
        return new PseudoClass(token, children.get(1).getText(), toInterpolabledVariable(parameter, parameter.getText()));
      return new PseudoClass(token, children.get(1).getText(), switchOn(parameter));
    }

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

  private InterpolableName toInterpolableName(HiddenTokenAwareTree token, List<HiddenTokenAwareTree> children) {
    InterpolableName result = new InterpolableName(token);
    for (HiddenTokenAwareTree kid : children) {
      String text = kid.getText();
      if (text == null || text.length() < 1)
        throw new BugHappened(GRAMMAR_MISMATCH, kid);

      if (kid.getType() == LessLexer.INTERPOLATED_VARIABLE) {
        result.add(new VariableNamePart(kid, toInterpolabledVariable(kid, text)));
      } else if (kid.getType() == LessLexer.HASH_SYMBOL) {
        // do nothing
View Full Code Here

    HiddenTokenAwareTree featureNode = children.get(0);
    if (children.size() == 1)
      return new FixedMediaExpression(token, new MediaExpressionFeature(featureNode, featureNode.getText()), null);

    if (children.size() == 2)
      throw new BugHappened(GRAMMAR_MISMATCH, token);

    HiddenTokenAwareTree colonNode = children.get(1);
    featureNode.addFollowing(colonNode.getPreceding());

    HiddenTokenAwareTree expressionNode = children.get(2);
View Full Code Here

    SupportsLogicalCondition result = new SupportsLogicalCondition(token, (SupportsCondition) switchOn(children.next()));
    while (children.hasNext()) {
      SupportsLogicalOperator logicalOperator = toSupportsLogicalOperator(children.next());
      if (!children.hasNext())
        throw new BugHappened(GRAMMAR_MISMATCH, token);
      SupportsCondition condition = (SupportsCondition) switchOn(children.next());
      result.addCondition(logicalOperator, condition);
    }
    return result;
  }
View Full Code Here

      } else {
        ASTCssNode urlMatchFunction = switchOn(token);
        if (urlMatchFunction.getType() == ASTCssNodeType.FUNCTION)
          result.add((FunctionExpression) termBuilder.buildFromChildTerm(token));
        else
          throw new BugHappened(GRAMMAR_MISMATCH, token);
      }

    }

    return result;
View Full Code Here

  private GeneralBody createGeneralBody(HiddenTokenAwareTree token) {
    List<ASTCssNode> list = handleBodyMembers(token);

    if (list.size() < 2)
      throw new BugHappened(GRAMMAR_MISMATCH, token);

    SyntaxOnlyElement lbrace = (SyntaxOnlyElement) list.remove(0);
    SyntaxOnlyElement rbrace = (SyntaxOnlyElement) list.remove(list.size() - 1);
    List<CommonToken> orphansOrFollowLastMember = rbrace.getUnderlyingStructure().chopPreceedingUpToLastOfType(LessLexer.NEW_LINE);
    if (list.isEmpty()) {
View Full Code Here

      if (token.getType() == LessLexer.COMMA) {
        token.pushHiddenToSiblings();
      } else if (token.getType() == LessLexer.IDENT || token.getType() == LessLexer.AT_NAME || token.getType()==LessLexer.INDIRECT_VARIABLE) {
        result.add(new KeyframesName(token.commentsLessClone(), termBuilder.buildFromTerm(token)));
      } else {
        throw new BugHappened(GRAMMAR_MISMATCH, token);
      }

    }

    return result;
View Full Code Here

TOP

Related Classes of com.github.sommeri.less4j.core.problems.BugHappened

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.