How to use the gonzales-pe.createNode function in gonzales-pe

To help you get started, we’ve selected a few gonzales-pe examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github csscomb / csscomb.js / src / options / sort-order.js View on Github external
if (currentNode.is('multilineComment') ||
          currentNode.is('singlelineComment')) {
        positions.push(i);
        continue;
      }

      // If there are any line breaks in a node with spaces, stop and
      // split the node into two: one with spaces before line break
      // and one with `\n` symbol and everything that goes after.
      // Combine the first one with declaration/@-rule's node:
      let linebreakIndex = currentNode.content.indexOf('\n');
      if (linebreakIndex !== -1) {
        var s = currentNode.content.substring(0, linebreakIndex);
        if (s === '') break;
        var space = gonzales.createNode({type: 'space', content: s});
        node.insert(i + 1, space);
        positions.push(i + 1);
        currentNode.content = currentNode.content
            .substring(linebreakIndex);
        break;
      }

      positions.push(i);
    }

    return positions;
  },
github csscomb / csscomb.js / src / options / space-after-opening-brace.js View on Github external
ast.traverse(function(node) {
      // If found block node stop at the next one for space check
      if (!node.is('block') && !node.is('atrulers')) return;

      if (node.first() &&
          node.first().is('space')) {
        node.first().content = value;
      } else if (value !== '') {
        var space = gonzales.createNode({
          type: 'space',
          content: value
        });
        node.insert(0, space);
      }
    });
  },
github csscomb / sublime-csscomb / node_modules / csscomb / lib / options / vendor-prefix-align.js View on Github external
payload: function (info, i) {
            // `node.get(i - 1)` can be either space or comment:
            var whitespaceNode = node.get(i - 1);
            if (!whitespaceNode) return;
            // If it's a comment, insert an empty space node:
            if (!whitespaceNode.is('space')) {
              whitespaceNode = gonzales.createNode({
                type: 'space',
                content: ''
              });
              node.insert(i - 1, whitespaceNode);
            }
            let content = whitespaceNode.content;
            let updatedContent = updateIndent(info, dict, content);
            whitespaceNode.content = updatedContent;
          }
        });
github csscomb / csscomb.js / src / options / vendor-prefix-align.js View on Github external
payload: function(info, i) {
            // `node.get(i - 1)` can be either space or comment:
            var whitespaceNode = node.get(i - 1);
            if (!whitespaceNode) return;
            // If it's a comment, insert an empty space node:
            if (!whitespaceNode.is('space')) {
              whitespaceNode = gonzales.createNode({
                type: 'space',
                content: ''
              });
              node.insert(i - 1, whitespaceNode);
            }
            let content = whitespaceNode.content;
            let updatedContent = updateIndent(info, dict, content);
            whitespaceNode.content = updatedContent;
          }
        });
github csscomb / csscomb.js / src / options / space-before-closing-brace.js View on Github external
if (blockIndent) {
          value += new Array(level).join(blockIndent);
        }
      }

      // If found block node stop at the next one for space check
      // For the pre-block node, find its last (the deepest) child
      var whitespaceNode = getLastWhitespaceNode(node);

      // If it's spaces, modify this node
      // If it's something different from spaces, add a space node
      // to the end
      if (whitespaceNode) {
        whitespaceNode.content = value;
      } else if (value !== '') {
        var space = gonzales.createNode({
          type: 'space',
          content: value
        });
        node.content.push(space);
      }

      processBlock(node, level);
    });
  }
github gmac / sass-thematic / lib / ast.js View on Github external
createNode: function(opts) {
    return this.extend(gonzales.createNode({
      type: 'stylesheet',
      syntax: 'scss',
      content: [],
      start: {line: 1, column: 1},
      end: {line: 1, column: 1}
    }), opts || {});
  },
github csscomb / csscomb.js / src / options / eof-newline.js View on Github external
process(ast) {
    var lastChild = ast.last();

    if (!lastChild.is('space')) {
      lastChild = gonzales.createNode({type: 'space', content: ''});
      ast.content.push(lastChild);
    }

    lastChild.content = lastChild.content.replace(/\n$/, '');
    if (this.value) lastChild.content += '\n';
  },
github csscomb / csscomb.js / src / options / lines-between-rulesets.js View on Github external
process(ast) {
    this.newLinesString = this.buildSpacing(ast.syntax);
    this.newLinesNode = gonzales.createNode({
      type: 'space',
      content: this.newLinesString
    });
    this.processBlock(ast);
  },
github csscomb / sublime-csscomb / node_modules / csscomb / lib / options / vendor-prefix-align.js View on Github external
payload: function (info, i) {
            for (var x = node.get(i).length; x--;) {
              if (node.get(i).get(x).is('value')) break;
            }

            let prevNode = node.get(i).get(x - 1);
            if (!prevNode.is('space')) {
              var space = gonzales.createNode({
                type: 'space',
                content: ''
              });
              node.get(i).insert(x, space);
              ++x;
            }

            let content = node.get(i).get(x - 1).content;
            let updatedIndent = updateIndent(info, dict, content);
            node.get(i).get(x - 1).content = updatedIndent;
          }
        });
github SC5 / sc5-styleguide / lib / modules / parsers / less.js View on Github external
return;
            }

            if (metOperator && atRuleNode.is('space') && !cleaned) {
                return;
            }

            if (!wrongVar) {
                cleaned = true;
                atRuleNode.type = 'string';
                atRuleNode.content = '';
            }

        });
        if (!wrongVar) {
            var newVal = gonzales.createNode({ type: 'string', content: variable.value, syntax: 'less' });
            node.content.push(newVal);
        }
    });