From afd22997a52b7db371955b65516131f7ded33243 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 24 Feb 2017 14:15:20 -0800 Subject: [PATCH] Remove legacy fields from Hunk We'll remove usages of these in TextBuffer --- src/bindings/em/patch.cc | 7 ------- src/bindings/patch-wrapper.cc | 18 ------------------ test/js/patch.test.js | 12 ------------ 3 files changed, 37 deletions(-) diff --git a/src/bindings/em/patch.cc b/src/bindings/em/patch.cc index ff10d027..5a94f9f2 100644 --- a/src/bindings/em/patch.cc +++ b/src/bindings/em/patch.cc @@ -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)) - .field("newExtent", WRAP(&get_new_extent), WRAP(&hunk_set_noop)) - ; } diff --git a/src/bindings/patch-wrapper.cc b/src/bindings/patch-wrapper.cc index 189c0edb..50bc112c 100644 --- a/src/bindings/patch-wrapper.cc +++ b/src/bindings/patch-wrapper.cc @@ -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(), - AccessControl::DEFAULT, PropertyAttribute::DontEnum); - Nan::SetAccessor(instance_template, Nan::New("oldExtent").ToLocalChecked(), get_old_extent, nullptr, Handle(), - AccessControl::DEFAULT, PropertyAttribute::DontEnum); - Nan::SetAccessor(instance_template, Nan::New("newExtent").ToLocalChecked(), get_new_extent, nullptr, Handle(), - AccessControl::DEFAULT, PropertyAttribute::DontEnum); - const auto &prototype_template = constructor_template->PrototypeTemplate(); prototype_template->Set(Nan::New("toString").ToLocalChecked(), Nan::New(to_string)); hunk_wrapper_constructor.Reset(constructor_template->GetFunction()); @@ -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 property, const Nan::PropertyCallbackInfo &info) { - Patch::Hunk &hunk = Nan::ObjectWrap::Unwrap(info.This())->hunk; - info.GetReturnValue().Set(PointWrapper::from_point(hunk.old_end.traversal(hunk.old_start))); - } - - static void get_new_extent(v8::Local property, const Nan::PropertyCallbackInfo &info) { - Patch::Hunk &hunk = Nan::ObjectWrap::Unwrap(info.This())->hunk; - info.GetReturnValue().Set(PointWrapper::from_point(hunk.new_end.traversal(hunk.new_start))); - } - static void to_string(const Nan::FunctionCallbackInfo &info) { Patch::Hunk &hunk = Nan::ObjectWrap::Unwrap(info.This())->hunk; std::stringstream result; diff --git a/test/js/patch.test.js b/test/js/patch.test.js index 218d146a..ceecd9ef 100644 --- a/test/js/patch.test.js +++ b/test/js/patch.test.js @@ -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 })