Remove now unused patch range from diff builders

Used to be needed for determining isOnParent, but that has now moved
elsewhere.

Change-Id: I46aaf7ee56e9b53bb770cb25c71b2c7f25c0ec4d
This commit is contained in:
Ole Rehmsen 2018-11-13 18:39:18 +01:00
parent 98ac18368c
commit f097a5d38b
8 changed files with 20 additions and 31 deletions

View File

@ -20,9 +20,9 @@
// Prevent redefinition.
if (window.GrDiffBuilderBinary) { return; }
function GrDiffBuilderBinary(diff, patchRange, commentThreadEls, prefs,
function GrDiffBuilderBinary(diff, commentThreadEls, prefs,
outputEl) {
GrDiffBuilder.call(this, diff, patchRange, commentThreadEls, prefs,
GrDiffBuilder.call(this, diff, commentThreadEls, prefs,
outputEl);
}

View File

@ -22,9 +22,9 @@
const IMAGE_MIME_PATTERN = /^image\/(bmp|gif|jpeg|jpg|png|tiff|webp)$/;
function GrDiffBuilderImage(diff, patchRange, commentThreadEls, prefs,
function GrDiffBuilderImage(diff, commentThreadEls, prefs,
outputEl, baseImage, revisionImage) {
GrDiffBuilderSideBySide.call(this, diff, patchRange, commentThreadEls,
GrDiffBuilderSideBySide.call(this, diff, commentThreadEls,
prefs, outputEl, []);
this._baseImage = baseImage;
this._revisionImage = revisionImage;

View File

@ -20,9 +20,9 @@
// Prevent redefinition.
if (window.GrDiffBuilderSideBySide) { return; }
function GrDiffBuilderSideBySide(diff, patchRange, commentThreadEls,
function GrDiffBuilderSideBySide(diff, commentThreadEls,
prefs, outputEl, layers) {
GrDiffBuilder.call(this, diff, patchRange, commentThreadEls, prefs,
GrDiffBuilder.call(this, diff, commentThreadEls, prefs,
outputEl, layers);
}
GrDiffBuilderSideBySide.prototype = Object.create(GrDiffBuilder.prototype);

View File

@ -20,9 +20,9 @@
// Prevent redefinition.
if (window.GrDiffBuilderUnified) { return; }
function GrDiffBuilderUnified(diff, patchRange, commentThreadEls, prefs,
function GrDiffBuilderUnified(diff, commentThreadEls, prefs,
outputEl, layers) {
GrDiffBuilder.call(this, diff, patchRange, commentThreadEls, prefs,
GrDiffBuilder.call(this, diff, commentThreadEls, prefs,
outputEl, layers);
}
GrDiffBuilderUnified.prototype = Object.create(GrDiffBuilder.prototype);

View File

@ -169,8 +169,7 @@ limitations under the License.
// Stop the processor and syntax layer (if they're running).
this.cancel();
this._builder = this._getDiffBuilder(
this.diff, comments.meta.patchRange, prefs);
this._builder = this._getDiffBuilder(this.diff, prefs);
this.$.processor.context = prefs.context;
this.$.processor.keyLocations = this._getKeyLocations(comments,
@ -294,7 +293,7 @@ limitations under the License.
throw Error(`Invalid preference value: ${pref}`);
},
_getDiffBuilder(diff, patchRange, prefs) {
_getDiffBuilder(diff, prefs) {
if (isNaN(prefs.tab_size) || prefs.tab_size <= 0) {
this._handlePreferenceError('tab size');
return;
@ -307,19 +306,19 @@ limitations under the License.
let builder = null;
if (this.isImageDiff) {
builder = new GrDiffBuilderImage(diff, patchRange,
builder = new GrDiffBuilderImage(diff,
this._commentThreadElements, prefs, this.diffElement,
this.baseImage, this.revisionImage);
} else if (diff.binary) {
// If the diff is binary, but not an image.
return new GrDiffBuilderBinary(diff, patchRange,
return new GrDiffBuilderBinary(diff,
this._commentThreadElements, prefs, this.diffElement);
} else if (this.viewMode === DiffViewMode.SIDE_BY_SIDE) {
builder = new GrDiffBuilderSideBySide(diff, patchRange,
builder = new GrDiffBuilderSideBySide(diff,
this._commentThreadElements, prefs, this.diffElement,
this._layers);
} else if (this.viewMode === DiffViewMode.UNIFIED) {
builder = new GrDiffBuilderUnified(diff, patchRange,
builder = new GrDiffBuilderUnified(diff,
this._commentThreadElements, prefs, this.diffElement,
this._layers);
}

View File

@ -96,10 +96,9 @@
*/
const REGEX_TAB_OR_SURROGATE_PAIR = /\t|[\uD800-\uDBFF][\uDC00-\uDFFF]/;
function GrDiffBuilder(diff, patchRange, commentThreadEls, prefs,
function GrDiffBuilder(diff, commentThreadEls, prefs,
outputEl, layers) {
this._diff = diff;
this._patchRange = patchRange;
this._prefs = prefs;
this._outputEl = outputEl;
this.groups = [];

View File

@ -75,8 +75,7 @@ limitations under the License.
show_tabs: true,
tab_size: 4,
};
builder = new GrDiffBuilder(
{content: []}, {left: [], right: []}, [], prefs);
builder = new GrDiffBuilder({content: []}, [], prefs);
});
teardown(() => { sandbox.restore(); });
@ -329,9 +328,7 @@ limitations under the License.
r5.setAttribute('comment-side', 'right');
r5.setAttribute('line-num', 5);
builder = new GrDiffBuilder(
{content: []}, {basePatchNum: 'PARENT', patchNum: '3'}, [l3, l5, r5],
prefs);
builder = new GrDiffBuilder({content: []}, [l3, l5, r5], prefs);
function checkThreadGroupProps(threadGroupEl,
expectedThreadEls) {
@ -357,8 +354,6 @@ limitations under the License.
builder._commentThreadGroupForLine(line, GrDiffBuilder.Side.LEFT);
checkThreadGroupProps(threadGroupEl, [l5]);
builder._patchRange.basePatchNum = '1';
threadGroupEl = builder._commentThreadGroupForLine(line);
checkThreadGroupProps(threadGroupEl, [l5, r5]);
@ -370,8 +365,6 @@ limitations under the License.
builder._commentThreadGroupForLine(line, GrDiffBuilder.Side.RIGHT);
checkThreadGroupProps(threadGroupEl, [r5]);
builder._patchRange.basePatchNum = 'PARENT';
line = new GrDiffLine(GrDiffLine.Type.REMOVE);
line.beforeNumber = 5;
line.afterNumber = 5;
@ -389,7 +382,7 @@ limitations under the License.
test('_handlePreferenceError called with invalid preference', () => {
sandbox.stub(element, '_handlePreferenceError');
const prefs = {tab_size: 0};
element._getDiffBuilder(element.diff, undefined, prefs);
element._getDiffBuilder(element.diff, prefs);
assert.isTrue(element._handlePreferenceError.lastCall
.calledWithExactly('tab size'));
});
@ -947,8 +940,7 @@ limitations under the License.
outputEl = element.queryEffectiveChildren('#diffTable');
comments = {left: [], right: [], meta: {patchRange: undefined}};
sandbox.stub(element, '_getDiffBuilder', () => {
const builder = new GrDiffBuilder(
{content}, undefined, [], prefs, outputEl);
const builder = new GrDiffBuilder({content}, [], prefs, outputEl);
sandbox.stub(builder, 'addColumns');
builder.buildSectionElement = function(group) {
const section = document.createElement('stub');

View File

@ -302,8 +302,7 @@ limitations under the License.
const mock = document.createElement('mock-diff-response');
element.$.diffBuilder._builder = element.$.diffBuilder._getDiffBuilder(
mock.diffResponse, {left: [], right: []},
{tab_size: 2, line_length: 80});
mock.diffResponse, {tab_size: 2, line_length: 80});
// No thread groups.
assert.isNotOk(element._getThreadGroupForLine(contentEl));