Package com.puppetlabs.geppetto.pp.dsl.services.PPGrammarAccess

Examples of com.puppetlabs.geppetto.pp.dsl.services.PPGrammarAccess.HashEntryElements


    Iterator<IDomNode> itor = node.treeIterator();
    Map<IDomNode, Integer> operatorNodes = Maps.newHashMap();
    IntegerCluster cluster = new IntegerCluster(clusterWidth);

    final LiteralHashElements access = grammarAccess.getLiteralHashAccess();
    final HashEntryElements hashAccess = grammarAccess.getHashEntryAccess();
    int previousKeyWidth = 0;
    while(itor.hasNext()) {
      IDomNode n = itor.next();
      EObject ge = n.getGrammarElement();
      if(ge == access.getLeftCurlyBracketKeyword_1()) {
        IDomNode nextLeaf = DomModelUtils.nextWhitespace(n);
        if(DomModelUtils.isWhitespace(nextLeaf) && breakAndAlign)
          nextLeaf.getStyles().add(StyleSet.withStyles(styles.oneLineBreak()));
      }
      else if(breakAndAlign) {
        if(ge == access.getCommaKeyword_2_1_0()) {
          IDomNode nextLeaf = DomModelUtils.nextWhitespace(n);
          if(DomModelUtils.isWhitespace(nextLeaf))
            nextLeaf.getStyles().add(StyleSet.withStyles(styles.oneLineBreak()));
        }
        else if(ge == hashAccess.getKeyLiteralNameOrStringParserRuleCall_0_0()) {
          DelegatingLayoutContext keyContext = new DelegatingLayoutContext(context);
          TextFlow keyFlow = new TextFlow(keyContext);
          ArrayList<IDomNode> children = Lists.newArrayList(n.getChildren());
          for(Iterator<IDomNode> subitor = children.iterator(); subitor.hasNext();) {
            IDomNode x = subitor.next();
            NodeType t = x.getNodeType();
            if(t == NodeType.ACTION || t == NodeType.WHITESPACE) {
              subitor.remove();
              continue;
            }
            break; // first non whitespace or action
          }
          feeder.sequence(children, keyFlow, context);
          previousKeyWidth = keyFlow.getWidthOfLastLine();
          cluster.add(previousKeyWidth);
          System.out.println("node= [" + keyFlow.getText() + "] width = " + previousKeyWidth);
        }
        else if(ge == hashAccess.getEqualsSignGreaterThanSignKeyword_1()) {
          operatorNodes.put(n, previousKeyWidth);
        }
      }
    }
View Full Code Here

TOP

Related Classes of com.puppetlabs.geppetto.pp.dsl.services.PPGrammarAccess.HashEntryElements

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.