<commit_before>const {parse} = require('postcss')
const atRules = require('./atrules')
const rules = require('./rules')
const selectors = require('./selectors')
const declarations = require('./declarations')

function processNodes(tree) {
  return {
    atRules: atRules(tree),
    rules: rules(tree),
    selectors: selectors(tree),
    declarations: declarations(tree)
  }
}

module.exports = async css => {
  try {
    const result = await parse(css)
    const rootNode = result.toResult().root

    return Promise.resolve(processNodes(rootNode))
  } catch (error) {
    const {line, column, reason} = error

    return Promise.reject(
      new SyntaxError(
        `${reason} at line ${line}, column ${column}:\n\n${error.showSourceCode(
          false
        )}`
      )
    )
  }
}<commit_msg>fix: error.showSourceCode is not a function (#196)<commit_after>const {parse} = require('postcss')
const atRules = require('./atrules')
const rules = require('./rules')
const selectors = require('./selectors')
const declarations = require('./declarations')

function processNodes(tree) {
  return {
    atRules: atRules(tree),
    rules: rules(tree),
    selectors: selectors(tree),
    declarations: declarations(tree)
  }
}

module.exports = async css => {
  try {
    const result = await parse(css)
    const rootNode = result.toResult().root

    return Promise.resolve(processNodes(rootNode))
  } catch (error) {
    const {line, column, reason} = error
    const message = error.showSourceCode
      ? `${reason} at line ${line}, column ${column}:\n\n${error.showSourceCode(
        false
      )}`
      : `${reason} at line ${line}, column ${column}:\n\n${error.source}`

    return Promise.reject(new SyntaxError(message))
  }
}
{'fraction_non_alphanumeric': 0.1482758620689655, 'fraction_numerical': 0.0017241379310344827, 'mean_word_length': 3.545691906005222, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1506239', 'n_tokens_mistral': 528, 'n_tokens_neox': 520, 'n_words': 128}