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

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


    HiddenTokenAwareTree charset = children.get(1);
    return new CharsetDeclaration(token, termBuilder.createCssString(charset, charset.getText()));
  }

  public RuleSet handleRuleSet(HiddenTokenAwareTree token) {
    RuleSet ruleSet = new RuleSet(token);

    List<Selector> selectors = new ArrayList<Selector>();
    List<Guard> guards = new ArrayList<Guard>();
    List<HiddenTokenAwareTree> children = token.getChildren();

    ASTCssNode previousKid = null;
    for (HiddenTokenAwareTree kid : children) {
      if (kid.getType() == LessLexer.SELECTOR) {
        Selector selector = handleSelector(kid);
        if (selector != null)
          selectors.add(selector);
        previousKid = selector;
      } else if (kid.getType() == LessLexer.BODY) {
        GeneralBody body = handleGeneralBody(kid);
        ruleSet.setBody(body);
        previousKid = body;
      } else if (kid.getType() == LessLexer.GUARD) {
        guards.add(handleGuard(kid));
      } else if (kid.getType() == LessLexer.COMMA) {
        if (previousKid != null)
          previousKid.getUnderlyingStructure().addFollowing(kid.getPreceding());
      }
    }

    ruleSet.addSelectors(selectors);
    ruleSet.addGuards(guards);
    return ruleSet;
  }
View Full Code Here


    for (ASTCssNode kid : childs) {
      if (isMixinReference(kid) || isDetachedRulesetReference(kid))
        continue;

      if (isRuleset(kid)) {
        RuleSet ruleSet = (RuleSet) kid;
        if (cssGuardsValidator.guardsSatisfied(ruleSet)) {
          ruleSet.removeGuards();
        } else {
          manipulator.removeFromClosestBody(ruleSet);
          //skip child scope
          iteratedScope.getNextChild();
          continue;
View Full Code Here

        if (bodyScope.hasParent())
          bodyScope.getParent().removedFromAst(); // remove also arguments scope from tree
        bodyScope.removedFromAst();
        detached.setScope(bodyScope);
      } else if (kid.getType() == ASTCssNodeType.RULE_SET) {
        RuleSet ruleSet = (RuleSet) kid;
        if (ruleSet.isUsableAsReusableStructure()) {
          IScope bodyScope = currentScope.childByOwners(ruleSet, ruleSet.getBody());
          currentScope.registerMixin(ruleSet.convertToReusableStructure(), bodyScope);
        }
      } else if (kid.getType() == ASTCssNodeType.MIXIN_REFERENCE) {
        currentScope.createDataPlaceholder();
      } else if (kid.getType() == ASTCssNodeType.DETACHED_RULESET_REFERENCE) {
        currentScope.createDataPlaceholder();
View Full Code Here

    case REUSABLE_STRUCTURE:
      currentScope.addNames(((ReusableStructure) node).getNamesAsStrings());
      break;

    case RULE_SET: {
      RuleSet ruleSet = (RuleSet) node;
      if (ruleSet.isUsableAsReusableStructure()) {
        currentScope.addNames(ruleSet.extractReusableStructureNames());
      }
      break;
    }

    default:
View Full Code Here

  }

  private void collectRulesets(ASTCssNode node) {
    switch (node.getType()) {
    case RULE_SET: {
      RuleSet ruleset = (RuleSet) node;
      allRulesets.add(ruleset);
      collectExtendingSelectors(ruleset);
      break;
    }
    default:
View Full Code Here

  private void collectChildRuleSets(ASTCssNode ownerNode, NestedInRulesetStack nestedNodes) {
    List<? extends ASTCssNode> childs = new ArrayList<ASTCssNode>(ownerNode.getChilds());
    for (ASTCssNode kid : childs) {
      switch (kid.getType()) {
      case RULE_SET: {
        RuleSet nestedSet = (RuleSet) kid;
        manipulator.removeFromBody(nestedSet);
        nestedNodes.collect(nestedSet);
        nestedNodes.pushSelectors(nestedSet);

        collectChildRuleSets(kid, nestedNodes);
View Full Code Here

    }
  }

  private void putMediaBodyIntoRuleset(Media media, List<Selector> selectors) {
    RuleSet newRuleset = new RuleSet(media.getUnderlyingStructure(), media.getBody(), selectors);
    GeneralBody newMediaBody = new GeneralBody(media.getUnderlyingStructure());
    newMediaBody.addMember(newRuleset);
    media.setBody(newMediaBody);

    newMediaBody.configureParentToAllChilds();
    media.configureParentToAllChilds();
    newRuleset.configureParentToAllChilds();
  }
View Full Code Here

  }

  public void propertiesMerger(ASTCssNode node) {
    switch (node.getType()) {
    case RULE_SET:
      RuleSet ruleset = (RuleSet) node;
      rulesetsBodyPropertiesMerger(ruleset.getBody());
      break;

    case CHARSET_DECLARATION:
    case IMPORT:
      break;
View Full Code Here

TOP

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

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.