Skip to content

Commit

Permalink
locStart and locEnd placeholders
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton committed Jul 2, 2019
1 parent 07c21d7 commit 4f519ae
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a

## [Unreleased]

### Added

- Added `locStart` and `locEnd` placeholders until we can get the functionality built. In the meantime it will stop breaking integrations.

### Changed

- Comments inside of `do...end` blocks that preceeded `call` nodes were associating the comment with the `var_ref` instead of the `call` itself. For example,
Expand Down
9 changes: 8 additions & 1 deletion src/ruby.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ const print = require("./print");
const pragmaPattern = /#\s*@(prettier|format)/;
const hasPragma = text => pragmaPattern.test(text);

// This is a placeholder until we have been node location reporting coming from
// the ripper parser.
const locStart = node => 0;
const locEnd = node => 0;

/*
* metadata mostly pulled from linguist and rubocop:
* https://github.com/github/linguist/blob/master/lib/linguist/languages.yml
Expand Down Expand Up @@ -75,7 +80,9 @@ module.exports = {
ruby: {
parse,
astFormat: "ruby",
hasPragma
hasPragma,
locStart,
locEnd
}
},
printers: {
Expand Down
2 changes: 0 additions & 2 deletions test/js/hasPragma.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

const { hasPragma } = require("../../src/ruby").parsers.ruby;

describe("hasPragma", () => {
Expand Down
10 changes: 10 additions & 0 deletions test/js/locations.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { ruby } = require("../../src/ruby").parsers;

describe("locations", () => {
test("locStart and locEnd are defined", () => {
const { hasOwnProperty } = Object.prototype;

expect(hasOwnProperty.call(ruby, "locStart")).toBe(true);
expect(hasOwnProperty.call(ruby, "locEnd")).toBe(true);
});
});

0 comments on commit 4f519ae

Please sign in to comment.