Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Remove legacy fields from Hunk
Browse files Browse the repository at this point in the history
We'll remove usages of these in TextBuffer
  • Loading branch information
maxbrunsfeld authored and Nathan Sobo committed Feb 24, 2017
1 parent 3b02be2 commit afd2299
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 37 deletions.
7 changes: 0 additions & 7 deletions src/bindings/em/patch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,6 @@ EMSCRIPTEN_BINDINGS(Patch) {
.field("oldText", WRAP_FIELD(Patch::Hunk, old_text))
.field("newText", WRAP_FIELD(Patch::Hunk, new_text))

// The following fields are legacy only (most notably, TextBuffer doesn't work without them)

.field("start", WRAP_FIELD(Patch::Hunk, new_start))

.field("oldExtent", WRAP(&get_old_extent), WRAP(&hunk_set_noop<Point>))
.field("newExtent", WRAP(&get_new_extent), WRAP(&hunk_set_noop<Point>))

;

}
18 changes: 0 additions & 18 deletions src/bindings/patch-wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ class HunkWrapper : public Nan::ObjectWrap {
Nan::SetAccessor(instance_template, Nan::New("oldEnd").ToLocalChecked(), get_old_end);
Nan::SetAccessor(instance_template, Nan::New("newEnd").ToLocalChecked(), get_new_end);

// Non-enumerable legacy properties for backward compatibility
Nan::SetAccessor(instance_template, Nan::New("start").ToLocalChecked(), get_new_start, nullptr, Handle<Value>(),
AccessControl::DEFAULT, PropertyAttribute::DontEnum);
Nan::SetAccessor(instance_template, Nan::New("oldExtent").ToLocalChecked(), get_old_extent, nullptr, Handle<Value>(),
AccessControl::DEFAULT, PropertyAttribute::DontEnum);
Nan::SetAccessor(instance_template, Nan::New("newExtent").ToLocalChecked(), get_new_extent, nullptr, Handle<Value>(),
AccessControl::DEFAULT, PropertyAttribute::DontEnum);

const auto &prototype_template = constructor_template->PrototypeTemplate();
prototype_template->Set(Nan::New<String>("toString").ToLocalChecked(), Nan::New<FunctionTemplate>(to_string));
hunk_wrapper_constructor.Reset(constructor_template->GetFunction());
Expand Down Expand Up @@ -101,16 +93,6 @@ class HunkWrapper : public Nan::ObjectWrap {
info.GetReturnValue().Set(PointWrapper::from_point(hunk.new_end));
}

static void get_old_extent(v8::Local<v8::String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
Patch::Hunk &hunk = Nan::ObjectWrap::Unwrap<HunkWrapper>(info.This())->hunk;
info.GetReturnValue().Set(PointWrapper::from_point(hunk.old_end.traversal(hunk.old_start)));
}

static void get_new_extent(v8::Local<v8::String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
Patch::Hunk &hunk = Nan::ObjectWrap::Unwrap<HunkWrapper>(info.This())->hunk;
info.GetReturnValue().Set(PointWrapper::from_point(hunk.new_end.traversal(hunk.new_start)));
}

static void to_string(const Nan::FunctionCallbackInfo<Value> &info) {
Patch::Hunk &hunk = Nan::ObjectWrap::Unwrap<HunkWrapper>(info.This())->hunk;
std::stringstream result;
Expand Down
12 changes: 0 additions & 12 deletions test/js/patch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@ describe('Patch', function () {
patch.delete();
})

it('expose legacy fields', function () {
const patch = new Patch({ mergeAdjacentHunks: false })

patch.splice({row: 0, column: 10}, {row: 0, column: 0}, {row: 1, column: 5})
patch.splice({row: 1, column: 5}, {row: 0, column: 2}, {row: 0, column: 8})

const hunk = patch.getHunks()[0];

assert.ok(hunk.oldExtent);
assert.ok(hunk.newExtent);
})

it('honors the mergeAdjacentHunks option set to true', function () {
const patch = new Patch({ mergeAdjacentHunks: true })

Expand Down

0 comments on commit afd2299

Please sign in to comment.