Sha256: f2c6e7ae035813050043170803505b685c130b56021a108ae4307b2a6f1fe7f0
Contents?: true
Size: 1.22 KB
Versions: 5
Compression:
Stored size: 1.22 KB
Contents
const parseSync = require("../parser/parseSync"); // This function is responsible for taking an input string of text and returning // to prettier a JavaScript object that is the equivalent AST that represents // the code stored in that string. We accomplish this by spawning a new Ruby // process of parser.rb and reading JSON off STDOUT. function parse(text, _parsers, _opts) { return parseSync("ruby", text); } const pragmaPattern = /#\s*@(prettier|format)/; // This function handles checking whether or not the source string has the // pragma for prettier. This is an optional workflow for incremental adoption. function hasPragma(text) { return pragmaPattern.test(text); } // This function is critical for comments and cursor support, and is responsible // for returning the index of the character within the source string that is the // beginning of the given node. function locStart(node) { return node.sc; } // This function is critical for comments and cursor support, and is responsible // for returning the index of the character within the source string that is the // ending of the given node. function locEnd(node) { return node.ec; } module.exports = { parse, astFormat: "ruby", hasPragma, locStart, locEnd };
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
prettier-1.5.3 | src/ruby/parser.js |
prettier-1.5.2 | src/ruby/parser.js |
prettier-1.5.1 | src/ruby/parser.js |
prettier-1.5.0 | src/ruby/parser.js |
prettier-1.4.0 | src/ruby/parser.js |